Showing 75 of 517 total issues

Method Parser.parseSimpleStmt has 71 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func (p *Parser) parseSimpleStmt(forIn bool) Stmt {
    if p.trace {
        defer untracep(tracep(p, "SimpleStmt"))
    }

Severity: Minor
Found in parser/parser.go - About 1 hr to fix

    Method VM.xOpUnary has 69 lines of code (exceeds 50 allowed). Consider refactoring.
    Confirmed

    func (vm *VM) xOpUnary() error {
        tok := token.Token(vm.curInsts[vm.ip+1])
        right := vm.stack[vm.sp-1]
        var value Object
    
    
    Severity: Minor
    Found in vm.go - About 1 hr to fix

      Method SimpleOptimizer.unaryop has 69 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

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

        Method Compiler.compileImportExpr has 66 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func (c *Compiler) compileImportExpr(node *parser.ImportExpr) error {
            moduleName := node.ModuleName
            if moduleName == "" {
                return c.errorf(node, "empty module name")
            }
        Severity: Minor
        Found in compiler_nodes.go - About 1 hr to fix

          Method VM.xOpSliceIndex has 65 lines of code (exceeds 50 allowed). Consider refactoring.
          Confirmed

          func (vm *VM) xOpSliceIndex() error {
              obj := vm.stack[vm.sp-3]
              left := vm.stack[vm.sp-2]
              right := vm.stack[vm.sp-1]
              vm.stack[vm.sp-3] = nil
          Severity: Minor
          Found in vm.go - About 1 hr to fix

            Method Scanner.scanNumber has 65 lines of code (exceeds 50 allowed). Consider refactoring.
            Open

            func (s *Scanner) scanNumber(seenDecimalPoint bool) (tok token.Token, lit string) {
                // digitVal(s.ch) < 10
                offs := s.offset
                tok = token.Int
            
            
            Severity: Minor
            Found in parser/scanner.go - About 1 hr to fix

              Method VM.xOpUnary has a Cognitive Complexity of 28 (exceeds 20 allowed). Consider refactoring.
              Confirmed

              func (vm *VM) xOpUnary() error {
                  tok := token.Token(vm.curInsts[vm.ip+1])
                  right := vm.stack[vm.sp-1]
                  var value Object
              
              
              Severity: Minor
              Found in vm.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 Compiler.compileForInStmt has 54 lines of code (exceeds 50 allowed). Consider refactoring.
              Open

              func (c *Compiler) compileForInStmt(stmt *parser.ForInStmt) error {
                  c.symbolTable = c.symbolTable.Fork(true)
                  defer func() {
                      c.symbolTable = c.symbolTable.Parent(false)
                  }()
              Severity: Minor
              Found in compiler_nodes.go - About 1 hr to fix

                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

                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

                  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

                        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