Showing 4 of 4 total issues
Function fetch
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
export async function fetch (options: SimpleSiteOptions): Promise<CanteenPlan[]> {
const ids = options.canteens ?? CANTEEN_IDS
const weeks = options.dates != null
? convertToWeeks(options.dates.filter(isDateSupported))
: [getCurrentWeek()]
- 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 parseMetadata
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
export function parseMetadata (json: UnparsedMetadata): Canteen[] {
const canteens: Canteen[] = []
if (json.mensa == null) return canteens
- 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 guessYear
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
function guessYear (refYear: number, refMonth: number, month: number): number {
// split the reference year into 3 sections and check whether the given month
// lies reasonably close to the reference third;
// if it does, year is probably the reference year;
// otherwise, it is the previous or the next year, depending on the section.
- 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 findCookie
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
function findCookie (headers?: AxiosResponseHeaders | RawAxiosResponseHeaders): string | undefined {
const setCookie = headers != null ? headers['set-cookie'] : undefined
if (setCookie == null) {
return undefined
}
- 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"