netdata/netdata

View on GitHub
src/go/collectors/go.d.plugin/pkg/matcher/glob.go

Summary

Maintainability
C
1 day
Test Coverage

Function matchChunk has a Cognitive Complexity of 47 (exceeds 20 allowed). Consider refactoring.
Open

func matchChunk(chunk, s string) (rest string, ok bool, err error) {
    for len(chunk) > 0 {
        if len(s) == 0 {
            return
        }
Severity: Minor
Found in src/go/collectors/go.d.plugin/pkg/matcher/glob.go - About 4 hrs 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

Method globMatcher.globMatch has a Cognitive Complexity of 30 (exceeds 20 allowed). Consider refactoring.
Open

func (m globMatcher) globMatch(name string) (matched bool, err error) {
    pattern := string(m)
Pattern:
    for len(pattern) > 0 {
        var star bool
Severity: Minor
Found in src/go/collectors/go.d.plugin/pkg/matcher/glob.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 matchChunk has 62 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func matchChunk(chunk, s string) (rest string, ok bool, err error) {
    for len(chunk) > 0 {
        if len(s) == 0 {
            return
        }
Severity: Minor
Found in src/go/collectors/go.d.plugin/pkg/matcher/glob.go - About 1 hr to fix

    Function matchChunk has 8 return statements (exceeds 4 allowed).
    Open

    func matchChunk(chunk, s string) (rest string, ok bool, err error) {
        for len(chunk) > 0 {
            if len(s) == 0 {
                return
            }
    Severity: Major
    Found in src/go/collectors/go.d.plugin/pkg/matcher/glob.go - About 50 mins to fix

      Avoid deeply nested control flow statements.
      Open

                          if hi, chunk, err = getEsc(chunk[1:]); err != nil {
                              return
                          }
      Severity: Major
      Found in src/go/collectors/go.d.plugin/pkg/matcher/glob.go - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                            if len(pattern) == 0 && len(t) > 0 {
                                continue
                            }
        Severity: Major
        Found in src/go/collectors/go.d.plugin/pkg/matcher/glob.go - About 45 mins to fix

          Method globMatcher.globMatch has 5 return statements (exceeds 4 allowed).
          Open

          func (m globMatcher) globMatch(name string) (matched bool, err error) {
              pattern := string(m)
          Pattern:
              for len(pattern) > 0 {
                  var star bool
          Severity: Major
          Found in src/go/collectors/go.d.plugin/pkg/matcher/glob.go - About 35 mins to fix

            There are no issues that match your filters.

            Category
            Status