benjamine/jsondiffpatch

View on GitHub

Showing 97 of 97 total issues

Function showUnchanged has 51 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export const showUnchanged = (
  show?: boolean,
  node?: Element | null,
  delay?: number,
) => {
Severity: Major
Found in packages/jsondiffpatch/src/formatters/html.ts - About 2 hrs to fix

    Function trivialMatchesDiffFilter has 50 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      function trivialMatchesDiffFilter(context) {
        if (context.left === context.right) {
          context.setResult(undefined).exit();
          return;
        }
    Severity: Minor
    Found in packages/jsondiffpatch/src/filters/trivial.ts - About 2 hrs to fix

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

      const get = function (
        array1: readonly unknown[],
        array2: readonly unknown[],
        match?: (
          array1: readonly unknown[],
      Severity: Major
      Found in packages/jsondiffpatch/src/filters/lcs.ts and 1 other location - About 1 hr to fix
      packages/jsondiffpatch/src/filters/lcs.ts on lines 20..64

      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 74.

      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 lengthMatrix = function (
        array1: readonly unknown[],
        array2: readonly unknown[],
        match: (
          array1: readonly unknown[],
      Severity: Major
      Found in packages/jsondiffpatch/src/filters/lcs.ts and 1 other location - About 1 hr to fix
      packages/jsondiffpatch/src/filters/lcs.ts on lines 121..141

      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 74.

      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

        format_movedestination(
          context: HtmlFormatterContext,
          delta: undefined,
          left: unknown,
        ) {
      Severity: Major
      Found in packages/jsondiffpatch/src/formatters/html.ts and 1 other location - About 1 hr to fix
      packages/jsondiffpatch/src/formatters/html.ts on lines 97..108

      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 73.

      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

        format_unchanged(
          context: HtmlFormatterContext,
          delta: undefined,
          left: unknown,
        ) {
      Severity: Major
      Found in packages/jsondiffpatch/src/formatters/html.ts and 1 other location - About 1 hr to fix
      packages/jsondiffpatch/src/formatters/html.ts on lines 110..121

      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 73.

      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 gist has 47 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        gist: function (id) {
          dom.getJson('https://api.github.com/gists/' + id, function (error, data) {
            interface GistError {
              message?: string;
            }
      Severity: Minor
      Found in demos/html-demo/demo.ts - About 1 hr to fix

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

            this.processor.pipe(
              new Pipe<ReverseContext>('reverse')
                .append(
                  nested.collectChildrenReverseFilter,
                  arrays.collectChildrenReverseFilter,
        Severity: Major
        Found in packages/jsondiffpatch/src/diffpatcher.ts and 2 other locations - About 1 hr to fix
        packages/jsondiffpatch/src/diffpatcher.ts on lines 20..31
        packages/jsondiffpatch/src/diffpatcher.ts on lines 32..43

        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 71.

        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

            this.processor.pipe(
              new Pipe<DiffContext>('diff')
                .append(
                  nested.collectChildrenDiffFilter,
                  trivial.diffFilter,
        Severity: Major
        Found in packages/jsondiffpatch/src/diffpatcher.ts and 2 other locations - About 1 hr to fix
        packages/jsondiffpatch/src/diffpatcher.ts on lines 32..43
        packages/jsondiffpatch/src/diffpatcher.ts on lines 44..55

        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 71.

        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

            this.processor.pipe(
              new Pipe<PatchContext>('patch')
                .append(
                  nested.collectChildrenPatchFilter,
                  arrays.collectChildrenPatchFilter,
        Severity: Major
        Found in packages/jsondiffpatch/src/diffpatcher.ts and 2 other locations - About 1 hr to fix
        packages/jsondiffpatch/src/diffpatcher.ts on lines 20..31
        packages/jsondiffpatch/src/diffpatcher.ts on lines 44..55

        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 71.

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

        function getDiffMatchPatch(options: Options | undefined, required?: boolean) {
          if (!cachedDiffPatch) {
            let instance: dmp;
            if (options?.textDiff?.diffMatchPatch) {
              instance = new options.textDiff.diffMatchPatch();
        Severity: Minor
        Found in packages/jsondiffpatch/src/filters/texts.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 data has 42 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          data: function (dataArg) {
            const data = dataArg || {};
            dom.text(document.getElementById('description')!, data.description || '');
            if (data.url && trim(data.url).substring(0, 10) !== 'javascript') {
              document.getElementById('external-link')!.setAttribute('href', data.url);
        Severity: Minor
        Found in demos/html-demo/demo.ts - About 1 hr to fix

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

            before(filterName: string, ...params: Filter<TContext>[]) {
              const index = this.indexOf(filterName);
              this.filters.splice(index, 0, ...params);
              return this;
            }
          Severity: Major
          Found in packages/jsondiffpatch/src/pipe.ts and 1 other location - About 1 hr to fix
          packages/jsondiffpatch/src/pipe.ts on lines 84..88

          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 67.

          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

            replace(filterName: string, ...params: Filter<TContext>[]) {
              const index = this.indexOf(filterName);
              this.filters.splice(index, 1, ...params);
              return this;
            }
          Severity: Major
          Found in packages/jsondiffpatch/src/pipe.ts and 1 other location - About 1 hr to fix
          packages/jsondiffpatch/src/pipe.ts on lines 78..82

          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 67.

          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 constructor has 37 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            constructor(options?: Options) {
              this.processor = new Processor(options);
              this.processor.pipe(
                new Pipe<DiffContext>('diff')
                  .append(
          Severity: Minor
          Found in packages/jsondiffpatch/src/diffpatcher.ts - About 1 hr to fix

            Function getDiffMatchPatch has 36 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function getDiffMatchPatch(options: Options | undefined, required?: boolean) {
              if (!cachedDiffPatch) {
                let instance: dmp;
                if (options?.textDiff?.diffMatchPatch) {
                  instance = new options.textDiff.diffMatchPatch();
            Severity: Minor
            Found in packages/jsondiffpatch/src/filters/texts.ts - About 1 hr to fix

              Function textDeltaReverse has 36 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              const textDeltaReverse = function (delta: string) {
                let i;
                let l;
                let line;
                let lineTmp;
              Severity: Minor
              Found in packages/jsondiffpatch/src/filters/texts.ts - About 1 hr to fix

                Function process has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                Open

                  process<TContext extends Context<any>>(
                    input: TContext,
                    pipe?: Pipe<TContext>,
                  ): TContext['result'] | undefined {
                    let context = input;
                Severity: Minor
                Found in packages/jsondiffpatch/src/processor.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 objectsDiffFilter has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                export const objectsDiffFilter: Filter<DiffContext> = (context) => {
                  if (context.leftIsArray || context.leftType !== 'object') {
                    return;
                  }
                
                
                Severity: Minor
                Found in packages/jsondiffpatch/src/filters/nested.ts - About 1 hr to fix

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

                    matrix: number[][] & {
                      match?: (
                        array1: readonly unknown[],
                        array2: readonly unknown[],
                        index1: number,
                  Severity: Major
                  Found in packages/jsondiffpatch/src/filters/lcs.ts and 1 other location - About 1 hr to fix
                  packages/jsondiffpatch/src/filters/lcs.ts on lines 37..45

                  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 63.

                  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