benjamine/jsondiffpatch

View on GitHub

Showing 156 of 156 total issues

File diffpatch.js has 1341 lines of code (exceeds 250 allowed). Consider refactoring.
Open

const examples = {};

const exampleDate = () => new Date(2020, 10, 30, 15, 10, 3);

/* jshint camelcase: false */
Severity: Major
Found in test/examples/diffpatch.js - About 3 days to fix

    Function demo has 672 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    (function demo() {
      const getExampleJson = function() {
        const data = {
          name: 'South America',
          summary:
    Severity: Major
    Found in docs/demo/demo.js - About 3 days to fix

      Function demo has a Cognitive Complexity of 157 (exceeds 5 allowed). Consider refactoring.
      Open

      (function demo() {
        const getExampleJson = function() {
          const data = {
            name: 'South America',
            summary:
      Severity: Minor
      Found in docs/demo/demo.js - About 3 days 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

      Identical 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 docs/demo/consoledemo.js and 1 other location - About 1 day to fix
      docs/demo/demo.js on lines 56..129

      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

      Identical 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 docs/demo/demo.js and 1 other location - About 1 day to fix
      docs/demo/consoledemo.js on lines 59..132

      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.js has 674 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      (function demo() {
        const getExampleJson = function() {
          const data = {
            name: 'South America',
            summary:
      Severity: Major
      Found in docs/demo/demo.js - About 1 day to fix

        File index.js has 661 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        /*
         * mocha's bdd syntax is inspired in RSpec
         *   please read: http://betterspecs.org/
         */
        import * as jsondiffpatch from '../build/jsondiffpatch.esm';
        Severity: Major
        Found in test/index.js - About 1 day to fix

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

            {
              name: 'nested with movements using custom objectHash',
              options: {
                objectHash(obj) {
                  if (obj && obj.itemKey) {
          Severity: Major
          Found in test/examples/diffpatch.js and 1 other location - About 1 day to fix
          test/examples/diffpatch.js on lines 931..993

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

          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

            {
              name: 'nested with movement',
              options: {
                objectHash(obj) {
                  if (obj && obj.id) {
          Severity: Major
          Found in test/examples/diffpatch.js and 1 other location - About 1 day to fix
          test/examples/diffpatch.js on lines 1285..1347

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

          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(rightValue)) {
                  dataLoaded.right.name = urlmatch.exec(rightValue)[1];
                  dataLoaded.right.fullname = rightValue;
                  dom.getJson(rightValue, function(error, data) {
                    if (error) {
          Severity: Major
          Found in docs/demo/demo.js and 1 other location - About 6 hrs to fix
          docs/demo/demo.js on lines 592..606

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

          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 docs/demo/demo.js and 1 other location - About 6 hrs to fix
          docs/demo/demo.js on lines 607..621

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

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

          export const diffFilter = function arraysDiffFilter(context) {
            if (!context.leftIsArray) {
              return;
            }
          
          
          Severity: Minor
          Found in src/filters/arrays.js - 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 arraysDiffFilter has 161 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export const diffFilter = function arraysDiffFilter(context) {
            if (!context.leftIsArray) {
              return;
            }
          
          
          Severity: Major
          Found in src/filters/arrays.js - About 6 hrs to fix

            File arrays.js has 432 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            import DiffContext from '../contexts/diff';
            import PatchContext from '../contexts/patch';
            import ReverseContext from '../contexts/reverse';
            
            import lcs from './lcs';
            Severity: Minor
            Found in src/filters/arrays.js - About 6 hrs to fix

              Function getExampleJson has 147 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

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

                Function forEachDeltaKey has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
                Open

                  forEachDeltaKey(delta, left, fn) {
                    const keys = getObjectKeys(delta);
                    const arrayKeys = delta._t === 'a';
                    const moveDestinations = {};
                    let name;
                Severity: Minor
                Found in src/formatters/base.js - 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 nestedPatchFilter has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
                Open

                export const patchFilter = function nestedPatchFilter(context) {
                  if (!context.nested) {
                    return;
                  }
                  if (context.delta._t !== 'a') {
                Severity: Minor
                Found in src/filters/arrays.js - About 4 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

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

                  before(filterName) {
                    let index = this.indexOf(filterName);
                    let params = Array.prototype.slice.call(arguments, 1);
                    if (!params.length) {
                      throw new Error('a filter is required');
                Severity: Major
                Found in src/pipe.js and 1 other location - About 3 hrs to fix
                src/pipe.js on lines 83..92

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

                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) {
                    let index = this.indexOf(filterName);
                    let params = Array.prototype.slice.call(arguments, 1);
                    if (!params.length) {
                      throw new Error('a filter is required');
                Severity: Major
                Found in src/pipe.js and 1 other location - About 3 hrs to fix
                src/pipe.js on lines 72..81

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

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

                let reverseArrayDeltaIndex = (delta, index, itemDelta) => {
                  if (typeof index === 'string' && index[0] === '_') {
                    return parseInt(index.substr(1), 10);
                  } else if (isArray(itemDelta) && itemDelta[2] === 0) {
                    return `_${index}`;
                Severity: Minor
                Found in src/filters/arrays.js - 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

                Severity
                Category
                Status
                Source
                Language