stoplightio/markdown

View on GitHub

Showing 31 of 69 total issues

File reader.spec.ts has 434 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import * as fs from 'fs';
import * as path from 'path';
import html from 'remark-html';
import unified from 'unified';

Severity: Minor
Found in src/reader/__tests__/reader.spec.ts - About 6 hrs to fix

    Function computeMetaProps has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
    Open

    function computeMetaProps(annotations: object) {
      const metaProps = [];
      if (Object.keys(annotations).length) {
        for (const key in annotations) {
          const annotationVal = annotations[key];
    Severity: Minor
    Found in src/plugins/stringify/code.ts - About 6 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 smdAnnotations has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
    Open

    export const smdAnnotations: unified.Attacher = function () {
      return function transform($root) {
        const root = $root as MDAST.Root;
        const nodes = root.children;
    
    
    Severity: Minor
    Found in src/plugins/run/annotations.ts - About 5 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 smdAnnotations has 91 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export const smdAnnotations: unified.Attacher = function () {
      return function transform($root) {
        const root = $root as MDAST.Root;
        const nodes = root.children;
    
    
    Severity: Major
    Found in src/plugins/run/annotations.ts - About 3 hrs to fix

      Function transform has 89 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        return function transform($root) {
          const root = $root as MDAST.Root;
          const nodes = root.children;
      
          const processed: MDAST.Content[] = [];
      Severity: Major
      Found in src/plugins/run/annotations.ts - About 3 hrs to fix

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

        function applicable(node: Parent, inLink?: boolean): boolean | null {
          let image: boolean | null = null;
          let children = node.children;
          let length = children.length;
          let index = -1;
        Severity: Minor
        Found in src/plugins/run/unwrap-images.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

        File resolver.spec.ts has 276 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import * as fs from 'fs';
        import * as path from 'path';
        import remarkStringify, { RemarkStringifyOptions } from 'remark-stringify';
        import unified from 'unified';
        
        
        Severity: Minor
        Found in src/plugins/run/__tests__/resolver.spec.ts - About 2 hrs to fix

          Function captureAnnotations has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
          Open

          function captureAnnotations<T extends Dictionary<any>>(node: MDAST.Content | undefined): T | {} {
            if (!node?.value) return {};
          
            if (
              // @ts-expect-error
          Severity: Minor
          Found in src/plugins/run/annotations.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 findNode has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

          function findNode(root: MDAST.Parent | MDAST.Content, node: MDAST.Content, path: JsonPath): MDAST.Content | undefined {
            if (node.position === undefined || root.position === undefined) return;
          
            if (
              node.position.start.line === root.position.start.line &&
          Severity: Minor
          Found in src/getJsonPathForNode.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 findNodeAtPosition has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

          function findNodeAtPosition(
            node: MDAST.Parent | MDAST.Content,
            position: IPosition,
            path: JsonPath,
          ): MDAST.Parent | MDAST.Content | undefined {
          Severity: Minor
          Found in src/getJsonPathForPosition.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

          File fronmatter.spec.ts has 253 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          import * as fs from 'fs';
          import { join } from 'path';
          
          import { MDAST } from '../../ast-types';
          import { parse } from '../../parse';
          Severity: Minor
          Found in src/frontmatter/__tests__/fronmatter.spec.ts - About 2 hrs to fix

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

            export const resolveCodeBlocks: unified.Attacher<[{ resolver?: Resolver }]> = function (opts) {
              const resolver = opts?.resolver;
              if (!resolver) return;
            
              return async function transformer(tree, _file) {
            Severity: Minor
            Found in src/plugins/run/resolver.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 unset has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
            Open

              public unset(prop: PropertyPath) {
                if (this.properties !== null) {
                  const path = _toPath(prop);
                  const lastSegment = Number(path[path.length - 1]);
                  if (!Number.isNaN(lastSegment)) {
            Severity: Minor
            Found in src/frontmatter/frontmatter.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 smdCode has 46 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export const smdCode: unified.Attacher = function () {
              return function transform(root) {
                let sequentialCodeBlocks: MDAST.Code[] = [];
                let lastIndex = -1;
                let lastParent: MDAST.Parent | undefined;
            Severity: Minor
            Found in src/plugins/run/code.ts - About 1 hr to fix

              Function transform has 44 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                return function transform(root) {
                  let sequentialCodeBlocks: MDAST.Code[] = [];
                  let lastIndex = -1;
                  let lastParent: MDAST.Parent | undefined;
              
              
              Severity: Minor
              Found in src/plugins/run/code.ts - About 1 hr to fix

                Function computeMetaProps has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                function computeMetaProps(annotations: object) {
                  const metaProps = [];
                  if (Object.keys(annotations).length) {
                    for (const key in annotations) {
                      const annotationVal = annotations[key];
                Severity: Minor
                Found in src/plugins/stringify/code.ts - About 1 hr to fix

                  Function captureAnnotations has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  function captureAnnotations<T extends Dictionary<any>>(node: MDAST.Content | undefined): T | {} {
                    if (!node?.value) return {};
                  
                    if (
                      // @ts-expect-error
                  Severity: Minor
                  Found in src/plugins/run/annotations.ts - About 1 hr to fix

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

                    export const resolveCodeBlocks: unified.Attacher<[{ resolver?: Resolver }]> = function (opts) {
                      const resolver = opts?.resolver;
                      if (!resolver) return;
                    
                      return async function transformer(tree, _file) {
                    Severity: Minor
                    Found in src/plugins/run/resolver.ts - About 1 hr to fix

                      Function applicable has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      function applicable(node: Parent, inLink?: boolean): boolean | null {
                        let image: boolean | null = null;
                        let children = node.children;
                        let length = children.length;
                        let index = -1;
                      Severity: Minor
                      Found in src/plugins/run/unwrap-images.ts - About 1 hr to fix

                        Function transformer has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          return async function transformer(tree, _file) {
                            const codes: Array<{ node: MDAST.Code; index: number | null; parent: Parent | null }> = [];
                            const promises: Array<Promise<void>> = [];
                        
                            visit<MDAST.Code>(tree, 'code', (node, index, parent) => {
                        Severity: Minor
                        Found in src/plugins/run/resolver.ts - About 1 hr to fix
                          Severity
                          Category
                          Status
                          Source
                          Language