hussar-lang/hussar

View on GitHub

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

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

          func (a *Array) Inspect() string {
              var out bytes.Buffer
          
              elements := []string{}
              for _, e := range a.Elements {
          Severity: Minor
          Found in object/object.go and 1 other location - About 1 hr to fix
          ast/ast.go on lines 331..344

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

          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 (al *ArrayLiteral) String() string {
              var out bytes.Buffer
          
              elements := []string{}
              for _, el := range al.Elements {
          Severity: Minor
          Found in ast/ast.go and 1 other location - About 1 hr to fix
          object/object.go on lines 132..145

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

          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

          func printParserErrors(out io.Writer, errors []string) {
              errColor := chalk.Red.NewStyle().WithTextStyle(chalk.Bold).Style
          
              io.WriteString(out, errColor("PARSER ERROR!\n"))
              for _, msg := range errors {
          Severity: Minor
          Found in cmd/run.go and 1 other location - About 40 mins to fix
          repl/repl.go on lines 46..53

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

          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

          func printParserErrors(out io.Writer, errors []string) {
              errColor := chalk.Red.NewStyle().WithTextStyle(chalk.Bold).Style
          
              io.WriteString(out, errColor("PARSER ERROR!\n"))
              for _, msg := range errors {
          Severity: Minor
          Found in repl/repl.go and 1 other location - About 40 mins to fix
          cmd/run.go on lines 102..109

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

          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

          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

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

                  case '!':
                      if l.peekCharIs('=') {
                          ch := l.ch
                          l.readChar()
                          literal := string(ch) + string(l.ch)
              Severity: Minor
              Found in lexer/lexer.go and 1 other location - About 35 mins to fix
              lexer/lexer.go on lines 33..41

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

              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

                  case '=':
                      if l.peekCharIs('=') {
                          ch := l.ch
                          l.readChar()
                          literal := string(ch) + string(l.ch)
              Severity: Minor
              Found in lexer/lexer.go and 1 other location - About 35 mins to fix
              lexer/lexer.go on lines 46..54

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

              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

              exported method IfExpression.TokenLiteral should have comment or be unexported
              Open

              func (ie *IfExpression) TokenLiteral() string { return ie.Token.Literal }
              Severity: Minor
              Found in ast/ast.go by golint

              exported type CallExpression should have comment or be unexported
              Open

              type CallExpression struct {
              Severity: Minor
              Found in ast/ast.go by golint

              exported method ExitLiteral.TokenLiteral should have comment or be unexported
              Open

              func (el *ExitLiteral) TokenLiteral() string { return el.Token.Literal }
              Severity: Minor
              Found in ast/ast.go by golint

              don't use ALL_CAPS in Go names; use CamelCase
              Open

                  NULL_OBJ         = "NULL"
              Severity: Minor
              Found in object/object.go by golint

              exported method Null.Inspect should have comment or be unexported
              Open

              func (n *Null) Inspect() string  { return "null" }
              Severity: Minor
              Found in object/object.go by golint

              exported method Builtin.Inspect should have comment or be unexported
              Open

              func (b *Builtin) Inspect() string  { return "builtin function" }
              Severity: Minor
              Found in object/object.go by golint
              Severity
              Category
              Status
              Source
              Language