Showing 36 of 60 total issues
Function kernelRequire
has 7 return statements (exceeds 4 allowed). Open
Open
func kernelRequire(context CallContext, args ...RubyObject) (RubyObject, error) {
if len(args) != 1 {
return nil, NewWrongNumberOfArgumentsError(1, len(args))
}
name, ok := args[0].(*String)
Method parser.parseContextCallExpression
has 6 return statements (exceeds 4 allowed). Open
Open
func (p *parser) parseContextCallExpression(context ast.Expression) ast.Expression {
if p.trace {
defer un(trace(p, "parseContextCallExpression"))
}
contextCallExpression := &ast.ContextCallExpression{Token: p.curToken, Context: context}
Function Parent
has 6 return statements (exceeds 4 allowed). Open
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
Open
name string,
superClass RubyClass,
instanceMethods,
classMethods map[string]RubyMethod,
builder func(RubyClassObject, ...RubyObject) (RubyObject, error),
Function ParseExprFrom
has 5 return statements (exceeds 4 allowed). Open
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
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
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
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
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
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
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
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
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
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
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
Open
func (p *parser) parseAssignment(left ast.Expression) ast.Expression {
if p.trace {
defer un(trace(p, "parseAssignment"))
}