Boostport/address

View on GitHub

Showing 22 of 33 total issues

Method worker.start has a Cognitive Complexity of 172 (exceeds 20 allowed). Consider refactoring.
Open

func (w *worker) start() {
    go func() {
        for {
        exit:
            select {
Severity: Minor
Found in generator/generate.go - About 3 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

File generate.go has 949 lines of code (exceeds 500 allowed). Consider refactoring.
Open

package main

import (
    "encoding/json"
    "errors"
Severity: Major
Found in generator/generate.go - About 1 day to fix

    Function processAdministrativeAreas has a Cognitive Complexity of 75 (exceeds 20 allowed). Consider refactoring.
    Open

    func processAdministrativeAreas(countryJSON countryJSON, language string) (map[string][]administrativeArea, map[string]postCodeRegex, error) {
    
        result := map[string][]administrativeArea{}
        postCodeResult := map[string]postCodeRegex{}
    
    
    Severity: Minor
    Found in generator/generate.go - About 1 day 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 worker.start has 172 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func (w *worker) start() {
        go func() {
            for {
            exit:
                select {
    Severity: Major
    Found in generator/generate.go - About 5 hrs to fix

      Function processLocalities has a Cognitive Complexity of 52 (exceeds 20 allowed). Consider refactoring.
      Open

      func processLocalities(administrativeAreaJSON subdivisionJSON, language string) (map[string][]locality, map[string]postCodeRegex, error) {
      
          result := map[string][]locality{}
          postCodeResult := map[string]postCodeRegex{}
      
      
      Severity: Minor
      Found in generator/generate.go - About 5 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

      Function processAdministrativeAreas has 122 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func processAdministrativeAreas(countryJSON countryJSON, language string) (map[string][]administrativeArea, map[string]postCodeRegex, error) {
      
          result := map[string][]administrativeArea{}
          postCodeResult := map[string]postCodeRegex{}
      
      
      Severity: Major
      Found in generator/generate.go - About 3 hrs to fix

        Method country.toCode has 111 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func (c country) toCode() string {
        
            str := fmt.Sprintf(`{
            ID: "%s",
            Name: "%s",`, c.ID, c.Name)
        Severity: Major
        Found in generator/generate.go - About 3 hrs to fix

          Function checkRequiredFields has a Cognitive Complexity of 35 (exceeds 20 allowed). Consider refactoring.
          Open

          func checkRequiredFields(address Address, requiredFields map[Field]struct{}) error {
          
              errors := ErrMissingRequiredFields{
                  country: address.Country,
              }
          Severity: Minor
          Found in validate.go - About 2 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 country.toCode has a Cognitive Complexity of 34 (exceeds 20 allowed). Consider refactoring.
          Open

          func (c country) toCode() string {
          
              str := fmt.Sprintf(`{
              ID: "%s",
              Name: "%s",`, c.ID, c.Name)
          Severity: Minor
          Found in generator/generate.go - About 2 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

          Function processLocalities has 87 lines of code (exceeds 50 allowed). Consider refactoring.
          Open

          func processLocalities(administrativeAreaJSON subdivisionJSON, language string) (map[string][]locality, map[string]postCodeRegex, error) {
          
              result := map[string][]locality{}
              postCodeResult := map[string]postCodeRegex{}
          
          
          Severity: Major
          Found in generator/generate.go - About 2 hrs to fix

            Function main has 72 lines of code (exceeds 50 allowed). Consider refactoring.
            Open

            func main() {
            
                fmt.Printf("Downloading address data from %s. This may take a few minutes.\n", rootURL)
            
                start := time.Now()
            Severity: Minor
            Found in generator/generate.go - About 1 hr to fix

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

              func checkSubdivisions(address Address, administrativeAreaData []administrativeArea) error {
              
                  var err *multierror.Error
              
                  if address.AdministrativeArea != "" {
              Severity: Minor
              Found in validate.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 checkPostCode has a Cognitive Complexity of 25 (exceeds 20 allowed). Consider refactoring.
              Open

              func checkPostCode(address Address, regex postCodeRegex) error {
              
                  var err *multierror.Error
              
                  if address.PostCode != "" && regex.regex != "" {
              Severity: Minor
              Found in validate.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 processLocalities has 9 return statements (exceeds 4 allowed).
              Open

              func processLocalities(administrativeAreaJSON subdivisionJSON, language string) (map[string][]locality, map[string]postCodeRegex, error) {
              
                  result := map[string][]locality{}
                  postCodeResult := map[string]postCodeRegex{}
              
              
              Severity: Major
              Found in generator/generate.go - About 55 mins to fix

                Function processAdministrativeAreas has 9 return statements (exceeds 4 allowed).
                Open

                func processAdministrativeAreas(countryJSON countryJSON, language string) (map[string][]administrativeArea, map[string]postCodeRegex, error) {
                
                    result := map[string][]administrativeArea{}
                    postCodeResult := map[string]postCodeRegex{}
                
                
                Severity: Major
                Found in generator/generate.go - About 55 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                              if language != countryJSON.Lang {
                  
                                                  countryData, err := http.Get(url + "--" + language)
                  
                                                  if err != nil {
                  Severity: Major
                  Found in generator/generate.go - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                            if err != nil {
                                                w.result <- workerResult{
                                                    Error: fmt.Errorf("error processing admin areas in the default language for country %s: %s", countryJSON.Key, err),
                                                }
                    
                    
                    Severity: Major
                    Found in generator/generate.go - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                          if !dependentLocalityRegex.MatchString(address.PostCode) {
                                              err = multierror.Append(err, ErrInvalidPostCode)
                                              return err.ErrorOrNil()
                                          }
                      Severity: Major
                      Found in validate.go - About 45 mins to fix

                        Function checkSubdivisions has 6 return statements (exceeds 4 allowed).
                        Open

                        func checkSubdivisions(address Address, administrativeAreaData []administrativeArea) error {
                        
                            var err *multierror.Error
                        
                            if address.AdministrativeArea != "" {
                        Severity: Major
                        Found in validate.go - About 40 mins to fix

                          Method Territory.contains has 5 return statements (exceeds 4 allowed).
                          Open

                          func (t Territory) contains(address Address) bool {
                          
                              if t.Country != "" && address.Country != t.Country {
                                  return false
                              }
                          Severity: Major
                          Found in zone.go - About 35 mins to fix
                            Severity
                            Category
                            Status
                            Source
                            Language