ckr/url-shortener

View on GitHub
lib/url-shortener-stack.ts

Summary

Maintainability
A
0 mins
Test Coverage

Function constructor has 122 lines of code (exceeds 25 allowed). Consider refactoring.
Wontfix

    constructor(scope: Construct, id: string, config: Config) {
        super(scope, id);

        this.createS3Bucket('Bucket', config.zoneName);
        this.meRedirect = config.getStackParam('meRedirect');
Severity: Major
Found in lib/url-shortener-stack.ts - About 4 hrs to fix

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

            super(config.getApp(), id, {
                env: config.getParam('aws_env_details'),
                tags: config.getParam('stack_tags'),
                description: 'Serverless private URL shortener based on Amazon S3, AWS Lambda, Amazon CloudFront and API Gateway.',
            });
    Severity: Minor
    Found in lib/url-shortener-stack.ts and 1 other location - About 40 mins to fix
    lib/url-shortner-cert-stack.ts on lines 8..12

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

    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

    Expected property shorthand in object literal ('{bucketName}').
    Open

                bucketName: bucketName,
    Severity: Minor
    Found in lib/url-shortener-stack.ts by tslint

    Rule: object-literal-shorthand

    Enforces/disallows use of ES6 object literal shorthand.

    Notes
    • Has Fix

    Config

    "always" assumed to be default option, thus with no options provided the rule enforces object literal methods and properties shorthands. With "never" option provided, any shorthand object literal syntax causes an error.

    The rule can be configured in a more granular way. With {"property": "never"} provided (which is equivalent to {"property": "never", "method": "always"}), the rule only flags property shorthand assignments, and respectively with {"method": "never"} (equivalent to {"property": "always", "method": "never"}), the rule fails only on method shorthands.

    Examples
    "object-literal-shorthand": true
    "object-literal-shorthand": true,never
    "object-literal-shorthand": true,[object Object]
    Schema
    {
      "oneOf": [
        {
          "type": "string",
          "enum": [
            "never"
          ]
        },
        {
          "type": "object",
          "properties": {
            "property": {
              "type": "string",
              "enum": [
                "never"
              ]
            },
            "method": {
              "type": "string",
              "enum": [
                "never"
              ]
            }
          },
          "minProperties": 1,
          "maxProperties": 2
        }
      ]
    }

    For more information see this page.

    Expected property shorthand in object literal ('{distribution}').
    Open

                distribution: distribution,
    Severity: Minor
    Found in lib/url-shortener-stack.ts by tslint

    Rule: object-literal-shorthand

    Enforces/disallows use of ES6 object literal shorthand.

    Notes
    • Has Fix

    Config

    "always" assumed to be default option, thus with no options provided the rule enforces object literal methods and properties shorthands. With "never" option provided, any shorthand object literal syntax causes an error.

    The rule can be configured in a more granular way. With {"property": "never"} provided (which is equivalent to {"property": "never", "method": "always"}), the rule only flags property shorthand assignments, and respectively with {"method": "never"} (equivalent to {"property": "always", "method": "never"}), the rule fails only on method shorthands.

    Examples
    "object-literal-shorthand": true
    "object-literal-shorthand": true,never
    "object-literal-shorthand": true,[object Object]
    Schema
    {
      "oneOf": [
        {
          "type": "string",
          "enum": [
            "never"
          ]
        },
        {
          "type": "object",
          "properties": {
            "property": {
              "type": "string",
              "enum": [
                "never"
              ]
            },
            "method": {
              "type": "string",
              "enum": [
                "never"
              ]
            }
          },
          "minProperties": 1,
          "maxProperties": 2
        }
      ]
    }

    For more information see this page.

    unused expression, expected an assignment or function call
    Open

            new CfnOutput(this, 'ShortUrlDns', { value: `https://${record.domainName}` });
    Severity: Minor
    Found in lib/url-shortener-stack.ts by tslint

    Rule: no-unused-expression

    Disallows unused expression statements.

    Unused expressions are expression statements which are not assignments or function calls (and thus usually no-ops).

    Rationale

    Detects potential errors where an assignment or function call was intended.

    Config

    Three arguments may be optionally provided:

    • allow-fast-null-checks allows to use logical operators to perform fast null checks and perform method or function calls for side effects (e.g. e && e.preventDefault()).
    • allow-new allows 'new' expressions for side effects (e.g. new ModifyGlobalState();.
    • allow-tagged-template allows tagged templates for side effects (e.g. this.add\foo`;`.
    Examples
    "no-unused-expression": true
    "no-unused-expression": true,allow-fast-null-checks
    Schema
    {
      "type": "array",
      "items": {
        "type": "string",
        "enum": [
          "allow-fast-null-checks",
          "allow-new",
          "allow-tagged-template"
        ]
      },
      "minLength": 0,
      "maxLength": 3
    }

    For more information see this page.

    comment must start with a space
    Open

                            //TODO: This is a hack find a way to fix
    Severity: Minor
    Found in lib/url-shortener-stack.ts by tslint

    Rule: comment-format

    Enforces formatting rules for single-line comments.

    Rationale

    Helps maintain a consistent, readable style in your codebase.

    Notes
    • Has Fix

    Config

    Four arguments may be optionally provided:

    • "check-space" requires that all single-line comments must begin with a space, as in // comment
      • note that for comments starting with multiple slashes, e.g. ///, leading slashes are ignored
      • TypeScript reference comments are ignored completely
    • "check-lowercase" requires that the first non-whitespace character of a comment must be lowercase, if applicable.
    • "check-uppercase" requires that the first non-whitespace character of a comment must be uppercase, if applicable.
    • "allow-trailing-lowercase" allows that only the first comment of a series of comments needs to be uppercase.
      • requires "check-uppercase"
      • comments must start at the same position

    Exceptions to "check-lowercase" or "check-uppercase" can be managed with object that may be passed as last argument.

    One of two options can be provided in this object:

    • "ignore-words" - array of strings - words that will be ignored at the beginning of the comment.
    • "ignore-pattern" - string - RegExp pattern that will be ignored at the beginning of the comment.
    Examples
    "comment-format": true,check-space,check-uppercase,allow-trailing-lowercase
    "comment-format": true,check-lowercase,[object Object]
    "comment-format": true,check-lowercase,[object Object]
    Schema
    {
      "type": "array",
      "items": {
        "anyOf": [
          {
            "type": "string",
            "enum": [
              "check-space",
              "check-lowercase",
              "check-uppercase",
              "allow-trailing-lowercase"
            ]
          },
          {
            "type": "object",
            "properties": {
              "ignore-words": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "ignore-pattern": {
                "type": "string"
              }
            },
            "minProperties": 1,
            "maxProperties": 1
          }
        ]
      },
      "minLength": 1,
      "maxLength": 5
    }

    For more information see this page.

    unused expression, expected an assignment or function call
    Open

            new UrlShortener(this, 'UrlShortener', config);
    Severity: Minor
    Found in lib/url-shortener-stack.ts by tslint

    Rule: no-unused-expression

    Disallows unused expression statements.

    Unused expressions are expression statements which are not assignments or function calls (and thus usually no-ops).

    Rationale

    Detects potential errors where an assignment or function call was intended.

    Config

    Three arguments may be optionally provided:

    • allow-fast-null-checks allows to use logical operators to perform fast null checks and perform method or function calls for side effects (e.g. e && e.preventDefault()).
    • allow-new allows 'new' expressions for side effects (e.g. new ModifyGlobalState();.
    • allow-tagged-template allows tagged templates for side effects (e.g. this.add\foo`;`.
    Examples
    "no-unused-expression": true
    "no-unused-expression": true,allow-fast-null-checks
    Schema
    {
      "type": "array",
      "items": {
        "type": "string",
        "enum": [
          "allow-fast-null-checks",
          "allow-new",
          "allow-tagged-template"
        ]
      },
      "minLength": 0,
      "maxLength": 3
    }

    For more information see this page.

    unused expression, expected an assignment or function call
    Open

            new BucketDeployment(this, `DeployPLinks-${file}`, {
                sources: [
                    Source.asset('./assets/p', {
                        exclude: ['**', `!${file}`]
                    })
    Severity: Minor
    Found in lib/url-shortener-stack.ts by tslint

    Rule: no-unused-expression

    Disallows unused expression statements.

    Unused expressions are expression statements which are not assignments or function calls (and thus usually no-ops).

    Rationale

    Detects potential errors where an assignment or function call was intended.

    Config

    Three arguments may be optionally provided:

    • allow-fast-null-checks allows to use logical operators to perform fast null checks and perform method or function calls for side effects (e.g. e && e.preventDefault()).
    • allow-new allows 'new' expressions for side effects (e.g. new ModifyGlobalState();.
    • allow-tagged-template allows tagged templates for side effects (e.g. this.add\foo`;`.
    Examples
    "no-unused-expression": true
    "no-unused-expression": true,allow-fast-null-checks
    Schema
    {
      "type": "array",
      "items": {
        "type": "string",
        "enum": [
          "allow-fast-null-checks",
          "allow-new",
          "allow-tagged-template"
        ]
      },
      "minLength": 0,
      "maxLength": 3
    }

    For more information see this page.

    There are no issues that match your filters.

    Category
    Status