src/_helpers/template7.js

Summary

Maintainability
F
6 days
Test Coverage

File template7.js has 592 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/**
 * Template7 1.4.1
 * Mobile-first HTML template engine
 * 
 * http://www.idangero.us/template7/
Severity: Major
Found in src/_helpers/template7.js - About 1 day to fix

    Function stringToBlocks has 111 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        stringToBlocks: function stringToBlocks(string) {
          var blocks = [];
          var i;
          var j;
          if (!string) { return []; }
    Severity: Major
    Found in src/_helpers/template7.js - About 4 hrs to fix

      Function compile has 89 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        Template7Class.prototype.compile = function compile (template, depth) {
            if ( template === void 0 ) template = this.template;
            if ( depth === void 0 ) depth = 1;
      
          var t = this;
      Severity: Major
      Found in src/_helpers/template7.js - About 3 hrs to fix

        Function helperToSlices has 55 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            helperToSlices: function helperToSlices(string) {
              var quoteDoubleRexExp = Template7Utils.quoteDoubleRexExp;
              var quoteSingleRexExp = Template7Utils.quoteSingleRexExp;
              var helperParts = string.replace(/[{}#}]/g, '').trim().split(' ');
              var slices = [];
        Severity: Major
        Found in src/_helpers/template7.js - About 2 hrs to fix

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

              getCompileVar: function getCompileVar(name, ctx, data) {
                if ( data === void 0 ) data = 'data_1';
          
                var variable = ctx;
                var parts;
          Severity: Minor
          Found in src/_helpers/template7.js - About 1 hr to fix

            Function js_if has 31 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                js_if: function js_if(expression, options) {
                  var data = options.data;
                  var func;
                  var execute = expression;
                  ('index first last key').split(' ').forEach(function (prop) {
            Severity: Minor
            Found in src/_helpers/template7.js - About 1 hr to fix

              Function parseJsParents has 31 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  parseJsParents: function parseJsParents(expression, parents) {
                    return expression.split(/([+ \-*^()&=|<>!%:?])/g).reduce(function (arr, part) {
                      if (!part) {
                        return arr;
                      }
              Severity: Minor
              Found in src/_helpers/template7.js - About 1 hr to fix

                Function js has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    js: function js(expression, options) {
                      var data = options.data;
                      var func;
                      var execute = expression;
                      ('index first last key').split(' ').forEach(function (prop) {
                Severity: Minor
                Found in src/_helpers/template7.js - About 1 hr to fix

                  Avoid deeply nested control flow statements.
                  Open

                                if (shiftIndex) { i = shiftIndex; }
                  Severity: Major
                  Found in src/_helpers/template7.js - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                for (j = i + 1; j < helperParts.length; j += 1) {
                                  hashContent += " " + (helperParts[j]);
                                  if (helperParts[j].indexOf(openingQuote) >= 0) {
                                    shiftIndex = j;
                                    break;
                    Severity: Major
                    Found in src/_helpers/template7.js - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                    if (stringBlocks[j].indexOf(("{{#" + helperName)) >= 0) {
                                      helperContent += stringBlocks[j];
                                      if (foundElse) { elseContent += stringBlocks[j]; }
                                      toSkip += 1;
                                    } else if (stringBlocks[j].indexOf(("{{/" + helperName)) >= 0) {
                      Severity: Major
                      Found in src/_helpers/template7.js - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                      if (stringBlocks[j].indexOf('{{/') >= 0) {
                                        depth -= 1;
                                      }
                        Severity: Major
                        Found in src/_helpers/template7.js - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                        if (helperParts[j].indexOf(openingQuote) >= 0) {
                                          shiftIndex = j;
                                          slices.push(part);
                                          break;
                                        }
                          Severity: Major
                          Found in src/_helpers/template7.js - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                          if (stringBlocks[j].indexOf('{{#') >= 0) {
                                            depth += 1;
                                          }
                            Severity: Major
                            Found in src/_helpers/template7.js - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

                                          if (shiftIndex) { i = shiftIndex; }
                              Severity: Major
                              Found in src/_helpers/template7.js - About 45 mins to fix

                                Avoid deeply nested control flow statements.
                                Open

                                            if (isPartial) {
                                              helperName = '_partial';
                                              if (helperContext[0]) {
                                                if (helperContext[0].indexOf('[') === 0) { helperContext[0] = helperContext[0].replace(/[[\]]/g, ''); }
                                                else { helperContext[0] = "\"" + (helperContext[0].replace(/"|'/g, '')) + "\""; }
                                Severity: Major
                                Found in src/_helpers/template7.js - About 45 mins to fix

                                  Avoid deeply nested control flow statements.
                                  Open

                                                if (helperName === 'raw') {
                                                  blocks.push({
                                                    type: 'plain',
                                                    content: helperContent,
                                                  });
                                  Severity: Major
                                  Found in src/_helpers/template7.js - About 45 mins to fix

                                    Avoid too many return statements within this function.
                                    Open

                                              return arr;
                                    Severity: Major
                                    Found in src/_helpers/template7.js - About 30 mins to fix

                                      Avoid too many return statements within this function.
                                      Open

                                              return arr;
                                      Severity: Major
                                      Found in src/_helpers/template7.js - About 30 mins to fix

                                        Similar blocks of code found in 2 locations. Consider refactoring.
                                        Open

                                              ('index first last key').split(' ').forEach(function (prop) {
                                                if (typeof data[prop] !== 'undefined') {
                                                  var re1 = new RegExp(("this.@" + prop), 'g');
                                                  var re2 = new RegExp(("@" + prop), 'g');
                                                  execute = execute
                                        Severity: Major
                                        Found in src/_helpers/template7.js and 1 other location - About 4 hrs to fix
                                        src/_helpers/template7.js on lines 461..469

                                        Duplicated Code

                                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                        Tuning

                                        This issue has a mass of 123.

                                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                        Refactorings

                                        Further Reading

                                        Similar blocks of code found in 2 locations. Consider refactoring.
                                        Open

                                              ('index first last key').split(' ').forEach(function (prop) {
                                                if (typeof data[prop] !== 'undefined') {
                                                  var re1 = new RegExp(("this.@" + prop), 'g');
                                                  var re2 = new RegExp(("@" + prop), 'g');
                                                  execute = execute
                                        Severity: Major
                                        Found in src/_helpers/template7.js and 1 other location - About 4 hrs to fix
                                        src/_helpers/template7.js on lines 432..440

                                        Duplicated Code

                                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                        Tuning

                                        This issue has a mass of 123.

                                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                        Refactorings

                                        Further Reading

                                        Similar blocks of code found in 2 locations. Consider refactoring.
                                        Open

                                                  resultString += "r += (Template7Helpers.each).call(" + ctx + ", " + variable + ", {hash:" + (JSON.stringify(block.hash)) + ", data: " + data + " || {}, fn: " + (getCompileFn(block, depth + 1)) + ", inverse: " + (getCompileInverse(block, depth + 1)) + ", root: root, parents: " + parents + "});";
                                        Severity: Major
                                        Found in src/_helpers/template7.js and 1 other location - About 2 hrs to fix
                                        src/_helpers/template7.js on lines 591..591

                                        Duplicated Code

                                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                        Tuning

                                        This issue has a mass of 93.

                                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                        Refactorings

                                        Further Reading

                                        Similar blocks of code found in 2 locations. Consider refactoring.
                                        Open

                                                  resultString += "r += (Template7Helpers.with).call(" + ctx + ", " + variable + ", {hash:" + (JSON.stringify(block.hash)) + ", data: " + data + " || {}, fn: " + (getCompileFn(block, depth + 1)) + ", inverse: " + (getCompileInverse(block, depth + 1)) + ", root: root, parents: " + parents + "});";
                                        Severity: Major
                                        Found in src/_helpers/template7.js and 1 other location - About 2 hrs to fix
                                        src/_helpers/template7.js on lines 589..589

                                        Duplicated Code

                                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                        Tuning

                                        This issue has a mass of 93.

                                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                        Refactorings

                                        Further Reading

                                        Identical blocks of code found in 2 locations. Consider refactoring.
                                        Open

                                              if (execute.indexOf('return') >= 0) {
                                                func = "(function(){" + execute + "})";
                                              } else {
                                                func = "(function(){return (" + execute + ")})";
                                              }
                                        Severity: Minor
                                        Found in src/_helpers/template7.js and 1 other location - About 55 mins to fix
                                        src/_helpers/template7.js on lines 479..483

                                        Duplicated Code

                                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                        Tuning

                                        This issue has a mass of 53.

                                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                        Refactorings

                                        Further Reading

                                        Identical blocks of code found in 2 locations. Consider refactoring.
                                        Open

                                              if (execute.indexOf('return') >= 0) {
                                                func = "(function(){" + execute + "})";
                                              } else {
                                                func = "(function(){return (" + execute + ")})";
                                              }
                                        Severity: Minor
                                        Found in src/_helpers/template7.js and 1 other location - About 55 mins to fix
                                        src/_helpers/template7.js on lines 450..454

                                        Duplicated Code

                                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                        Tuning

                                        This issue has a mass of 53.

                                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                        Refactorings

                                        Further Reading

                                        Similar blocks of code found in 2 locations. Consider refactoring.
                                        Open

                                            function getCompileFn(block, newDepth) {
                                              if (block.content) { return t.compile(block.content, newDepth); }
                                              return function empty() { return ''; };
                                            }
                                        Severity: Minor
                                        Found in src/_helpers/template7.js and 1 other location - About 45 mins to fix
                                        src/_helpers/template7.js on lines 528..531

                                        Duplicated Code

                                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                        Tuning

                                        This issue has a mass of 50.

                                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                        Refactorings

                                        Further Reading

                                        Similar blocks of code found in 2 locations. Consider refactoring.
                                        Open

                                            function getCompileInverse(block, newDepth) {
                                              if (block.inverseContent) { return t.compile(block.inverseContent, newDepth); }
                                              return function empty() { return ''; };
                                            }
                                        Severity: Minor
                                        Found in src/_helpers/template7.js and 1 other location - About 45 mins to fix
                                        src/_helpers/template7.js on lines 524..527

                                        Duplicated Code

                                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                        Tuning

                                        This issue has a mass of 50.

                                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                        Refactorings

                                        Further Reading

                                        Identical blocks of code found in 2 locations. Consider refactoring.
                                        Open

                                              if (options.root && execute.indexOf('@root') >= 0) {
                                                execute = Template7Utils.parseJsVariable(execute, '@root', options.root);
                                              }
                                        Severity: Minor
                                        Found in src/_helpers/template7.js and 1 other location - About 40 mins to fix
                                        src/_helpers/template7.js on lines 470..472

                                        Duplicated Code

                                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                        Tuning

                                        This issue has a mass of 48.

                                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                        Refactorings

                                        Further Reading

                                        Identical blocks of code found in 2 locations. Consider refactoring.
                                        Open

                                              if (options.root && execute.indexOf('@root') >= 0) {
                                                execute = Template7Utils.parseJsVariable(execute, '@root', options.root);
                                              }
                                        Severity: Minor
                                        Found in src/_helpers/template7.js and 1 other location - About 40 mins to fix
                                        src/_helpers/template7.js on lines 441..443

                                        Duplicated Code

                                        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                        Tuning

                                        This issue has a mass of 48.

                                        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                        Refactorings

                                        Further Reading

                                        There are no issues that match your filters.

                                        Category
                                        Status