Showing 75 of 517 total issues
Method Parser.parseSimpleStmt
has 71 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (p *Parser) parseSimpleStmt(forIn bool) Stmt {
if p.trace {
defer untracep(tracep(p, "SimpleStmt"))
}
Method VM.xOpUnary
has 69 lines of code (exceeds 50 allowed). Consider refactoring. Confirmed
Confirmed
func (vm *VM) xOpUnary() error {
tok := token.Token(vm.curInsts[vm.ip+1])
right := vm.stack[vm.sp-1]
var value Object
Method SimpleOptimizer.unaryop
has 69 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (so *SimpleOptimizer) unaryop(
op token.Token,
expr parser.Expr,
) (parser.Expr, bool) {
Method Compiler.compileImportExpr
has 66 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (c *Compiler) compileImportExpr(node *parser.ImportExpr) error {
moduleName := node.ModuleName
if moduleName == "" {
return c.errorf(node, "empty module name")
}
Method VM.xOpSliceIndex
has 65 lines of code (exceeds 50 allowed). Consider refactoring. Confirmed
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
Method Scanner.scanNumber
has 65 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (s *Scanner) scanNumber(seenDecimalPoint bool) (tok token.Token, lit string) {
// digitVal(s.ch) < 10
offs := s.offset
tok = token.Int
Method VM.xOpUnary
has a Cognitive Complexity of 28 (exceeds 20 allowed). Consider refactoring. Confirmed
Confirmed
func (vm *VM) xOpUnary() error {
tok := token.Token(vm.curInsts[vm.ip+1])
right := vm.stack[vm.sp-1]
var value Object
- 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 Compiler.compileForInStmt
has 54 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (c *Compiler) compileForInStmt(stmt *parser.ForInStmt) error {
c.symbolTable = c.symbolTable.Fork(true)
defer func() {
c.symbolTable = c.symbolTable.Parent(false)
}()
Method RuntimeError.Format
has a Cognitive Complexity of 25 (exceeds 20 allowed). Consider refactoring. Open
Open
func (o *RuntimeError) Format(s fmt.State, verb rune) {
switch verb {
case 'v', 's':
switch {
case s.Flag('+'):
- 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 builtinSortReverseFunc
has 10 return statements (exceeds 4 allowed). Open
Open
func builtinSortReverseFunc(arg Object) (Object, error) {
switch obj := arg.(type) {
case Array:
var err error
sort.Slice(obj, func(i, j int) bool {
Method SimpleOptimizer.unaryop
has 9 return statements (exceeds 4 allowed). Open
Open
func (so *SimpleOptimizer) unaryop(
op token.Token,
expr parser.Expr,
) (parser.Expr, bool) {
Method Parser.parseOperand
has 9 return statements (exceeds 4 allowed). Open
Open
func (p *Parser) parseOperand() Expr {
if p.trace {
defer untracep(tracep(p, "Operand"))
}
Function parseFuncEx
has 8 return statements (exceeds 4 allowed). Confirmed
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))
Avoid deeply nested control flow statements. Open
Open
if err = vm.throwGenErr(err); err != nil {
vm.err = err
return
}
Avoid deeply nested control flow statements. Open
Open
for i := vm.sp; i >= handler.sp; i-- {
vm.stack[i] = nil
}
Avoid deeply nested control flow statements. Open
Open
switch err {
case ErrNotIndexable:
err = ErrNotIndexable.NewError(target.TypeName())
case ErrIndexOutOfBounds:
err = ErrIndexOutOfBounds.NewError(index.String())
Method Compiler.Compile
has 6 return statements (exceeds 4 allowed). Open
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())))
Function MakeInstruction
has 6 return statements (exceeds 4 allowed). Open
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",
Method SimpleOptimizer.optimize
has 6 return statements (exceeds 4 allowed). Open
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())))
Method Compiler.compileModule
has 6 return statements (exceeds 4 allowed). Open
Open
func (c *Compiler) compileModule(
node parser.Node,
modulePath string,
moduleMap *ModuleMap,
src []byte,