01alchemist/sls-yaml

View on GitHub

Showing 17 of 17 total issues

Function emitNode has a Cognitive Complexity of 51 (exceeds 5 allowed). Consider refactoring.
Open

export function emitNode({
  node,
  basePath = ".",
  parentPath = "",
  parentName = null,
Severity: Minor
Found in src/template-compiler/index.ts - About 7 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

File index.ts has 449 lines of code (exceeds 250 allowed). Consider refactoring.
Open

const fs = require("fs");
// const util = require("util");
const path = require("path");
const { spawnSync } = require("child_process");
const get = require("lodash.get");
Severity: Minor
Found in src/template-compiler/index.ts - About 6 hrs to fix

    Function parseToken has 62 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export function parseToken(value: any, parent: Node) {
      let buffer: string = "";
      const parentNode = createNode(parent, NodeKind.GROUP);
    
      let lastParent: Node | null = parentNode;
    Severity: Major
    Found in src/template-compiler/index.ts - About 2 hrs to fix

      Function decodeHelmTemplates has 51 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export function decodeHelmTemplates(data: string) {
        /* istanbul ignore next */
        if (!data) {
          return data;
        }
      Severity: Major
      Found in src/helm-template/index.ts - About 2 hrs to fix

        Function encodeHelmTemplates has 35 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export function encodeHelmTemplates(data: string) {
          const lines = data.split("\n");
          return lines
            .map(line => {
              if (line) {
        Severity: Minor
        Found in src/helm-template/index.ts - About 1 hr to fix

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

            file: (
              [uri, encoding],
              { basePath, parentName, globalObj, parentPath = "", parentObj, context }
            ) => {
              const ext = uri.substring(uri.lastIndexOf(".") + 1, uri.length);
          Severity: Minor
          Found in src/template-compiler/index.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 readHelmTemplateSync has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export function readHelmTemplateSync(
            pathOrData: Path | Buffer,
            parent?: ParentObject,
            context?: any
          ) {
          Severity: Minor
          Found in src/helm-template/index.ts - About 1 hr to fix

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

              global: ([name, defaultValue]: string[], { globalObj }: any) => {
                const value = get(globalObj, name);
                return value === undefined ? defaultValue : value;
              },
            Severity: Major
            Found in src/template-compiler/index.ts and 1 other location - About 1 hr to fix
            src/template-compiler/index.ts on lines 113..116

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

            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

              self: ([name, defaultValue]: string[], { selfObj }: any) => {
                const value = get(selfObj, name);
                return value === undefined ? defaultValue : value;
              },
            Severity: Major
            Found in src/template-compiler/index.ts and 1 other location - About 1 hr to fix
            src/template-compiler/index.ts on lines 109..112

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

            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

            Avoid deeply nested control flow statements.
            Open

                        if (buffer[0] === ",") {
                          buffer = buffer.substring(1);
                        }
            Severity: Major
            Found in src/template-compiler/index.ts - About 45 mins to fix

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

              export function parse({ content, parent = null }: ParseArg): any {
                if (typeof content === "object") {
                  if (!content) {
                    return createNode(parent, NodeKind.VALUE, content);
                  }
              Severity: Minor
              Found in src/template-compiler/index.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 result;
              Severity: Major
              Found in src/template-compiler/index.ts - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                      return value;
                Severity: Major
                Found in src/template-compiler/index.ts - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                        return emitNode({
                          node: child,
                          ...options
                        });
                  Severity: Major
                  Found in src/template-compiler/index.ts - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                      return node;
                    Severity: Major
                    Found in src/template-compiler/index.ts - About 30 mins to fix

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

                      function createNode(parent: Node | null, kind: NodeKind, value?: any) {
                        const node = new Node(kind);
                        if (value !== undefined) node.value = value;
                        if (parent) {
                          node.parent = parent;
                      Severity: Minor
                      Found in src/template-compiler/index.ts - 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

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

                      export function printNodes(node: Node | null, indent: string = ""): string {
                        if (node) {
                          let str =
                            indent +
                            `[node:${NodeKind[node.kind]}]${
                      Severity: Minor
                      Found in src/template-compiler/utils.ts - 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

                      Severity
                      Category
                      Status
                      Source
                      Language