arminhammer/wolkenkratzer

View on GitHub

Showing 18 of 74 total issues

Function Template has a Cognitive Complexity of 52 (exceeds 5 allowed). Consider refactoring.
Open

export function Template(): ITemplate {
  return {
    AWSTemplateFormatVersion: '2010-09-09',
    Conditions: {},
    Mappings: {},
Severity: Minor
Found in src/template/index.ts - About 1 day 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 Template has 235 lines of code (exceeds 150 allowed). Consider refactoring.
Open

export function Template(): ITemplate {
  return {
    AWSTemplateFormatVersion: '2010-09-09',
    Conditions: {},
    Mappings: {},
Severity: Major
Found in src/template/index.ts - About 4 hrs to fix

    Function Bucket has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
    Open

    const Bucket: TransformFunctionType = function(
      name: string,
      AWSClient: AWS.S3,
      logical: string
    ): Promise<IResource> {
    Severity: Minor
    Found in src/transform/S3.ts - 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 _cleanObject has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

    function _cleanObject(object: any) {
      if (Array.isArray(object)) {
        for (let v = 0; v < object.length; v++) {
          object[v] = _cleanObject(object[v]);
        }
    Severity: Minor
    Found in src/template/build.ts - 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 buildIntrinsic has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

    export function buildIntrinsic(input) {
      if (input['Fn::Equals']) {
        return FnEquals(
          buildIntrinsic(input['Fn::Equals'][0]),
          buildIntrinsic(input['Fn::Equals'][1])
    Severity: Minor
    Found in src/intrinsic.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

    Consider simplifying this complex logical expression.
    Open

            if (
              !properties[p].kind &&
              (properties[p].kind !== 'Ref' && !properties[p].Ref) &&
              (properties[p].kind !== 'FnGetAZs' &&
                typeof properties[p]['Fn::GetAZ'] !== 'undefined') &&
    Severity: Critical
    Found in src/elements/resource.ts - About 1 hr to fix

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

      function _buildFnSelect(t: IFnSelect) {
        if (Array.isArray(t.FnSelect)) {
          const values = t.FnSelect.map(x => {
            if (typeof x === 'string') {
              return x;
      Severity: Minor
      Found in src/template/build.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 _buildResource has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      function _buildResource(t: IResource) {
        const newT = cloneDeep(t);
        const {
          Type,
          Properties,
      Severity: Minor
      Found in src/template/build.ts - About 45 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 Output has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      export function Output(name: string, properties: IOutputProperties): IOutput {
        if (!name || !properties || !properties.Value) {
          throw new SyntaxError(
            `New Output with ${JSON.stringify({
              name,
      Severity: Minor
      Found in src/elements/output.ts - About 45 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 deeply nested control flow statements.
      Open

                    if (mapping) {
                      element = mapping;
                    } else {
                      throw new SyntaxError(`Could not find ${JSON.stringify(e)}`);
                    }
      Severity: Major
      Found in src/template/index.ts - About 45 mins to fix

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

        function _validateRef(t: ITemplate, ref: IRef): void | SyntaxError {
          if (ref.Ref) {
            if (!(t.Parameters[ref.Ref] || t.Resources[ref.Ref])) {
              if (!Object.values(Pseudo).includes(ref.Ref)) {
                throw new SyntaxError(`Could not find ${JSON.stringify(ref)}`);
        Severity: Minor
        Found in src/template/validate.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 input;
        Severity: Major
        Found in src/intrinsic.ts - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

              return FnIf(input['Fn::If'].map(x => buildIntrinsic(x)));
          Severity: Major
          Found in src/intrinsic.ts - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                return FnNot(input['Fn::Not'].map(x => buildIntrinsic(x)));
            Severity: Major
            Found in src/intrinsic.ts - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                  return FnAnd(
                    buildIntrinsic(input['Fn::And'][0]),
                    buildIntrinsic(input['Fn::And'][1])
                  );
              Severity: Major
              Found in src/intrinsic.ts - About 30 mins to fix

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

                export function Resource(name: string, properties, options): IResource {
                  if (!name) {
                    throw new SyntaxError(`New Resource is invalid. A Name is required.`);
                  }
                  if (!properties) {
                Severity: Minor
                Found in src/elements/resource.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 _buildFnJoin has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                function _buildFnJoin(t: IFnJoin) {
                  if (Array.isArray(t.Values)) {
                    const jsonValues = t.Values.map(x => {
                      if (typeof x === 'string') {
                        return x;
                Severity: Minor
                Found in src/template/build.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 _calcFromExistingTemplate has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                function _calcFromExistingTemplate(t: ITemplate, inputTemplate: any) {
                  if (inputTemplate.Description) {
                    t = t.add(Description(inputTemplate.Description));
                  }
                  if (inputTemplate.Parameters) {
                Severity: Minor
                Found in src/template/import.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