Function sortByIndexTerms
has 54 lines of code (exceeds 25 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) {
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 sortByRelatorTerm
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
function sortByRelatorTerm(fieldA, fieldB) {
//if (!['600', '610', '611', '630', '700', '710', '711', '730', '800', '810', '811', '830'].includes(fieldA.tag)) {
if (!['700', '710', '711', '730'].includes(fieldA.tag)) {
return 0;
}
- 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 sortByOccurrenceNumber
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
function sortByOccurrenceNumber(fieldA, fieldB) { // Sort by subfield $6
function fieldGetOccurrenceNumber(field) { // should this function be exported? (based on validator sortRelatorFields.js)
if (!field.subfields) {
return 0;
Function sortByRelatorTerm
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
function sortByRelatorTerm(fieldA, fieldB) {
//if (!['600', '610', '611', '630', '700', '710', '711', '730', '800', '810', '811', '830'].includes(fieldA.tag)) {
if (!['700', '710', '711', '730'].includes(fieldA.tag)) {
return 0;
}
Function sortByOccurrenceNumber
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
function sortByOccurrenceNumber(fieldA, fieldB) { // Sort by subfield $6
function fieldGetOccurrenceNumber(field) { // should this function be exported? (based on validator sortRelatorFields.js)
if (!field.subfields) {
return 0;
- 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 -1;
Avoid too many return
statements within this function. Open
return 1;
Avoid too many return
statements within this function. Open
return -1;
Avoid too many return
statements within this function. Open
return -1;
Avoid too many return
statements within this function. Open
return -1;
Avoid too many return
statements within this function. Open
return 1;
Avoid too many return
statements within this function. Open
return 1;
Avoid too many return
statements within this function. Open
return 0;