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 {
- Read upRead up
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"
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{}
- Read upRead up
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 {
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{}
- Read upRead up
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{}
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)
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,
}
- Read upRead up
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)
- Read upRead up
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{}
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()
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 != "" {
- Read upRead up
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 != "" {
- Read upRead up
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 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{}
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{}
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),
}
Avoid deeply nested control flow statements. Open
if language != countryJSON.Lang {
countryData, err := http.Get(url + "--" + language)
if err != nil {
Avoid deeply nested control flow statements. Open
if !dependentLocalityRegex.MatchString(address.PostCode) {
err = multierror.Append(err, ErrInvalidPostCode)
return err.ErrorOrNil()
}
Function checkSubdivisions
has 6 return statements (exceeds 4 allowed). Open
func checkSubdivisions(address Address, administrativeAreaData []administrativeArea) error {
var err *multierror.Error
if address.AdministrativeArea != "" {
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
}