Function from
has a Cognitive Complexity of 53 (exceeds 5 allowed). Consider refactoring. Open
export function from(dataStr, validationOptions = {}) {
const leader = dataStr.substring(0, 24);
const record = {
leader,
fields: []
- 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 from
has 107 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function from(dataStr, validationOptions = {}) {
const leader = dataStr.substring(0, 24);
const record = {
leader,
fields: []
Function to
has 57 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function to(record) {
//let tag; // eslint-disable-line functional/no-let
//let ind1; // eslint-disable-line functional/no-let
//let ind2; // eslint-disable-line functional/no-let
Function reader
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function reader(stream, validationOptions = {}) {
const emitter = new class extends EventEmitter { }();
start();
Function utf8Substr
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
function utf8Substr(str, startInBytes, lengthInBytes) {
const strBytes = stringToByteArray(str);
const subStrBytes = [];
let count = 0; // eslint-disable-line functional/no-let
- 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
Avoid deeply nested control flow statements. Open
if (currElementStr !== '') { // eslint-disable-line max-depth
// eslint-disable-next-line functional/no-conditional-statements
if (j === dataElementStr.length - 1) { // eslint-disable-line max-depth
currElementStr += dataElementStr.charAt(j);
}
Function stringToByteArray
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
function stringToByteArray(str) {
const byteArray = [];
// eslint-disable-next-line functional/no-loop-statements, functional/no-let, no-plusplus
for (let i = 0; i < str.length; i++) {
- 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"