Function contentTypeByMimeString
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
export function contentTypeByMimeString(contentType: string, ext: string): string | undefined {
if (contentType.includes(F_NTRIPLES) || contentType.includes(F_NTRIPLES_DEP)) {
return F_NTRIPLES;
} else if (contentType.includes(F_PLAIN) && ["ntriples", "nt"].indexOf(ext) >= 0) {
return F_NTRIPLES;
- 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 getContentType
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
export function getContentType(res: ResponseAndFallbacks): string {
const contentTypeRaw = getHeader(res, "Content-Type");
if (contentTypeRaw === undefined || contentTypeRaw === null) {
return "";
}
- 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 ext;
Avoid too many return
statements within this function. Open
return undefined;
Avoid too many return
statements within this function. Open
return F_RDF_XML;
Avoid too many return
statements within this function. Open
return F_JSONLD;
Function getHeader
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
export function getHeader(res: ResponseAndFallbacks, header: string): string | null {
if (res instanceof Response) {
return res.headers.get(header);
} else if (typeof XMLHttpRequest !== "undefined" && res instanceof XMLHttpRequest) {
return (res as XMLHttpRequest).getResponseHeader(header) || null;
- 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"