slm-lang/slm

View on GitHub

Showing 71 of 71 total issues

Function _parseQuotedAttribute has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

p._parseQuotedAttribute = function(quote) {
  var value = '', count = 0;

  while (count !== 0 || this._line[0] !== quote) {
    var m = /^(\\)?$/.exec(this._line);
Severity: Minor
Found in lib/parser.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

Consider simplifying this complex logical expression.
Open

    if (
      // HTML comment
      this._matchLineThen(htmlCommentRe, _parseHtmlComment) ||
      // or HTML conditional comment
      this._matchLineThen(htmlConditionalCommentRe, _parseHtmlConditionalComment) ||
Severity: Critical
Found in lib/parser.js - About 2 hrs to fix

    Function assertHtml has 47 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    exports.assertHtml = function(template, src, result, options) {
    
      if (Array.isArray(src)) {
        src = src.join('\n');
      }
    Severity: Minor
    Found in __tests__/helper.js - About 1 hr to fix

      Function escape has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

      function escape(str) {
        if (typeof str !== 'string') {
          if (!str) {
            return '';
          }
      Severity: Minor
      Found in lib/vm.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 on_html_doctype has 38 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      p.on_html_doctype = function(exps) {
        var type = exps[2];
      
        var html = '<!DOCTYPE html>';
      
      
      Severity: Minor
      Found in lib/html/fast.js - About 1 hr to fix

        Function _parseTextBlock has 37 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        p._parseTextBlock = function(firstLine, textIndent, inTag) {
          var result = ['multi'];
        
          if (!firstLine || !firstLine.length) {
            textIndent = null;
        Severity: Minor
        Found in lib/parser.js - About 1 hr to fix

          Function _merge has 36 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          p._merge = function(names, values) {
            var attrs = [];
            for (var i = 0, il = names.length; i < il; i++) {
              var name = names[i];
              var value = values[name], delimiter = this._mergeAttrs[name];
          Severity: Minor
          Found in lib/filters/attr_merge.js - About 1 hr to fix

            Function on_multi has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

            StaticMerger.prototype.on_multi = function(exps) {
              var res = ['multi'], node;
            
              for (var i = 1, l = exps.length; i < l; i++) {
                var exp = exps[i];
            Severity: Minor
            Found in lib/filters/static_merger.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 _parseLine has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

            p._parseLine = function() {
              if (emptyLineRe.test(this._line)) {
                this._pushOnTop(['newline']);
                return;
              }
            Severity: Minor
            Found in lib/parser.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 _parseJSCode has 35 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            p._parseJSCode = function(outerDelimeter) {
              var code = '', count = 0, delimiter, closeDelimiter, m;
            
              // Attribute ends with space or attribute delimiter
              var endRe = new RegExp('^[\\s' + this._escapeRegExp(outerDelimeter) + ']');
            Severity: Minor
            Found in lib/parser.js - About 1 hr to fix

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

              exports.assertHtml = function(template, src, result, options) {
              
                if (Array.isArray(src)) {
                  src = src.join('\n');
                }
              Severity: Minor
              Found in __tests__/helper.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 content has 30 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              VMProto.content = function() {
                var cb, mod, name;
                switch (arguments.length) {
                  case 0: // return main content
                    return safe(this.res);
              Severity: Minor
              Found in lib/vm.js - About 1 hr to fix

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

                  test('interpolation with escaping', function() {
                    var src = '. ${this.evilMethod()}';
                    expect(
                      template.render(src, {evilMethod: function() {return '<script>do_something_evil();</script>';}})
                    ).toEqual(
                Severity: Major
                Found in __tests__/filters/interpolation.js and 2 other locations - About 1 hr to fix
                __tests__/filters/interpolation.js on lines 89..94
                __tests__/filters/interpolation.js on lines 96..102

                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 58.

                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 3 locations. Consider refactoring.
                Open

                  test('interpolation without escaping', function() {
                    var src = '| ${= this.evilMethod()}';
                    expect(
                      template.render(src, {evilMethod: function() {return '<script>do_something_evil();</script>';}})
                    ).toEqual('<script>do_something_evil();</script>');
                Severity: Major
                Found in __tests__/filters/interpolation.js and 2 other locations - About 1 hr to fix
                __tests__/filters/interpolation.js on lines 81..87
                __tests__/filters/interpolation.js on lines 96..102

                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 58.

                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 3 locations. Consider refactoring.
                Open

                  test('interpolation with escaping and delimiter', function() {
                    var src = '| ${(this.evilMethod())}';
                    expect(
                      template.render(src, {evilMethod: function() {return '<script>do_something_evil();</script>';}})
                    ).toEqual(
                Severity: Major
                Found in __tests__/filters/interpolation.js and 2 other locations - About 1 hr to fix
                __tests__/filters/interpolation.js on lines 81..87
                __tests__/filters/interpolation.js on lines 89..94

                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 58.

                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

                Function _parseLine has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                p._parseLine = function() {
                  if (emptyLineRe.test(this._line)) {
                    this._pushOnTop(['newline']);
                    return;
                  }
                Severity: Minor
                Found in lib/parser.js - About 1 hr to fix

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

                    test('should process if', function(){
                      expect(
                        filter.exec(['if', 'condition', ['static', 'Hello']])
                      ).toEqual(
                        ['multi',
                  Severity: Major
                  Found in __tests__/filters/control_flow.js and 2 other locations - About 1 hr to fix
                  __tests__/html/fast.js on lines 31..34
                  __tests__/html/fast.js on lines 36..41

                  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 57.

                  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 3 locations. Consider refactoring.
                  Open

                    test('compile html comment', function() {
                      expect(filter.exec(['html', 'comment', ['static', 'test']]))
                      .toEqual(['multi', ['static', '<!--'], ['static', 'test'], ['static', '-->']]);
                    });
                  Severity: Major
                  Found in __tests__/html/fast.js and 2 other locations - About 1 hr to fix
                  __tests__/filters/control_flow.js on lines 22..32
                  __tests__/html/fast.js on lines 36..41

                  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 57.

                  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 3 locations. Consider refactoring.
                  Open

                    test('compile js wrapped in comments', function() {
                      expect(filter.exec(['html', 'js', ['static', 'test']]))
                        .toEqual(
                        ['multi', ['static', '\n//<![CDATA[\n'], ['static', 'test'], ['static', '\n//]]>\n']]
                      );
                  Severity: Major
                  Found in __tests__/html/fast.js and 2 other locations - About 1 hr to fix
                  __tests__/filters/control_flow.js on lines 22..32
                  __tests__/html/fast.js on lines 31..34

                  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 57.

                  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

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

                  p.on_html_attr = function(exps) {
                    var name = exps[2], value = exps[3];
                    if (value[0] === 'slm' && value[1] === 'attrvalue' && !this._mergeAttrs[name]) {
                      // We handle the attribute as a boolean attribute
                      var escape = value[2], code = value[3];
                  Severity: Minor
                  Found in lib/filters/code_attributes.js - About 1 hr to fix
                    Severity
                    Category
                    Status
                    Source
                    Language