pkg/cli/term/reader_unix.go
Function readEvent
has a Cognitive Complexity of 86 (exceeds 20 allowed). Consider refactoring. Open
Open
func readEvent(rd byteReaderWithTimeout) (event Event, err error) {
var r rune
r, err = readRune(rd, -1)
if err != nil {
return
- Read upRead up
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
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
- Read upRead up
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
Open
func readEvent(rd byteReaderWithTimeout) (event Event, err error) {
var r rune
r, err = readRune(rd, -1)
if err != nil {
return
Function parseCSI
has 8 return statements (exceeds 4 allowed). Open
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
Avoid deeply nested control flow statements. Open
Open
if len(nums) != 3 {
badSeq("bad SGR mouse event")
return
}
Avoid deeply nested control flow statements. Open
Open
if len(nums) == 0 {
nums = append(nums, 0)
}
Avoid deeply nested control flow statements. Open
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)