benjamine/jsondiffpatch

View on GitHub
demos/html-demo/demo.ts

Summary

Maintainability
F
1 wk
Test Coverage

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

    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

      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

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

          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

            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

              Function gist has a Cognitive Complexity of 11 (exceeds 5 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

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

                getJson: function (
                  url: string,
                  callback: (error: Error | string | null, data?: unknown) => void,
                ) {
                  let request: XMLHttpRequest | null = new XMLHttpRequest();
              Severity: Minor
              Found in demos/html-demo/demo.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 leftright has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                leftright: function (descriptionArg, leftValueArg, rightValueArg) {
                  try {
                    const description = decodeURIComponent(descriptionArg || '');
                    const leftValue = decodeURIComponent(leftValueArg);
                    const rightValue = decodeURIComponent(rightValueArg);
              Severity: Minor
              Found in demos/html-demo/demo.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

              Function text has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                text: function (el: HTMLElement, text: string) {
                  if (typeof el.textContent !== 'undefined') {
                    if (typeof text === 'undefined') {
                      return el.textContent;
                    }
              Severity: Minor
              Found in demos/html-demo/demo.ts - About 25 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

                  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

                    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

              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

                  document
                    .getElementById('json-panel-left')!
                    .querySelector('h2')!
                    .setAttribute(
                      'title',
              Severity: Major
              Found in demos/html-demo/demo.ts and 1 other location - About 1 hr to fix
              demos/html-demo/demo.ts on lines 604..610

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

              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

                  dom.text(
                    document.getElementById('json-panel-left')!.querySelector('h2')!,
                    (data.left && (data.left as DataObject).name) || 'left.json',
                  );
              Severity: Major
              Found in demos/html-demo/demo.ts and 1 other location - About 1 hr to fix
              demos/html-demo/demo.ts on lines 592..595

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

              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

                  dom.text(
                    document.getElementById('json-panel-right')!.querySelector('h2')!,
                    (data.right && (data.right as DataObject).name) || 'right.json',
                  );
              Severity: Major
              Found in demos/html-demo/demo.ts and 1 other location - About 1 hr to fix
              demos/html-demo/demo.ts on lines 588..591

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

              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

                  document
                    .getElementById('json-panel-right')!
                    .querySelector('h2')!
                    .setAttribute(
                      'title',
              Severity: Major
              Found in demos/html-demo/demo.ts and 1 other location - About 1 hr to fix
              demos/html-demo/demo.ts on lines 597..603

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

              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

              There are no issues that match your filters.

              Category
              Status