grokify/mogo

View on GitHub

Showing 148 of 148 total issues

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

func (tc *TLSConfig) LoadClientCACert(caCertFilepath string) error {
    cert, err := os.ReadFile(caCertFilepath)
    if err != nil {
        return errorsutil.Wrap(err, "err in LoadClientCACert")
    }
Severity: Major
Found in crypto/tlsutil/tlsutil.go and 1 other location - About 1 hr to fix
crypto/tlsutil/tlsutil.go on lines 83..97

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

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

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

    func (rng *RangeFloat64) CellIndexForValue(v float64) (int32, error) {
        err := rng.isInitialized()
        if err != nil {
            return int32(0), err
        }
    Severity: Major
    Found in math/mathutil/rangefloat64.go and 1 other location - About 1 hr to fix
    math/mathutil/rangeint64.go on lines 19..29

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

    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 (rng *RangeInt64) CellIndexForValue(v int64) (int32, error) {
        err := rng.isInitialized()
        if err != nil {
            return int32(0), err
        }
    Severity: Major
    Found in math/mathutil/rangeint64.go and 1 other location - About 1 hr to fix
    math/mathutil/rangefloat64.go on lines 21..31

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

    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

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

        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

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

            func DecodeGunzipJSON(encoded string, output any) error {
                encoded = strings.TrimSpace(encoded)
                if strings.Index(encoded, "{") == 0 || strings.Index(encoded, "[") == 0 {
                    return json.Unmarshal([]byte(encoded), output)
                }
            Severity: Major
            Found in encoding/base62/base62.go and 1 other location - About 1 hr to fix
            encoding/base64/base64.go on lines 93..103

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

            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 DecodeGunzipJSON(encoded string, output any) error {
                encoded = strings.TrimSpace(encoded)
                if strings.Index(encoded, "{") == 0 || strings.Index(encoded, "[") == 0 {
                    return json.Unmarshal([]byte(encoded), output)
                }
            Severity: Major
            Found in encoding/base64/base64.go and 1 other location - About 1 hr to fix
            encoding/base62/base62.go on lines 71..81

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

            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 strings.Contains(overlayLocation, LocLeft) {
                    pt.X = src.Min.X + padX
                } else if strings.Contains(overlayLocation, LocRight) {
                    pt.X = src.Max.X - overlay.Dx() - padX
                } else {
            Severity: Major
            Found in image/imageutil/overlay.go and 1 other location - About 1 hr to fix
            image/imageutil/overlay.go on lines 35..41

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

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

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

                if strings.Contains(overlayLocation, LocUpper) {
                    pt.Y = src.Min.Y + padY
                } else if strings.Contains(overlayLocation, LocLower) {
                    pt.Y = src.Max.Y - overlay.Dy() - padY
                } else {
            Severity: Major
            Found in image/imageutil/overlay.go and 1 other location - About 1 hr to fix
            image/imageutil/overlay.go on lines 42..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 135.

            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 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 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 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 (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, 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 79..84

              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

              Severity
              Category
              Status
              Source
              Language