Showing 324 of 517 total issues

Method RuntimeError.Format has a Cognitive Complexity of 25 (exceeds 20 allowed). Consider refactoring.
Open

func (o *RuntimeError) Format(s fmt.State, verb rune) {
    switch verb {
    case 'v', 's':
        switch {
        case s.Flag('+'):
Severity: Minor
Found in objects.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 (c *Compiler) compileIndexExpr(node *parser.IndexExpr) error {
    expr, indexes := resolveIndexExprs(node)
    if err := c.Compile(expr); err != nil {
        return err
    }
Severity: Major
Found in compiler_nodes.go and 1 other location - About 1 hr to fix
compiler_nodes.go on lines 931..943

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

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 (c *Compiler) compileSelectorExpr(node *parser.SelectorExpr) error {
    expr, selectors := resolveSelectorExprs(node)
    if err := c.Compile(expr); err != nil {
        return err
    }
Severity: Major
Found in compiler_nodes.go and 1 other location - About 1 hr to fix
compiler_nodes.go on lines 954..966

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

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 builtinSortReverseFunc has 10 return statements (exceeds 4 allowed).
Open

func builtinSortReverseFunc(arg Object) (Object, error) {
    switch obj := arg.(type) {
    case Array:
        var err error
        sort.Slice(obj, func(i, j int) bool {
Severity: Major
Found in builtins.go - About 1 hr to fix

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

        if stmt.Key.Name != "_" {
            keySymbol, exists := c.symbolTable.DefineLocal(stmt.Key.Name)
            if exists {
                return c.errorf(stmt, "%q redeclared in this block", stmt.Key.Name)
            }
    Severity: Minor
    Found in compiler_nodes.go and 1 other location - About 55 mins to fix
    compiler_nodes.go on lines 781..790

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

    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

        if stmt.Value.Name != "_" {
            valueSymbol, exists := c.symbolTable.DefineLocal(stmt.Value.Name)
            if exists {
                return c.errorf(stmt, "%q redeclared in this block", stmt.Value.Name)
            }
    Severity: Minor
    Found in compiler_nodes.go and 1 other location - About 55 mins to fix
    compiler_nodes.go on lines 769..778

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

    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 SimpleOptimizer.unaryop has 9 return statements (exceeds 4 allowed).
    Open

    func (so *SimpleOptimizer) unaryop(
        op token.Token,
        expr parser.Expr,
    ) (parser.Expr, bool) {
    
    
    Severity: Major
    Found in optimizer.go - About 55 mins to fix

      Method Parser.parseOperand has 9 return statements (exceeds 4 allowed).
      Open

      func (p *Parser) parseOperand() Expr {
          if p.trace {
              defer untracep(tracep(p, "Operand"))
          }
      
      
      Severity: Major
      Found in parser/parser.go - About 55 mins to fix

        Function parseFuncEx has 8 return statements (exceeds 4 allowed).
        Confirmed

        func parseFuncEx(c ugo.Call) (ugo.Object, error) {
            size := c.Len()
            if size != 2 && size != 3 {
                return ugo.Undefined, ugo.ErrWrongNumArguments.NewError(
                    "want=2..3 got=" + strconv.Itoa(size))
        Severity: Major
        Found in stdlib/time/module.go - About 50 mins to fix

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

                  switch v := o[k].(type) {
                  case String:
                      sb.WriteString(strconv.Quote(v.String()))
                  case Char:
                      sb.WriteString(strconv.QuoteRune(rune(v)))
          Severity: Minor
          Found in objects.go and 1 other location - About 50 mins to fix
          objects.go on lines 898..907

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

          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

                  switch v := o[i].(type) {
                  case String:
                      sb.WriteString(strconv.Quote(v.String()))
                  case Char:
                      sb.WriteString(strconv.QuoteRune(rune(v)))
          Severity: Minor
          Found in objects.go and 1 other location - About 50 mins to fix
          objects.go on lines 1132..1141

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

          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 (p *Parser) parseBlockStmt() *BlockStmt {
              if p.trace {
                  defer untracep(tracep(p, "BlockStmt"))
              }
          
          
          Severity: Minor
          Found in parser/parser.go and 1 other location - About 50 mins to fix
          parser/parser.go on lines 615..628

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

          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 (p *Parser) parseBody() *BlockStmt {
              if p.trace {
                  defer untracep(tracep(p, "Body"))
              }
          
          
          Severity: Minor
          Found in parser/parser.go and 1 other location - About 50 mins to fix
          parser/parser.go on lines 1032..1045

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

          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

          Avoid deeply nested control flow statements.
          Open

                              if err = vm.throwGenErr(err); err != nil {
                                  vm.err = err
                                  return
                              }
          Severity: Major
          Found in vm.go - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                            for i := vm.sp; i >= handler.sp; i-- {
                                vm.stack[i] = nil
                            }
            Severity: Major
            Found in vm.go - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                  switch err {
                                  case ErrNotIndexable:
                                      err = ErrNotIndexable.NewError(target.TypeName())
                                  case ErrIndexOutOfBounds:
                                      err = ErrIndexOutOfBounds.NewError(index.String())
              Severity: Major
              Found in vm.go - About 45 mins to fix

                Method Compiler.Compile has 6 return statements (exceeds 4 allowed).
                Open

                func (c *Compiler) Compile(node parser.Node) error {
                    if c.trace != nil {
                        if node != nil {
                            defer untracec(tracec(c, fmt.Sprintf("%s (%s)",
                                node.String(), reflect.TypeOf(node).Elem().Name())))
                Severity: Major
                Found in compiler.go - About 40 mins to fix

                  Function MakeInstruction has 6 return statements (exceeds 4 allowed).
                  Open

                  func MakeInstruction(buf []byte, op Opcode, args ...int) ([]byte, error) {
                      operands := OpcodeOperands[op]
                      if len(operands) != len(args) {
                          return buf, fmt.Errorf(
                              "MakeInstruction: %s expected %d operands, but got %d",
                  Severity: Major
                  Found in compiler.go - About 40 mins to fix

                    Method SimpleOptimizer.optimize has 6 return statements (exceeds 4 allowed).
                    Open

                    func (so *SimpleOptimizer) optimize(node parser.Node) (parser.Expr, bool) {
                        if so.trace != nil {
                            if node != nil {
                                defer untraceoptim(traceoptim(so, fmt.Sprintf("%s (%s)",
                                    node.String(), reflect.TypeOf(node).Elem().Name())))
                    Severity: Major
                    Found in optimizer.go - About 40 mins to fix

                      Method Compiler.compileModule has 6 return statements (exceeds 4 allowed).
                      Open

                      func (c *Compiler) compileModule(
                          node parser.Node,
                          modulePath string,
                          moduleMap *ModuleMap,
                          src []byte,
                      Severity: Major
                      Found in compiler.go - About 40 mins to fix
                        Severity
                        Category
                        Status
                        Source
                        Language