Showing 85 of 144 total issues
Function ParseCurrency
has a Cognitive Complexity of 38 (exceeds 20 allowed). Consider refactoring. Open
func ParseCurrency(opts *ParseCurrencyOpts, s string) (string, float64, error) {
try := strings.TrimSpace(s)
if len(try) == 0 {
return "", 0, nil
}
- 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 CurrencyCodesAll
has 97 lines of code (exceeds 50 allowed). Consider refactoring. Open
func CurrencyCodesAll() []string {
return []string{
CurrencyAFN, // Afghanistan Afghani
CurrencyALL, // Albania Lek
CurrencyANG, // Netherlands Antilles Guilder
TimeMore
has 25 methods (exceeds 20 allowed). Consider refactoring. Open
type TimeMore struct {
time time.Time
weekStartDay time.Weekday
}
Function MergeFilterCSVFilesToJSONL
has a Cognitive Complexity of 33 (exceeds 20 allowed). Consider refactoring. Open
func MergeFilterCSVFilesToJSONL(inPaths []string, outPath string, inComma rune, andFilter map[string]stringsutil.MatchInfo) error {
outFh, err := os.Create(outPath)
if err != nil {
return err
}
- 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 NextTokens
has a Cognitive Complexity of 33 (exceeds 20 allowed). Consider refactoring. Open
func NextTokens(z *html.Tokenizer, opts NextTokensOpts) (Tokens, error) {
// func NextTokens(z *html.Tokenizer, skipErrors, includeChain, includeMatch bool, start, end []html.Token) ([]html.Token, error) {
matches := []html.Token{}
if z == nil {
return matches, ErrTokenizerNotInitialized
- 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 ParseTimeRangeInterval
has 70 lines of code (exceeds 50 allowed). Consider refactoring. Open
func ParseTimeRangeInterval(s string) (TimeRange, error) {
s1 := strings.ToUpper(strings.TrimSpace(s))
m := rxParseTimeRange.FindStringSubmatch(s1)
if len(m) == 0 {
return TimeRange{}, fmt.Errorf("cannot parse time range rx (%s)", s)
Function ParseCurrency
has 68 lines of code (exceeds 50 allowed). Consider refactoring. Open
func ParseCurrency(opts *ParseCurrencyOpts, s string) (string, float64, error) {
try := strings.TrimSpace(s)
if len(try) == 0 {
return "", 0, nil
}
Function Match
has 59 lines of code (exceeds 50 allowed). Consider refactoring. Open
func Match(s string, matchInfo MatchInfo) (bool, error) {
switch matchInfo.MatchType {
case MatchExact:
return s == matchInfo.String, nil
case MatchStringTrimSpace:
Function Match
has 14 return statements (exceeds 4 allowed). Open
func Match(s string, matchInfo MatchInfo) (bool, error) {
switch matchInfo.MatchType {
case MatchExact:
return s == matchInfo.String, nil
case MatchStringTrimSpace:
Consider simplifying this complex logical expression. Open
if (incStart && needle.Before(rangeStart)) ||
(needle.Before(rangeStart) || needle.Equal(rangeStart)) ||
(incEnd && needle.After(rangeEnd)) ||
(needle.After(rangeEnd) || needle.Equal(rangeEnd)) {
Function MergeFilterCSVFilesToJSONL
has 57 lines of code (exceeds 50 allowed). Consider refactoring. Open
func MergeFilterCSVFilesToJSONL(inPaths []string, outPath string, inComma rune, andFilter map[string]stringsutil.MatchInfo) error {
outFh, err := os.Create(outPath)
if err != nil {
return err
}
Function outputConstants
has a Cognitive Complexity of 26 (exceeds 20 allowed). Consider refactoring. Open
func outputConstants(filename string, currs currencyutil.Currencies) error {
set, err := currencyutil.NewCurrencySet(currs...)
if err != nil {
return err
}
- 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 outputConstants
has 56 lines of code (exceeds 50 allowed). Consider refactoring. Open
func outputConstants(filename string, currs currencyutil.Currencies) error {
set, err := currencyutil.NewCurrencySet(currs...)
if err != nil {
return err
}
Function Match
has a Cognitive Complexity of 25 (exceeds 20 allowed). Consider refactoring. Open
func Match(s string, matchInfo MatchInfo) (bool, error) {
switch matchInfo.MatchType {
case MatchExact:
return s == matchInfo.String, nil
case MatchStringTrimSpace:
- 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 MergeFilterCSVFilesToJSONL
has 10 return statements (exceeds 4 allowed). Open
func MergeFilterCSVFilesToJSONL(inPaths []string, outPath string, inComma rune, andFilter map[string]stringsutil.MatchInfo) error {
outFh, err := os.Create(outPath)
if err != nil {
return err
}
Function outputConstants
has 9 return statements (exceeds 4 allowed). Open
func outputConstants(filename string, currs currencyutil.Currencies) error {
set, err := currencyutil.NewCurrencySet(currs...)
if err != nil {
return err
}
Function ResizePathJPEGDir
has 9 return statements (exceeds 4 allowed). Open
func ResizePathJPEGDir(src, out string, x, y uint, o *JPEGEncodeOptions) error {
if src == "" {
return ErrSrcDirNotDefined
} else if out == "" {
return ErrOutDirNotDefined
Function ToInt
has 8 return statements (exceeds 4 allowed). Open
func ToInt(v any, defaultValue int) int {
if v == nil {
return defaultValue
} else if valBool, ok := v.(bool); ok {
if valBool {
Avoid deeply nested control flow statements. Open
} else if opts.IncludeChain {
matches = append(matches, tok)
}
Function Filenames
has 7 return statements (exceeds 4 allowed). Open
func Filenames(name string, rx *regexp.Regexp, inclEmptyFiles, absPath bool) ([]string, error) {
isFile, err := IsFile(name, !inclEmptyFiles)
if err != nil {
return []string{}, err
}