Function test
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
Critr.prototype.test = function (data, criteria) {
var result = false;
var properties = utils.getProperties(criteria);
while(properties.length > 0) {
var p = properties.shift();
- 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 group
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Critr.prototype.group = function (data, expression) {
var grouper = new Grouper(expression._id || '');
data.forEach(grouper.makeFilter(), this);
var accumulators = utils.map(utils.getProperties(expression).filter(function (p) {
return !grouper._idExpression || p.value !== grouper._idExpression;
- Create a ticketCreate a ticket
Function test
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Critr.prototype.test = function (data, criteria) {
var result = false;
var properties = utils.getProperties(criteria);
while(properties.length > 0) {
var p = properties.shift();
- Create a ticketCreate a ticket
Function evaluate
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
Critr.prototype.evaluate = function (obj, expression) {
var result = null;
if (typeof expression === 'string' && expression[0] === '$') {
result = utils.resolve(obj, expression.slice(1));
} else if (typeof expression === 'number') {
- 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 makeOperatorStorageFn
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
var makeOperatorStorageFn = function (containerName) {
return function (key, handler, overwrite) {
var container = this[containerName];
if (arguments.length === 1) {
return container[key];
- 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"