Showing 49 of 101 total issues
Function vonLastFirst
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
function vonLastFirst(authorTokens) {
let commaPos = -1;
for (let i = 0; i < authorTokens.length; i++)
if (authorTokens[i].type == ',') {
commaPos = 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
Function flatten
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
function flatten(obj) {
if (typeof obj === 'object' &&
(obj.type == 'quotedstring' ||
obj.type == 'quotedstringwrapper' ||
obj.type == 'bracedstringwrapper')
Function render
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
render() {
const obj = this.props.entry;
const isEntry = (obj instanceof Entry);
if (!isEntry) throw new Error("Object must be of type Entry: " + JSON.stringify(obj));
Function joinTokens
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function joinTokens(arr){
var strs = [];
for(var i=0;i<arr.length;i++){
if(typeof arr[i] == 'object'){
if(!arr[i].string) throw new Error("Expected token to have a string field called 'string' in object "+JSON.stringify(arr[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
Function firstVonLast
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function firstVonLast(authorTokens) {
let vonStartInclusive = -1;
let vonEndExclusive = -1;
let firstNameEndExclusive = -1;
for (let i = 0; i < authorTokens.length - 1; i++) {// -1 because last word must be lastName
- 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
Consider simplifying this complex logical expression. Open
if (wordSegment.type == 'braced'
&& wordSegment.data[0]
&& wordSegment.data[0].constructor == Array
&& wordSegment.data[0].length == 1
&& typeof wordSegment.data[0][0] == 'string'
Function joinSimpleString
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
static joinSimpleString(data) {
if (typeof data === 'string') return data;
else if (data.constructor == Array) {
const str = [];
for (let i = 0; i < data.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
if (Number.isFinite(number)) return number;
Avoid too many return
statements within this function. Open
else if (wordObj.unicode) return getFirstLetter(wordObj.unicode);
Avoid too many return
statements within this function. Open
else return new Token(NUMBER, numString);
Avoid too many return
statements within this function. Open
else if (typeof data.data == 'string') return data.string;
Avoid too many return
statements within this function. Open
else if (typeof obj === 'object' && obj.type == 'quotedstring') return StringValue.computeUnicodeString(braceDepth, obj.data);
Avoid too many return
statements within this function. Open
return new Token(ID, chars.join("").trim());
Avoid too many return
statements within this function. Open
else if (authorToken.constructor == Array) return authorToken.map(flattenToString).join('');
Avoid too many return
statements within this function. Open
else if (typeof obj === 'string') return obj;
Avoid too many return
statements within this function. Open
return StringValue.computeUnicodeString(braceDepth, obj.data.map(o => {
if (!o) throw new Error("Expected non-null elements in " + JSON.stringify(o));
//console.log("braced", obj.data);
return StringValue.computeUnicodeString(braceDepth + 1, o)
}));
Avoid too many return
statements within this function. Open
else if (typeof obj === 'object' && obj.unicode) return obj.unicode;
Avoid too many return
statements within this function. Open
else if (obj.constructor === Number) return obj + "";
Avoid too many return
statements within this function. Open
if (specialChar) return specialChar(specialChar);
Avoid too many return
statements within this function. Open
else if (wordObj.constructor == Array) return getFirstLetter(flattenToString(wordObj).trim());