grokify/mogo

View on GitHub

Showing 159 of 159 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

func (msmsi MapStringMapStringInt) Add(str1, str2 string, val int) {
    if _, ok := msmsi[str1]; !ok {
        msmsi[str1] = map[string]int{}
    }
    if _, ok := msmsi[str1][str2]; !ok {
Severity: Minor
Found in type/maputil/map_string_map_string_int.go and 1 other location - About 45 mins to fix
type/maputil/map_string_map_string_int.go on lines 14..22

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 117.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

func MinMaxUint(vals ...uint) (uint, uint) {
    min := uint(0)
    max := uint(0)
    for i, val := range vals {
        if i == 0 {
Severity: Minor
Found in math/mathutil/int.go and 1 other location - About 45 mins to fix
math/mathutil/int.go on lines 11..28

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 116.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

func MinMaxInt32(vals ...int32) (int32, int32) {
    min := int32(0)
    max := int32(0)
    for i, val := range vals {
        if i == 0 {
Severity: Minor
Found in math/mathutil/int.go and 1 other location - About 45 mins to fix
math/mathutil/int.go on lines 31..48

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 116.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

      func FilenModAgeGTE(filename string, s string) (bool, error) {
          ageCheck, err := time.ParseDuration(s)
          if err != nil {
              return false, err
          }
      Severity: Minor
      Found in os/osutil/fileinfomore.go and 1 other location - About 45 mins to fix
      os/osutil/fileinfomore.go on lines 58..72

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 115.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

      func FileModAgeLTE(filename string, s string) (bool, error) {
          ageCheck, err := time.ParseDuration(s)
          if err != nil {
              return false, err
          }
      Severity: Minor
      Found in os/osutil/fileinfomore.go and 1 other location - About 45 mins to fix
      os/osutil/fileinfomore.go on lines 42..56

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 115.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      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