Showing 60 of 60 total issues
Function Parent
has 6 return statements (exceeds 4 allowed). Open
func Parent(root, child Node) (Node, bool) {
if root == child {
return nil, false
}
if !Contains(root, child) {
Function newClassWithEnv
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
name string,
superClass RubyClass,
instanceMethods,
classMethods map[string]RubyMethod,
builder func(RubyClassObject, ...RubyObject) (RubyObject, error),
Similar blocks of code found in 4 locations. Consider refactoring. Open
func integerAdd(context CallContext, args ...RubyObject) (RubyObject, error) {
i := context.Receiver().(*Integer)
add, ok := args[0].(*Integer)
if !ok {
return nil, NewCoercionTypeError(args[0], i)
- 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 106.
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
Similar blocks of code found in 4 locations. Consider refactoring. Open
func integerModulo(context CallContext, args ...RubyObject) (RubyObject, error) {
i := context.Receiver().(*Integer)
mod, ok := args[0].(*Integer)
if !ok {
return nil, NewCoercionTypeError(args[0], i)
- 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 106.
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
Similar blocks of code found in 4 locations. Consider refactoring. Open
func integerMul(context CallContext, args ...RubyObject) (RubyObject, error) {
i := context.Receiver().(*Integer)
factor, ok := args[0].(*Integer)
if !ok {
return nil, NewCoercionTypeError(args[0], i)
- 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 106.
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
Similar blocks of code found in 4 locations. Consider refactoring. Open
func integerSub(context CallContext, args ...RubyObject) (RubyObject, error) {
i := context.Receiver().(*Integer)
sub, ok := args[0].(*Integer)
if !ok {
return nil, NewCoercionTypeError(args[0], i)
- 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 106.
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
Function ParseExprFrom
has 5 return statements (exceeds 4 allowed). Open
func ParseExprFrom(fset *gotoken.FileSet, filename string, src interface{}, mode Mode) (ast.Expression, error) {
if fset == nil {
panic("parser.ParseExprFrom: no token.FileSet provided (fset == nil)")
}
Function handleException
has 5 return statements (exceeds 4 allowed). Open
func handleException(err error, rescues []*ast.RescueBlock, env object.Environment) (object.RubyObject, error) {
if err != nil && len(rescues) == 0 {
return nil, err
}
errorObject := err.(object.RubyObject)
Method parser.parseReturnStatement
has 5 return statements (exceeds 4 allowed). Open
func (p *parser) parseReturnStatement() *ast.ReturnStatement {
if p.trace {
defer un(trace(p, "parseReturnStatement"))
}
stmt := &ast.ReturnStatement{Token: p.curToken}
Method parser.parseExpression
has 5 return statements (exceeds 4 allowed). Open
func (p *parser) parseExpression(precedence int) ast.Expression {
if p.trace {
defer un(trace(p, "parseExpression"))
}
prefix := p.prefixParseFns[p.curToken.Type]
Function exceptionException
has 5 return statements (exceeds 4 allowed). Open
func exceptionException(context CallContext, args ...RubyObject) (RubyObject, error) {
receiver := context.Receiver()
if len(args) == 0 {
return receiver, nil
}
Function evalArrayIndexExpression
has 5 return statements (exceeds 4 allowed). Open
func evalArrayIndexExpression(arrayObject *object.Array, index object.RubyObject) object.RubyObject {
idx := index.(*object.Integer).Value
maxNegative := -int64(len(arrayObject.Elements))
maxPositive := maxNegative*-1 - 1
if maxPositive < 0 {
Function readSource
has 5 return statements (exceeds 4 allowed). Open
func readSource(filename string, src interface{}) ([]byte, error) {
if src != nil {
switch s := src.(type) {
case string:
return []byte(s), nil
Method parser.parseParameters
has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring. Open
func (p *parser) parseParameters(startToken, endToken token.Type) []*ast.FunctionParameter {
if p.trace {
defer un(trace(p, "parseParameters"))
}
hasDelimiters := false
- 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 Equal
has 5 return statements (exceeds 4 allowed). Open
func Equal(a, b Node) bool {
if a == b {
return true
}
if reflect.DeepEqual(a, b) {
Method parser.parseHash
has 5 return statements (exceeds 4 allowed). Open
func (p *parser) parseHash() ast.Expression {
hash := &ast.HashLiteral{Token: p.curToken, Map: make(map[ast.Expression]ast.Expression)}
if p.trace {
defer un(trace(p, "parseHash"))
}
Method parser.parseMethodCall
has 5 return statements (exceeds 4 allowed). Open
func (p *parser) parseMethodCall(context ast.Expression) ast.Expression {
if p.trace {
defer un(trace(p, "parseMethodCall"))
}
contextCallExpression := &ast.ContextCallExpression{Token: p.curToken, Context: context}
Method parser.parseAssignment
has 5 return statements (exceeds 4 allowed). Open
func (p *parser) parseAssignment(left ast.Expression) ast.Expression {
if p.trace {
defer un(trace(p, "parseAssignment"))
}
Similar blocks of code found in 2 locations. Consider refactoring. Open
func booleanEq(context CallContext, args ...RubyObject) (RubyObject, error) {
b := context.Receiver().(*Boolean)
right, ok := args[0].(*Boolean)
if !ok {
return FALSE, nil
- 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 103.
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
Similar blocks of code found in 2 locations. Consider refactoring. Open
func booleanNeq(context CallContext, args ...RubyObject) (RubyObject, error) {
b := context.Receiver().(*Boolean)
right, ok := args[0].(*Boolean)
if !ok {
return TRUE, nil
- 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 103.
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