fbredius/storybook

View on GitHub
scripts/run-e2e.ts

Summary

Maintainability
B
4 hrs
Test Coverage

Function getConfig has 48 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const getConfig = async (): Promise<Parameters[]> => {
  let e2eConfigsToRun = Object.values(typedConfigs);

  if (shouldRunAllFrameworks) {
    // Nothing to do here
Severity: Minor
Found in scripts/run-e2e.ts - About 1 hr to fix

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

    const getConfig = async (): Promise<Parameters[]> => {
      let e2eConfigsToRun = Object.values(typedConfigs);
    
      if (shouldRunAllFrameworks) {
        // Nothing to do here
    Severity: Minor
    Found in scripts/run-e2e.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 runTests has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

    const runTests = async ({ name, ...rest }: Parameters) => {
      const options = {
        name,
        ...rest,
        cwd: path.join(siblingDir, `${name}`),
    Severity: Minor
    Found in scripts/run-e2e.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

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

      if (startWithCleanSlate) {
        logger.log();
        logger.info(`♻️  Starting with a clean slate, removing existing ${name} folder`);
        await cleanDirectory({ ...parameters, cwd });
      }
    Severity: Minor
    Found in scripts/run-e2e.ts and 1 other location - About 50 mins to fix
    scripts/run-e2e.ts on lines 138..145

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

    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

        if (cleanup) {
          logger.log();
          logger.info(`🗑 Cleaning ${cwd}`);
          await cleanDirectory({ ...parameters, cwd });
        } else {
    Severity: Minor
    Found in scripts/run-e2e.ts and 1 other location - About 50 mins to fix
    scripts/run-e2e.ts on lines 150..154

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

    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

    Identifier 'pnp' is never reassigned; use 'const' instead of 'let'.
    Open

    let { pnp, useLocalSbCli, clean: startWithCleanSlate }: ProgramOptions = program;
    Severity: Minor
    Found in scripts/run-e2e.ts by tslint

    Rule: prefer-const

    Requires that variable declarations use const instead of let and var if possible.

    If a variable is only assigned to once when it is declared, it should be declared using 'const'

    Notes
    • Has Fix

    Config

    An optional object containing the property "destructuring" with two possible values:

    • "any" (default) - If any variable in destructuring can be const, this rule warns for those variables.
    • "all" - Only warns if all variables in destructuring can be const.
    Examples
    "prefer-const": true
    "prefer-const": true,[object Object]
    Schema
    {
      "type": "object",
      "properties": {
        "destructuring": {
          "type": "string",
          "enum": [
            "all",
            "any"
          ]
        }
      }
    }

    For more information see this page.

    Multiple imports from '../lib/cli/src/repro-generators/configs' can be combined into one.
    Open

    import { Parameters } from '../lib/cli/src/repro-generators/configs';
    Severity: Minor
    Found in scripts/run-e2e.ts by tslint

    Rule: no-duplicate-imports

    Disallows multiple import statements from the same module.

    Rationale

    Using a single import statement per module will make the code clearer because you can see everything being imported from that module on one line.

    Config

    "allow-namespace-imports" allows you to import namespaces on separate lines.

    Examples
    "no-duplicate-imports": true,[object Object]
    Schema
    {
      "type": "object",
      "properties": {
        "allow-namespace-imports": {
          "type": "boolean"
        }
      }
    }

    For more information see this page.

    Identifier 'startWithCleanSlate' is never reassigned; use 'const' instead of 'let'.
    Open

    let { pnp, useLocalSbCli, clean: startWithCleanSlate }: ProgramOptions = program;
    Severity: Minor
    Found in scripts/run-e2e.ts by tslint

    Rule: prefer-const

    Requires that variable declarations use const instead of let and var if possible.

    If a variable is only assigned to once when it is declared, it should be declared using 'const'

    Notes
    • Has Fix

    Config

    An optional object containing the property "destructuring" with two possible values:

    • "any" (default) - If any variable in destructuring can be const, this rule warns for those variables.
    • "all" - Only warns if all variables in destructuring can be const.
    Examples
    "prefer-const": true
    "prefer-const": true,[object Object]
    Schema
    {
      "type": "object",
      "properties": {
        "destructuring": {
          "type": "string",
          "enum": [
            "all",
            "any"
          ]
        }
      }
    }

    For more information see this page.

    There are no issues that match your filters.

    Category
    Status