collinbrewer/predicate

View on GitHub

Showing 10 of 41 total issues

Function evaluateWithObject has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
Open

ComparisonPredicate.prototype.evaluateWithObject = function (o, vars) {
    vars || (vars = this._substitutionVariables);

    var leftExpressionValue = (this.left.type === 'variable' ? this.left.getValueWithObject(o, vars) : this.left.getValueWithObject(o));
    var rightExpressionValue = (this.right.type === 'variable' ? this.right.getValueWithObject(o, vars) : this.right.getValueWithObject(o));
Severity: Minor
Found in src/types/comparison-predicate.js - About 6 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 parse has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
Open

CompoundPredicate.parse = function (str, vars) {
    var predicate;

    function getParts (s) {
        var matches = s.match(regex);
Severity: Minor
Found in src/types/compound-predicate.js - About 5 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 parse has 79 lines of code (exceeds 25 allowed). Consider refactoring.
Open

CompoundPredicate.parse = function (str, vars) {
    var predicate;

    function getParts (s) {
        var matches = s.match(regex);
Severity: Major
Found in src/types/compound-predicate.js - About 3 hrs to fix

    Function evaluateWithObject has 57 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    ComparisonPredicate.prototype.evaluateWithObject = function (o, vars) {
        vars || (vars = this._substitutionVariables);
    
        var leftExpressionValue = (this.left.type === 'variable' ? this.left.getValueWithObject(o, vars) : this.left.getValueWithObject(o));
        var rightExpressionValue = (this.right.type === 'variable' ? this.right.getValueWithObject(o, vars) : this.right.getValueWithObject(o));
    Severity: Major
    Found in src/types/comparison-predicate.js - About 2 hrs to fix

      Function splitByGates has 51 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          function splitByGates (s) {
              var subpredicates = [];
              var gate;
              var i;
              var l;
      Severity: Major
      Found in src/types/compound-predicate.js - About 2 hrs to fix

        Function evaluateWithObject has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

        CompoundPredicate.prototype.evaluateWithObject = function (o, vars) {
            vars || (vars = this._substitutionVariables);
        
            var subpredicates = this.subpredicates;
            var gate = this.gate;
        Severity: Minor
        Found in src/types/compound-predicate.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

        Avoid deeply nested control flow statements.
        Open

                            if (current) {
                                subpredicates.push(current);
                            }
        Severity: Major
        Found in src/types/compound-predicate.js - About 45 mins to fix

          Function ensurePredicate has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

          function ensurePredicate (p, args) {
              var Predicate = require('../predicate.js');
              var predicate;
              var type = typeof p;
          
          
          Severity: Minor
          Found in src/types/compound-predicate.js - About 35 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

          Function getExpressions has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

          Predicate.getExpressions = function (p) {
              var es = [];
          
              if (p.left) { // comparison predicate
                  es.push(p.left);
          Severity: Minor
          Found in src/predicate.js - About 35 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

          Function ComparisonPredicate has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

          function ComparisonPredicate (left, right, operator) {
              this.type = 'comparison';
          
              if (arguments.length === 1 && typeof arguments[0] === 'object') {
                  var o = arguments[0];
          Severity: Minor
          Found in src/types/comparison-predicate.js - About 25 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

          Severity
          Category
          Status
          Source
          Language