Showing 830 of 830 total issues
Similar blocks of code found in 3 locations. Consider refactoring. Open
const record = new MarcRecord({
fields: [
{tag: '001', value: '1234567'},
{tag: '500', ind1: ' ', ind2: ' ',
subfields: [
- 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 65.
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
const data = {tag: '337', ind1: ' ', ind2: ' ', subfields: [
{code: 'a', value: a},
{code: 'b', value: b},
{code: '2', value: 'rdamedia'}
]};
- 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 65.
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 4 locations. Consider refactoring. Open
const f337nonElectronic = {
tag: '337',
ind1: ' ',
ind2: ' ',
subfields: [
- 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 65.
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 fix(record) {
record.fields.forEach(field => {
normalizeQualifyingInformationField(field);
});
- 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 65.
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
Function recordMatchesConfigElement
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
function recordMatchesConfigElement(record, searchedField, confObj, dependencies) {
const foundFields = record.get(searchedField);
// If field has dependencies and fields matching configuration is not found
if (foundFields.length === 0 && confObj.dependencies) {
return false;
Function sortByIndexTerms
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
function sortByIndexTerms(fieldA, fieldB) { // eslint-disable-line complexity, max-statements
const indexTermFields = ['600', '610', '611', '630', '648', '650', '651', '652', '653', '654', '655', '656', '657', '658', '659', '662'];
function scoreInd2(val) {
- 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 getNormalizedValue
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
function getNormalizedValue(subfield, field) {
return uppercaseLanguage(handleMovies(handleInitials(subfield.value, subfield.code, field)));
function handleMovies(value) {
- 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 default
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
export default function (tagPattern) {
return {
description: 'Swap adjacent subfields',
validate, fix
Function excludeFields
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
function excludeFields(record, conf, fix) {
const res = {message: [], valid: true};
// Parse trough every element of config array
forEach(conf, ([, confObj]) => {
Function mergePrintData
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
function mergePrintData(value1, value2) {
const [index1, print1, year1] = value1.split(' ');
const [index2, print2, year2] = value2.split(' ');
const betterIndex = index1 ? index1 : index2; // just to cheat eslint...
Function default
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
export default function () {
return {
description: 'Justify left and sort character groups within 008/18-24',
validate, fix
Function validateField
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
function validateField(value, spec, tag) {
const messagePrefix = tag ? `Field ${tag}` : 'Leader';
if (typeof spec.length === 'number') {
if (value.length !== spec.length) {
Function getRelevantFields
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
function getRelevantFields(record) {
//return record.get(/^(?:020|022)$/u).filter(field => {
return record.fields.filter(field => {
if (!field.subfields) {
return false;
Function default
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
export default function (tagPattern) {
if (tagPattern instanceof RegExp) {
return {
description:
'Handles data fields that only differ in the first indicator',
Function processCharacterGroup
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
function processCharacterGroup(field, group) {
const originalContent = field.value.substring(group.start, group.end + 1);
const content = removeDuplicateValues(fixBlanks(originalContent));
//console.info(`008/${group.start}-${group.end}: '${originalContent}'`); // eslint-disable-line no-console
const charArray = content.split('');
Function default
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
export default function () {
const PATTERN = Object.keys(MAP_CONVERSION).reduce((result, key, index, list) => index === list.length - 1 ? new RegExp(`${result}${key})`, 'u') : `${result}${key}|`, '(');
return {
description: 'Unicode decomposer',
Function default
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
export default function () {
return {
description: 'Handles subfields that contains non-breaking space character',
validate,
fix
Function default
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
export default function () {
// NB! We should and could handle ISNIs here as well.
return {
description: 'Normalizes identifiers such as subfield $0 values',
Similar blocks of code found in 2 locations. Consider refactoring. Open
function normalizeNonFilingIndicator2(field, languages = []) {
if (!hasNonFilingIndicator2(field) || !modifiableIndicatorValue(field.ind2)) {
return;
}
- 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 61.
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 normalizeNonFilingIndicator1(field, languages = []) {
if (!hasNonFilingIndicator1(field) || !modifiableIndicatorValue(field.ind1)) {
return;
}
- 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 61.
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