JamieMason/expect-more

View on GitHub

Showing 13 of 315 total issues

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 generateDocsForPackage has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

    const generateDocsForPackage = (name: string): void => {
      const rootDir = path.resolve(__dirname, '..');
      const fullApi = [];
    
      const visitFile = ({ filePath, gitHubUrl }) => {
    Severity: Minor
    Found in scripts/generate-docs.ts - 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 generateDocsForPackage has 62 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    const generateDocsForPackage = (name: string): void => {
      const rootDir = path.resolve(__dirname, '..');
      const fullApi = [];
    
      const visitFile = ({ filePath, gitHubUrl }) => {
    Severity: Major
    Found in scripts/generate-docs.ts - About 2 hrs to fix

      Function generateJasmineMemberMatcher has 57 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export const generateJasmineMemberMatcher = (file: FileMeta): void => {
        try {
          const { jasmineMemberMatcherPath, jsDoc, matcherInputs, matcherInputsWithoutTypes, name } =
            file;
          const { description, matcherMessage, memberMatcherName, matcherNotMessage, params } = jsDoc;
      Severity: Major
      Found in scripts/generate-matchers/jasmine-member-matcher.ts - About 2 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 generateJasmineMatcher has 44 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export const generateJasmineMatcher = (file: FileMeta): void => {
          try {
            const { jasmineMatcherPath, jsDoc, matcherInputs, matcherInputsWithoutTypes, name } = file;
            const { description, matcherMessage, matcherName, matcherNotMessage, params } = jsDoc;
            const utilImports = matcherInputs.length > 0 ? 'printExpected, printReceived' : 'printReceived';
        Severity: Minor
        Found in scripts/generate-matchers/jasmine-matcher.ts - About 1 hr to fix

          Function generateJestMatcher has 40 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export const generateJestMatcher = (file: FileMeta): void => {
            try {
              const { jestMatcherPath, jsDoc, matcherInputs, matcherInputsWithoutTypes, name } = file;
              const { description, matcherMessage, matcherName, matcherNotMessage, params } = jsDoc;
              const utilImports = matcherInputs.length > 0 ? 'printExpected, printReceived' : 'printReceived';
          Severity: Minor
          Found in scripts/generate-matchers/jest-matcher.ts - About 1 hr to fix

            Function treeWalker has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
            Open

            function* treeWalker(rootNode: any): Generator<TreeNode, void> {
              function* visit(node: TreeNode): Generator<TreeNode, void> {
                yield node;
                if (isArray(node.value)) {
                  for (let i = 0, len = node.value.length; i < len; i++) {
            Severity: Minor
            Found in packages/expect-more/src/gen/lib.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

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

              export const generateJestMatcherTest = (file: FileMeta): void => {
                const { jestMatcherTestPath, jsDoc } = file;
                const { matcherName, params } = jsDoc;
                let comment = '';
                let valueExample = params.find(({ name }) => name === 'value').exampleValue;
              Severity: Minor
              Found in scripts/generate-matchers/jest-matcher-test.ts - About 1 hr to fix

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

                    const visitNode = (node) => {
                      switch (node.kind) {
                        case ts.SyntaxKind.InterfaceDeclaration:
                          const isAsymmetricMatcher = node.name.text === 'Expect';
                          const isMatcher = node.name.text === 'Matchers';
                Severity: Minor
                Found in scripts/generate-docs.ts - About 1 hr to fix

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

                  export function curry3<R>(fn: Fn3<R>): CurriedFn3<R> {
                    return function curriedFn3(c, b, a) {
                      const len = arguments.length;
                      if (len >= 3) return fn(c, b, a);
                      if (len >= 2) return curry1<R>(fn.bind(null, c, b));
                  Severity: Minor
                  Found in packages/expect-more/src/lib/curry3.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 permutingTreeWalker has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                  function* permutingTreeWalker(rootNode: any, visitor: DeepNodeVisitor): Generator<any, void> {
                    const traverser = annotatedTreeWalker(rootNode);
                    for (const node of traverser) {
                      if (isDeepNode(node)) {
                        let permutation;
                  Severity: Minor
                  Found in packages/expect-more/src/gen/lib.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

                  Severity
                  Category
                  Status
                  Source
                  Language