gfw-api/gfw-viirs-fires-api

View on GitHub

Showing 6 of 34 total issues

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();
Severity: Major
Found in src/app.ts - About 2 hrs to fix

    Function getViirsAlerts has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

        static async getViirsAlerts(
            apiKey: string,
            alertQuery: string,
            queryParams: Record<string, any>,
            datasetIds: {
    Severity: Minor
    Found in src/services/datasetService.ts - About 2 hrs to fix

    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

    File datasetService.ts has 253 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import config from 'config';
    import logger from 'logger';
    import Mustache from 'mustache';
    import GeostoreService from 'services/geostoreService';
    import { RWAPIMicroservice } from "rw-api-microservice-node";
    Severity: Minor
    Found in src/services/datasetService.ts - About 2 hrs to fix

      Function getViirsAlerts has 43 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          static async getViirsAlerts(
              apiKey: string,
              alertQuery: string,
              queryParams: Record<string, any>,
              datasetIds: {
      Severity: Minor
      Found in src/services/datasetService.ts - About 1 hr to fix

        Function getAdm has 38 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            static async getAdm(apiKey: string, iso: string, forSubscription: string, period: string = defaultDate(), group: boolean = false, adm1: string = null, adm2: string = null): Promise<Record<string, any>> {
                logger.debug('Obtaining national of iso %s and period %s', iso, period);
                const periods: string[] = period.split(',');
                const params: {
                    iso: string;
        Severity: Minor
        Found in src/services/datasetService.ts - About 1 hr to fix

          Function use has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              static async use(ctx: Context): Promise<void> {
                  logger.info('Obtaining use data with name %s and id %s', ctx.params.name, ctx.params.id);
                  let useTable: string = null;
                  switch (ctx.params.name) {
                      case 'mining':
          Severity: Minor
          Found in src/routes/firesv1.router.ts - About 1 hr to fix
            Severity
            Category
            Status
            Source
            Language