elves/elvish

View on GitHub

Showing 221 of 222 total issues

Method compiler.parseIndexingLValue has 9 return statements (exceeds 4 allowed).
Open

func (cp *compiler) parseIndexingLValue(n *parse.Indexing, f lvalueFlag) lvaluesGroup {
    if n.Head.Type == parse.Braced {
        // Braced list of lvalues may not have indices.
        if len(n.Indices) > 0 {
            cp.errorpf(n, "braced list may not have indices when used as lvalue")
Severity: Major
Found in pkg/eval/compile_lvalue.go - About 55 mins to fix

    Method file.Read has 9 return statements (exceeds 4 allowed).
    Open

    func (f file) Read() ([]NavigationFile, []byte, error) {
        // On Unix, opening a named pipe for reading is blocking when there are no
        // writers, so we need to do this check at the very beginning of this
        // function.
        //
    Severity: Major
    Found in pkg/cli/modes/navigation_fs.go - About 55 mins to fix

      Method slice.Less has 9 return statements (exceeds 4 allowed).
      Open

      func (s *slice) Less(i, j int) bool {
          if s.err != nil {
              return true
          }
      
      
      Severity: Major
      Found in pkg/eval/builtin_fn_stream.go - About 55 mins to fix

        Function ConvertListIndex has 9 return statements (exceeds 4 allowed).
        Open

        func ConvertListIndex(rawIndex any, n int) (*ListIndex, error) {
            switch rawIndex := rawIndex.(type) {
            case int:
                index, err := adjustAndCheckIndex(rawIndex, n, false)
                if err != nil {
        Severity: Major
        Found in pkg/eval/vals/index_list.go - About 55 mins to fix

          Function ConvertListIndex has a Cognitive Complexity of 24 (exceeds 20 allowed). Consider refactoring.
          Open

          func ConvertListIndex(rawIndex any, n int) (*ListIndex, error) {
              switch rawIndex := rawIndex.(type) {
              case int:
                  index, err := adjustAndCheckIndex(rawIndex, n, false)
                  if err != nil {
          Severity: Minor
          Found in pkg/eval/vals/index_list.go - About 55 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

          Function doTilde has 9 return statements (exceeds 4 allowed).
          Open

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

            Method assignOp.exec has 9 return statements (exceeds 4 allowed).
            Open

            func (op *assignOp) exec(fm *Frame) Exception {
                variables := make([]vars.Var, len(op.lhs.lvalues))
                for i, lvalue := range op.lhs.lvalues {
                    variable, err := derefLValue(fm, lvalue)
                    if err != nil {
            Severity: Major
            Found in pkg/eval/compile_lvalue.go - About 55 mins to fix

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

              func (c *client) NextCmd(from int, prefix string) (storedefs.Cmd, error) {
                  req := &api.NextCmdRequest{From: from, Prefix: prefix}
                  res := &api.NextCmdResponse{}
                  err := c.call("NextCmd", req, res)
                  return storedefs.Cmd{Text: res.Text, Seq: res.Seq}, err
              Severity: Minor
              Found in pkg/daemon/client.go and 1 other location - About 55 mins to fix
              pkg/daemon/client.go on lines 144..149

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

              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 (c *client) PrevCmd(upto int, prefix string) (storedefs.Cmd, error) {
                  req := &api.PrevCmdRequest{Upto: upto, Prefix: prefix}
                  res := &api.PrevCmdResponse{}
                  err := c.call("PrevCmd", req, res)
                  return storedefs.Cmd{Text: res.Text, Seq: res.Seq}, err
              Severity: Minor
              Found in pkg/daemon/client.go and 1 other location - About 55 mins to fix
              pkg/daemon/client.go on lines 137..142

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

              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 completionStart has a Cognitive Complexity of 24 (exceeds 20 allowed). Consider refactoring.
              Open

              func completionStart(ed *Editor, bindings tk.Bindings, ev *eval.Evaler, cfg complete.Config, smart bool) {
                  codeArea, ok := focusedCodeArea(ed.app)
                  if !ok {
                      return
                  }
              Severity: Minor
              Found in pkg/edit/completion.go - About 55 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

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

              func (s *service) PrevCmd(req *api.PrevCmdRequest, res *api.PrevCmdResponse) error {
                  if s.err != nil {
                      return s.err
                  }
                  cmd, err := s.store.PrevCmd(req.Upto, req.Prefix)
              Severity: Minor
              Found in pkg/daemon/service.go and 1 other location - About 55 mins to fix
              pkg/daemon/service.go on lines 75..82

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

              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 (s *service) NextCmd(req *api.NextCmdRequest, res *api.NextCmdResponse) error {
                  if s.err != nil {
                      return s.err
                  }
                  cmd, err := s.store.NextCmd(req.From, req.Prefix)
              Severity: Minor
              Found in pkg/daemon/service.go and 1 other location - About 55 mins to fix
              pkg/daemon/service.go on lines 84..91

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

              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

              Method service.call has 7 arguments (exceeds 4 allowed). Consider refactoring.
              Open

              func (s *service) call(server *Server, sending *sync.Mutex, wg *sync.WaitGroup, mtype *methodType, req *Request, argv, replyv reflect.Value, codec ServerCodec) {
              Severity: Major
              Found in pkg/rpc/server.go - About 50 mins to fix

                Method redirOp.exec has 8 return statements (exceeds 4 allowed).
                Open

                func (op *redirOp) exec(fm *Frame) Exception {
                    var dst int
                    if op.dstOp == nil {
                        // No explicit FD destination specified; use default destinations
                        switch op.mode {
                Severity: Major
                Found in pkg/eval/compile_effect.go - About 50 mins to fix

                  Function ScanToGo has 8 return statements (exceeds 4 allowed).
                  Open

                  func ScanToGo(src any, ptr any) error {
                      switch ptr := ptr.(type) {
                      case *int:
                          i, err := elvToInt(src)
                          if err == nil {
                  Severity: Major
                  Found in pkg/eval/vals/conversion.go - About 50 mins to fix

                    Function convertEvent has 8 return statements (exceeds 4 allowed).
                    Open

                    func convertEvent(event ewindows.InputEvent) Event {
                        switch event := event.(type) {
                        case *ewindows.KeyEvent:
                            if event.BKeyDown == 0 {
                                // Ignore keyup events.
                    Severity: Major
                    Found in pkg/cli/term/reader_windows.go - About 50 mins to fix

                      Function useFromFile has 8 return statements (exceeds 4 allowed).
                      Open

                      func useFromFile(fm *Frame, spec, path string, r diag.Ranger) (*Ns, error) {
                          if ns, ok := fm.Evaler.modules[path]; ok {
                              return ns, nil
                          }
                          _, err := os.Stat(path + ".so")
                      Severity: Major
                      Found in pkg/eval/builtin_special.go - About 50 mins to fix

                        Method externalCmd.Call has 8 return statements (exceeds 4 allowed).
                        Open

                        func (e externalCmd) Call(fm *Frame, argVals []any, opts map[string]any) error {
                            if len(opts) > 0 {
                                return ErrExternalCmdOpts
                            }
                            if fsutil.DontSearch(e.Name) {
                        Severity: Major
                        Found in pkg/eval/external_cmd.go - About 50 mins to fix

                          Function set has 8 return statements (exceeds 4 allowed).
                          Open

                          func set(fm *Frame, r diag.Ranger, temp bool, variable vars.Var, value any) Exception {
                              if temp {
                                  saved := variable.Get()
                          
                                  needUnset := false
                          Severity: Major
                          Found in pkg/eval/compile_lvalue.go - About 50 mins to fix

                            Function parseCSI has 8 return statements (exceeds 4 allowed).
                            Open

                            func parseCSI(nums []int, last rune, seq string) ui.Key {
                                if k, ok := csiSeqByLast[last]; ok {
                                    if len(nums) == 0 {
                                        // Unmodified: \e[A (Up)
                                        return k
                            Severity: Major
                            Found in pkg/cli/term/reader_unix.go - About 50 mins to fix
                              Severity
                              Category
                              Status
                              Source
                              Language