JamieMason/expect-more

View on GitHub
scripts/generate-matchers/index.ts

Summary

Maintainability
C
7 hrs
Test Coverage

Function getMetadata has 112 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const getMetadata = (filePath): FileMeta => {
  const sourceFile = program.getSourceFile(filePath);
  const result: FileMeta = {
    filePath,
    inputs: [],
Severity: Major
Found in scripts/generate-matchers/index.ts - About 4 hrs to fix

    Function getMetadata has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

    const getMetadata = (filePath): FileMeta => {
      const sourceFile = program.getSourceFile(filePath);
      const result: FileMeta = {
        filePath,
        inputs: [],
    Severity: Minor
    Found in scripts/generate-matchers/index.ts - 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 visitNode has 37 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      const visitNode = (node) => {
        if (node.jsDoc) {
          const [jsDocComment] = node.jsDoc;
          result.jsDoc.description = unwrap(jsDocComment.comment);
          jsDocComment.tags.forEach(({ comment, name, tagName }) => {
    Severity: Minor
    Found in scripts/generate-matchers/index.ts - About 1 hr to fix

      Array type using 'Array<t>' is forbidden. Use 'T[]' instead.</t>
      Open

        params: Array<{
          name: string;
          exampleValue: string;
        }>;
      Severity: Minor
      Found in scripts/generate-matchers/index.ts by tslint

      Rule: array-type

      Requires using either 'T[]' or 'Array<t>' for arrays.</t>

      Notes
      • TypeScript Only
      • Has Fix

      Config

      One of the following arguments must be provided:

      • "array" enforces use of T[] for all types T.
      • "generic" enforces use of Array<T> for all types T.
      • "array-simple" enforces use of T[] if T is a simple type (primitive or type reference).
      Examples
      "array-type": true,array
      "array-type": true,generic
      "array-type": true,array-simple
      Schema
      {
        "type": "string",
        "enum": [
          "array",
          "generic",
          "array-simple"
        ]
      }

      For more information see this page.

      There are no issues that match your filters.

      Category
      Status