elves/elvish

View on GitHub

Showing 221 of 222 total issues

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

func take(fm *Frame, n int, inputs Inputs) error {
    out := fm.ValueOutput()
    var errOut error
    i := 0
    inputs(func(v any) {
Severity: Minor
Found in pkg/eval/builtin_fn_stream.go and 1 other location - About 50 mins to fix
pkg/eval/builtin_fn_stream.go on lines 72..86

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

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 drop(fm *Frame, n int, inputs Inputs) error {
    out := fm.ValueOutput()
    var errOut error
    i := 0
    inputs(func(v any) {
Severity: Minor
Found in pkg/eval/builtin_fn_stream.go and 1 other location - About 50 mins to fix
pkg/eval/builtin_fn_stream.go on lines 56..70

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

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 d, ok := opts.desc[opt]; ok {
            if e, ok := opts.argDesc[opt]; ok {
                c.Display = ui.T(c.Stem + " " + e + " (" + d + ")")
            } else {
                c.Display = ui.T(c.Stem + " (" + d + ")")
Severity: Minor
Found in pkg/edit/complete_getopt.go and 1 other location - About 50 mins to fix
pkg/edit/complete_getopt.go on lines 47..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 119.

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 d, ok := opts.desc[opt]; ok {
            if e, ok := opts.argDesc[opt]; ok {
                c.Display = ui.T(c.Stem + " " + e + " (" + d + ")")
            } else {
                c.Display = ui.T(c.Stem + " (" + d + ")")
Severity: Minor
Found in pkg/edit/complete_getopt.go and 1 other location - About 50 mins to fix
pkg/edit/complete_getopt.go on lines 36..42

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

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

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

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

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

Refactorings

Further Reading

Avoid deeply nested control flow statements.
Open

                    if r == eof {
                        break literal
                    }
Severity: Major
Found in pkg/glob/parse.go - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                        if !ok {
                            ps.backup()
                            ps.error(errInvalidEscapeHex)
                            break
                        }
    Severity: Major
    Found in pkg/parse/parse.go - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                  if m := atxHeadingAttributeRegexp.FindStringSubmatch(line); m != nil {
                      attr = m[1]
                      line = strings.TrimRight(line[:len(line)-len(m[0])], " \t")
                  }
      Severity: Major
      Found in pkg/md/md.go - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                            if r < '0' || r > '7' {
                                ps.backup()
                                ps.error(errInvalidEscapeOct)
                                break
                            }
        Severity: Major
        Found in pkg/parse/parse.go - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                      if len(runes) != 3 {
                          return nil, badRangeExpr
                      }
          Severity: Major
          Found in pkg/eval/glob.go - About 45 mins to fix

            Function doTilde has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring.
            Open

            func doTilde(v any) (any, error) {
                switch v := v.(type) {
                case string:
                    s := v
                    // TODO: Make this correct on Windows.
            Severity: Minor
            Found in pkg/eval/compile_value.go - About 45 mins to fix

            Cognitive Complexity

            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

            A method's cognitive complexity is based on a few simple rules:

            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
            • Code is considered more complex for each "break in the linear flow of the code"
            • Code is considered more complex when "flow breaking structures are nested"

            Further reading

            Avoid deeply nested control flow statements.
            Open

                                if parseWithCloser("]]>") {
                                    continue
                                }
            Severity: Major
            Found in pkg/md/inline.go - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                  if parseWithCloser(">") {
                                      continue
                                  }
              Severity: Major
              Found in pkg/md/inline.go - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                    if autolink != "" {
                                        p.pos = begin + len(autolink)
                                        // Autolinks support character references but not
                                        // backslashes, so UnescapeHTML gives us the desired
                                        // behavior.
                Severity: Major
                Found in pkg/md/inline.go - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                          } else if r <= 0x7f {
                              // Unprintable characters in the ASCII range can be escaped with \x
                              // since they are one byte in UTF-8.
                              buf.WriteByte('\\')
                              buf.WriteByte('x')
                  Severity: Major
                  Found in pkg/parse/quote.go - About 45 mins to fix

                    Function derefLValue has 7 return statements (exceeds 4 allowed).
                    Open

                    func derefLValue(fm *Frame, lv lvalue) (vars.Var, error) {
                        variable := deref(fm, lv.ref)
                        if variable == nil {
                            return nil, NoSuchVariable(fm.srcMeta.Code[lv.From:lv.To])
                        }
                    Severity: Major
                    Found in pkg/eval/compile_lvalue.go - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                  if closer := atxHeadingCloserRegexp.FindString(line); closer != "" {
                                      line = strings.TrimRight(line[:len(line)-len(closer)], " \t")
                                  }
                      Severity: Major
                      Found in pkg/md/md.go - About 45 mins to fix

                        Function parseOneStyling has 7 return statements (exceeds 4 allowed).
                        Open

                        func parseOneStyling(name string) Styling {
                            switch {
                            case name == "default" || name == "fg-default":
                                return FgDefault
                            case strings.HasPrefix(name, "fg-"):
                        Severity: Major
                        Found in pkg/ui/styling.go - About 45 mins to fix

                          Function order has 7 return statements (exceeds 4 allowed).
                          Open

                          func order(fm *Frame, opts orderOptions, inputs Inputs) error {
                              if opts.Total && opts.LessThan != nil {
                                  return ErrBothTotalAndLessThan
                              }
                              var values, keys []any
                          Severity: Major
                          Found in pkg/eval/builtin_fn_stream.go - About 45 mins to fix

                            Function checkRlimitsMapKeys has 7 return statements (exceeds 4 allowed).
                            Open

                            func checkRlimitsMapKeys(val any) error {
                                wantedKeys := make(map[string]struct{}, len(rlimitKeys))
                                for _, key := range rlimitKeys {
                                    wantedKeys[key] = struct{}{}
                                }
                            Severity: Major
                            Found in pkg/mods/unix/rlimit.go - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

                                                  if parseWithCloser("-->") {
                                                      continue
                                                  }
                              Severity: Major
                              Found in pkg/md/inline.go - About 45 mins to fix
                                Severity
                                Category
                                Status
                                Source
                                Language