Showing 11 of 31 total issues
Function getNational
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
async getNational(iso: string, thresh: string, period: string): Promise<Record<string, any>> {
const data: Record<string, any> = await executeThunk(this.client, ISO, {
iso,
thresh
});
- 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 getSubnational
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
async getSubnational(iso: string, id1: string, thresh: string, period: string): Promise<Record<string, any>> {
const data: Record<string, any> = await executeThunk(this.client, ID1, {
iso,
id1,
thresh
- 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 init
has 61 lines of code (exceeds 25 allowed). Consider refactoring. Open
const init: () => Promise<IInit> = async (): Promise<IInit> => {
return new Promise((resolve: (value: IInit | PromiseLike<IInit>) => void
) => {
const app: Koa = new Koa();
Function fetchData
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
static async fetchData(ctx: Context): Promise<void> {
logger.info('Obtaining data for', ctx.params);
const thresh: string = (ctx.query.thresh as string) || '30';
const period: string[] = ctx.query.period ? (ctx.query.period as string).split(',').map((el: string) => el.trim()) : [];
const iso: string = (ctx.params.iso as string) || null;
Function getSubnational
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
async getSubnational(iso: string, id1: string, thresh: string, period: string): Promise<Record<string, any>> {
const data: Record<string, any> = await executeThunk(this.client, ID1, {
iso,
id1,
thresh
Function getNational
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
async getNational(iso: string, thresh: string, period: string): Promise<Record<string, any>> {
const data: Record<string, any> = await executeThunk(this.client, ISO, {
iso,
thresh
});
Function fetchData
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
static async fetchData(ctx: Context): Promise<void> {
logger.info('Obtaining data for', ctx.params);
const thresh: string = (ctx.query.thresh as string) || '30';
const period: string[] = ctx.query.period ? (ctx.query.period as string).split(',').map((el: string) => el.trim()) : [];
const iso: string = (ctx.params.iso as string) || 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 fetchData
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
async fetchData(params: Record<string, any>, apiKey: string): Promise<Record<string, any> | Array<void>> {
let baseData: Record<string, any> = await ElasticService.getData(BASE_QUERY, params, apiKey);
if (!baseData || !baseData.data || baseData.data.length === 0) {
logger.error('No base data found.');
baseData = [];
Function getData
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
static async getData(sqlTemplate: string, params: Record<string, any>, apiKey: string): Promise<Record<string, any>> {
const { adm1, adm2 } = params;
const sql: string = sqlTemplate.replace('{location}', getLocationString(params))
.replace('{vars}', getLocationVars(params))
.replace('{threshold}', params.thresh);
Function fetchData
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
async fetchData(params: Record<string, any>, apiKey: string): Promise<Record<string, any> | Array<void>> {
let baseData: Record<string, any> = await ElasticService.getData(BASE_QUERY, params, apiKey);
if (!baseData || !baseData.data || baseData.data.length === 0) {
logger.error('No base data found.');
baseData = [];
- 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 validatePeriod
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
static validatePeriod(period: string[]): boolean {
if (period.length && (!moment(period[0], DATE_FORMAT, true).isValid() || !moment(period[1], DATE_FORMAT, true).isValid())) {
logger.error('Period must be in the format: YYYY-MM-DD,YYYY-MM-DD');
throw new InvalidPeriod('Period must be in the format: YYYY-MM-DD,YYYY-MM-DD');
- 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"