Showing 8 of 129 total issues
Parser
has 34 methods (exceeds 20 allowed). Consider refactoring. Open
Open
type Parser struct {
l *lexer.Lexer
errors []string
curToken token.Token
Method Lexer.NextToken
has 73 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (l *Lexer) NextToken() token.Token {
l.skipWhitespace()
if l.ch == '/' && l.peekCharIs('/') {
l.skipComment()
Function Eval
has 71 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func Eval(node ast.Node, env *object.Environment) object.Object {
switch node := node.(type) {
// Statements
case *ast.Program:
return evalProgram(node, env)
Function Eval
has 15 return statements (exceeds 4 allowed). Open
Open
func Eval(node ast.Node, env *object.Environment) object.Object {
switch node := node.(type) {
// Statements
case *ast.Program:
return evalProgram(node, env)
Function Eval
has a Cognitive Complexity of 26 (exceeds 20 allowed). Consider refactoring. Open
Open
func Eval(node ast.Node, env *object.Environment) object.Object {
switch node := node.(type) {
// Statements
case *ast.Program:
return evalProgram(node, env)
- Read upRead up
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
Open
func getSourceFile(sourceFile string) ([]byte, error) {
if sourceFile == "" {
cwd, err := os.Getwd()
if err != nil {
log.WithError(err).Fatal()
- Read upRead up
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
Open
func (p *Parser) parseIfExpression() ast.Expression {
expression := &ast.IfExpression{Token: p.curToken}
if !p.expectPeek(token.LPAREN) {
// error
Function evalWhileExpression
has 5 return statements (exceeds 4 allowed). Open
Open
func evalWhileExpression(we *ast.WhileExpression, env *object.Environment) object.Object {
condition := Eval(we.Condition, env)
if isError(condition) {
return condition
}