Function to
has a Cognitive Complexity of 186 (exceeds 5 allowed). Consider refactoring. Open
export function to(record, useCrForContinuingResource = false) {
const MAX_FIELD_LENGTH = 2000;
const SPLIT_MAX_FIELD_LENGTH = 1000;
- 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 to
has 261 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function to(record, useCrForContinuingResource = false) {
const MAX_FIELD_LENGTH = 2000;
const SPLIT_MAX_FIELD_LENGTH = 1000;
File aleph-sequential.js
has 466 lines of code (exceeds 250 allowed). Consider refactoring. Open
/* eslint-disable max-lines */
/**
*
* @licstart The following is the entire license notice for the JavaScript code in this file.
*
Function formatDatafield
has 168 lines of code (exceeds 25 allowed). Consider refactoring. Open
function formatDatafield(field) {
let subfieldLines; // eslint-disable-line functional/no-let
const ind1 = field.ind1 && field.ind1.length > 0 ? field.ind1 : ' ';
const ind2 = field.ind2 && field.ind2.length > 0 ? field.ind2 : ' ';
const header = `${id} ${field.tag}${ind1}${ind2} L `;
Function reduceToLines
has 144 lines of code (exceeds 25 allowed). Consider refactoring. Open
function reduceToLines(result, subfield, index, arr) {
let code; // eslint-disable-line functional/no-let
let sliceOffset; // eslint-disable-line functional/no-let
let slicedSegment; // eslint-disable-line functional/no-let
const tempLength = result.temp ? result.temp.length : 0;
Function from
has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring. Open
export function from(data, validationOptions = {}) {
let i = 0; // eslint-disable-line functional/no-let
const lines = data.split('\n').filter(l => l.length > 0);
// eslint-disable-next-line functional/no-loop-statements
- 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 iterate
has 110 lines of code (exceeds 25 allowed). Consider refactoring. Open
function iterate(segment, firstCall) {
const HYPHEN = 45;
const SPACE = 32;
const CARET = 94;
const DOLLAR = 36;
Function from
has 109 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function from(data, validationOptions = {}) {
let i = 0; // eslint-disable-line functional/no-let
const lines = data.split('\n').filter(l => l.length > 0);
// eslint-disable-next-line functional/no-loop-statements
Function reader
has 82 lines of code (exceeds 25 allowed). Consider refactoring. Open
export function reader(stream, validationOptions = {}, genF001fromSysNo = false) {
const emitter = new class extends EventEmitter { }();
start();
return emitter;
Function getSliceOffset
has 78 lines of code (exceeds 25 allowed). Consider refactoring. Open
function getSliceOffset(arr) {
const offset = findSeparatorOffset(arr) || findPeriodOffset(arr) || findSpaceOffset(arr) || SPLIT_MAX_FIELD_LENGTH;
return offset;
Function start
has 77 lines of code (exceeds 25 allowed). Consider refactoring. Open
function start() {
let charbuffer = ''; // eslint-disable-line functional/no-let
const linebuffer = []; // eslint-disable-line functional/no-let
let count = 0; // eslint-disable-line functional/no-let
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 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 too many return
statements within this function. Open
return 'SE';
Avoid too many return
statements within this function. Open
return 'VM';
Avoid too many return
statements within this function. Open
return 'MX';
Avoid too many return
statements within this function. Open
return 'MU';
Avoid too many return
statements within this function. Open
return 'MP';
Avoid too many return
statements within this function. Open
return 'BK';
Avoid too many return
statements within this function. Open
return true;
Similar blocks of code found in 2 locations. Consider refactoring. Open
function findSeparatorOffset(arr) {
let offset = find(); // eslint-disable-line functional/no-let
if (offset !== undefined) {
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 238.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. 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
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 238.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76