fbredius/storybook

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

Summary

Maintainability
B
6 hrs
Test Coverage

Function handleADD has 49 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function handleADD(node, parent, storiesOfIdentifiers) {
  if (!node.property || !node.property.name || node.property.name !== 'add') {
    return {};
  }

Severity: Minor
Found in lib/source-loader/src/abstract-syntax-tree/parse-helpers.js - About 1 hr to fix

    Consider simplifying this complex logical expression.
    Open

        if (
          parent.type === 'Program' &&
          callee.type === 'MemberExpression' &&
          callee.object.type === 'Identifier' &&
          callee.property.type === 'Identifier' &&
    Severity: Critical
    Found in lib/source-loader/src/abstract-syntax-tree/parse-helpers.js - About 1 hr to fix

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

      function findTemplate(templateName, program) {
        let template = null;
        program.body.find((node) => {
          let declarations = null;
          if (node.type === 'VariableDeclaration') {
      Severity: Minor
      Found in lib/source-loader/src/abstract-syntax-tree/parse-helpers.js - About 1 hr to fix

        Function handleADD has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

        export function handleADD(node, parent, storiesOfIdentifiers) {
          if (!node.property || !node.property.name || node.property.name !== 'add') {
            return {};
          }
        
        
        Severity: Minor
        Found in lib/source-loader/src/abstract-syntax-tree/parse-helpers.js - About 55 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 expandBindExpression has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

        function expandBindExpression(node, parent) {
          if (node.type === 'CallExpression') {
            const { callee, arguments: bindArguments } = node;
            if (
              parent.type === 'Program' &&
        Severity: Minor
        Found in lib/source-loader/src/abstract-syntax-tree/parse-helpers.js - About 45 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

        Avoid too many return statements within this function.
        Open

          return {};
        Severity: Major
        Found in lib/source-loader/src/abstract-syntax-tree/parse-helpers.js - About 30 mins to fix

          Parsing error: The keyword 'import' is reserved
          Open

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

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

          There are no issues that match your filters.

          Category
          Status