Showing 45 of 81 total issues
Function reader
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function reader (stream, validationOptions = {}, nameSpace = '') {
const emitter = new class extends EventEmitter { }();
const nameSpacePrefix = nameSpace === '' ? nameSpace : `${nameSpace}:`;
MarcRecord.setValidationOptions(validationOptions);
Function to
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
export function to(record, {omitDeclaration = false, indent = false} = {}) {
const obj = {
record: {
...generateFields(),
$: {
- 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 start
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
function start() {
MarcRecord.setValidationOptions(validationOptions);
var buffer = ''; // eslint-disable-line
Function reader
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function reader(stream, validationOptions = {}) {
const emitter = new class extends EventEmitter { }();
MarcRecord.setValidationOptions(validationOptions);
start();
Function from
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
export async function from(str, validationOptions = {}) {
const record = new MarcRecord(undefined, validationOptions);
const obj = await toObject();
// eslint-disable-next-line functional/immutable-data
Function start
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
function start() {
// eslint-disable-next-line functional/no-let
let charbuffer = '';
stream.on('end', () => {
Function parseFieldFromLine
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
function parseFieldFromLine(lineStr) {
const tag = lineStr.substring(10, 13);
if (tag === undefined || tag.length !== 3) {
throw new Error(`Could not parse tag from line: ${lineStr}`);
Function recordFormat
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
function recordFormat(record, useCrForContinuingResource) {
const {leader} = record;
const l6 = leader.slice(6, 7);
const l7 = leader.slice(7, 8);
Function start
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
function start() {
let charbuffer = ''; // eslint-disable-line functional/no-let
stream.on('end', () => {
Function generateFields
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
function generateFields() {
return {
leader: [record.leader],
controlfield: record.getControlfields().map(({value: _, tag}) => {
if (_) {
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
Function findPeriodOffset
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
function findPeriodOffset(arr) {
let offset = find(); // eslint-disable-line functional/no-let
if (offset !== undefined) {
// Append the number of chars in separator
Function findSeparatorOffset
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
function findSeparatorOffset(arr) {
let offset = find(); // eslint-disable-line functional/no-let
if (offset !== undefined) {
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"
Further reading
Avoid too many return
statements within this function. Open
return 'MP';
Avoid too many return
statements within this function. Open
return 'SE';
Avoid too many return
statements within this function. Open
return true;
Avoid too many return
statements within this function. Open
return 'MU';