Showing 22 of 41 total issues
File timeslot.js
has 393 lines of code (exceeds 250 allowed). Consider refactoring. Open
const HashLru = require('hashlru');
const instances = HashLru(1e3);
/**
Function _getEpidemiologicWeekEpoch
has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open
static _getEpidemiologicWeekEpoch(year, periodicity) {
var SUNDAY = 0,
MONDAY = 1,
TUESDAY = 2,
WEDNESDAY = 3,
- 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 firstDate
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
get firstDate() {
if (!this._firstDate) {
if (this._periodicity === 'day') this._firstDate = new Date(this._value + 'T00:00:00Z');
else if (
this._periodicity === 'month_week_sat' ||
- 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 lastDate
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
get lastDate() {
if (!this._lastDate) {
if (this._periodicity === 'day')
// last day is current day
this._lastDate = this.firstDate;
- 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 fromDate
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
static fromDate(utcDate, periodicity) {
if (typeof utcDate === 'string') utcDate = new Date(utcDate);
if (periodicity === 'day') return TimeSlot.fromValue(utcDate.toISOString().substring(0, 10));
else if (
- 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 lastDate
has 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
get lastDate() {
if (!this._lastDate) {
if (this._periodicity === 'day')
// last day is current day
this._lastDate = this.firstDate;
Function _getEpidemiologicWeekEpoch
has 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
static _getEpidemiologicWeekEpoch(year, periodicity) {
var SUNDAY = 0,
MONDAY = 1,
TUESDAY = 2,
WEDNESDAY = 3,
Function firstDate
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
get firstDate() {
if (!this._firstDate) {
if (this._periodicity === 'day') this._firstDate = new Date(this._value + 'T00:00:00Z');
else if (
this._periodicity === 'month_week_sat' ||
Function fromDate
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
static fromDate(utcDate, periodicity) {
if (typeof utcDate === 'string') utcDate = new Date(utcDate);
if (periodicity === 'day') return TimeSlot.fromValue(utcDate.toISOString().substring(0, 10));
else if (
Function constructor
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
constructor(value, check = false) {
this._value = value;
this._firstDate = null;
this._lastDate = null;
this._previous = 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"
Further reading
Function constructor
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
constructor(value, check = false) {
this._value = value;
this._firstDate = null;
this._lastDate = null;
this._previous = null;
Function toChildPeriodicity
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
toChildPeriodicity(newPeriodicity) {
if (!this._children[newPeriodicity]) {
if (this._periodicity === 'all')
throw new Error('Would yield an infinite amount of children');
- 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 toParentPeriodicity
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
toParentPeriodicity(newPeriodicity) {
if (!this._parents[newPeriodicity]) {
if (newPeriodicity == this._periodicity) {
this._parents[newPeriodicity] = this;
} else {
- 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 humanizeValue
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
humanizeValue(periodicity, value) {
const year = value.substring(0, 4);
switch (periodicity) {
case 'all':
Function humanizeValue
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
humanizeValue(periodicity, value) {
const year = value.substring(0, 4);
switch (periodicity) {
case 'all':
Avoid deeply nested control flow statements. Open
if (month2 < 10) month2 = '0' + month2;
Avoid deeply nested control flow statements. Open
} else if (this._periodicity === 'year')
this._firstDate = new Date(this._value + '-01-01T00:00:00Z');
else if (this._periodicity === 'all') this._firstDate = new Date(-8640000000000000);
Avoid too many return
statements within this function. Open
return TimeSlot.fromValue(
utcDate.getUTCFullYear().toString() +
'-S' +
(1 + Math.floor(utcDate.getUTCMonth() / 6)).toString()
);
Avoid too many return
statements within this function. Open
return TimeSlot.fromValue(utcDate.toISOString().substring(0, 7));
Avoid too many return
statements within this function. Open
else if (periodicity === 'all') return TimeSlot.fromValue('all');