luraproject / lura

Function with cyclomatic complexity higher than threshold GO-R1005
Anti-pattern
Minor
6 months ago8 months old
func sequentialMerge has a cyclomatic complexity of 25 with "high" risk
120
121var reMergeKey = regexp.MustCompile(`\{\{\.Resp(\d+)_([\w-\.]+)\}\}`)
122
123func sequentialMerge(reqCloner func(*Request) *Request, patterns []string, timeout time.Duration, rc ResponseCombiner, next ...Proxy) Proxy {124	return func(ctx context.Context, request *Request) (*Response, error) {
125		localCtx, cancel := context.WithTimeout(ctx, timeout)
126
func newPluginMiddleware has a cyclomatic complexity of 17 with "high" risk
 42		fmt.Sprintf("%s %s -> %s", remote.ParentEndpointMethod, remote.ParentEndpoint, remote.URLPattern), cfg)
 43}
 44
 45func newPluginMiddleware(logger logging.Logger, tag, pattern string, cfg map[string]interface{}) Middleware { 46	plugins, ok := cfg["name"].([]interface{})
 47	if !ok {
 48		return emptyMiddlewareFallback(logger)
func TestNewHTTPProxy_ok has a cyclomatic complexity of 19 with "high" risk
 20	"github.com/luraproject/lura/v2/transport/http/client"
 21)
 22
 23func TestNewHTTPProxy_ok(t *testing.T) { 24	expectedMethod := "GET"
 25	backendServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
 26		if r.ContentLength != 11 {
func generateCerts has a cyclomatic complexity of 17 with "high" risk
 22	}
 23}
 24
 25func generateCerts() error { 26	hosts := []string{"127.0.0.1", "::1", "localhost"}
 27
 28	priv, err := rsa.GenerateKey(rand.Reader, 2048)
func NewEngine has a cyclomatic complexity of 17 with "high" risk
 31}
 32
 33// NewEngine returns an initialized gin engine
 34func NewEngine(cfg config.ServiceConfig, opt EngineOptions) *gin.Engine { 35	gin.SetMode(gin.ReleaseMode)
 36	if cfg.Debug {
 37		opt.Logger.Debug(logPrefix, "Debug enabled")