dbmedialab/reader-critics

View on GitHub
src/base/diff/diffString.ts

Summary

Maintainability
A
2 hrs
Test Coverage

Function diffString has a Cognitive Complexity of 36 (exceeds 8 allowed). Consider refactoring.
Invalid

export function diffString(orgStr : string, newStr : string) : Array<DiffBit> {
    // Updates the previous string part adding to it value and count of current item
    function updatePrevious(value : string) {
        const lastIndex : number = result.length - 1;
        const lastItem : DiffBit = result[lastIndex];
Severity: Minor
Found in src/base/diff/diffString.ts - 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

Function diffString has 80 lines of code (exceeds 40 allowed). Consider refactoring.
Invalid

export function diffString(orgStr : string, newStr : string) : Array<DiffBit> {
    // Updates the previous string part adding to it value and count of current item
    function updatePrevious(value : string) {
        const lastIndex : number = result.length - 1;
        const lastItem : DiffBit = result[lastIndex];
Severity: Major
Found in src/base/diff/diffString.ts - About 2 hrs to fix

    Function diffPreParse has a Cognitive Complexity of 15 (exceeds 8 allowed). Consider refactoring.
    Open

    function diffPreParse(o : string[], n : string[]) : DiffResultObject {
        const ns : DiffParsingObject = {};  // Info for new string
        const os : DiffParsingObject = {};  // Info for old string
        const nn : any[] = Object.assign([], n);  // Object to change while parsing new string
        const no : any[] = Object.assign([], o);  // Object to change while parsing old string
    Severity: Minor
    Found in src/base/diff/diffString.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 diffPreParse has 41 lines of code (exceeds 40 allowed). Consider refactoring.
    Open

    function diffPreParse(o : string[], n : string[]) : DiffResultObject {
        const ns : DiffParsingObject = {};  // Info for new string
        const os : DiffParsingObject = {};  // Info for old string
        const nn : any[] = Object.assign([], n);  // Object to change while parsing new string
        const no : any[] = Object.assign([], o);  // Object to change while parsing old string
    Severity: Minor
    Found in src/base/diff/diffString.ts - About 1 hr to fix

      There are no issues that match your filters.

      Category
      Status