goruby/goruby

View on GitHub

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) {
Severity: Major
Found in ast/walk.go - About 40 mins to fix

    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),
    Severity: Minor
    Found in object/class.go - About 35 mins to fix

      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)
      Severity: Major
      Found in object/integer.go and 3 other locations - About 35 mins to fix
      object/integer.go on lines 66..73
      object/integer.go on lines 84..91
      object/integer.go on lines 93..100

      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

      Further Reading

      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)
      Severity: Major
      Found in object/integer.go and 3 other locations - About 35 mins to fix
      object/integer.go on lines 66..73
      object/integer.go on lines 75..82
      object/integer.go on lines 84..91

      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

      Further Reading

      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)
      Severity: Major
      Found in object/integer.go and 3 other locations - About 35 mins to fix
      object/integer.go on lines 75..82
      object/integer.go on lines 84..91
      object/integer.go on lines 93..100

      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

      Further Reading

      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)
      Severity: Major
      Found in object/integer.go and 3 other locations - About 35 mins to fix
      object/integer.go on lines 66..73
      object/integer.go on lines 75..82
      object/integer.go on lines 93..100

      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

      Further Reading

      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)")
          }
      
      
      Severity: Major
      Found in parser/interface.go - About 35 mins to fix

        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)
        Severity: Major
        Found in evaluator/evaluator.go - About 35 mins to fix

          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}
          Severity: Major
          Found in parser/parser.go - About 35 mins to fix

            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]
            Severity: Major
            Found in parser/parser.go - About 35 mins to fix

              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
                  }
              Severity: Major
              Found in object/exception.go - About 35 mins to fix

                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 {
                Severity: Major
                Found in evaluator/evaluator.go - About 35 mins to fix

                  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
                  Severity: Major
                  Found in parser/interface.go - About 35 mins to fix

                    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
                    Severity: Minor
                    Found in parser/parser.go - About 35 mins 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 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) {
                    Severity: Major
                    Found in ast/equal.go - About 35 mins to fix

                      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"))
                          }
                      Severity: Major
                      Found in parser/parser.go - About 35 mins to fix

                        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}
                        Severity: Major
                        Found in parser/parser.go - About 35 mins to fix

                          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"))
                              }
                          
                          
                          Severity: Major
                          Found in parser/parser.go - About 35 mins to fix

                            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
                            Severity: Minor
                            Found in object/boolean.go and 1 other location - About 35 mins to fix
                            object/boolean.go on lines 70..80

                            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

                            Further Reading

                            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
                            Severity: Minor
                            Found in object/boolean.go and 1 other location - About 35 mins to fix
                            object/boolean.go on lines 58..68

                            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

                            Further Reading

                            Severity
                            Category
                            Status
                            Source
                            Language