goruby/goruby

View on GitHub

Showing 60 of 60 total issues

Function Eval has a Cognitive Complexity of 172 (exceeds 20 allowed). Consider refactoring.
Open

func Eval(node ast.Node, env object.Environment) (object.RubyObject, error) {
    switch node := node.(type) {

    // Statements
    case *ast.Program:
Severity: Minor
Found in evaluator/evaluator.go - About 3 days 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 parser.go has 1337 lines of code (exceeds 500 allowed). Consider refactoring.
Open

package parser

import (
    "fmt"
    gotoken "go/token"
Severity: Major
Found in parser/parser.go - About 2 days to fix

    Function Eval has 369 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func Eval(node ast.Node, env object.Environment) (object.RubyObject, error) {
        switch node := node.(type) {
    
        // Statements
        case *ast.Program:
    Severity: Major
    Found in evaluator/evaluator.go - About 1 day to fix

      parser has 66 methods (exceeds 20 allowed). Consider refactoring.
      Open

      type parser struct {
          file   *gotoken.File
          l      *lexer.Lexer
          errors []error
      
      
      Severity: Major
      Found in parser/parser.go - About 1 day to fix

        File ast.go has 762 lines of code (exceeds 500 allowed). Consider refactoring.
        Open

        package ast
        
        import (
            "bytes"
            "fmt"
        Severity: Major
        Found in ast/ast.go - About 1 day to fix

          Function Walk has a Cognitive Complexity of 65 (exceeds 20 allowed). Consider refactoring.
          Open

          func Walk(v Visitor, node Node) {
              if v = v.Visit(node); v == nil {
                  return
              }
          
          
          Severity: Minor
          Found in ast/walk.go - About 7 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 startLexer has 193 lines of code (exceeds 50 allowed). Consider refactoring.
          Open

          func startLexer(l *Lexer) StateFn {
              r := l.next()
              if isWhitespace(r) {
                  l.ignore()
                  return startLexer
          Severity: Major
          Found in lexer/lexer.go - About 6 hrs to fix

            File evaluator.go has 665 lines of code (exceeds 500 allowed). Consider refactoring.
            Open

            package evaluator
            
            import (
                "fmt"
                "sort"
            Severity: Minor
            Found in evaluator/evaluator.go - About 5 hrs to fix

              Function Eval has 62 return statements (exceeds 4 allowed).
              Open

              func Eval(node ast.Node, env object.Environment) (object.RubyObject, error) {
                  switch node := node.(type) {
              
                  // Statements
                  case *ast.Program:
              Severity: Major
              Found in evaluator/evaluator.go - About 5 hrs to fix

                Function startLexer has a Cognitive Complexity of 49 (exceeds 20 allowed). Consider refactoring.
                Open

                func startLexer(l *Lexer) StateFn {
                    r := l.next()
                    if isWhitespace(r) {
                        l.ignore()
                        return startLexer
                Severity: Minor
                Found in lexer/lexer.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 startLexer has 46 return statements (exceeds 4 allowed).
                Open

                func startLexer(l *Lexer) StateFn {
                    r := l.next()
                    if isWhitespace(r) {
                        l.ignore()
                        return startLexer
                Severity: Major
                Found in lexer/lexer.go - About 4 hrs to fix

                  Function Walk has 117 lines of code (exceeds 50 allowed). Consider refactoring.
                  Open

                  func Walk(v Visitor, node Node) {
                      if v = v.Visit(node); v == nil {
                          return
                      }
                  
                  
                  Severity: Major
                  Found in ast/walk.go - About 3 hrs to fix

                    Method parser.parseFunctionLiteral has a Cognitive Complexity of 39 (exceeds 20 allowed). Consider refactoring.
                    Open

                    func (p *parser) parseFunctionLiteral() ast.Expression {
                        if p.trace {
                            defer un(trace(p, "parseFunctionLiteral"))
                        }
                        lit := &ast.FunctionLiteral{Token: p.curToken}
                    Severity: Minor
                    Found in parser/parser.go - About 3 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

                    Method parser.init has 77 lines of code (exceeds 50 allowed). Consider refactoring.
                    Open

                    func (p *parser) init(fset *gotoken.FileSet, filename string, src []byte, mode Mode) {
                        p.file = fset.AddFile(filename, -1, len(src))
                    
                        p.l = lexer.New(string(src))
                        p.errors = []error{}
                    Severity: Major
                    Found in parser/parser.go - About 2 hrs to fix

                      Method parser.parseFunctionLiteral has 74 lines of code (exceeds 50 allowed). Consider refactoring.
                      Open

                      func (p *parser) parseFunctionLiteral() ast.Expression {
                          if p.trace {
                              defer un(trace(p, "parseFunctionLiteral"))
                          }
                          lit := &ast.FunctionLiteral{Token: p.curToken}
                      Severity: Minor
                      Found in parser/parser.go - About 1 hr to fix

                        Method parser.parseParameters has 59 lines of code (exceeds 50 allowed). Consider refactoring.
                        Open

                        func (p *parser) parseParameters(startToken, endToken token.Type) []*ast.FunctionParameter {
                            if p.trace {
                                defer un(trace(p, "parseParameters"))
                            }
                            hasDelimiters := false
                        Severity: Minor
                        Found in parser/parser.go - About 1 hr to fix

                          Function kernelRequire has 58 lines of code (exceeds 50 allowed). Consider refactoring.
                          Open

                          func kernelRequire(context CallContext, args ...RubyObject) (RubyObject, error) {
                              if len(args) != 1 {
                                  return nil, NewWrongNumberOfArgumentsError(1, len(args))
                              }
                              name, ok := args[0].(*String)
                          Severity: Minor
                          Found in object/kernel.go - About 1 hr to fix

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

                                if p.peekTokenIs(token.LPAREN) {
                                    p.accept(token.LPAREN)
                                    p.nextToken()
                                    contextCallExpression.Arguments = p.parseExpressionList(token.RPAREN)
                                    if p.peekTokenOneOf(token.LBRACE, token.DO) {
                            Severity: Major
                            Found in parser/parser.go and 1 other location - About 1 hr to fix
                            parser/parser.go on lines 1253..1262

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

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

                                if p.peekTokenIs(token.LPAREN) {
                                    p.accept(token.LPAREN)
                                    p.nextToken()
                                    contextCallExpression.Arguments = p.parseExpressionList(token.RPAREN)
                                    if p.peekTokenOneOf(token.LBRACE, token.DO) {
                            Severity: Major
                            Found in parser/parser.go and 1 other location - About 1 hr to fix
                            parser/parser.go on lines 1306..1315

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

                            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

                            Similar blocks of code found in 6 locations. Consider refactoring.
                            Open

                            func integerLte(context CallContext, args ...RubyObject) (RubyObject, error) {
                                i := context.Receiver().(*Integer)
                                right, ok := args[0].(*Integer)
                                if !ok {
                                    return nil, NewArgumentError(
                            Severity: Major
                            Found in object/integer.go and 5 other locations - About 1 hr to fix
                            object/integer.go on lines 102..115
                            object/integer.go on lines 117..130
                            object/integer.go on lines 132..145
                            object/integer.go on lines 147..160
                            object/integer.go on lines 180..193

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

                            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

                            Severity
                            Category
                            Status
                            Source
                            Language