hussar-lang/hussar

View on GitHub
evaluator/evaluator.go

Summary

Maintainability
B
5 hrs
Test Coverage

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

func Eval(node ast.Node, env *object.Environment) object.Object {
    switch node := node.(type) {
    // Statements
    case *ast.Program:
        return evalProgram(node, env)
Severity: Minor
Found in evaluator/evaluator.go - About 1 hr to fix

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

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

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

      func Eval(node ast.Node, env *object.Environment) object.Object {
          switch node := node.(type) {
          // Statements
          case *ast.Program:
              return evalProgram(node, env)
      Severity: Minor
      Found in evaluator/evaluator.go - About 1 hr 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 evalWhileExpression has 5 return statements (exceeds 4 allowed).
      Open

      func evalWhileExpression(we *ast.WhileExpression, env *object.Environment) object.Object {
          condition := Eval(we.Condition, env)
          if isError(condition) {
              return condition
          }
      Severity: Major
      Found in evaluator/evaluator.go - About 35 mins to fix

        exported var NULL should have comment or be unexported
        Open

            NULL  = &object.Null{}
        Severity: Minor
        Found in evaluator/evaluator.go by golint

        exported function Eval should have comment or be unexported
        Open

        func Eval(node ast.Node, env *object.Environment) object.Object {
        Severity: Minor
        Found in evaluator/evaluator.go by golint

        There are no issues that match your filters.

        Category
        Status