grokify/mogo

View on GitHub

Showing 159 of 159 total issues

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

func (sint *SliceInt) Max() (int, error) {
    if len(sint.Elements) == 0 {
        return 0, ErrEmptyList
    }
    if !sort.IntsAreSorted(sint.Elements) {
Severity: Minor
Found in math/mathutil/sliceint.go and 1 other location - About 45 mins to fix
math/mathutil/slicefloat64.go on lines 49..57

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

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 (ts Times) Min() *time.Time {
    if len(ts) == 0 {
        return nil
    }
    var min time.Time
Severity: Minor
Found in time/timeutil/times.go and 1 other location - About 45 mins to fix
time/timeutil/times.go on lines 96..109

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

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 (ts Times) Max() *time.Time {
    if len(ts) == 0 {
        return nil
    }
    var max time.Time
Severity: Minor
Found in time/timeutil/times.go and 1 other location - About 45 mins to fix
time/timeutil/times.go on lines 111..124

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

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 (sf64 *SliceFloat64) Max() (float64, error) {
    if len(sf64.Elements) == 0 {
        return 0, ErrEmptyList
    }
    if !sort.Float64sAreSorted(sf64.Elements) {
Severity: Minor
Found in math/mathutil/slicefloat64.go and 1 other location - About 45 mins to fix
math/mathutil/sliceint.go on lines 46..54

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

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

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

        if maxLength > 0 && curLength+len(begQuote+word+endQuote+sep) > maxLength {
            words = append(words, strings.Join(curWords, sep))
            curWords = []string{}
            curLength = 0
        } else {
Severity: Minor
Found in type/stringsutil/join/join.go and 1 other location - About 45 mins to fix
type/stringsutil/join/join.go on lines 127..134

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

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

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

        if maxLength > 0 && curLength+len(begQuote+word+endQuote+sep) > maxLength {
            words = append(words, strings.Join(curWords, sep))
            curWords = []string{}
            curLength = 0
        } else {
Severity: Minor
Found in type/stringsutil/join/join.go and 1 other location - About 45 mins to fix
type/stringsutil/join/join.go on lines 48..55

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

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

    switch strings.ToLower(strings.TrimSpace(align)) {
    case AlignLeft:
        xMin = src.Bounds().Min.X
    case AlignRight:
        xMin = src.Bounds().Max.X - int(width)
Severity: Minor
Found in image/imageutil/crop.go and 1 other location - About 40 mins to fix
image/imageutil/crop.go on lines 54..61

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

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

    switch strings.ToLower(strings.TrimSpace(align)) {
    case AlignTop:
        yMin = src.Bounds().Min.Y
    case AlignBottom:
        yMin = src.Bounds().Max.Y - int(height)
Severity: Minor
Found in image/imageutil/crop.go and 1 other location - About 40 mins to fix
image/imageutil/crop.go on lines 33..40

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

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

Function DirRemoveAllChildren has 6 return statements (exceeds 4 allowed).
Open

func DirRemoveAllChildren(dir string) error {
    isDir, err := IsDir(dir)
    if err != nil {
        return err
    }
Severity: Major
Found in os/osutil/dir.go - About 40 mins to fix

    Function CopyFile has 6 return statements (exceeds 4 allowed).
    Open

    func CopyFile(src, dst string) error {
        r, err := os.Open(src)
        if err != nil {
            return err
        }
    Severity: Major
    Found in os/osutil/copy.go - About 40 mins to fix

      Function AnyStringToQuarterTime has 6 return statements (exceeds 4 allowed).
      Open

      func AnyStringToQuarterTime(yyyyqSrcStr string) time.Time {
          yyyyqSrcStr = strings.TrimSpace(yyyyqSrcStr)
          // If not a string, return now time.
          if len(yyyyqSrcStr) != 5 {
              return time.Now().UTC()
      Severity: Major
      Found in time/timeutil/quarter_int.go - About 40 mins to fix

        Method SliceInt.BuildStats has 6 return statements (exceeds 4 allowed).
        Open

        func (sint *SliceInt) BuildStats() (SliceIntStats, error) {
            stats := NewSliceIntStats()
            stats.Len = sint.Len()
            max, err := sint.Max()
            if err != nil {
        Severity: Major
        Found in math/mathutil/sliceint.go - About 40 mins to fix

          Function AddFileToArchive has 6 return statements (exceeds 4 allowed).
          Open

          func AddFileToArchive(tw *tar.Writer, filename, archivename string) error {
              // Open the file which will be written into the archive
              file, err := os.Open(filename)
              if err != nil {
                  return err
          Severity: Major
          Found in archive/tarutil/writer.go - About 40 mins to fix

            Function ToBool has 6 return statements (exceeds 4 allowed).
            Open

            func ToBool(v any) bool {
                if v == nil {
                    return false
                } else if valBool, ok := v.(bool); ok {
                    return valBool
            Severity: Major
            Found in type/interfaceutil/interfaceutil.go - About 40 mins to fix

              Function Dd6ToTime has 6 return statements (exceeds 4 allowed).
              Open

              func Dd6ToTime(dd6 string, reverse bool) (time.Time, error) {
                  dd6 = strings.ToLower(strings.TrimSpace(dd6))
                  yyyy := ""
                  mm36 := ""
                  dd36 := ""
              Severity: Major
              Found in time/timeutil/day.go - About 40 mins to fix

                Function GetWriteFile has 6 return statements (exceeds 4 allowed).
                Open

                func GetWriteFile(client *http.Client, url, filename string) (*http.Response, error) {
                    if client == nil {
                        client = &http.Client{}
                    }
                    resp, err := client.Get(url)
                Severity: Major
                Found in net/http/httputilmore/http_request.go - About 40 mins to fix

                  Method SliceFloat64.BuildStats has 6 return statements (exceeds 4 allowed).
                  Open

                  func (sf64 *SliceFloat64) BuildStats() (SliceFloat64Stats, error) {
                      stats := NewSliceFloat64Stats()
                      stats.Len = sf64.Len()
                      max, err := sf64.Max()
                      if err != nil {
                  Severity: Major
                  Found in math/mathutil/slicefloat64.go - About 40 mins to fix

                    Consider simplifying this complex logical expression.
                    Open

                        if t.Before(tr.Min) || t.After(tr.Max) ||
                            (!inclusiveMin && t.Equal(tr.Min)) ||
                            (!inclusiveMax && t.Equal(tr.Max)) {
                    Severity: Major
                    Found in time/timeutil/time_range.go - About 40 mins to fix

                      Function VisitFiles has 6 return statements (exceeds 4 allowed).
                      Open

                      func VisitFiles(name string, visitFunc func(dir string, info fs.FileInfo) error) error {
                          fileInfo, err := os.Stat(name)
                          if err != nil {
                              return err
                          }
                      Severity: Major
                      Found in os/osutil/dir.go - About 40 mins to fix

                        Function DT6sToString has 6 return statements (exceeds 4 allowed).
                        Open

                        func DT6sToString(startDT6, endDT6 int32, layout, presentText, prefixText, joinText, suffixText string) (string, error) {
                            if startDT6 <= 0 && endDT6 <= 0 {
                                return "", nil
                            }
                            startText, endText, err := DT6sToStrings(startDT6, endDT6, layout, presentText)
                        Severity: Major
                        Found in time/month/strconv.go - About 40 mins to fix
                          Severity
                          Category
                          Status
                          Source
                          Language