Showing 98 of 159 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 BuildBinsDefault
has a Cognitive Complexity of 36 (exceeds 20 allowed). Consider refactoring. Open
func BuildBinsDefault(durs []time.Duration, extLeft, extRight *time.Duration) Bins {
durs = slicesutil.Dedupe(durs)
if len(durs) == 0 {
if extLeft == nil && extRight == nil {
return Bins{}
- 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 DurationStringUnit
has 16 return statements (exceeds 4 allowed). Open
func DurationStringUnit(d, unit time.Duration, prec int, addSuffix bool) string {
switch unit {
case time.Nanosecond:
if v := strconv.Itoa(int(d)); addSuffix {
return v + UnitSuffixNanosecond
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:
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 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:
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 BuildBinsDefault
has 11 return statements (exceeds 4 allowed). Open
func BuildBinsDefault(durs []time.Duration, extLeft, extRight *time.Duration) Bins {
durs = slicesutil.Dedupe(durs)
if len(durs) == 0 {
if extLeft == nil && extRight == nil {
return Bins{}
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 DurationStringUnit
has a Cognitive Complexity of 25 (exceeds 20 allowed). Consider refactoring. Open
func DurationStringUnit(d, unit time.Duration, prec int, addSuffix bool) string {
switch unit {
case time.Nanosecond:
if v := strconv.Itoa(int(d)); addSuffix {
return v + UnitSuffixNanosecond
- 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 BuildBinsDefault
has 52 lines of code (exceeds 50 allowed). Consider refactoring. Open
func BuildBinsDefault(durs []time.Duration, extLeft, extRight *time.Duration) Bins {
durs = slicesutil.Dedupe(durs)
if len(durs) == 0 {
if extLeft == nil && extRight == nil {
return Bins{}
Function DurationStringUnit
has 52 lines of code (exceeds 50 allowed). Consider refactoring. Open
func DurationStringUnit(d, unit time.Duration, prec int, addSuffix bool) string {
switch unit {
case time.Nanosecond:
if v := strconv.Itoa(int(d)); addSuffix {
return v + UnitSuffixNanosecond