Showing 44 of 76 total issues
File period-instance.js
has 663 lines of code (exceeds 250 allowed). Consider refactoring. Open
import { chunk, head, last, range } from 'lodash';
import { Calendar } from './calendars/calendar';
export class PeriodInstance {
Function deducePeriodType
has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open
static deducePeriodType(periodId) {
let periodType;
const numberLikePeriod = parseInt(periodId, 10);
- 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 getChildrenPeriods
has 86 lines of code (exceeds 25 allowed). Consider refactoring. Open
getChildrenPeriods(parentId, parentType, childrenType, preferences) {
let periods = [];
switch (parentType) {
case 'Yearly': {
Function getRelativePeriods
has 85 lines of code (exceeds 25 allowed). Consider refactoring. Open
getRelativePeriods(type) {
switch (type) {
case 'RelativeBiMonth': {
return [
{ id: 'THIS_BIMONTH', type, name: 'This Bi-month' },
CalendarDate
has 27 functions (exceeds 20 allowed). Consider refactoring. Open
export class CalendarDate {
constructor(calendar, year, month, day) {
this._calendar = calendar;
this._year = year;
this._month = month;
PeriodInstance
has 27 functions (exceeds 20 allowed). Consider refactoring. Open
export class PeriodInstance {
constructor(calendarId, type, preferences, year) {
this._calendarId = calendarId || 'gregorian';
this._type = type;
this._preferences = preferences;
File base-calendar.js
has 295 lines of code (exceeds 250 allowed). Consider refactoring. Open
import {
CalendarDate
} from './calendar-date';
export class BaseCalender {
Function getCurrentPeriodId
has 73 lines of code (exceeds 25 allowed). Consider refactoring. Open
getCurrentPeriodId(type) {
switch (type) {
case 'Monthly': {
return this.getMonthPeriodId(
this._calendar.getCurrentYear(),
Function getSanitizedAnalyticsMetadata
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
getSanitizedAnalyticsMetadata(analyticMetadata, version) {
let sanitizedMetadata = {};
if (analyticMetadata) {
if (analyticMetadata.ouHierarchy) {
- 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 getChildrenPeriods
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
getChildrenPeriods(parentId, parentType, childrenType, preferences) {
let periods = [];
switch (parentType) {
case 'Yearly': {
- 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
BaseCalender
has 24 functions (exceeds 20 allowed). Consider refactoring. Open
export class BaseCalender {
constructor() {
this._validateLevel = 0;
this._name = '';
this._hasYearZero = false;
Function getPeriods
has 61 lines of code (exceeds 25 allowed). Consider refactoring. Open
getPeriods(type, year, offset = 0) {
let periods;
switch (type) {
case 'Monthly': {
Function _fetch
has 56 lines of code (exceeds 25 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", ' +
Function constructor
has 55 lines of code (exceeds 25 allowed). Consider refactoring. Open
constructor() {
super();
this._name = 'Ethiopian';
this._jdEpoch = 1723856;
this._gregorianEpoch = 1721426;
Function constructor
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
constructor() {
super();
this._name = 'Gregorian';
this._jdEpoch = 1721425.5;
this._daysPerMonth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
Function standardizeAnalytics
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
standardizeAnalytics(analyticsObject, version = 25) {
if (typeof version === 'boolean') {
if (version) {
version = 25;
} else {
Function standardizeAnalytics
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
standardizeAnalytics(analyticsObject, version = 25) {
if (typeof version === 'boolean') {
if (version) {
version = 25;
} 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 _add
has a Cognitive Complexity of 15 (exceeds 5 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)
- 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 deducePeriodType
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
static deducePeriodType(periodId) {
let periodType;
const numberLikePeriod = parseInt(periodId, 10);
Function getSanitizedAnalyticsMetadata
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
getSanitizedAnalyticsMetadata(analyticMetadata, version) {
let sanitizedMetadata = {};
if (analyticMetadata) {
if (analyticMetadata.ouHierarchy) {