fbredius/storybook

View on GitHub
addons/docs/src/lib/jsdocParser.ts

Summary

Maintainability
C
1 day
Test Coverage

Function extractJsDocTags has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

function extractJsDocTags(ast: doctrine.Annotation): ExtractedJsDoc {
  const extractedTags: ExtractedJsDoc = {
    params: null,
    returns: null,
    ignore: false,
Severity: Minor
Found in addons/docs/src/lib/jsdocParser.ts - About 2 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 extractTypeName has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

function extractTypeName(type: doctrine.Type): string {
  if (type.type === 'NameExpression') {
    return type.name;
  }

Severity: Minor
Found in addons/docs/src/lib/jsdocParser.ts - About 2 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 extractTypeName has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function extractTypeName(type: doctrine.Type): string {
  if (type.type === 'NameExpression') {
    return type.name;
  }

Severity: Minor
Found in addons/docs/src/lib/jsdocParser.ts - About 1 hr to fix

    Function extractJsDocTags has 37 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function extractJsDocTags(ast: doctrine.Annotation): ExtractedJsDoc {
      const extractedTags: ExtractedJsDoc = {
        params: null,
        returns: null,
        ignore: false,
    Severity: Minor
    Found in addons/docs/src/lib/jsdocParser.ts - About 1 hr to fix

      Avoid deeply nested control flow statements.
      Open

                  if (extractedTags.params == null) {
                    extractedTags.params = [];
                  }
      Severity: Major
      Found in addons/docs/src/lib/jsdocParser.ts - About 45 mins to fix

        Function extractParam has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

        function extractParam(tag: doctrine.Tag): ExtractedJsDocParam {
          const paramName = tag.name;
        
          // When the @param doesn't have a name but have a type and a description, "null-null" is returned.
          if (paramName != null && paramName !== 'null-null') {
        Severity: Minor
        Found in addons/docs/src/lib/jsdocParser.ts - 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 extractTypeName(type.expression);
        Severity: Major
        Found in addons/docs/src/lib/jsdocParser.ts - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

            return null;
          Severity: Major
          Found in addons/docs/src/lib/jsdocParser.ts - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                return 'any';
            Severity: Major
            Found in addons/docs/src/lib/jsdocParser.ts - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                      return `${arrayType}[]`;
              Severity: Major
              Found in addons/docs/src/lib/jsdocParser.ts - About 30 mins to fix

                Expected a 'for-of' loop instead of a 'for' loop with this simple iteration
                Open

                  for (let i = 0; i < ast.tags.length; i += 1) {
                Severity: Minor
                Found in addons/docs/src/lib/jsdocParser.ts by tslint

                Rule: prefer-for-of

                Recommends a 'for-of' loop over a standard 'for' loop if the index is only used to access the array being iterated.

                Rationale

                A for(... of ...) loop is easier to implement and read when the index is not needed.

                Config

                Not configurable.

                Examples
                "prefer-for-of": true

                For more information see this page.

                There are no issues that match your filters.

                Category
                Status