server/core/lib/timeserie.ts
Function buildGroupInterval
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
Open
function buildGroupInterval (startDate: Date, endDate: Date): string {
const aYear = 31536000
const aMonth = 2678400
const aDay = 86400
const anHour = 3600
- 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
Open
if (diffSeconds >= 15 * aDay) return '1 day'
Avoid too many return
statements within this function. Open
Open
return '1 minute'
Avoid too many return
statements within this function. Open
Open
if (diffSeconds >= 15 * anHour) return '1 hour'
Avoid too many return
statements within this function. Open
Open
if (diffSeconds >= 180 * aMinute) return '10 minutes'
Avoid too many return
statements within this function. Open
Open
if (diffSeconds >= 8 * aDay) return '12 hours'
Avoid too many return
statements within this function. Open
Open
if (diffSeconds >= 4 * aDay) return '6 hours'
Function buildGroupByAndBoundaries
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Open
function buildGroupByAndBoundaries (startDateString: string, endDateString: string) {
const startDate = new Date(startDateString)
const endDate = new Date(endDateString)
const groupInterval = buildGroupInterval(startDate, endDate)
- 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"