friedemannsommer/templata

View on GitHub

Showing 27 of 27 total issues

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

    return input.replace(/\&amp\;/g, '\u0026')
        // less-than sign
        .replace(/\&lt\;/g, '\u003C')
        // greater-than sign
        .replace(/\&gt\;/g, '\u003E')
Severity: Major
Found in src/lib/html-unescape.ts and 1 other location - About 6 days to fix
src/lib/html-escape.ts on lines 3..175

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

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

    return input.replace(/\u0026/g, '&')
        // number sign (hashtag)
        .replace(/\u0023/g, '#')
        // less-than sign
        .replace(/\u003C/g, '<')
Severity: Major
Found in src/lib/html-escape.ts and 1 other location - About 6 days to fix
src/lib/html-unescape.ts on lines 3..175

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

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

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

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

          function filterUppercase(
              _name: string,
              input: string,
              buffer: Templata.IBuffer,
              compiler: Templata.ICompiler
          Severity: Major
          Found in src/filter/uppercase.ts and 1 other location - About 2 hrs to fix
          src/filter/lowercase.ts on lines 9..18

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

          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 filterLowercase(
              _name: string,
              input: string,
              buffer: Templata.IBuffer,
              compiler: Templata.ICompiler
          Severity: Major
          Found in src/filter/lowercase.ts and 1 other location - About 2 hrs to fix
          src/filter/uppercase.ts on lines 9..18

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

          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

                  case '?':
                      if (parameter && parameter !== '') {
                          // if
                          return buffer.END + 'if(' + stringTrim(unescape(parameter)) + '){' + buffer.START
                      } else {
          Severity: Major
          Found in src/helper/condition.ts and 1 other location - About 2 hrs to fix
          src/helper/condition.ts on lines 27..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 81.

          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

                  case '??':
                      if (parameter && parameter !== '') {
                          // elseif
                          return buffer.END + '}else if(' + stringTrim(unescape(parameter)) + '){' + buffer.START
                      } else {
          Severity: Major
          Found in src/helper/condition.ts and 1 other location - About 2 hrs to fix
          src/helper/condition.ts on lines 19..26

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

          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

                  return template
                      .replace(this.replaceExpressions.EMPTY_START_APPEND_BUFFER, '$1+=')
                      .replace(this.replaceExpressions.EMPTY_APPEND_BUFFER, '')
                      .replace(this.replaceExpressions.EMPTY_START_BUFFER, '')
                      .replace(this.replaceExpressions.EMPTY_LINES, '')
          Severity: Major
          Found in src/lib/compiler.ts and 1 other location - About 1 hr to fix
          src/lib/compiler.ts on lines 229..233

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

          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

                          template
                              .replace(this.replaceExpressions.EMPTY_COMMENT_TAG, '')
                              .replace(this.replaceExpressions.BEFORE_HTML_TAG, '<')
                              .replace(this.replaceExpressions.AFTER_HTML_TAG, '>')
                              .replace(this.replaceExpressions.NEW_LINE, '')
          Severity: Major
          Found in src/lib/compiler.ts and 1 other location - About 1 hr to fix
          src/lib/compiler.ts on lines 247..251

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

          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

              if (input.slice(0, buffer.START.length) === buffer.START) {
                  return input.replace(buffer.START, '').replace(buffer.END, '')
              }
          Severity: Major
          Found in src/lib/remove-previous-buffer.ts and 1 other location - About 1 hr to fix
          src/lib/remove-previous-buffer.ts on lines 4..6

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

          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

              if (input.slice(0, buffer.APPEND.length) === buffer.APPEND) {
                  return input.replace(buffer.APPEND, '').replace(buffer.POST_APPEND, '')
              }
          Severity: Major
          Found in src/lib/remove-previous-buffer.ts and 1 other location - About 1 hr to fix
          src/lib/remove-previous-buffer.ts on lines 8..10

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

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

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

                  const filterSeperator: string = Compiler.settings.DELIMITER.SPACE
                      + Compiler.settings.DELIMITER.FILTER_SEPERATOR
                      + Compiler.settings.DELIMITER.SPACE
          Severity: Major
          Found in src/lib/compiler.ts and 1 other location - About 1 hr to fix
          src/lib/compiler.ts on lines 403..405

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

          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

                  const filterSeperator: string = Compiler.settings.DELIMITER.SPACE
                      + Compiler.settings.DELIMITER.FILTER_SEPERATOR
                      + Compiler.settings.DELIMITER.SPACE
          Severity: Major
          Found in src/lib/compiler.ts and 1 other location - About 1 hr to fix
          src/lib/compiler.ts on lines 380..382

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

          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 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 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 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
                Severity
                Category
                Status
                Source
                Language