stoplightio/markdown

View on GitHub

Showing 69 of 69 total issues

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

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

                    (position.character >= item.position!.start.column - 1 &&
                      position.character <= item.position!.end.column - 1))
        Severity: Major
        Found in src/getJsonPathForPosition.ts and 1 other location - About 1 hr to fix
        src/getJsonPathForPosition.ts on lines 17..17

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 57.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

          if (position.line >= node.position!.start.line - 1 && position.line <= node.position!.end.line - 1) {
        Severity: Major
        Found in src/getJsonPathForPosition.ts and 1 other location - About 1 hr to fix
        src/getJsonPathForPosition.ts on lines 25..26

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 57.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        Identical blocks of code found in 2 locations. Consider refactoring.
        Open

            it.each`
              line  | character | path
              ${10} | ${0}      | ${['children', 5, 'children', 0]}
              ${65} | ${0}      | ${['children', 18, 'children', 1, 'children', 1]}
              ${65} | ${3}      | ${['children', 18, 'children', 1, 'children', 1, 'children', 1]}
        Severity: Major
        Found in src/__tests__/getJsonPathForPosition.spec.ts and 1 other location - About 1 hr to fix
        src/__tests__/getJsonPathForPosition.spec.ts on lines 16..33

        Duplicated Code

        Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

        Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

        When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

        Tuning

        This issue has a mass of 56.

        We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

        The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

        If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

        See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

        Refactorings

        Further Reading

        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

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

            const processorInstance = processor()
              .data('settings', Object.assign({}, remarkParsePreset.settings, opts.settings))
              .use(opts.remarkPlugins || []);
          Severity: Minor
          Found in src/parse.ts and 1 other location - About 55 mins to fix
          src/stringify.ts on lines 42..44

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 54.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

            const processorInstance = processor()
              .data('settings', Object.assign({}, remarkStringifyPreset.settings, opts.settings))
              .use(opts.remarkPlugins || []);
          Severity: Minor
          Found in src/stringify.ts and 1 other location - About 55 mins to fix
          src/parse.ts on lines 59..61

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 54.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

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

          export const getProperty = (propName: string, element?: string, data?: MDAST.Root) => {
            let target: string | void | undefined;
          
            if (data) {
              try {
          Severity: Minor
          Found in src/getters/get-property.ts - 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

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

                start: {
                  character: data.position!.start.column - 1,
                  line: data.position!.start.line - 1,
                },
          Severity: Minor
          Found in src/getLocationForJsonPath.ts and 1 other location - About 50 mins to fix
          src/getLocationForJsonPath.ts on lines 17..20

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 52.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

                end: {
                  character: data.position!.end.column - 1,
                  line: data.position!.end.line - 1,
                },
          Severity: Minor
          Found in src/getLocationForJsonPath.ts and 1 other location - About 50 mins to fix
          src/getLocationForJsonPath.ts on lines 13..16

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 52.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

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

          function replaceRefs(obj: object) {
            for (const value of Object.values(obj)) {
              if (typeof value !== 'object' || value === null) continue;
              if ('$ref' in value) {
                value.$ref = '<replaced>';
          Severity: Minor
          Found in src/plugins/run/__tests__/resolver.spec.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 deeply nested control flow statements.
          Open

                  if (annotationVal === 'json_schema') {
                    // camelCase to be consistent with rest of annotation props
                    metaProps.push('jsonSchema');
                  }
          Severity: Major
          Found in src/plugins/stringify/code.ts - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                  } else if (key === 'highlightLines') {
                    // handle deprecated way of adding highlightLines via array annotation
                    if (Array.isArray(annotationVal)) {
                      const rangeVals = [];
                      for (const val of annotationVal) {
            Severity: Major
            Found in src/plugins/stringify/code.ts - About 45 mins to fix

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                it('should not fail if tags is null', () => {
                  const tags = getTags(
                    parse(`---
              tags: null
              ---`),
              Severity: Minor
              Found in src/getters/__tests__/get-tags.test.ts and 1 other location - About 40 mins to fix
              src/getters/__tests__/get-tags.test.ts on lines 30..38

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 49.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                it('should not fail if tags is undefined', () => {
                  const tags = getTags(
                    parse(`---
              tags: undefined
              ---`),
              Severity: Minor
              Found in src/getters/__tests__/get-tags.test.ts and 1 other location - About 40 mins to fix
              src/getters/__tests__/get-tags.test.ts on lines 40..48

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 49.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                  let tabPlaceholder: MDAST.Tabs = {
                    type: 'tabs',
                    data: {
                      hName: 'tabs',
                    },
              Severity: Minor
              Found in src/plugins/run/annotations.ts and 1 other location - About 40 mins to fix
              src/plugins/run/annotations.ts on lines 87..101

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 48.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                        tabPlaceholder = {
                          type: 'tabs',
                          data: {
                            hName: 'tabs',
                          },
              Severity: Minor
              Found in src/plugins/run/annotations.ts and 1 other location - About 40 mins to fix
              src/plugins/run/annotations.ts on lines 22..36

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 48.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 3 locations. Consider refactoring.
              Open

                it('should return first paragraph if present', () => {
                  const summary = getSummary(
                    parse(`# Other Title
              
              Paragraph 1.
              Severity: Minor
              Found in src/getters/__tests__/get-summary.test.ts and 2 other locations - About 40 mins to fix
              src/getters/__tests__/get-summary.test.ts on lines 5..18
              src/getters/__tests__/get-summary.test.ts on lines 33..37

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 48.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Severity
              Category
              Status
              Source
              Language