fbredius/storybook

View on GitHub
app/angular/src/client/preview/decorateStory.test.ts

Summary

Maintainability
F
5 days
Test Coverage

File decorateStory.test.ts has 348 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { Component, Input, Output } from '@angular/core';
import { DecoratorFunction, StoryContext } from '@storybook/addons';
import { componentWrapperDecorator } from './decorators';

import decorateStory from './decorateStory';
Severity: Minor
Found in app/angular/src/client/preview/decorateStory.test.ts - About 4 hrs to fix

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

          const decorators: DecoratorFunction<StoryFnAngularReturnType>[] = [
            (s) => {
              const story = s();
              return {
                ...story,
    Severity: Major
    Found in app/angular/src/client/preview/decorateStory.test.ts and 3 other locations - About 5 hrs to fix
    app/angular/src/client/preview/decorateStory.test.ts on lines 99..121
    app/angular/src/client/preview/decorateStory.test.ts on lines 165..187
    app/angular/src/client/preview/decorateStory.test.ts on lines 198..220

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

    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 4 locations. Consider refactoring.
    Open

          const decorators: DecoratorFunction<StoryFnAngularReturnType>[] = [
            (s) => {
              const story = s();
              return {
                ...story,
    Severity: Major
    Found in app/angular/src/client/preview/decorateStory.test.ts and 3 other locations - About 5 hrs to fix
    app/angular/src/client/preview/decorateStory.test.ts on lines 99..121
    app/angular/src/client/preview/decorateStory.test.ts on lines 132..154
    app/angular/src/client/preview/decorateStory.test.ts on lines 198..220

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

    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 4 locations. Consider refactoring.
    Open

          const decorators: DecoratorFunction<StoryFnAngularReturnType>[] = [
            (s) => {
              const story = s();
              return {
                ...story,
    Severity: Major
    Found in app/angular/src/client/preview/decorateStory.test.ts and 3 other locations - About 5 hrs to fix
    app/angular/src/client/preview/decorateStory.test.ts on lines 132..154
    app/angular/src/client/preview/decorateStory.test.ts on lines 165..187
    app/angular/src/client/preview/decorateStory.test.ts on lines 198..220

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

    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 4 locations. Consider refactoring.
    Open

          const decorators: DecoratorFunction<StoryFnAngularReturnType>[] = [
            (s) => {
              const story = s();
              return {
                ...story,
    Severity: Major
    Found in app/angular/src/client/preview/decorateStory.test.ts and 3 other locations - About 5 hrs to fix
    app/angular/src/client/preview/decorateStory.test.ts on lines 99..121
    app/angular/src/client/preview/decorateStory.test.ts on lines 132..154
    app/angular/src/client/preview/decorateStory.test.ts on lines 165..187

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

    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 3 locations. Consider refactoring.
    Open

            (s, c) => {
              const story = s({ ...c, k: 3, parameters: { p: 3 } });
              return {
                ...story,
                props: { a: [...story.props.a, c.k], p: [...story.props.p, c.parameters.p] },
    Severity: Major
    Found in app/angular/src/client/preview/decorateStory.test.ts and 2 other locations - About 3 hrs to fix
    app/angular/src/client/preview/decorateStory.test.ts on lines 316..322
    app/angular/src/client/preview/decorateStory.test.ts on lines 323..329

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

    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 3 locations. Consider refactoring.
    Open

            (s, c) => {
              const story = s({ ...c, k: 2, parameters: { p: 2 } });
              return {
                ...story,
                props: { a: [...story.props.a, c.k], p: [...story.props.p, c.parameters.p] },
    Severity: Major
    Found in app/angular/src/client/preview/decorateStory.test.ts and 2 other locations - About 3 hrs to fix
    app/angular/src/client/preview/decorateStory.test.ts on lines 316..322
    app/angular/src/client/preview/decorateStory.test.ts on lines 330..336

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

    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 3 locations. Consider refactoring.
    Open

            (s, c) => {
              const story = s({ ...c, k: 1, parameters: { p: 1 } });
              return {
                ...story,
                props: { a: [...story.props.a, c.k], p: [...story.props.p, c.parameters.p] },
    Severity: Major
    Found in app/angular/src/client/preview/decorateStory.test.ts and 2 other locations - About 3 hrs to fix
    app/angular/src/client/preview/decorateStory.test.ts on lines 323..329
    app/angular/src/client/preview/decorateStory.test.ts on lines 330..336

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

    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 3 locations. Consider refactoring.
    Open

            (s, c) => {
              const story = s({ ...c, k: 1 });
              return { ...story, props: { a: [...story.props.a, c.k] } };
            },
    Severity: Major
    Found in app/angular/src/client/preview/decorateStory.test.ts and 2 other locations - About 1 hr to fix
    app/angular/src/client/preview/decorateStory.test.ts on lines 300..303
    app/angular/src/client/preview/decorateStory.test.ts on lines 304..307

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

    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 3 locations. Consider refactoring.
    Open

            (s, c) => {
              const story = s({ ...c, k: 3 });
              return { ...story, props: { a: [...story.props.a, c.k] } };
            },
    Severity: Major
    Found in app/angular/src/client/preview/decorateStory.test.ts and 2 other locations - About 1 hr to fix
    app/angular/src/client/preview/decorateStory.test.ts on lines 296..299
    app/angular/src/client/preview/decorateStory.test.ts on lines 300..303

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

    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 3 locations. Consider refactoring.
    Open

            (s, c) => {
              const story = s({ ...c, k: 2 });
              return { ...story, props: { a: [...story.props.a, c.k] } };
            },
    Severity: Major
    Found in app/angular/src/client/preview/decorateStory.test.ts and 2 other locations - About 1 hr to fix
    app/angular/src/client/preview/decorateStory.test.ts on lines 296..299
    app/angular/src/client/preview/decorateStory.test.ts on lines 304..307

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

    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 3 locations. Consider refactoring.
    Open

            (s) => {
              const story = s();
              return { ...story, props: { a: [...story.props.a, 1] } };
            },
    Severity: Minor
    Found in app/angular/src/client/preview/decorateStory.test.ts and 2 other locations - About 40 mins to fix
    app/angular/src/client/preview/decorateStory.test.ts on lines 280..283
    app/angular/src/client/preview/decorateStory.test.ts on lines 284..287

    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

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

            (s) => {
              const story = s();
              return { ...story, props: { a: [...story.props.a, 3] } };
            },
    Severity: Minor
    Found in app/angular/src/client/preview/decorateStory.test.ts and 2 other locations - About 40 mins to fix
    app/angular/src/client/preview/decorateStory.test.ts on lines 276..279
    app/angular/src/client/preview/decorateStory.test.ts on lines 280..283

    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

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

            (s) => {
              const story = s();
              return { ...story, props: { a: [...story.props.a, 2] } };
            },
    Severity: Minor
    Found in app/angular/src/client/preview/decorateStory.test.ts and 2 other locations - About 40 mins to fix
    app/angular/src/client/preview/decorateStory.test.ts on lines 276..279
    app/angular/src/client/preview/decorateStory.test.ts on lines 284..287

    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

    block is empty
    Open

              parentOutput: () => {},

    Rule: no-empty

    Disallows empty blocks.

    Blocks with a comment inside are not considered empty.

    Rationale

    Empty blocks are often indicators of missing code.

    Config

    If allow-empty-catch is specified, then catch blocks are allowed to be empty. If allow-empty-functions is specified, then function definitions are allowed to be empty.

    Examples
    "no-empty": true
    "no-empty": true,allow-empty-catch
    "no-empty": true,allow-empty-functions
    "no-empty": true,allow-empty-catch,allow-empty-functions
    Schema
    {
      "type": "array",
      "items": {
        "anyOf": [
          {
            "type": "string",
            "enum": [
              "allow-empty-catch"
            ]
          },
          {
            "type": "string",
            "enum": [
              "allow-empty-functions"
            ]
          }
        ]
      }
    }

    For more information see this page.

    Type assertion on object literals is forbidden, use a type annotation instead.
    Open

      return {
        id: 'id',
        kind: 'kind',
        name: 'name',
        viewMode: 'story',

    Rule: no-object-literal-type-assertion

    Forbids an object literal to appear in a type assertion expression. Casting to any or to unknown is still allowed.

    Rationale

    Always prefer const x: T = { ... }; to const x = { ... } as T;. The type assertion in the latter case is either unnecessary or hides an error. The compiler will warn for excess properties with this syntax, but not missing required fields. For example: const x: { foo: number } = {} will fail to compile, but const x = {} as { foo: number } will succeed. Additionally, the const assertion const x = { foo: 1 } as const, introduced in TypeScript 3.4, is considered beneficial and is ignored by this rule.

    Notes
    • TypeScript Only

    Config

    One option may be configured:

    • allow-arguments allows type assertions to be used on object literals inside call expressions.
    Examples
    "no-object-literal-type-assertion": true
    "no-object-literal-type-assertion": true,[object Object]
    Schema
    {
      "type": "object",
      "properties": {
        "allow-arguments": {
          "type": "boolean"
        }
      },
      "additionalProperties": false
    }

    For more information see this page.

    block is empty
    Open

                  parentOutput: () => {},

    Rule: no-empty

    Disallows empty blocks.

    Blocks with a comment inside are not considered empty.

    Rationale

    Empty blocks are often indicators of missing code.

    Config

    If allow-empty-catch is specified, then catch blocks are allowed to be empty. If allow-empty-functions is specified, then function definitions are allowed to be empty.

    Examples
    "no-empty": true
    "no-empty": true,allow-empty-catch
    "no-empty": true,allow-empty-functions
    "no-empty": true,allow-empty-catch,allow-empty-functions
    Schema
    {
      "type": "array",
      "items": {
        "anyOf": [
          {
            "type": "string",
            "enum": [
              "allow-empty-catch"
            ]
          },
          {
            "type": "string",
            "enum": [
              "allow-empty-functions"
            ]
          }
        ]
      }
    }

    For more information see this page.

    There are no issues that match your filters.

    Category
    Status