biter777/countries

View on GitHub
countries.go

Summary

Maintainability
F
2 wks
Test Coverage

File countries.go has 5849 lines of code (exceeds 500 allowed). Consider refactoring.
Invalid

// Package countries - ISO 3166 (ISO3166-1, ISO3166, Digit, Alpha-2 and Alpha-3) countries codes and names (on eng and rus), ISO 4217 currency designators, ITU-T E.164 IDD calling phone codes, countries capitals, UN M.49 regions codes, ccTLD countries domains, IOC/NOC and FIFA letters codes, VERY FAST, NO maps[], NO slices[], NO external links/files/data, NO interface{}, NO specific dependencies, Databases compatible, Emoji countries flags and currencies support, full support ISO-3166-1, ISO-4217, ITU-T E.164, Unicode CLDR and ccTLD standarts. Full support ISO-3166-1, ISO-4217, ITU-T E.164, Unicode CLDR and ccTLD standarts.
/*
Package countries - ISO 3166 (ISO3166-1, ISO3166, Digit, Alpha-2 and Alpha-3) countries codes and names (on eng and rus), ISO 4217 currency designators, ITU-T E.164 IDD calling phone codes, countries capitals, UN M.49 regions codes, ccTLD countries domains, IOC/NOC and FIFA letters codes, VERY FAST, NO maps[], NO slices[], NO external links/files/data, NO interface{}, NO specific dependencies, Databases compatible, Emoji countries flags and currencies support, full support ISO-3166-1, ISO-4217, ITU-T E.164, Unicode CLDR and ccTLD standarts.
Full support ISO-3166-1, ISO-4217, ITU-T E.164, Unicode CLDR and ccTLD standarts.

Severity: Major
Found in countries.go - About 2 wks to fix

    Function ByName has 537 lines of code (exceeds 50 allowed). Consider refactoring.
    Invalid

    func ByName(name string) CountryCode { //nolint:misspell,gocyclo
        switch textPrepare(name) {
        case "AU", "AUS", "AUSTRALIA", "AVSTRALIA", "AVSTRALIYA", "AUSTRALIYA", "AUSTRALIEN":
            return AUS
        case "AT", "AUT", "AUSTRIA", "AVSTRIA", "AUSTRIYA", "AVSTRIYA", "ÖSTERREICH", "OESTERREICH":
    Severity: Major
    Found in countries.go - About 2 days to fix

      Method CountryCode.CallCodes has 532 lines of code (exceeds 50 allowed). Consider refactoring.
      Invalid

      func (c CountryCode) CallCodes() []CallCode { //nolint:gocyclo
          switch c {
          case AUS:
              return []CallCode{CallCode(61)}
          case AUT:
      Severity: Major
      Found in countries.go - About 2 days to fix

        Method CountryCode.StringRus has 531 lines of code (exceeds 50 allowed). Consider refactoring.
        Invalid

        func (c CountryCode) StringRus() string { //nolint:gocyclo
            switch c {
            case 8:
                return "Албания"
            case 12:
        Severity: Major
        Found in countries.go - About 2 days to fix

          Method CountryCode.FIPS has 531 lines of code (exceeds 50 allowed). Consider refactoring.
          Open

          func (c CountryCode) FIPS() string {
              switch c {
              case 8:
                  return "AL"
              case 12:
          Severity: Major
          Found in countries.go - About 2 days to fix

            Method CountryCode.String has 531 lines of code (exceeds 50 allowed). Consider refactoring.
            Invalid

            func (c CountryCode) String() string { //nolint:gocyclo
                switch c {
                case 8:
                    return "Albania"
                case 12:
            Severity: Major
            Found in countries.go - About 2 days to fix

              Method CountryCode.Alpha2 has 531 lines of code (exceeds 50 allowed). Consider refactoring.
              Invalid

              func (c CountryCode) Alpha2() string { //nolint:gocyclo
                  switch c {
                  case 8:
                      return "AL"
                  case 12:
              Severity: Major
              Found in countries.go - About 2 days to fix

                Method CountryCode.Alpha3 has 531 lines of code (exceeds 50 allowed). Consider refactoring.
                Invalid

                func (c CountryCode) Alpha3() string { //nolint:gocyclo
                    switch c {
                    case 8:
                        return "ALB"
                    case 12:
                Severity: Major
                Found in countries.go - About 2 days to fix

                  Method CountryCode.Region has 512 lines of code (exceeds 50 allowed). Consider refactoring.
                  Invalid

                  func (c CountryCode) Region() RegionCode { //nolint:gocyclo
                      switch c {
                      case AUS:
                          return RegionOC
                      case AUT:
                  Severity: Major
                  Found in countries.go - About 2 days to fix

                    Method CountryCode.Capital has 512 lines of code (exceeds 50 allowed). Consider refactoring.
                    Invalid

                    func (c CountryCode) Capital() CapitalCode { //nolint:gocyclo
                        switch c {
                        case AUS:
                            return CapitalAU
                        case AUT:
                    Severity: Major
                    Found in countries.go - About 2 days to fix

                      Method CountryCode.Currency has 494 lines of code (exceeds 50 allowed). Consider refactoring.
                      Invalid

                      func (c CountryCode) Currency() CurrencyCode { //nolint:gocyclo
                          switch c {
                          case AUS:
                              return CurrencyAUD
                          case AUT, AND, MAF:
                      Severity: Major
                      Found in countries.go - About 2 days to fix

                        Function All has 254 lines of code (exceeds 50 allowed). Consider refactoring.
                        Invalid

                        func All() []CountryCode {
                            return []CountryCode{
                                AUS,
                                AUT,
                                AZE,
                        Severity: Major
                        Found in countries.go - About 1 day to fix

                          Method CountryCode.IOC has 183 lines of code (exceeds 50 allowed). Consider refactoring.
                          Invalid

                          func (c CountryCode) IOC() string { //nolint:gocyclo
                              switch c {
                              case DZA:
                                  return `ALG`
                              case ASM:
                          Severity: Major
                          Found in countries.go - About 6 hrs to fix

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

                            func (c CountryCode) FIPS() string {
                                switch c {
                                case 8:
                                    return "AL"
                                case 12:
                            Severity: Major
                            Found in countries.go and 3 other locations - About 3 days to fix
                            countries.go on lines 162..694
                            countries.go on lines 1773..2305
                            countries.go on lines 2310..2842

                            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 1887.

                            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 4 locations. Consider refactoring.
                            Open

                            func (c CountryCode) Alpha2() string { //nolint:gocyclo
                                switch c {
                                case 8:
                                    return "AL"
                                case 12:
                            Severity: Major
                            Found in countries.go and 3 other locations - About 3 days to fix
                            countries.go on lines 162..694
                            countries.go on lines 1236..1768
                            countries.go on lines 2310..2842

                            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 1887.

                            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 4 locations. Consider refactoring.
                            Open

                            func (c CountryCode) String() string { //nolint:gocyclo
                                switch c {
                                case 8:
                                    return "Albania"
                                case 12:
                            Severity: Major
                            Found in countries.go and 3 other locations - About 3 days to fix
                            countries.go on lines 1236..1768
                            countries.go on lines 1773..2305
                            countries.go on lines 2310..2842

                            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 1887.

                            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 4 locations. Consider refactoring.
                            Open

                            func (c CountryCode) Alpha3() string { //nolint:gocyclo
                                switch c {
                                case 8:
                                    return "ALB"
                                case 12:
                            Severity: Major
                            Found in countries.go and 3 other locations - About 3 days to fix
                            countries.go on lines 162..694
                            countries.go on lines 1236..1768
                            countries.go on lines 1773..2305

                            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 1887.

                            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 6 locations. Consider refactoring.
                            Invalid

                            func (country *Country) Scan(src interface{}) error {
                                if country == nil {
                                    return fmt.Errorf("countries::Scan: Country scan err: country == nil")
                                }
                                switch src := src.(type) {
                            Severity: Major
                            Found in countries.go and 5 other locations - About 45 mins to fix
                            callcodes.go on lines 847..860
                            capitals.go on lines 1072..1085
                            currencies.go on lines 1646..1659
                            domains.go on lines 103..116
                            regions.go on lines 97..110

                            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 117.

                            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

                            receiver name should not be an underscore, omit the name if it is unused
                            Open

                            func (_ CountryCode) Type() string {
                            Severity: Minor
                            Found in countries.go by golint

                            receiver name should not be an underscore, omit the name if it is unused
                            Open

                            func (_ *Country) Type() string {
                            Severity: Minor
                            Found in countries.go by golint

                            There are no issues that match your filters.

                            Category
                            Status