Function processCommands
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
function processCommands (commands) {
// If a string, force to one-element array, otherwise expect an array of strings
if (typeof commands === 'string') {
commands = new Array(commands)
}
- Read upRead up
- Create a ticketCreate a ticket
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 registerKeypress
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
export function registerKeypress (commands, options, callback) {
// Defaults
// For shiftKey, metaKey, and altKey, specifies what it should
// match on the event object reported by the browser. For instance,
// if event.metaKey is false, it means the command must be executed
- Read upRead up
- Create a ticketCreate a ticket
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 deregisterKeypress
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
export function deregisterKeypress (commands, callback) {
const commandObj = processCommands(commands)
// Process each command input
for (const key in commandObj) {
- Read upRead up
- Create a ticketCreate a ticket
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 processCommands
has 62 lines of code (exceeds 25 allowed). Consider refactoring. Open
function processCommands (commands) {
// If a string, force to one-element array, otherwise expect an array of strings
if (typeof commands === 'string') {
commands = new Array(commands)
}
- Create a ticketCreate a ticket
Function registerKeypress
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function registerKeypress (commands, options, callback) {
// Defaults
// For shiftKey, metaKey, and altKey, specifies what it should
// match on the event object reported by the browser. For instance,
// if event.metaKey is false, it means the command must be executed
- Create a ticketCreate a ticket
Function onGlobalKeyDown
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
function onGlobalKeyDown (event) {
const toExecute = []
const key = event.key
// There is a bug in Chrome where events can be fired with an
- Read upRead up
- Create a ticketCreate a ticket
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
Consider simplifying this complex logical expression. Open
if (
(item.shiftKey === event.shiftKey || item.shiftKey === 'optional') &&
(item.altKey === event.altKey || item.altKey === 'optional') &&
(item.metaKey === event.metaKey ||
item.metaKey === event.ctrlKey ||
- Create a ticketCreate a ticket
Avoid deeply nested control flow statements. Open
if (isShiftOrOptional && isAltOrOptional && isMetaOrOptional) {
// If matches, remove it from the command list.
inputs[key].splice(x, 1)
}
- Create a ticketCreate a ticket
Function execute
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
function execute (input, event) {
// Check if condition is satisfied
if (!input.condition()) return
// Check if focus is on the correct place
- Read upRead up
- Create a ticketCreate a ticket
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"