syntheticore/declaire

View on GitHub
src/evaluator.js

Summary

Maintainability
F
1 wk
Test Coverage

Function Evaluator has a Cognitive Complexity of 216 (exceeds 5 allowed). Consider refactoring.
Open

var Evaluator = function(topNode, viewModels, parseTrees, interface, mainModel) {

  // Replace all mustaches in text with the value at their paths
  var resolveMustaches = function(text, scope, node, cb) {
    // Collect mustaches in reverse order
Severity: Minor
Found in src/evaluator.js - About 4 days 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 Evaluator has 683 lines of code (exceeds 25 allowed). Consider refactoring.
Open

var Evaluator = function(topNode, viewModels, parseTrees, interface, mainModel) {

  // Replace all mustaches in text with the value at their paths
  var resolveMustaches = function(text, scope, node, cb) {
    // Collect mustaches in reverse order
Severity: Major
Found in src/evaluator.js - About 3 days to fix

    File evaluator.js has 688 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    var _ = require('./utils.js');
    var Scope = require('./scope.js');
    
    
    // Renders a parse tree from <topNode> downward and emits either
    Severity: Major
    Found in src/evaluator.js - About 1 day to fix

      Function evaluate has 306 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          evaluate: function(node, scope, preFormated) {
            var self = this;
            var frag = interface.createFragment();
      
            var recurse = function(frag, scope, pre) {
      Severity: Major
      Found in src/evaluator.js - About 1 day to fix

        Function evalExpr has 50 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          var evalExpr = function(scope, expr, node) {
            var m;
            // Negation
            var negate = (expr[0] == '!');
            if(negate) expr = expr.slice(1);
        Severity: Minor
        Found in src/evaluator.js - About 2 hrs to fix

          Function evalCompoundExpr has 45 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            var evalCompoundExpr = function(scope, expr, node) {
              var booleans = ['||', '&&'];
              var comparisons = ['==', '!=', '>', '<', '>=', '<='];
              var allOps = _.union(booleans, comparisons);
              // Separate expression into values and operators
          Severity: Minor
          Found in src/evaluator.js - About 1 hr to fix

            Function execMicroStatements has 40 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                execMicroStatements: function(statements, elem) {
                  _.each(statements, function(statement) {
                    // Register action handlers
                    if(statement.statement == 'on' && _.onClient()) {
                      var eName = statement.event;
            Severity: Minor
            Found in src/evaluator.js - About 1 hr to fix

              Function promises has 35 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                      var promises = _.compact(_.flatten(_.values(_.map(node.attributes, function(attr, key) {
                        // Dynamic attribute
                        if(attr.type == 'dynamic') {
                          var expr = attr.expression;
                          // Collect two way binding
              Severity: Minor
              Found in src/evaluator.js - About 1 hr to fix

                Avoid deeply nested control flow statements.
                Open

                                        if(!newItems) newItems = _.clone(items.items);
                Severity: Major
                Found in src/evaluator.js - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                    if(elem.tagName == 'INPUT' && elem.type == 'number') {
                                      value = parseFloat(value);
                                    }
                  Severity: Major
                  Found in src/evaluator.js - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                  if(_.last(expr) == '!') {
                                    expr = expr.slice(0, -1);
                                    save = true;
                                  }
                    Severity: Major
                    Found in src/evaluator.js - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                    if(!attr.oneTimeOnly) {
                                      attributePaths.push({
                                        type: 'CSS',
                                        klassName: klassName,
                                        expr: expr,
                      Severity: Major
                      Found in src/evaluator.js - About 45 mins to fix

                        Function Evaluator has 5 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                        var Evaluator = function(topNode, viewModels, parseTrees, interface, mainModel) {
                        Severity: Minor
                        Found in src/evaluator.js - About 35 mins to fix

                          Avoid too many return statements within this function.
                          Open

                                    if(op == '>=') return a >= b;
                          Severity: Major
                          Found in src/evaluator.js - About 30 mins to fix

                            Avoid too many return statements within this function.
                            Open

                                      if(op == '<=') return a <= b;
                            Severity: Major
                            Found in src/evaluator.js - About 30 mins to fix

                              There are no issues that match your filters.

                              Category
                              Status