jufemaiz/go-aemo

View on GitHub

Showing 41 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

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

        reasonDescriptions = map[Reason]string{ //nolint:dupl,gochecknoglobals
            ReasonFreeTextDescription:                   "Free text description",
            ReasonMeterEquipmentChanged:                 "Meter/equipment changed",
            ReasonExtremeWeatherConditions:              "Extreme weather conditions",
            ReasonQuarantinedPremises:                   "Quarantined premises",
    Severity: Major
    Found in nem12/reason.go and 1 other location - About 6 hrs to fix
    nem12/reason.go on lines 437..532

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 486.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

        ReasonName = map[Reason]string{ //nolint:dupl,gochecknoglobals
            ReasonFreeTextDescription:                   "0",
            ReasonMeterEquipmentChanged:                 "1",
            ReasonExtremeWeatherConditions:              "2",
            ReasonQuarantinedPremises:                   "3",
    Severity: Major
    Found in nem12/reason.go and 1 other location - About 6 hrs to fix
    nem12/reason.go on lines 633..728

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 486.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

            case parseStateNextIntervalEvent:
                switch ri { //nolint:exhaustive
                case RecordB2BDetails:
                    p.state = parseStateNextB2BDetails
                    p.backup()
    Severity: Major
    Found in nem12/parser.go and 1 other location - About 5 hrs to fix
    nem12/parser.go on lines 198..276

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 372.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

            case parseStateNextIntervalData:
                switch ri { //nolint:exhaustive
                case RecordB2BDetails:
                    p.state = parseStateNextB2BDetails
                    p.backup()
    Severity: Major
    Found in nem12/parser.go and 1 other location - About 5 hrs to fix
    nem12/parser.go on lines 293..371

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 372.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    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

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                methodDescriptions = map[Method]string{ //nolint:gochecknoglobals
                    Method11Check:                      "check",
                    Method12Calculated:                 "calculated",
                    Method13SCADA:                      "scada",
                    Method14LikeDay:                    "like day",
            Severity: Major
            Found in nem12/method.go and 1 other location - About 1 hr to fix
            nem12/method.go on lines 120..155

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 186.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 2 locations. Consider refactoring.
            Open

                MethodName = map[Method]string{ //nolint:gochecknoglobals
                    Method11Check:                      "11",
                    Method12Calculated:                 "12",
                    Method13SCADA:                      "13",
                    Method14LikeDay:                    "14",
            Severity: Major
            Found in nem12/method.go and 1 other location - About 1 hr to fix
            nem12/method.go on lines 196..231

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 186.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            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

                  Similar blocks of code found in 2 locations. Consider refactoring.
                  Open

                  func validateFieldStartInterval(v string) error {
                      if v == "" {
                          return fmt.Errorf("field start interval: %w", ErrFieldNil)
                      }
                  
                  
                  Severity: Major
                  Found in nem12/field.go and 1 other location - About 1 hr to fix
                  nem12/field.go on lines 544..563

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 130.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  Similar blocks of code found in 2 locations. Consider refactoring.
                  Open

                  func validateFieldFinishInterval(v string) error {
                      if v == "" {
                          return fmt.Errorf("field finish interval: %w", ErrFieldNil)
                      }
                  
                  
                  Severity: Major
                  Found in nem12/field.go and 1 other location - About 1 hr to fix
                  nem12/field.go on lines 523..542

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 130.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  Similar blocks of code found in 2 locations. Consider refactoring.
                  Open

                      reasonsDeprecated = map[Reason]bool{ //nolint:gochecknoglobals
                          ReasonConsumerWanted:                  true,
                          ReasonMeterStopSwitchOn:               true,
                          ReasonExtremeWeatherHot:               true,
                          ReasonWetPaint:                        true,
                  Severity: Minor
                  Found in nem12/reason.go and 1 other location - About 55 mins to fix
                  nem12/unitofmeasure.go on lines 174..198

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 127.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  Severity
                  Category
                  Status
                  Source
                  Language