danielkrainas/critr

View on GitHub
lib/critr.js

Summary

Maintainability
B
6 hrs
Test Coverage

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();
Severity: Minor
Found in lib/critr.js - About 2 hrs to fix

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;
Severity: Minor
Found in lib/critr.js - About 1 hr to fix

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();
Severity: Minor
Found in lib/critr.js - About 1 hr to fix

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') {
Severity: Minor
Found in lib/critr.js - About 1 hr to fix

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];
Severity: Minor
Found in lib/critr.js - About 55 mins to fix

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

There are no issues that match your filters.

Category
Status