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
- 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 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
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
- 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 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
- 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 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
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
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
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
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
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
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)
}
Avoid deeply nested control flow statements. Wontfix
if parameters.metadataTag != "" {
parameters.genbank.Meta.Other[parameters.metadataTag] = parseMetadata(parameters.metadataData)
}
Avoid deeply nested control flow statements. Wontfix
switch expression[firstInnerParentheses+i] {
case []byte("(")[0]:
ParenthesesCount++
case []byte(")")[0]:
ParenthesesCount--
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
TODO found Wontfix
// TODO rewrite with proper error handling.
- Exclude checks
TODO found Wontfix
// TODO: could use reflection to get keys and make more general.
- Exclude checks
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
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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 = ""
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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 = ""
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76