dotcloud/docker

View on GitHub
daemon/config/config.go

Summary

Maintainability
B
6 hrs
Test Coverage

Function getConflictFreeConfiguration has a Cognitive Complexity of 29 (exceeds 20 allowed). Consider refactoring.
Open

func getConflictFreeConfiguration(configFile string, flags *pflag.FlagSet) (*Config, error) {
    b, err := os.ReadFile(configFile)
    if err != nil {
        return nil, err
    }
Severity: Minor
Found in daemon/config/config.go - About 1 hr to fix

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 findConfigurationConflicts has a Cognitive Complexity of 29 (exceeds 20 allowed). Consider refactoring.
Open

func findConfigurationConflicts(config map[string]interface{}, flags *pflag.FlagSet) error {
    // 1. Search keys from the file that we don't recognize as flags.
    unknownKeys := make(map[string]interface{})
    for key, value := range config {
        if flag := flags.Lookup(key); flag == nil && !skipValidateOptions[key] {
Severity: Minor
Found in daemon/config/config.go - About 1 hr to fix

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 Validate has 10 return statements (exceeds 4 allowed).
Open

func Validate(config *Config) error {
    // validate log-level
    if config.LogLevel != "" {
        // FIXME(thaJeztah): find a better way for this; this depends on knowledge of containerd's log package internals.
        // Alternatively: try  log.SetLevel(config.LogLevel), and restore the original level, but this also requires internal knowledge.
Severity: Major
Found in daemon/config/config.go - About 1 hr to fix

    Function getConflictFreeConfiguration has 7 return statements (exceeds 4 allowed).
    Open

    func getConflictFreeConfiguration(configFile string, flags *pflag.FlagSet) (*Config, error) {
        b, err := os.ReadFile(configFile)
        if err != nil {
            return nil, err
        }
    Severity: Major
    Found in daemon/config/config.go - About 45 mins to fix

      Function Reload has 5 return statements (exceeds 4 allowed).
      Open

      func Reload(configFile string, flags *pflag.FlagSet, reload func(*Config)) error {
          log.G(context.TODO()).Infof("Got signal to reload configuration, reloading from: %s", configFile)
          newConfig, err := getConflictFreeConfiguration(configFile, flags)
          if err != nil {
              if flags.Changed("config-file") || !os.IsNotExist(err) {
      Severity: Major
      Found in daemon/config/config.go - About 35 mins to fix

        Function ValidateMinAPIVersion has 5 return statements (exceeds 4 allowed).
        Open

        func ValidateMinAPIVersion(ver string) error {
            if ver == "" {
                return errors.New(`value is empty`)
            }
            if strings.EqualFold(ver[0:1], "v") {
        Severity: Major
        Found in daemon/config/config.go - About 35 mins to fix

          Function Validate has a Cognitive Complexity of 21 (exceeds 20 allowed). Consider refactoring.
          Open

          func Validate(config *Config) error {
              // validate log-level
              if config.LogLevel != "" {
                  // FIXME(thaJeztah): find a better way for this; this depends on knowledge of containerd's log package internals.
                  // Alternatively: try  log.SetLevel(config.LogLevel), and restore the original level, but this also requires internal knowledge.
          Severity: Minor
          Found in daemon/config/config.go - About 25 mins to fix

          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

          There are no issues that match your filters.

          Category
          Status