src/evaluator.js
Function Evaluator
has a Cognitive Complexity of 216 (exceeds 5 allowed). Consider refactoring. Open
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
- 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 Evaluator
has 683 lines of code (exceeds 25 allowed). Consider refactoring. Open
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
File evaluator.js
has 688 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
var _ = require('./utils.js');
var Scope = require('./scope.js');
// Renders a parse tree from <topNode> downward and emits either
Function evaluate
has 306 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
evaluate: function(node, scope, preFormated) {
var self = this;
var frag = interface.createFragment();
var recurse = function(frag, scope, pre) {
Function evalExpr
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
var evalExpr = function(scope, expr, node) {
var m;
// Negation
var negate = (expr[0] == '!');
if(negate) expr = expr.slice(1);
Function evalCompoundExpr
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
var evalCompoundExpr = function(scope, expr, node) {
var booleans = ['||', '&&'];
var comparisons = ['==', '!=', '>', '<', '>=', '<='];
var allOps = _.union(booleans, comparisons);
// Separate expression into values and operators
Function execMicroStatements
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
execMicroStatements: function(statements, elem) {
_.each(statements, function(statement) {
// Register action handlers
if(statement.statement == 'on' && _.onClient()) {
var eName = statement.event;
Function promises
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
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
Avoid deeply nested control flow statements. Open
Open
if(!newItems) newItems = _.clone(items.items);
Avoid deeply nested control flow statements. Open
Open
if(elem.tagName == 'INPUT' && elem.type == 'number') {
value = parseFloat(value);
}
Avoid deeply nested control flow statements. Open
Open
if(_.last(expr) == '!') {
expr = expr.slice(0, -1);
save = true;
}
Avoid deeply nested control flow statements. Open
Open
if(!attr.oneTimeOnly) {
attributePaths.push({
type: 'CSS',
klassName: klassName,
expr: expr,
Function Evaluator
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
var Evaluator = function(topNode, viewModels, parseTrees, interface, mainModel) {
Avoid too many return
statements within this function. Open
Open
if(op == '>=') return a >= b;
Avoid too many return
statements within this function. Open
Open
if(op == '<=') return a <= b;