goruby/goruby

View on GitHub

Showing 36 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

                            Method parser.parseFunctionLiteral has 8 return statements (exceeds 4 allowed).
                            Open

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

                              Function kernelRequire has 7 return statements (exceeds 4 allowed).
                              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: Major
                              Found in object/kernel.go - About 45 mins to fix

                                Function fileExpandPath has 7 return statements (exceeds 4 allowed).
                                Open

                                func fileExpandPath(context CallContext, args ...RubyObject) (RubyObject, error) {
                                    switch len(args) {
                                    case 1:
                                        str, ok := args[0].(*String)
                                        if !ok {
                                Severity: Major
                                Found in object/file.go - About 45 mins to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language