elves/elvish

View on GitHub
pkg/cli/term/reader_unix.go

Summary

Maintainability
D
2 days
Test Coverage

Function readEvent has a Cognitive Complexity of 86 (exceeds 20 allowed). Consider refactoring.
Open

func readEvent(rd byteReaderWithTimeout) (event Event, err error) {
    var r rune
    r, err = readRune(rd, -1)
    if err != nil {
        return
Severity: Minor
Found in pkg/cli/term/reader_unix.go - About 1 day 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 parseCSI has a Cognitive Complexity of 31 (exceeds 20 allowed). Consider refactoring.
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: Minor
Found in pkg/cli/term/reader_unix.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 readEvent has 13 return statements (exceeds 4 allowed).
Open

func readEvent(rd byteReaderWithTimeout) (event Event, err error) {
    var r rune
    r, err = readRune(rd, -1)
    if err != nil {
        return
Severity: Major
Found in pkg/cli/term/reader_unix.go - About 1 hr 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

      Avoid deeply nested control flow statements.
      Open

                      if len(nums) != 3 {
                          badSeq("bad SGR mouse event")
                          return
                      }
      Severity: Major
      Found in pkg/cli/term/reader_unix.go - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                            if len(nums) == 0 {
                                nums = append(nums, 0)
                            }
        Severity: Major
        Found in pkg/cli/term/reader_unix.go - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                      } else if r == '~' && len(nums) == 1 && (nums[0] == 200 || nums[0] == 201) {
                          b := nums[0] == 200
                          event = PasteSetting(b)
                      } else {
                          k := parseCSI(nums, r, currentSeq)
          Severity: Major
          Found in pkg/cli/term/reader_unix.go - About 45 mins to fix

            There are no issues that match your filters.

            Category
            Status