fbredius/storybook

View on GitHub
lib/source-loader/src/abstract-syntax-tree/traverse-helpers.js

Summary

Maintainability
C
1 day
Test Coverage

Function popParametersObjectFromDefaultExport has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

export function popParametersObjectFromDefaultExport(source, ast) {
  let splicedSource = source;
  let parametersSliceOfCode = '';
  let indexWhereToAppend = -1;
  let foundParametersProperty = false;
Severity: Minor
Found in lib/source-loader/src/abstract-syntax-tree/traverse-helpers.js - About 3 hrs 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 popParametersObjectFromDefaultExport has 40 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function popParametersObjectFromDefaultExport(source, ast) {
  let splicedSource = source;
  let parametersSliceOfCode = '';
  let indexWhereToAppend = -1;
  let foundParametersProperty = false;
Severity: Minor
Found in lib/source-loader/src/abstract-syntax-tree/traverse-helpers.js - About 1 hr to fix

    Function findExportsMap has 36 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export function findExportsMap(ast) {
      const addsMap = {};
      estraverse.traverse(ast, {
        fallback: 'iteration',
        enter: (node, parent) => {
    Severity: Minor
    Found in lib/source-loader/src/abstract-syntax-tree/traverse-helpers.js - About 1 hr to fix

      Function splitExports has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

      export function splitExports(ast, source) {
        const parts = [];
        let lastIndex = 0;
      
        const includeExclude = findIncludeExclude(ast);
      Severity: Minor
      Found in lib/source-loader/src/abstract-syntax-tree/traverse-helpers.js - About 1 hr 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 splitExports has 35 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export function splitExports(ast, source) {
        const parts = [];
        let lastIndex = 0;
      
        const includeExclude = findIncludeExclude(ast);
      Severity: Minor
      Found in lib/source-loader/src/abstract-syntax-tree/traverse-helpers.js - About 1 hr to fix

        Function enter has 30 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            enter: (node) => {
              patchNode(node);
        
              const isDefaultExport = node.type === 'ExportDefaultDeclaration';
              const isObjectExpression = node.declaration?.type === 'ObjectExpression';
        Severity: Minor
        Found in lib/source-loader/src/abstract-syntax-tree/traverse-helpers.js - About 1 hr to fix

          Function enter has 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              enter: (node, parent) => {
                patchNode(node);
          
                const isNamedExport = node.type === 'ExportNamedDeclaration' && node.declaration;
          
          
          Severity: Minor
          Found in lib/source-loader/src/abstract-syntax-tree/traverse-helpers.js - About 1 hr to fix

            Consider simplifying this complex logical expression.
            Open

                  if (
                    isDefaultExport &&
                    (isObjectExpression || isTsAsExpression) &&
                    (targetNode.properties || []).length
                  ) {
            Severity: Major
            Found in lib/source-loader/src/abstract-syntax-tree/traverse-helpers.js - About 40 mins to fix

              Function findExportsMap has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

              export function findExportsMap(ast) {
                const addsMap = {};
                estraverse.traverse(ast, {
                  fallback: 'iteration',
                  enter: (node, parent) => {
              Severity: Minor
              Found in lib/source-loader/src/abstract-syntax-tree/traverse-helpers.js - About 35 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

              Parsing error: The keyword 'import' is reserved
              Open

              import { isExportStory } from '@storybook/csf';

              For more information visit Source: http://eslint.org/docs/rules/

              There are no issues that match your filters.

              Category
              Status