benjamine/jsondiffpatch

View on GitHub

Showing 53 of 97 total issues

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

      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

        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

            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

                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

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

                        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

                              Severity
                              Category
                              Status
                              Source
                              Language