grokify/mogo

View on GitHub

Showing 98 of 159 total issues

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

          Function BuildBinsDuration has 8 return statements (exceeds 4 allowed).
          Open

          func BuildBinsDuration(d, extLeft, extRight time.Duration) Bins {
              if extLeft == extRight {
                  if d < extRight {
                      return BuildBinsDurationLeftRight(d, extRight)
                  } else {
          Severity: Major
          Found in time/duration/durationbin/bins.go - About 50 mins to fix

            Method Request.BodyBytes has 7 return statements (exceeds 4 allowed).
            Open

            func (req *Request) BodyBytes() ([]byte, error) {
                if req.Body == nil {
                    return []byte{}, nil
                } else if reqBodyBytes, ok := req.Body.([]byte); ok {
                    return reqBodyBytes, nil
            Severity: Major
            Found in net/http/httpsimple/simplerequest.go - About 45 mins to fix

              Function ReadDirRxSubmatch has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring.
              Open

              func ReadDirRxSubmatch(dir string, rx *regexp.Regexp, subMatchIdx uint, inclDirs, inclFiles, inclEmptyFiles bool) (map[string][]os.DirEntry, error) {
                  entryMap := map[string][]os.DirEntry{}
              
                  entries, err := os.ReadDir(dir)
                  if err != nil {
              Severity: Minor
              Found in os/osutil/dir.go - About 45 mins 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 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

                Avoid deeply nested control flow statements.
                Open

                    } else if valFloat, ok := v.(float64); ok {
                        return valFloat != 0.0
                    }
                Severity: Major
                Found in type/interfaceutil/interfaceutil.go - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                      } else if valFloat, ok := v.(float64); ok {
                          return int(valFloat)
                      } else {
                          return defaultValue
                      }
                  Severity: Major
                  Found in type/interfaceutil/interfaceutil.go - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                            } else if endDd.MatchLeft(tok, nil) {
                                curDesc.Description = append(curDesc.Description, tok)
                                dl = append(dl, curDesc)
                                matching = ""
                                curDesc = Description{}
                    Severity: Major
                    Found in html/htmlutil/descriptionlist_parser.go - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

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

                        Function SeverityInclude has 7 return statements (exceeds 4 allowed).
                        Open

                        func SeverityInclude(filterLevel, itemLevel string) (bool, error) {
                            filterLevelGood, err := Parse(filterLevel)
                            if err != nil || filterLevelGood == SeverityDisabled {
                                return false, err
                            }
                        Severity: Major
                        Found in log/severity/severity.go - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                  } else if extLeft != nil {
                                      return BuildBinsDurationLeftRight(*extLeft, durs[0])
                                  } else {
                                      return BuildBinsDurationLeftRight(durs[0], *extRight)
                                  }
                          Severity: Major
                          Found in time/duration/durationbin/bins.go - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                    } else if units == "y" {
                                        s = fmt.Sprintf("%vs", i*YearSeconds)
                                    } else {
                                        return zeroDuration, errors.New("timeutil.ParseDuration Parse Error")
                                    }
                            Severity: Major
                            Found in time/timeutil/duration.go - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

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

                                Avoid deeply nested control flow statements.
                                Open

                                    } else if req.BodyType == BodyTypeXML {
                                        return xmlutil.MarshalIndent(req.Body, "", "", req.AddXMLDocType)
                                    } else if req.BodyType == BodyTypeForm {
                                        if v, ok := req.Body.(url.Values); ok {
                                            return []byte(v.Encode()), nil
                                Severity: Major
                                Found in net/http/httpsimple/simplerequest.go - About 45 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

                                    Avoid deeply nested control flow statements.
                                    Open

                                        } else if !stringsutil.UniqueRunes(a2) {
                                            return errors.New("alphabet 2 chars are not unique")
                                        }
                                    Severity: Major
                                    Found in encoding/basex/encoding.go - About 45 mins to fix

                                      Avoid deeply nested control flow statements.
                                      Open

                                          } else if bl, ok := a.(bool); ok {
                                              if bl {
                                                  *s = String("true")
                                              } else {
                                                  *s = String("false")
                                      Severity: Major
                                      Found in encoding/jsonutil/tolerant_reader_types.go - About 45 mins to fix
                                        Severity
                                        Category
                                        Status
                                        Source
                                        Language