slm-lang/slm

View on GitHub
lib/parser.js

Summary

Maintainability
F
4 days
Test Coverage

File parser.js has 515 lines of code (exceeds 250 allowed). Consider refactoring.
Open

var attrDelimRe = /^\s*([\(\)\[\]])/;
var blockExpressionRe = /^\s*:\s*/;
var closedTagRe = /^\s*\/\s*/;
var delimRe = /^[\(\[]/;
var doctypeRe = /^doctype\b/i;
Severity: Major
Found in lib/parser.js - About 1 day to fix

    Function _parseTag has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
    Open

    p._parseTag = function(tag) {
      var m, trailingWS, leadingWS;
      if (tagShortcut[tag]) {
        tag = tagShortcut[tag];
      }
    Severity: Minor
    Found in lib/parser.js - About 4 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 _parseTextBlock has a Cognitive Complexity of 29 (exceeds 5 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 4 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 _parseJSCode has a Cognitive Complexity of 24 (exceeds 5 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 3 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 _parseTag has 75 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    p._parseTag = function(tag) {
      var m, trailingWS, leadingWS;
      if (tagShortcut[tag]) {
        tag = tagShortcut[tag];
      }
    Severity: Major
    Found in lib/parser.js - About 3 hrs to fix

      Function _parseAttributes has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
      Open

      p._parseAttributes = function(attributes) {
        // Check to see if there is a delimiter right after the tag name
        var delimiter, m;
      
        m = attrDelimRe.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

      Function _parseAttributes has 54 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      p._parseAttributes = function(attributes) {
        // Check to see if there is a delimiter right after the tag name
        var delimiter, m;
      
        m = attrDelimRe.exec(this._line);
      Severity: Major
      Found in lib/parser.js - About 2 hrs to fix

        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 _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 _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 _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

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

                var _parseCommentBlock = function(parser) {
                  while (parser._lines.length) {
                    if (!emptyLineRe.test(parser._lines[0])) {
                      var indent = parser._getIndent(parser._lines[0]);
                      if (indent <= parser._indents._last()) {
                Severity: Minor
                Found in lib/parser.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

                There are no issues that match your filters.

                Category
                Status