packages/check/match.js
Function testSubtree
has a Cognitive Complexity of 82 (exceeds 5 allowed). Consider refactoring. Open
Open
const testSubtree = (value, pattern) => {
// Match anything!
if (pattern === Match.Any) {
return false;
- 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 testSubtree
has 197 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const testSubtree = (value, pattern) => {
// Match anything!
if (pattern === Match.Any) {
return false;
File match.js
has 370 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
// XXX docs
import { isPlainObject } from './isPlainObject';
// Things we explicitly do NOT support:
// - heterogenous arrays
Avoid deeply nested control flow statements. Open
Open
if (result) {
result.path = _prependPath(key, result.path);
return result;
}
Avoid too many return
statements within this function. Open
Open
return {
message: `Expected null, got ${stringForErrorMessage(value)}`,
path: '',
};
Avoid too many return
statements within this function. Open
Open
return false;
Avoid too many return
statements within this function. Open
Open
return EJSON.stringify(value);
Avoid too many return
statements within this function. Open
Open
return false;
Avoid too many return
statements within this function. Open
Open
return {
message: `Bad pattern: arrays must have one type element ${stringForErrorMessage(pattern)}`,
path: '',
};
Avoid too many return
statements within this function. Open
Open
return {
message: `Missing key '${keys[0]}'`,
path: '',
};
Avoid too many return
statements within this function. Open
Open
return result;
Avoid too many return
statements within this function. Open
Open
return {
message: 'Failed Match.Where validation',
path: '',
};
Avoid too many return
statements within this function. Open
Open
return false;
Avoid too many return
statements within this function. Open
Open
return result;
Avoid too many return
statements within this function. Open
Open
return false;
Avoid too many return
statements within this function. Open
Open
return result;
Avoid too many return
statements within this function. Open
Open
return false;
Avoid too many return
statements within this function. Open
Open
return {
message: `Expected object, got ${typeof value}`,
path: '',
};
Avoid too many return
statements within this function. Open
Open
return {
message: err.message,
path: err.path
};
Avoid too many return
statements within this function. Open
Open
return {
message: `Expected object, got null`,
path: '',
};
Avoid too many return
statements within this function. Open
Open
return result;
Avoid too many return
statements within this function. Open
Open
return {
message: `Expected ${pattern}, got ${stringForErrorMessage(value)}`,
path: '',
};
Avoid too many return
statements within this function. Open
Open
return {
message: 'Failed Match.OneOf, Match.Maybe or Match.Optional validation',
path: '',
};
Avoid too many return
statements within this function. Open
Open
return {
message: `Expected plain object`,
path: '',
};
Avoid too many return
statements within this function. Open
Open
return {
message: 'Bad pattern: unknown pattern type',
path: '',
};
Avoid too many return
statements within this function. Open
Open
return false;
Avoid too many return
statements within this function. Open
Open
return {
message: `Expected array, got ${stringForErrorMessage(value)}`,
path: '',
};
Avoid too many return
statements within this function. Open
Open
return {
message: `Expected ${pattern.name || 'particular constructor'}`,
path: '',
};
Avoid too many return
statements within this function. Open
Open
return {
message: `Expected Integer, got ${stringForErrorMessage(value)}`,
path: '',
};
Avoid too many return
statements within this function. Open
Open
return {
message: 'Unknown key',
path: key,
};
Function stringForErrorMessage
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Open
const stringForErrorMessage = (value, options = {}) => {
if ( value === null ) {
return 'null';
}
- 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"