fbredius/storybook

View on GitHub
app/angular/src/client/preview/angular-beta/AbstractRenderer.ts

Summary

Maintainability
A
1 hr
Test Coverage

Function render has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  public async render({
    storyFnAngular,
    forced,
    parameters,
    component,
Severity: Minor
Found in app/angular/src/client/preview/angular-beta/AbstractRenderer.ts - About 1 hr to fix

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

      public async render({
        storyFnAngular,
        forced,
        parameters,
        component,
    Severity: Minor
    Found in app/angular/src/client/preview/angular-beta/AbstractRenderer.ts and 1 other location - About 35 mins to fix
    app/angular/src/client/preview/angular-beta/DocsRenderer.ts on lines 8..14

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

    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

    Unnecessary semicolon
    Open

      };

    Rule: semicolon

    Enforces consistent semicolon usage at the end of every statement.

    Notes
    • Has Fix

    Config

    One of the following arguments must be provided:

    • "always" enforces semicolons at the end of every statement.
    • "never" disallows semicolons at the end of every statement except for when they are necessary.

    The following arguments may be optionally provided:

    • "ignore-interfaces" skips checking semicolons at the end of interface members.
    • "ignore-bound-class-methods" skips checking semicolons at the end of bound class methods.
    • "strict-bound-class-methods" disables any special handling of bound class methods and treats them as any other assignment. This option overrides "ignore-bound-class-methods".
    Examples
    "semicolon": true,always
    "semicolon": true,never
    "semicolon": true,always,ignore-interfaces
    "semicolon": true,always,ignore-bound-class-methods
    Schema
    {
      "type": "array",
      "items": [
        {
          "type": "string",
          "enum": [
            "always",
            "never"
          ]
        },
        {
          "type": "string",
          "enum": [
            "ignore-interfaces"
          ]
        }
      ],
      "additionalItems": false
    }

    For more information see this page.

    Don't assign members of this to local variables.
    Open

        const { previousStoryRenderInfo } = this;

    Rule: no-this-assignment

    Disallows unnecessary references to this.

    Rationale

    Assigning a variable to this instead of properly using arrow lambdas may be a symptom of pre-ES6 practices or not managing scope well.

    Instead of storing a reference to this and using it inside a function () {:

    const self = this;
    
    setTimeout(function () {
        self.doWork();
    });

    Use () => arrow lambdas, as they preserve this scope for you:

    setTimeout(() => {
        this.doWork();
    });

    Config

    Two options may be provided on an object:

    • allow-destructuring allows using destructuring to access members of this (e.g. { foo, bar } = this;).
    • allowed-names may be specified as a list of regular expressions to match allowed variable names.
    Examples
    "no-this-assignment": true
    "no-this-assignment": true,[object Object]
    Schema
    {
      "additionalProperties": false,
      "properties": {
        "allow-destructuring": {
          "type": "boolean"
        },
        "allowed-names": {
          "listType": "string",
          "type": "list"
        }
      },
      "type": "object"
    }

    For more information see this page.

    There are no issues that match your filters.

    Category
    Status