friedemannsommer/templata

View on GitHub

Showing 13 of 27 total issues

File compiler.ts has 391 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/// <reference path="../typings/index.d.ts" />

import escape from './escape'
import objectKeys from './object-keys'
import regexEscape from './regex-escape'
Severity: Minor
Found in src/lib/compiler.ts - About 5 hrs to fix

    Compiler has 39 functions (exceeds 20 allowed). Consider refactoring.
    Open

    export default class Compiler implements Templata.ICompiler {
        public static settings: Templata.ICompilerSettings = {
            DELIMITER: {
                CLOSING: '/',
                CLOSING_BLOCK: '}}',
    Severity: Minor
    Found in src/lib/compiler.ts - About 5 hrs to fix

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

      function htmlUnescape(input: string): string {
          // ampersand
          return input.replace(/\&amp\;/g, '\u0026')
              // less-than sign
              .replace(/\&lt\;/g, '\u003C')
      Severity: Major
      Found in src/lib/html-unescape.ts - About 3 hrs to fix

        Function htmlEscape has 87 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function htmlEscape(input: string): string {
            // ampersand
            return input.replace(/\u0026/g, '&amp;')
                // number sign (hashtag)
                .replace(/\u0023/g, '&#35;')
        Severity: Major
        Found in src/lib/html-escape.ts - About 3 hrs to fix

          Function default has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

          export default function(
              operator: string,
              parameter: string,
              _selfClosing: boolean,
              closingTag: boolean,
          Severity: Minor
          Found in src/helper/condition.ts - 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 print has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              _operator: string,
              parameter: string,
              _selfClosing: boolean,
              _closingTag: boolean,
              buffer: Templata.IBuffer,
          Severity: Minor
          Found in src/helper/print.ts - About 45 mins to fix

            Function comment has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                _operator: string,
                _parameter: string,
                _selfClosing: boolean,
                _closingTag: boolean,
                _buffer: Templata.IBuffer,
            Severity: Minor
            Found in src/helper/comment.ts - About 45 mins to fix

              Function default has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  operator: string,
                  parameter: string,
                  _selfClosing: boolean,
                  closingTag: boolean,
                  buffer: Templata.IBuffer,
              Severity: Minor
              Found in src/helper/condition.ts - About 45 mins to fix

                Function default has 6 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    _operator: string,
                    parameter: string,
                    _selfClosing: boolean,
                    _closingTag: boolean,
                    buffer: Templata.IBuffer,
                Severity: Minor
                Found in src/helper/encode-value.ts - About 45 mins to fix

                  Function javascript has 6 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      _operator: string,
                      parameter: string,
                      _selfClosing: boolean,
                      _closingTag: boolean,
                      buffer: Templata.IBuffer,
                  Severity: Minor
                  Found in src/helper/pure-javascript.ts - About 45 mins to fix

                    Function iterate has 6 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                        _operator: string,
                        parameter: string,
                        _selfClosing: boolean,
                        closingTag: boolean,
                        buffer: Templata.IBuffer,
                    Severity: Minor
                    Found in src/helper/iterate.ts - About 45 mins to fix

                      Function iterate has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                      Open

                      function iterate(
                          _operator: string,
                          parameter: string,
                          _selfClosing: boolean,
                          closingTag: boolean,
                      Severity: Minor
                      Found in src/helper/iterate.ts - About 35 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

                      Avoid too many return statements within this function.
                      Open

                                      return buffer.END + '}else{' + buffer.START
                      Severity: Major
                      Found in src/helper/condition.ts - About 30 mins to fix
                        Severity
                        Category
                        Status
                        Source
                        Language