benjamine/jsondiffpatch

View on GitHub

Showing 53 of 97 total issues

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

    Function trivialMatchesPatchFilter has 34 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      function trivialMatchesPatchFilter(context) {
        if (typeof context.delta === 'undefined') {
          context.setResult(context.left).exit();
          return;
        }
    Severity: Minor
    Found in packages/jsondiffpatch/src/filters/trivial.ts - About 1 hr to fix

      Function backtrack has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      const backtrack = function (
        matrix: number[][] & {
          match?: (
            array1: readonly unknown[],
            array2: readonly unknown[],
      Severity: Minor
      Found in packages/jsondiffpatch/src/filters/lcs.ts - About 1 hr to fix

        Function prepareContext has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

          prepareContext(context: Partial<ConsoleFormatterContext>) {
            super.prepareContext(context);
            context.indent = function (levels) {
              this.indentLevel =
                (this.indentLevel || 0) + (typeof levels === 'undefined' ? 1 : levels);
        Severity: Minor
        Found in packages/jsondiffpatch/src/formatters/console.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 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 trivialMatchesPatchFilter has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

          function trivialMatchesPatchFilter(context) {
            if (typeof context.delta === 'undefined') {
              context.setResult(context.left).exit();
              return;
            }
        Severity: Minor
        Found in packages/jsondiffpatch/src/filters/trivial.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 lengthMatrix has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        const lengthMatrix = function (
          array1: readonly unknown[],
          array2: readonly unknown[],
          match: (
            array1: readonly unknown[],
        Severity: Minor
        Found in packages/jsondiffpatch/src/filters/lcs.ts - About 1 hr to fix

          Function prepareContext has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            prepareContext(context: Partial<ConsoleFormatterContext>) {
              super.prepareContext(context);
              context.indent = function (levels) {
                this.indentLevel =
                  (this.indentLevel || 0) + (typeof levels === 'undefined' ? 1 : levels);
          Severity: Minor
          Found in packages/jsondiffpatch/src/formatters/console.ts - About 1 hr to fix

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

            const lengthMatrix = function (
              array1: readonly unknown[],
              array2: readonly unknown[],
              match: (
                array1: readonly unknown[],
            Severity: Minor
            Found in packages/jsondiffpatch/src/filters/lcs.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 process has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

              process(input: TContext) {
                if (!this.processor) {
                  throw new Error('add this pipe to a processor before using it');
                }
                const debug = this.debug;
            Severity: Minor
            Found in packages/jsondiffpatch/src/pipe.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 backtrack has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

            const backtrack = function (
              matrix: number[][] & {
                match?: (
                  array1: readonly unknown[],
                  array2: readonly unknown[],
            Severity: Minor
            Found in packages/jsondiffpatch/src/filters/lcs.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 clone has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

            export default function clone(arg: unknown): unknown {
              if (typeof arg !== 'object') {
                return arg;
              }
              if (arg === null) {
            Severity: Minor
            Found in packages/jsondiffpatch/src/clone.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 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 datesDiffFilter has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

            export const diffFilter: Filter<DiffContext> = function datesDiffFilter(
              context,
            ) {
              if (context.left instanceof Date) {
                if (context.right instanceof Date) {
            Severity: Minor
            Found in packages/jsondiffpatch/src/filters/dates.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 pipe has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

              pipe<TContext extends Context<any>>(
                name: string | Pipe<TContext>,
                pipeArg?: Pipe<TContext>,
              ) {
                let pipe = pipeArg;
            Severity: Minor
            Found in packages/jsondiffpatch/src/processor.ts - About 45 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 collectChildrenDiffFilter has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

            export const collectChildrenDiffFilter: Filter<DiffContext> = (context) => {
              if (!context || !context.children) {
                return;
              }
              const length = context.children.length;
            Severity: Minor
            Found in packages/jsondiffpatch/src/filters/nested.ts - About 45 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 setResult has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

              setResult(result: Delta) {
                if (this.options!.cloneDiffValues && typeof result === 'object') {
                  const clone =
                    typeof this.options!.cloneDiffValues === 'function'
                      ? this.options!.cloneDiffValues
            Severity: Minor
            Found in packages/jsondiffpatch/src/contexts/diff.ts - About 45 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 formatAnyChange has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

              this: AnnotatedFormatter,
              context: AnnotatedFormatterContext,
              delta: DeltaTypeAnnotationsMap[TDeltaType],
              left: unknown,
              key: string | undefined,
            Severity: Minor
            Found in packages/jsondiffpatch/src/formatters/annotated.ts - About 45 mins to fix

              Function textDeltaReverse has a Cognitive Complexity of 8 (exceeds 5 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 45 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

              Severity
              Category
              Status
              Source
              Language