Showing 44 of 76 total issues
Function _add
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
_add(yearOrDate, month, day) {
this._validateLevel++;
if (day === 'd' || day === 'w') {
const d = yearOrDate.fromJD(
yearOrDate.toJD() + month * (day === 'w' ? this.daysInWeek() : 1)
Function getSixMonthlyNovemberPeriods
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
getSixMonthlyNovemberPeriods(year) {
return chunk(
this.getMonthsByOffset(
this.getMonthWithYears(this._monthNames, year, -2),
this._quarterMonthOffset
Function getQuarterlyPeriods
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
getQuarterlyPeriods(year) {
return chunk(
this.getMonthsByOffset(
this.getMonthWithYears(
this._monthNames,
Function getSixMonthlyAprilPeriods
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
getSixMonthlyAprilPeriods(year) {
const months = this.getMonthWithYears(this._monthNames, year + 1, -9);
return (
chunk([...months.slice(3), ...months.slice(0, 3)] || [], 6) || []
Function _fetch
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
_fetch(fetcher, resolve, reject) {
if (!_instance) {
let error =
'Configuration not set please configure function ' +
'analytics eg {baseUrl:"dhis_base_url", username:"username", ' +
- 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 getYearlyPeriods
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
getYearlyPeriods(year, type, idSuffix = '', monthIndex = -1) {
return range(10)
.map(yearIndex => {
const periodYear = parseInt(year, 10) - yearIndex;
const id = this.getYearlyPeriodId(periodYear, idSuffix);
Function getBiMonthlyPeriods
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
getBiMonthlyPeriods(year) {
return (chunk(this._monthNames || [], 2) || []).map(
(biMonths, biMonthIndex) => {
const id = this.getBiMonthlyPeriodId(year, biMonthIndex + 1);
Function getSixMonthlyPeriods
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
getSixMonthlyPeriods(year) {
return (chunk(this._monthNames || [], 6) || []).map(
(sixMonths, sixMonthIndex) => {
const id = this.getSixMonthlyPeriodId(year, sixMonthIndex + 1);
Function url
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
get url() {
var url = this._urlParameters;
this._filters.forEach(filter => {
if (url !== '') {
Function getCurrentPeriodId
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
getCurrentPeriodId(type) {
switch (type) {
case 'Monthly': {
return this.getMonthPeriodId(
this._calendar.getCurrentYear(),
- 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 _correctAdd
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
_correctAdd(a, b, c, d) {
if (!this._hasYearZero && (d === 'y' || d === 'm')) {
if (b[0] === 0 || a.year() > 0 !== b[0] > 0) {
const e = {
y: [1, 1, 'y'],
- 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 compareTo
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
compareTo(instance) {
let comparer = this._year - instance._year;
if (this._year === instance._year) {
comparer = this._day - instance._day;
- 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 [
{ id: 'THIS_FINANCIAL_YEAR', type, name: 'This Financial Year' },
{
id: 'LAST_FINANCIAL_YEAR',
type,
Avoid too many return
statements within this function. Open
return this.getSixMonthlyPeriodId(
this._calendar.getCurrentYear(),
this._sixmonthApril,
'April'
);
Avoid too many return
statements within this function. Open
return [
{ id: 'THIS_WEEK', type, name: 'This Week' },
{ id: 'LAST_WEEK', type, name: 'Last Week' },
{
id: 'LAST_4_WEEKS',
Avoid too many return
statements within this function. Open
return this.getYearlyPeriodId(
this._month >= 10 ? currentYear : currentYear - 1,
'FinancialOctober'
);
Avoid too many return
statements within this function. Open
return [
{ id: 'THIS_YEAR', type, name: 'This Year' },
{
id: 'LAST_YEAR',
type,
Avoid too many return
statements within this function. Open
return this.getSixMonthlyPeriodId(
this._calendar.getCurrentYear(),
this._sixMonthNovember,
'Nov'
);
Avoid too many return
statements within this function. Open
return this.getYearlyPeriodId(
this._month >= 7 ? currentYear : currentYear - 1,
'FinancialJuly'
);
Avoid too many return
statements within this function. Open
return this.getYearlyPeriodId(
this._month >= 11 ? currentYear : currentYear - 1,
'FinancialNovember'
);