src/base/diff/diffString.ts
Function diffString
has a Cognitive Complexity of 36 (exceeds 8 allowed). Consider refactoring. Invalid
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];
- Read upRead up
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
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];
Function diffPreParse
has a Cognitive Complexity of 15 (exceeds 8 allowed). Consider refactoring. Open
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
- Read upRead up
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
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