grokify/mogo

View on GitHub

Showing 159 of 159 total issues

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

      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

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

        func ParseQuarterInt32(yyyyq int32) (int32, uint8, error) {
            yyyy := int32(float32(yyyyq) / 10.0)
            q := yyyyq - 10*yyyy
            if q < 0 {
                q = -1 * q
        Severity: Minor
        Found in time/timeutil/quarter_int.go and 1 other location - About 1 hr to fix
        time/timeutil/quarter_int.go on lines 172..182

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

        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 ParseHalf(yyyyh int32) (int32, uint8, error) {
            yyyy := int32(float32(yyyyh) / 10.0)
            h := yyyyh - 10*yyyy
            if h < 0 {
                h = -1 * h
        Severity: Minor
        Found in time/timeutil/quarter_int.go and 1 other location - About 1 hr to fix
        time/timeutil/quarter_int.go on lines 105..115

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

        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 (sint *SliceInt) Median() (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 55 mins to fix
        math/mathutil/slicefloat64.go on lines 89..98

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

        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) Median() (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 55 mins to fix
        math/mathutil/sliceint.go on lines 86..95

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

        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

            case width < height:
                new := AddBackgroundColor(image.NewRGBA(image.Rect(0, 0, height, height)), bgcolor)
                draw.Draw(new, new.Bounds(), src, image.Point{
                    X: src.Bounds().Min.X + ((width - height) / 2),
                    Y: src.Bounds().Min.Y}, draw.Over)
        Severity: Minor
        Found in image/imageutil/crop.go and 1 other location - About 55 mins to fix
        image/imageutil/crop.go on lines 87..92

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

        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 len(newSlice) {
            case 0:
                return ""
            case 1:
                return newSlice[0]
        Severity: Minor
        Found in type/stringsutil/stringsutil.go and 1 other location - About 55 mins to fix
        type/stringsutil/stringsutil.go on lines 249..260

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

        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

            case width > height:
                new := AddBackgroundColor(image.NewRGBA(image.Rect(0, 0, width, width)), bgcolor)
                draw.Draw(new, new.Bounds(), src, image.Point{
                    Y: src.Bounds().Min.Y + ((height - width) / 2),
                    X: src.Bounds().Min.X}, draw.Over)
        Severity: Minor
        Found in image/imageutil/crop.go and 1 other location - About 55 mins to fix
        image/imageutil/crop.go on lines 93..98

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

        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 len(slice) {
            case 0:
                return ""
            case 1:
                return slice[0]
        Severity: Minor
        Found in type/stringsutil/stringsutil.go and 1 other location - About 55 mins to fix
        type/stringsutil/stringsutil.go on lines 265..276

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

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

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

                    if err != nil {
                        errs = append(errs, err)
                        gr := ResponseInfo{
                            Body: err.Error()}
                        bytes, err = jsonutil.MarshalSimple(gr, "", "  ")
            Severity: Minor
            Found in net/http/httputilmore/http_response.go and 1 other location - About 50 mins to fix
            net/http/httputilmore/http_response.go on lines 122..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 122.

            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

                if useXrlHyphen {
                    rlstat.XRateLimitLimit = strconvutil.AtoiOrDefault(resp.Header.Get("X-Rate-Limit-Limit"), 0)
                    rlstat.XRateLimitRemaining = strconvutil.AtoiOrDefault(resp.Header.Get("X-Rate-Limit-Remaining"), 0)
                    rlstat.XRateLimitReset = strconvutil.AtoiOrDefault(resp.Header.Get("X-Rate-Limit-Reset"), 0)
                    rlstat.XRateLimitWindow = strconvutil.AtoiOrDefault(resp.Header.Get("X-Rate-Limit-Window"), 0)
            Severity: Minor
            Found in net/http/httputilmore/httputil.go and 1 other location - About 50 mins to fix
            net/http/httputilmore/httputil.go on lines 131..136

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

            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

                } else {
                    rlstat.XRateLimitLimit = strconvutil.AtoiOrDefault(resp.Header.Get("X-RateLimit-Limit"), 0)
                    rlstat.XRateLimitRemaining = strconvutil.AtoiOrDefault(resp.Header.Get("X-RateLimit-Remaining"), 0)
                    rlstat.XRateLimitReset = strconvutil.AtoiOrDefault(resp.Header.Get("X-RateLimit-Reset"), 0)
                    rlstat.XRateLimitWindow = strconvutil.AtoiOrDefault(resp.Header.Get("X-RateLimit-Window"), 0)
            Severity: Minor
            Found in net/http/httputilmore/httputil.go and 1 other location - About 50 mins to fix
            net/http/httputilmore/httputil.go on lines 126..131

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

            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 err != nil {
                        errs = append(errs, err)
                        gr := ResponseInfo{
                            Body: err.Error()}
                        bytes, err = jsonutil.MarshalSimple(gr, "", "  ")
            Severity: Minor
            Found in net/http/httputilmore/http_response.go and 1 other location - About 50 mins to fix
            net/http/httputilmore/http_response.go on lines 136..148

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

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

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

                func (msmsi MapStringMapStringInt) Set(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 25..33

                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

                Severity
                Category
                Status
                Source
                Language