fbredius/storybook

View on GitHub
lib/core-common/src/presets.test.ts

Summary

Maintainability
D
2 days
Test Coverage

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

function wrapPreset(basePresets: any): { babel: Function; webpack: Function } {
  return {
    babel: async (config: any, args: any) => basePresets.apply('babel', config, args),
    webpack: async (config: any, args: any) => basePresets.apply('webpack', config, args),
  };
Severity: Minor
Found in lib/core-common/src/presets.test.ts - About 7 hrs to fix

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

        expect(mockPresetBarExtendBabel).toHaveBeenCalledWith(expect.anything(), {
          bar: 'a',
          presetsList: expect.arrayContaining([
            expect.objectContaining({ name: 'preset-foo' }),
            expect.objectContaining({ name: 'preset-bar' }),
    Severity: Major
    Found in lib/core-common/src/presets.test.ts and 1 other location - About 2 hrs to fix
    lib/core-common/src/presets.test.ts on lines 295..302

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

    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

        expect(mockPresetBarExtendWebpack).toHaveBeenCalledWith(expect.anything(), {
          bar: 'a',
          presetsList: expect.arrayContaining([
            expect.objectContaining({ name: 'preset-foo' }),
            expect.objectContaining({ name: 'preset-bar' }),
    Severity: Major
    Found in lib/core-common/src/presets.test.ts and 1 other location - About 2 hrs to fix
    lib/core-common/src/presets.test.ts on lines 244..251

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

    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

      it('should resolve packages with metadata (relative path)', () => {
        mockPreset('./local/preset', {
          presets: [],
        });
        expect(resolveAddonName({}, './local/preset')).toEqual({
    Severity: Major
    Found in lib/core-common/src/presets.test.ts and 1 other location - About 1 hr to fix
    lib/core-common/src/presets.test.ts on lines 371..379

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

    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

      it('should resolve packages with metadata (absolute path)', () => {
        mockPreset('/absolute/preset', {
          presets: [],
        });
        expect(resolveAddonName({}, '/absolute/preset')).toEqual({
    Severity: Major
    Found in lib/core-common/src/presets.test.ts and 1 other location - About 1 hr to fix
    lib/core-common/src/presets.test.ts on lines 361..369

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

    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

      it('should resolve preset packages', () => {
        expect(resolveAddonName({}, '@storybook/addon-essentials')).toEqual({
          name: '@storybook/addon-essentials',
          type: 'presets',
        });
    Severity: Major
    Found in lib/core-common/src/presets.test.ts and 3 other locations - About 30 mins to fix
    lib/core-common/src/presets.test.ts on lines 381..386
    lib/core-common/src/presets.test.ts on lines 388..393
    lib/core-common/src/presets.test.ts on lines 395..400

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

    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

      it('should resolve managerEntries', () => {
        expect(resolveAddonName({}, '@storybook/addon-actions/register')).toEqual({
          name: '@storybook/addon-actions/register',
          type: 'managerEntries',
        });
    Severity: Major
    Found in lib/core-common/src/presets.test.ts and 3 other locations - About 30 mins to fix
    lib/core-common/src/presets.test.ts on lines 381..386
    lib/core-common/src/presets.test.ts on lines 395..400
    lib/core-common/src/presets.test.ts on lines 402..407

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

    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

      it('should resolve presets', () => {
        expect(resolveAddonName({}, '@storybook/addon-docs')).toEqual({
          name: '@storybook/addon-docs/preset',
          type: 'presets',
        });
    Severity: Major
    Found in lib/core-common/src/presets.test.ts and 3 other locations - About 30 mins to fix
    lib/core-common/src/presets.test.ts on lines 381..386
    lib/core-common/src/presets.test.ts on lines 388..393
    lib/core-common/src/presets.test.ts on lines 402..407

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

    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

      it('should resolve packages without metadata', () => {
        expect(resolveAddonName({}, '@storybook/preset-create-react-app')).toEqual({
          name: '@storybook/preset-create-react-app',
          type: 'presets',
        });
    Severity: Major
    Found in lib/core-common/src/presets.test.ts and 3 other locations - About 30 mins to fix
    lib/core-common/src/presets.test.ts on lines 388..393
    lib/core-common/src/presets.test.ts on lines 395..400
    lib/core-common/src/presets.test.ts on lines 402..407

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

    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

    Don't use 'Function' as a type. Avoid using the Function type. Prefer a specific function type, like () => void.
    Open

    function wrapPreset(basePresets: any): { babel: Function; webpack: Function } {
    Severity: Minor
    Found in lib/core-common/src/presets.test.ts by tslint

    Rule: ban-types

    Bans specific types from being used. Does not ban the corresponding runtime objects from being used.

    Notes
    • TypeScript Only

    Config

    A list of ["regex", "optional explanation here"], which bans types that match regex

    Examples
    "ban-types": true,Object,Use {} instead.,String
    Schema
    {
      "type": "list",
      "listType": {
        "type": "array",
        "items": {
          "type": "string"
        },
        "minLength": 1,
        "maxLength": 2
      }
    }

    For more information see this page.

    Don't use 'Function' as a type. Avoid using the Function type. Prefer a specific function type, like () => void.
    Open

    function wrapPreset(basePresets: any): { babel: Function; webpack: Function } {
    Severity: Minor
    Found in lib/core-common/src/presets.test.ts by tslint

    Rule: ban-types

    Bans specific types from being used. Does not ban the corresponding runtime objects from being used.

    Notes
    • TypeScript Only

    Config

    A list of ["regex", "optional explanation here"], which bans types that match regex

    Examples
    "ban-types": true,Object,Use {} instead.,String
    Schema
    {
      "type": "list",
      "listType": {
        "type": "array",
        "items": {
          "type": "string"
        },
        "minLength": 1,
        "maxLength": 2
      }
    }

    For more information see this page.

    There are no issues that match your filters.

    Category
    Status