grokify/mogo

View on GitHub

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
    }
Severity: Minor
Found in text/currencyutil/parse.go - About 3 hrs 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 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{}
Severity: Minor
Found in time/duration/durationbin/bins.go - About 2 hrs 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 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
Severity: Major
Found in text/currencyutil/currency_codes.go - About 2 hrs to fix

    TimeMore has 25 methods (exceeds 20 allowed). Consider refactoring.
    Open

    type TimeMore struct {
        time         time.Time
        weekStartDay time.Weekday
    }
    Severity: Minor
    Found in time/timeutil/timemore.go - About 2 hrs to fix

      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
          }
      Severity: Minor
      Found in encoding/csvutil/csvutil.go - About 2 hrs 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 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
      Severity: Minor
      Found in html/htmlutil/tokenizer.go - About 2 hrs 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 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)
      Severity: Minor
      Found in time/timeutil/time_range.go - About 1 hr to fix

        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
            }
        Severity: Minor
        Found in text/currencyutil/parse.go - About 1 hr to fix

          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
          Severity: Major
          Found in time/timeutil/duration_string.go - About 1 hr to fix

            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:
            Severity: Minor
            Found in type/stringsutil/match.go - About 1 hr to fix

              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)) {
              Severity: Critical
              Found in time/timeutil/time_range.go - About 1 hr to fix

                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:
                Severity: Major
                Found in type/stringsutil/match.go - About 1 hr to fix

                  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
                      }
                  Severity: Minor
                  Found in encoding/csvutil/csvutil.go - About 1 hr to fix

                    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
                        }
                    Severity: Minor
                    Found in text/currencyutil/internal/cmd/build_currency_codes/main.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 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
                        }
                    Severity: Minor
                    Found in text/currencyutil/internal/cmd/build_currency_codes/main.go - About 1 hr to fix

                      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{}
                      Severity: Major
                      Found in time/duration/durationbin/bins.go - About 1 hr to fix

                        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:
                        Severity: Minor
                        Found in type/stringsutil/match.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 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
                        Severity: Minor
                        Found in time/timeutil/duration_string.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 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{}
                        Severity: Minor
                        Found in time/duration/durationbin/bins.go - About 1 hr to fix

                          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
                          Severity: Minor
                          Found in time/timeutil/duration_string.go - About 1 hr to fix
                            Severity
                            Category
                            Status
                            Source
                            Language