Showing 81 of 81 total issues
Avoid deeply nested control flow statements. Open
if en < len(e.Value.(*node).b) &&
(isFloatLetter(e.Value.(*node).b[en])) {
if en+1 < len(e.Value.(*node).b) &&
(e.Value.(*node).b[en+1] == '+' || e.Value.(*node).b[en+1] == '-') {
en++
Similar blocks of code found in 2 locations. Consider refactoring. Open
percent_error=float(list_results[2][dtype]+list_results[3][dtype])/float(list_results[0][dtype])*100
- 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 35.
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
Avoid deeply nested control flow statements. Open
if rightPart[rightSeparator].tok == token.RPAREN {
counter--
}
Avoid deeply nested control flow statements. Open
switch p.ns[pos].tok {
case token.LPAREN:
counter++
case token.RPAREN:
counter--
Method scanner.scanTokensAfter
has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring. Open
func (s *scanner) scanTokensAfter() {
entities := []struct {
tok token.Token
pattern []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
Similar blocks of code found in 3 locations. Consider refactoring. Open
print(str(list_results[1][4])+"\n"+str(list_results[2][4]+list_results[3][4]))
- 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 35.
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
Avoid deeply nested control flow statements. Open
switch p.ns[p.ident].tok {
case token.LPAREN:
counter++
case token.RPAREN:
counter--
Avoid deeply nested control flow statements. Open
if counter == 0 {
break
}
Avoid deeply nested control flow statements. Open
if len(arg.Name) > 10 && arg.Name[:7] == "func()*" {
arg.Name = "*" + arg.Name
continue
}
Avoid deeply nested control flow statements. Open
if par, ok := un.X.(*goast.ParenExpr); ok {
if id, ok := par.X.(*goast.IndexExpr); ok {
call.Args[i] = id
continue
}
Avoid deeply nested control flow statements. Open
if ok {
// add init
var inject []node
inject = append(inject, typ...)
for i := start; i < pos; i++ {
Avoid deeply nested control flow statements. Open
if rightSeparator+1 <= len(rightPart) {
for {
if rightPart[rightSeparator].tok == token.LBRACK {
counter++
}
Avoid deeply nested control flow statements. Open
if strings.Contains(arg.Name, "func()*[]byte{y:=[]byte(") {
arg.Name = arg.Name[17:]
index := strings.LastIndex(arg.Name, "\")")
arg.Name = arg.Name[:index+2]
if i > 1 {
Similar blocks of code found in 3 locations. Consider refactoring. Open
print("--> ALL PRECISIONS\t"+str(list_results[0][4])+"\t\t"+str(list_results[1][4])+"\t("+"%.3f" % percent_num_error+"%)\t"+str(list_results[2][4]+list_results[3][4])+"\t("+"%.3f" % percent_error+"%)\t""\n")
- 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 35.
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
Avoid deeply nested control flow statements. Open
if counter == 0 {
break
}
Avoid deeply nested control flow statements. Open
if len(f.b) > 1 {
s += "%" + string(f.b[1:]) + "s"
} else {
s += "%s"
}
Avoid deeply nested control flow statements. Open
if st, ok := par.X.(*goast.StarExpr); ok {
call.Args[i] = st.X
}
Method parser.parseStmt
has 6 return statements (exceeds 4 allowed). Open
func (p *parser) parseStmt() (stmts []goast.Stmt) {
onlyForRecover := p.ident
pos := p.ns[p.ident].pos
Method parser.isComplex
has 5 return statements (exceeds 4 allowed). Open
func (p *parser) isComplex(e goast.Expr) (isComplex, ok bool) {
if par, ok := e.(*goast.ParenExpr); ok {
if st, ok := par.X.(*goast.StarExpr); ok {
if id, ok := st.X.(*goast.Ident); ok {
if v, ok := p.initVars.get(id.Name); ok {
Method strChanger.Visit
has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring. Open
func (s strChanger) Visit(node goast.Node) (w goast.Visitor) {
if call, ok := node.(*goast.CallExpr); ok {
if sel, ok := call.Fun.(*goast.SelectorExpr); ok {
if id, ok := sel.X.(*goast.Ident); ok {
if id.Name == "fmt" || id.Name == "math" {
- 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"