grokify/mogo

View on GitHub

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
    }
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 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 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

            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

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

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

                        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
                        Severity: Major
                        Found in image/imageutil/write.go - About 55 mins to fix

                          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 {
                          Severity: Major
                          Found in type/interfaceutil/interfaceutil.go - About 50 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                            } else if opts.IncludeChain {
                                                matches = append(matches, tok)
                                            }
                            Severity: Major
                            Found in html/htmlutil/tokenizer.go - About 45 mins to fix

                              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
                                  }
                              Severity: Major
                              Found in os/osutil/filepath.go - About 45 mins to fix
                                Severity
                                Category
                                Status
                                Source
                                Language