Showing 21 of 48 total issues
Method Config.applyEnvOverrides
has a Cognitive Complexity of 72 (exceeds 20 allowed). Consider refactoring. Open
func (c *Config) applyEnvOverrides(prefix string, spec reflect.Value) error {
// If we have a pointer, dereference it
s := spec
if spec.Kind() == reflect.Ptr {
s = spec.Elem()
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function metricsData
has a Cognitive Complexity of 53 (exceeds 20 allowed). Consider refactoring. Open
func metricsData(registry metrics.Registry, cfg *config.Config) []*cloudwatch.MetricDatum {
data := []*cloudwatch.MetricDatum{}
timestamp := aws.Time(time.Now())
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function metricsData
has 103 lines of code (exceeds 50 allowed). Consider refactoring. Open
func metricsData(registry metrics.Registry, cfg *config.Config) []*cloudwatch.MetricDatum {
data := []*cloudwatch.MetricDatum{}
timestamp := aws.Time(time.Now())
Method Config.applyEnvOverrides
has 86 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (c *Config) applyEnvOverrides(prefix string, spec reflect.Value) error {
// If we have a pointer, dereference it
s := spec
if spec.Kind() == reflect.Ptr {
s = spec.Elem()
Function MapToStruct
has a Cognitive Complexity of 32 (exceeds 20 allowed). Consider refactoring. Open
func MapToStruct(t interface{}, values map[string]interface{}) error {
ps := reflect.ValueOf(t)
// struct
s := ps.Elem()
if s.Kind() != reflect.Struct {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method Worker.Start
has a Cognitive Complexity of 31 (exceeds 20 allowed). Consider refactoring. Open
func (w *Worker) Start() {
go func() {
for {
// Add ourselves into the worker queue.
w.WorkerQueue <- w.Work
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method Config.applyEnvOverrides
has 11 return statements (exceeds 4 allowed). Open
func (c *Config) applyEnvOverrides(prefix string, spec reflect.Value) error {
// If we have a pointer, dereference it
s := spec
if spec.Kind() == reflect.Ptr {
s = spec.Elem()
Avoid deeply nested control flow statements. Open
} else if !c.HTTPExecutor.Enabled {
t.Fatalf("unexpected http executor enabled %v", c.HTTPExecutor.Enabled)
} else if !c.CrontabSource.Enabled {
t.Fatalf("unexpected crontab source enabled %v", c.CrontabSource.Enabled)
}
Avoid deeply nested control flow statements. Open
} else if len(c.RegistryURL) != 1 {
t.Fatalf("unexpected registry urls: %v", c.RegistryURL)
} else if c.CACert != "/etc/ssl/certs/ca.crt" {
t.Fatalf("unexpected ssl cert root: %v", c.CACert)
} else if c.SourceFolder != "/cron/jobs" {
Avoid deeply nested control flow statements. Open
if err != nil {
return fmt.Errorf("failed to apply %v to %v using type %v and value '%v'", key, fieldKey, f.Type().String(), value)
}
Avoid deeply nested control flow statements. Open
} else if c.JWTSubject != "0" {
t.Fatalf("unexpected jwt subject: %v", c.JWTSubject)
} else if c.Issuer != "issuer" {
t.Fatalf("unexpected issuer: %v", c.Issuer)
} else if c.JWTSecret != "" {
Avoid deeply nested control flow statements. Open
if err := c.applyEnvOverrides(key, f.Index(i)); err != nil {
return err
}
Avoid deeply nested control flow statements. Open
if err := c.applyEnvOverrides(fmt.Sprintf("%s_%d", key, i), f.Index(i)); err != nil {
return err
}
Avoid deeply nested control flow statements. Open
if err != nil {
return fmt.Errorf("failed to apply %v to %v using type %v and value '%v'", key, fieldKey, f.Type().String(), value)
}
Method Command.Run
has 6 return statements (exceeds 4 allowed). Open
func (cmd *Command) Run(args ...string) error {
options, err := cmd.ParseFlags(args...)
if err != nil {
return err
Method ExecutionProvider.Execute
has 6 return statements (exceeds 4 allowed). Open
func (p *ExecutionProvider) Execute(t interface{}, r *provider.Response) error {
if !p.Config.Enabled {
return fmt.Errorf("Local Executor is disabled. Please enable it in the configuration")
}
var task ExecutionData
Method Executor.Request
has 5 return statements (exceeds 4 allowed). Open
func (e *Executor) Request(url, method string, resq *provider.Response) (response *http.Response, erro error) {
e.RequestTiming.Time(func() {
req, err := http.NewRequest(strings.ToUpper(method), url, nil)
if err != nil {
e.ErrorCounter.Inc(1)
Method Options.GetConfigPath
has 5 return statements (exceeds 4 allowed). Open
func (opt *Options) GetConfigPath() string {
if opt.ConfigPath != "" {
if opt.ConfigPath == os.DevNull {
return ""
}
Method PrintConfigCommand.Run
has 5 return statements (exceeds 4 allowed). Open
func (cmd *PrintConfigCommand) Run(args ...string) error {
// Parse command flags.
fs := flag.NewFlagSet("", flag.ContinueOnError)
configPath := fs.String("config", "", "")
fs.Usage = func() { fmt.Fprintln(cmd.Stderr, printConfigUsage) }
Method Reporter.LogResult
has 5 return statements (exceeds 4 allowed). Open
func (r *Reporter) LogResult(evt *adapters.LogEvent) error {
var reader io.Reader
buf := new(bytes.Buffer)
if err := r.parseTemplate(evt, buf); err != nil {
return err