grokify/mogo

View on GitHub

Showing 144 of 144 total issues

Function ParseCurrency has a Cognitive Complexity of 38 (exceeds 20 allowed). Consider refactoring.
Open

func ParseCurrency(opts *ParseCurrencyOpts, s string) (string, float64, error) {
    try := strings.TrimSpace(s)
    if len(try) == 0 {
        return "", 0, nil
    }
Severity: Minor
Found in text/currencyutil/parse.go - About 3 hrs 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

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 and 1 other location - About 2 hrs to fix
math/mathutil/slicefloat64.go on lines 101..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 243.

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) BuildStats() (SliceFloat64Stats, error) {
    stats := NewSliceFloat64Stats()
    stats.Len = sf64.Len()
    max, err := sf64.Max()
    if err != nil {
Severity: Major
Found in math/mathutil/slicefloat64.go and 1 other location - About 2 hrs to fix
math/mathutil/sliceint.go on lines 98..128

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

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 CurrencyCodesAll has 97 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func CurrencyCodesAll() []string {
    return []string{
        CurrencyAFN, // Afghanistan Afghani
        CurrencyALL, // Albania Lek
        CurrencyANG, // Netherlands Antilles Guilder
Severity: Major
Found in text/currencyutil/currency_codes.go - About 2 hrs to fix

    TimeMore has 25 methods (exceeds 20 allowed). Consider refactoring.
    Open

    type TimeMore struct {
        time         time.Time
        weekStartDay time.Weekday
    }
    Severity: Minor
    Found in time/timeutil/timemore.go - About 2 hrs to fix

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

      func (rng *RangeInt64) binarySearch(v int64, l, r int32) (int32, error) {
          rng.iter += 1
          if rng.iter > MaxTries {
              return int32(0), fmt.Errorf("struct RangeInt64 too many (%v) binary search iterations", MaxTries)
          }
      Severity: Major
      Found in math/mathutil/rangeint64.go and 1 other location - About 2 hrs to fix
      math/mathutil/rangefloat64.go on lines 33..53

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

      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 *RangeFloat64) binarySearch(v float64, l, r int32) (int32, error) {
          rng.iter += 1
          if rng.iter > MaxTries {
              return int32(0), fmt.Errorf("too many (%v) binary search iterations", MaxTries)
          }
      Severity: Major
      Found in math/mathutil/rangefloat64.go and 1 other location - About 2 hrs to fix
      math/mathutil/rangeint64.go on lines 31..51

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

      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 ResizeMin(minWidth, minHeight uint, src image.Image, scale draw.Scaler) image.Image {
          srcWidth := uint(src.Bounds().Dx())
          srcHeight := uint(src.Bounds().Dy())
          if srcWidth >= minWidth && srcHeight >= minHeight {
              return src
      Severity: Major
      Found in image/imageutil/modify.go and 1 other location - About 2 hrs to fix
      image/imageutil/modify.go on lines 68..90

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

      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 ResizeMax(maxWidth, maxHeight uint, src image.Image, scale draw.Scaler) image.Image {
          srcWidth := uint(src.Bounds().Dx())
          srcHeight := uint(src.Bounds().Dy())
          if srcWidth <= maxWidth && srcHeight <= maxHeight {
              return src
      Severity: Major
      Found in image/imageutil/modify.go and 1 other location - About 2 hrs to fix
      image/imageutil/modify.go on lines 95..117

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

      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 a Cognitive Complexity of 33 (exceeds 20 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 2 hrs 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 NextTokens has a Cognitive Complexity of 33 (exceeds 20 allowed). Consider refactoring.
      Open

      func NextTokens(z *html.Tokenizer, opts NextTokensOpts) (Tokens, error) {
          // func NextTokens(z *html.Tokenizer, skipErrors, includeChain, includeMatch bool, start, end []html.Token) ([]html.Token, error) {
          matches := []html.Token{}
          if z == nil {
              return matches, ErrTokenizerNotInitialized
      Severity: Minor
      Found in html/htmlutil/tokenizer.go - About 2 hrs 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

      func (rng *RangeFloat64) CellMinMax(idx int32) (float64, float64, error) {
          err := rng.isInitialized()
          if err != nil {
              return float64(0), float64(0), err
          }
      Severity: Major
      Found in math/mathutil/rangefloat64.go and 1 other location - About 2 hrs to fix
      math/mathutil/rangeint64.go on lines 70..85

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

      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) CellMinMax(idx int32) (int64, int64, error) {
          err := rng.isInitialized()
          if err != nil {
              return int64(0), int64(0), err
          }
      Severity: Major
      Found in math/mathutil/rangeint64.go and 1 other location - About 2 hrs to fix
      math/mathutil/rangefloat64.go on lines 72..87

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

      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 DecimalSeparator(lang string) (string, error) {
          lang = strings.ToLower(strings.TrimSpace(lang))
          if lang == languageutil.English ||
              lang == languageutil.Thai {
              return ".", nil
      Severity: Major
      Found in strconv/strconvutil/strconv_lang.go and 1 other location - About 1 hr to fix
      strconv/strconvutil/strconv_lang.go on lines 46..62

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

      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 ThousandsSeparator(lang string) (string, error) {
          lang = strings.ToLower(strings.TrimSpace(lang))
          if lang == languageutil.English ||
              lang == languageutil.Thai {
              return ",", nil
      Severity: Major
      Found in strconv/strconvutil/strconv_lang.go and 1 other location - About 1 hr to fix
      strconv/strconvutil/strconv_lang.go on lines 28..44

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

      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 ParseTimeRangeInterval has 70 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func ParseTimeRangeInterval(s string) (TimeRange, error) {
          s1 := strings.ToUpper(strings.TrimSpace(s))
          m := rxParseTimeRange.FindStringSubmatch(s1)
          if len(m) == 0 {
              return TimeRange{}, fmt.Errorf("cannot parse time range rx (%s)", s)
      Severity: Minor
      Found in time/timeutil/time_range.go - About 1 hr to fix

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

        func TimesYearStarts(times ...time.Time) timeutil.Times {
            timesStarts := timeutil.Times{}
            if len(times) == 0 {
                return timesStarts
            }
        Severity: Major
        Found in time/year/year.go and 1 other location - About 1 hr to fix
        time/month/month.go on lines 114..129

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

        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 TimesMonthStarts(times ...time.Time) timeutil.Times {
            timesStarts := timeutil.Times{}
            if len(times) == 0 {
                return timesStarts
            }
        Severity: Major
        Found in time/month/month.go and 1 other location - About 1 hr to fix
        time/year/year.go on lines 10..24

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

        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 ParseCurrency has 68 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func ParseCurrency(opts *ParseCurrencyOpts, s string) (string, float64, error) {
            try := strings.TrimSpace(s)
            if len(try) == 0 {
                return "", 0, nil
            }
        Severity: Minor
        Found in text/currencyutil/parse.go - About 1 hr to fix

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

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

          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

          Severity
          Category
          Status
          Source
          Language