Method Scanner.Scan
has a Cognitive Complexity of 47 (exceeds 20 allowed). Consider refactoring. Open
func (s *Scanner) Scan() (
tok token.Token,
literal string,
pos Pos,
) {
- 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 Scanner.Scan
has 143 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (s *Scanner) Scan() (
tok token.Token,
literal string,
pos Pos,
) {
File scanner.go
has 590 lines of code (exceeds 500 allowed). Consider refactoring. Open
// A modified version Go and Tengo parsers.
// Copyright (c) 2020-2023 Ozan Hacıbekiroğlu.
// Use of this source code is governed by a MIT License
// that can be found in the LICENSE file.
Method Scanner.scanNumber
has a Cognitive Complexity of 39 (exceeds 20 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
- 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 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
Consider simplifying this complex logical expression. Open
if ch != '\r' || comment && i > len("/*") && c[i-1] == '*' &&
j+1 < len(b) && b[j+1] == '/' {
Method Scanner.scanEscape
has 5 return statements (exceeds 4 allowed). Open
func (s *Scanner) scanEscape(quote rune) bool {
offs := s.offset
var n int
var base, max uint32
Method Scanner.Scan
has 5 return statements (exceeds 4 allowed). Open
func (s *Scanner) Scan() (
tok token.Token,
literal string,
pos Pos,
) {
Method Scanner.findLineEnd
has 5 return statements (exceeds 4 allowed). Open
func (s *Scanner) findLineEnd() bool {
// initial '/' already consumed
defer func(offs int) {
// reset scanner state to where it was upon calling findLineEnd
Method Scanner.scanComment
has a Cognitive Complexity of 21 (exceeds 20 allowed). Consider refactoring. Open
func (s *Scanner) scanComment() string {
// initial '/' already consumed; s.ch == '/' || s.ch == '*'
offs := s.offset - 1 // position of initial '/'
var numCR int
- 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"