TimothyStiles/poly

View on GitHub
io/genbank/genbank.go

Summary

Maintainability
A
0 mins
Test Coverage

Function ParseMultiNth has a Cognitive Complexity of 89 (exceeds 20 allowed). Consider refactoring.
Wontfix

func ParseMultiNth(r io.Reader, count int) ([]Genbank, error) {
    scanner := bufio.NewScanner(r)
    var genbanks []Genbank

    // Sequence setup
Severity: Minor
Found in io/genbank/genbank.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

File genbank.go has 752 lines of code (exceeds 500 allowed). Consider refactoring.
Wontfix

/*
Package genbank provides genbank parsers and writers.

GenBank is a flat text file format developed in the 1980s to annotate genetic
sequences, and has since become the standard for sharing annotated genetic
Severity: Major
Found in io/genbank/genbank.go - About 1 day to fix

    Function parseLocation has a Cognitive Complexity of 57 (exceeds 20 allowed). Consider refactoring.
    Wontfix

    func parseLocation(locationString string) (Location, error) {
        var location Location
        location.GbkLocationString = locationString
        if !(strings.ContainsAny(locationString, "(")) { // Case checks for simple expression of x..x
            if !(strings.ContainsAny(locationString, ".")) { //Case checks for simple expression x
    Severity: Minor
    Found in io/genbank/genbank.go - About 6 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 buildMultiNth has a Cognitive Complexity of 49 (exceeds 20 allowed). Consider refactoring.
    Wontfix

    func buildMultiNth(sequences []Genbank, count int) ([]byte, error) {
        var gbkString bytes.Buffer
        for _, sequence := range sequences {
            locus := sequence.Meta.Locus
            var shape string
    Severity: Minor
    Found in io/genbank/genbank.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 ParseMultiNth has 149 lines of code (exceeds 50 allowed). Consider refactoring.
    Wontfix

    func ParseMultiNth(r io.Reader, count int) ([]Genbank, error) {
        scanner := bufio.NewScanner(r)
        var genbanks []Genbank
    
        // Sequence setup
    Severity: Major
    Found in io/genbank/genbank.go - About 4 hrs to fix

      Function buildMultiNth has 92 lines of code (exceeds 50 allowed). Consider refactoring.
      Wontfix

      func buildMultiNth(sequences []Genbank, count int) ([]byte, error) {
          var gbkString bytes.Buffer
          for _, sequence := range sequences {
              locus := sequence.Meta.Locus
              var shape string
      Severity: Major
      Found in io/genbank/genbank.go - About 2 hrs to fix

        Function parseLocation has 79 lines of code (exceeds 50 allowed). Consider refactoring.
        Wontfix

        func parseLocation(locationString string) (Location, error) {
            var location Location
            location.GbkLocationString = locationString
            if !(strings.ContainsAny(locationString, "(")) { // Case checks for simple expression of x..x
                if !(strings.ContainsAny(locationString, ".")) { //Case checks for simple expression x
        Severity: Major
        Found in io/genbank/genbank.go - About 2 hrs to fix

          Function parseLocation has 8 return statements (exceeds 4 allowed).
          Wontfix

          func parseLocation(locationString string) (Location, error) {
              var location Location
              location.GbkLocationString = locationString
              if !(strings.ContainsAny(locationString, "(")) { // Case checks for simple expression of x..x
                  if !(strings.ContainsAny(locationString, ".")) { //Case checks for simple expression x
          Severity: Major
          Found in io/genbank/genbank.go - About 50 mins to fix

            Function ParseMultiNth has 7 return statements (exceeds 4 allowed).
            Wontfix

            func ParseMultiNth(r io.Reader, count int) ([]Genbank, error) {
                scanner := bufio.NewScanner(r)
                var genbanks []Genbank
            
                // Sequence setup
            Severity: Major
            Found in io/genbank/genbank.go - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Wontfix

                          } else if strings.Contains(parameters.currentLine, "/") { // current line is a new qualifier
              
                              // save our completed attribute / qualifier string to the current feature
                              if parameters.attributeValue != "" {
                                  parameters.feature.Attributes[parameters.attribute] = parameters.attributeValue
              Severity: Major
              Found in io/genbank/genbank.go - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Wontfix

                                    if err != nil {
                                        return []Genbank{}, fmt.Errorf("Failed in parsing reference above line %d. Got error: %s", lineNum, err)
                                    }
                Severity: Major
                Found in io/genbank/genbank.go - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Wontfix

                                      if parameters.metadataTag != "" {
                                          parameters.genbank.Meta.Other[parameters.metadataTag] = parseMetadata(parameters.metadataData)
                                      }
                  Severity: Major
                  Found in io/genbank/genbank.go - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Wontfix

                                        switch expression[firstInnerParentheses+i] {
                                        case []byte("(")[0]:
                                            ParenthesesCount++
                                        case []byte(")")[0]:
                                            ParenthesesCount--
                    Severity: Major
                    Found in io/genbank/genbank.go - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Wontfix

                                      if !strings.Contains(parameters.currentLine, "\"") && (countLeadingSpaces(parameters.currentLine) > countLeadingSpaces(parameters.prevline) || parameters.multiLineFeature) {
                                          parameters.feature.Location.GbkLocationString += strings.TrimSpace(line)
                                          parameters.multiLineFeature = true // without this we can't tell if something is a multiline feature or multiline qualifier
                                      } else { // it's a continued line of a qualifier
                      
                      
                      Severity: Major
                      Found in io/genbank/genbank.go - About 45 mins to fix

                        TODO found
                        Wontfix

                        // TODO rewrite with proper error handling.
                        Severity: Minor
                        Found in io/genbank/genbank.go by fixme

                        TODO found
                        Wontfix

                                // TODO: could use reflection to get keys and make more general.
                        Severity: Minor
                        Found in io/genbank/genbank.go by fixme

                        Identical blocks of code found in 2 locations. Consider refactoring.
                        Wontfix

                        func getFeatureSequence(feature Feature, location Location) (string, error) {
                            var sequenceBuffer bytes.Buffer
                            var sequenceString string
                            parentSequence := feature.ParentSequence.Sequence
                        
                        
                        Severity: Major
                        Found in io/genbank/genbank.go and 1 other location - About 2 hrs to fix
                        io/gff/gff.go on lines 92..115

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

                        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

                        Identical blocks of code found in 2 locations. Consider refactoring.
                        Wontfix

                                        if parameters.attributeValue != "" {
                                            parameters.feature.Attributes[parameters.attribute] = parameters.attributeValue
                                            parameters.features = append(parameters.features, parameters.feature)
                                            parameters.attributeValue = ""
                                            parameters.attribute = ""
                        Severity: Minor
                        Found in io/genbank/genbank.go and 1 other location - About 30 mins to fix
                        io/genbank/genbank.go on lines 497..506

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

                        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

                        Identical blocks of code found in 2 locations. Consider refactoring.
                        Wontfix

                                        if parameters.attributeValue != "" {
                                            parameters.feature.Attributes[parameters.attribute] = parameters.attributeValue
                                            parameters.features = append(parameters.features, parameters.feature)
                                            parameters.attributeValue = ""
                                            parameters.attribute = ""
                        Severity: Minor
                        Found in io/genbank/genbank.go and 1 other location - About 30 mins to fix
                        io/genbank/genbank.go on lines 533..540

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

                        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

                        There are no issues that match your filters.

                        Category
                        Status