Showing 12 of 12 total issues
Function parseLines
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
function* parseLines(lines, options) {
let report = null;
for (const [lineno, line] of enumerate(lines, 1)) {
const parts = line.split(options.separator);
- 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 insertRecord
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
export default function insertRecord(report, record) {
let {kind} = report;
if (record.reference !== report.reference) {
throw new Error(
Function parseRecord
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
export default function parseRecord(parts, options) {
let [descriptor, reference, ...rest] = parts;
descriptor = descriptor.trim(); // To remove <feff> byte order mark
reference = reference.trim(); // To remove leading and trailing spaces
parts = [descriptor, reference, ...rest];
Function expandOptions
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
function expandOptions(options) {
const copy = Object.assign({}, options);
if (
copy.trailing === undefined ||
copy.trailing.constructor.prototype !== Object.prototype
Function validateLineLength
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
export default function validateLineLength(
parts,
kind,
validLengths,
trailingSlash,
Function validateLineLength
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
export default function validateLineLength(
parts,
kind,
validLengths,
trailingSlash,
- 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 parseA2
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
export default function parseA2(parts, options) {
validateLineLength(parts, 'A2', [6, 7], options.trailing.A2);
validateRequiredField(parts, 'lastname', 3, options.required.lastname);
validateRequiredField(parts, 'firstname', 4, options.required.firstname);
Function parseLines
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
function* parseLines(lines, options) {
let report = null;
for (const [lineno, line] of enumerate(lines, 1)) {
const parts = line.split(options.separator);
Function insertRecord
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
export default function insertRecord(report, record) {
let {kind} = report;
if (record.reference !== report.reference) {
throw new Error(
- 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 too many return
statements within this function. Open
return parseL5(parts, options);
Avoid too many return
statements within this function. Open
return parseL1(parts, options);
Avoid too many return
statements within this function. Open
return parseA5(parts, options);