pkg/cli/term/reader_windows.go
Function convertEvent
has 8 return statements (exceeds 4 allowed). Open
Open
func convertEvent(event ewindows.InputEvent) Event {
switch event := event.(type) {
case *ewindows.KeyEvent:
if event.BKeyDown == 0 {
// Ignore keyup events.
Avoid deeply nested control flow statements. Open
Open
} else if filteredMod == leftCtrl|rightAlt || filteredMod == leftCtrl|rightAlt|shift {
// The combination leftCtrl|rightAlt is used to represent AltGr.
// Furthermore, when the actual left Ctrl and right Alt are used
// together, the UChar field seems to be always 0; so if we are
// here, we can actually be sure that it's AltGr.
Method reader.ReadEvent
has 6 return statements (exceeds 4 allowed). Open
Open
func (r *reader) ReadEvent() (Event, error) {
r.mutex.Lock()
defer r.mutex.Unlock()
handles := []windows.Handle{r.console, r.stopEvent}
var leadingSurrogate *surrogateKeyEvent
Function convertEvent
has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring. Open
Open
func convertEvent(event ewindows.InputEvent) Event {
switch event := event.(type) {
case *ewindows.KeyEvent:
if event.BKeyDown == 0 {
// Ignore keyup events.
- 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 convertRune
has 5 return statements (exceeds 4 allowed). Open
Open
func convertRune(keyCode uint16, mod ui.Mod) rune {
r, ok := keyCodeToRune[keyCode]
if ok {
return r
}