benjamine/jsondiffpatch

View on GitHub

Showing 97 of 97 total issues

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

    countries: [
      {
        name: 'Argentina',
        capital: 'Buenos Aires',
        independence: new Date(1816, 6, 9),
Severity: Major
Found in demos/html-demo/demo.ts and 1 other location - About 1 day to fix
demos/console-demo/demo.ts on lines 83..156

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

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

  countries: [
    {
      name: 'Argentina',
      capital: 'Buenos Aires',
      independence: new Date(1816, 6, 9),
Severity: Major
Found in demos/console-demo/demo.ts and 1 other location - About 1 day to fix
demos/html-demo/demo.ts on lines 100..173

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

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

File demo.ts has 782 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import * as jsondiffpatch from 'jsondiffpatch/with-text-diffs';
import * as annotatedFormatter from 'jsondiffpatch/formatters/annotated';
import * as htmlFormatter from 'jsondiffpatch/formatters/html';

import 'jsondiffpatch/formatters/styles/html.css';
Severity: Major
Found in demos/html-demo/demo.ts - About 1 day to fix

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

          if (urlmatch.test(rightValue)) {
            dataLoaded.right.name = urlmatch.exec(rightValue)![1];
            dataLoaded.right.fullname = rightValue;
            dom.getJson(rightValue, function (error, data) {
              if (error) {
    Severity: Major
    Found in demos/html-demo/demo.ts and 1 other location - About 1 day to fix
    demos/html-demo/demo.ts on lines 696..713

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

    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 (urlmatch.test(leftValue)) {
            dataLoaded.left.name = urlmatch.exec(leftValue)![1];
            dataLoaded.left.fullname = leftValue;
            dom.getJson(leftValue, function (error, data) {
              if (error) {
    Severity: Major
    Found in demos/html-demo/demo.ts and 1 other location - About 1 day to fix
    demos/html-demo/demo.ts on lines 714..731

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

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

    const getExampleJson = function () {
      const data: Continent = {
        name: 'South America',
        summary:
          'South America (Spanish: América del Sur, Sudamérica or  \n' +
    Severity: Major
    Found in demos/html-demo/demo.ts - About 5 hrs to fix

      File html.ts has 315 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import BaseFormatter from './base.js';
      import type { BaseFormatterContext, DeltaType, NodeType } from './base.js';
      import type {
        AddedDelta,
        ArrayDelta,
      Severity: Minor
      Found in packages/jsondiffpatch/src/formatters/html.ts - About 3 hrs to fix

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

          added(delta, left, key, leftKey) {
            const formatLegend = ' <pre>([newValue])</pre>';
            if (typeof leftKey === 'undefined') {
              return `new value${formatLegend}`;
            }
        Severity: Major
        Found in packages/jsondiffpatch/src/formatters/annotated.ts and 2 other locations - About 2 hrs to fix
        packages/jsondiffpatch/src/formatters/annotated.ts on lines 234..243
        packages/jsondiffpatch/src/formatters/annotated.ts on lines 244..253

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

        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

          modified(delta, left, key, leftKey) {
            const formatLegend = ' <pre>([previousValue, newValue])</pre>';
            if (typeof leftKey === 'undefined') {
              return `modify value${formatLegend}`;
            }
        Severity: Major
        Found in packages/jsondiffpatch/src/formatters/annotated.ts and 2 other locations - About 2 hrs to fix
        packages/jsondiffpatch/src/formatters/annotated.ts on lines 224..233
        packages/jsondiffpatch/src/formatters/annotated.ts on lines 244..253

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

        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

          deleted(delta, left, key, leftKey) {
            const formatLegend = ' <pre>([previousValue, 0, 0])</pre>';
            if (typeof leftKey === 'undefined') {
              return `delete value${formatLegend}`;
            }
        Severity: Major
        Found in packages/jsondiffpatch/src/formatters/annotated.ts and 2 other locations - About 2 hrs to fix
        packages/jsondiffpatch/src/formatters/annotated.ts on lines 224..233
        packages/jsondiffpatch/src/formatters/annotated.ts on lines 234..243

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

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

        const compare = function () {
          let left, right, error;
          document.getElementById('results')!.style.display = 'none';
          try {
            left = areas.left.parse();
        Severity: Major
        Found in demos/html-demo/demo.ts - About 2 hrs to fix

          File annotated.ts has 280 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          import BaseFormatter from './base.js';
          import type { BaseFormatterContext, DeltaType, NodeType } from './base.js';
          import type {
            AddedDelta,
            ArrayDelta,
          Severity: Minor
          Found in packages/jsondiffpatch/src/formatters/annotated.ts - About 2 hrs to fix

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

                  'South America (Spanish: América del Sur, Sudamérica or  \n' +
                  'Suramérica; Portuguese: América do Sul; Quechua and Aymara:  \n' +
                  'Urin Awya Yala; Guarani: Ñembyamérika; Dutch: Zuid-Amerika;  \n' +
                  'French: Amérique du Sud) is a continent situated in the  \n' +
                  'Western Hemisphere, mostly in the Southern Hemisphere, with  \n' +
            Severity: Major
            Found in demos/html-demo/demo.ts and 1 other location - About 2 hrs to fix
            demos/console-demo/demo.ts on lines 36..58

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

            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

                'South America (Spanish: América del Sur, Sudamérica or Suramérica;' +
                ' Portuguese: América do Sul; Quechua and Aymara: Urin Awya Yala;' +
                ' Guarani: Ñembyamérika; Dutch: Zuid-Amerika; French: Amérique du Sud)' +
                ' is a continent situated in the Western Hemisphere, mostly in the' +
                ' Southern Hemisphere, with a relatively small portion in the Northern' +
            Severity: Major
            Found in demos/console-demo/demo.ts and 1 other location - About 2 hrs to fix
            demos/html-demo/demo.ts on lines 50..72

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

            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 trivialMatchesDiffFilter has a Cognitive Complexity of 19 (exceeds 5 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

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

              leftright: function (descriptionArg, leftValueArg, rightValueArg) {
                try {
                  const description = decodeURIComponent(descriptionArg || '');
                  const leftValue = decodeURIComponent(leftValueArg);
                  const rightValue = decodeURIComponent(rightValueArg);
            Severity: Major
            Found in demos/html-demo/demo.ts - About 2 hrs to fix

              Function objectsDiffFilter has a Cognitive Complexity of 17 (exceeds 5 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 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 jsondiffpatchHtmlFormatterAdjustArrows has 56 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              const adjustArrows = function jsondiffpatchHtmlFormatterAdjustArrows(
                nodeArg?: Element,
              ) {
                const node = nodeArg || document;
                const getElementText = ({ textContent, innerText }: HTMLDivElement) =>
              Severity: Major
              Found in packages/jsondiffpatch/src/formatters/html.ts - About 2 hrs to fix

                Function compare has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                Open

                const compare = function () {
                  let left, right, error;
                  document.getElementById('results')!.style.display = 'none';
                  try {
                    left = areas.left.parse();
                Severity: Minor
                Found in demos/html-demo/demo.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 data has a Cognitive Complexity of 16 (exceeds 5 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 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

                Severity
                Category
                Status
                Source
                Language