jufemaiz/go-aemo

View on GitHub

Showing 28 of 41 total issues

Method parser.readDay has a Cognitive Complexity of 127 (exceeds 20 allowed). Consider refactoring.
Open

func (p *parser) readDay() (set *IntervalSet, err error) { //nolint:cyclop,gocyclo
    defer func() {
        if err != nil && !errors.Is(err, io.EOF) {
            err = p.error(err)
        }
Severity: Minor
Found in nem12/parser.go - About 2 days 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 parser.readDay has 229 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func (p *parser) readDay() (set *IntervalSet, err error) { //nolint:cyclop,gocyclo
    defer func() {
        if err != nil && !errors.Is(err, io.EOF) {
            err = p.error(err)
        }
Severity: Major
Found in nem12/parser.go - About 1 day to fix

    Method parser.cacheValues has a Cognitive Complexity of 48 (exceeds 20 allowed). Consider refactoring.
    Open

    func (p *parser) cacheValues(rec Record) (err error) { //nolint:cyclop,funlen,gocognit,gocyclo
        // Reset the values first.
        p.resetDay()
    
        var (
    Severity: Minor
    Found in nem12/parser.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

    File reason.go has 587 lines of code (exceeds 500 allowed). Consider refactoring.
    Open

    package nem12
    
    import (
        "fmt"
        "strings"
    Severity: Minor
    Found in nem12/reason.go - About 4 hrs to fix

      File parser.go has 562 lines of code (exceeds 500 allowed). Consider refactoring.
      Open

      package nem12
      
      import (
          "encoding/csv"
          "errors"
      Severity: Minor
      Found in nem12/parser.go - About 3 hrs to fix

        Method parser.cacheValues has 104 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func (p *parser) cacheValues(rec Record) (err error) { //nolint:cyclop,funlen,gocognit,gocyclo
            // Reset the values first.
            p.resetDay()
        
            var (
        Severity: Major
        Found in nem12/parser.go - About 3 hrs to fix

          Method parser.readDay has 27 return statements (exceeds 4 allowed).
          Open

          func (p *parser) readDay() (set *IntervalSet, err error) { //nolint:cyclop,gocyclo
              defer func() {
                  if err != nil && !errors.Is(err, io.EOF) {
                      err = p.error(err)
                  }
          Severity: Major
          Found in nem12/parser.go - About 2 hrs to fix

            Function newIntervalEvent has a Cognitive Complexity of 28 (exceeds 20 allowed). Consider refactoring.
            Open

            func newIntervalEvent(rec Record) (*intervalEvent, error) {
                var (
                    start      int
                    finish     int
                    qm         QualityMethod
            Severity: Minor
            Found in nem12/interval.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

            Method Field.Validate has 60 lines of code (exceeds 50 allowed). Consider refactoring.
            Open

            func (f Field) Validate() error { //nolint:cyclop,gocyclo
                switch f.Type {
                case FieldRecordIndicator:
                    return validateFieldRecordIndicator(f.Value)
                case FieldVersionHeader:
            Severity: Minor
            Found in nem12/field.go - About 1 hr to fix

              Function newIntervalEvent has 57 lines of code (exceeds 50 allowed). Consider refactoring.
              Open

              func newIntervalEvent(rec Record) (*intervalEvent, error) {
                  var (
                      start      int
                      finish     int
                      qm         QualityMethod
              Severity: Minor
              Found in nem12/interval.go - About 1 hr to fix

                Method parser.cacheValues has 12 return statements (exceeds 4 allowed).
                Open

                func (p *parser) cacheValues(rec Record) (err error) { //nolint:cyclop,funlen,gocognit,gocyclo
                    // Reset the values first.
                    p.resetDay()
                
                    var (
                Severity: Major
                Found in nem12/parser.go - About 1 hr to fix

                  Avoid deeply nested control flow statements.
                  Open

                                      if err != nil {
                                          return nil, err
                                      }
                  Severity: Major
                  Found in nem12/parser.go - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                        if err != nil {
                                            return nil, err
                                        }
                    Severity: Major
                    Found in nem12/parser.go - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                          if err != nil {
                                              return nil, err
                                          }
                      Severity: Major
                      Found in nem12/parser.go - About 45 mins to fix

                        Method QualityMethod.Validate has 7 return statements (exceeds 4 allowed).
                        Open

                        func (qm QualityMethod) Validate() error {
                            strLen := len(qm)
                        
                            if strLen == 0 {
                                return ErrQualityMethodNil
                        Severity: Major
                        Found in nem12/qualitymethod.go - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                              if err != nil {
                                                  return nil, err
                                              }
                          Severity: Major
                          Found in nem12/parser.go - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                                if err != nil {
                                                    return nil, err
                                                }
                            Severity: Major
                            Found in nem12/parser.go - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

                                                  if err != nil {
                                                      return nil, err
                                                  }
                              Severity: Major
                              Found in nem12/parser.go - About 45 mins to fix

                                Avoid deeply nested control flow statements.
                                Open

                                                    if err != nil {
                                                        return nil, err
                                                    }
                                Severity: Major
                                Found in nem12/parser.go - About 45 mins to fix

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

                                  func newIntervalEvent(rec Record) (*intervalEvent, error) {
                                      var (
                                          start      int
                                          finish     int
                                          qm         QualityMethod
                                  Severity: Major
                                  Found in nem12/interval.go - About 45 mins to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language