hussar-lang/hussar

View on GitHub

Showing 8 of 129 total issues

Parser has 34 methods (exceeds 20 allowed). Consider refactoring.
Open

type Parser struct {
    l      *lexer.Lexer
    errors []string

    curToken  token.Token
Severity: Minor
Found in parser/parser.go - About 4 hrs to fix

    Method Lexer.NextToken has 73 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    func (l *Lexer) NextToken() token.Token {
        l.skipWhitespace()
    
        if l.ch == '/' && l.peekCharIs('/') {
            l.skipComment()
    Severity: Minor
    Found in lexer/lexer.go - About 1 hr to fix

      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 getSourceFile has a Cognitive Complexity of 25 (exceeds 20 allowed). Consider refactoring.
          Open

          func getSourceFile(sourceFile string) ([]byte, error) {
              if sourceFile == "" {
                  cwd, err := os.Getwd()
                  if err != nil {
                      log.WithError(err).Fatal()
          Severity: Minor
          Found in cmd/run.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

          Method Parser.parseIfExpression has 5 return statements (exceeds 4 allowed).
          Open

          func (p *Parser) parseIfExpression() ast.Expression {
              expression := &ast.IfExpression{Token: p.curToken}
          
              if !p.expectPeek(token.LPAREN) {
                  // error
          Severity: Major
          Found in parser/parser.go - About 35 mins to fix

            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
              Severity
              Category
              Status
              Source
              Language