gfw-api/gfw-subscription-api

View on GitHub

Showing 129 of 129 total issues

Avoid too many return statements within this function.
Open

            return null;
Severity: Major
Found in app/src/services/analysisService.js - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

        return null;
    Severity: Major
    Found in app/src/services/imageService.js - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

                  return GeostoreService.getGeostoreFromUseId(params.use, params.useid);
      Severity: Major
      Found in app/src/services/geostoreService.js - About 30 mins to fix

        Function searchImage has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        const searchImage = (story) => {
            if (story.media) {
                for (let i = 0, { length } = story.media; i < length; i++) {
                    if (story.media[i].previewUrl) {
                        return DOMAIN_IMAGE + story.media[i].previewUrl;
        Severity: Minor
        Found in app/src/adapters/storyAdapter.js - About 25 mins 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

        Function validateSubscription has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            static validateSubscription(subs) {
                if ((!subs.datasets || subs.datasets.length === 0) && (!subs.datasetsQuery || subs.datasetsQuery.length === 0)) {
                    return 'Datasets or datasetsQuery required';
                }
                if (!subs.language) {
        Severity: Minor
        Found in app/src/routes/api/v1/subscription.router.js - About 25 mins 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

        Function calculateAlertFrequency has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            static async calculateAlertFrequency(thisYearAlerts, lastYearAlerts, lang) {
                const lastYearAverage = _.mean(lastYearAlerts.map((al) => al.alert__count));
                const lastYearStdDev = EmailHelpersService.standardDeviation(lastYearAlerts.map((al) => al.alert__count));
                const currentAvg = _.mean(thisYearAlerts.map((al) => al.alert__count));
        
        
        Severity: Minor
        Found in app/src/services/emailHelpersService.js - About 25 mins 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

        Function checkUpdated has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            static async checkUpdated(dataset) {
                logger.info(`Checking if dataset ${dataset} was updated`);
                try {
                    const result = await ctRegisterMicroservice.requestToMicroservice({
                        uri: `/${dataset}/latest`,
        Severity: Minor
        Found in app/src/services/updateService.js - About 25 mins 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

        Function execute has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            static async execute(subscription, layerSlug, begin, end, forSubscription) {
        
                logger.info('Executing analysis for', layerSlug, begin, end);
        
                const period = `${formatDate(begin)},${formatDate(end)}`;
        Severity: Minor
        Found in app/src/services/analysisService.js - About 25 mins 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

        Function findAllSubscriptions has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            static async findAllSubscriptions(ctx) {
                logger.info(`[SubscriptionsRouter] Getting ALL subscriptions`);
        
                const page = ctx.query.page && ctx.query.page.number ? parseInt(ctx.query.page.number, 10) : 1;
                const limit = ctx.query.page && ctx.query.page.size ? parseInt(ctx.query.page.size, 10) : 10;
        Severity: Minor
        Found in app/src/routes/api/v1/subscription.router.js - About 25 mins 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

        Severity
        Category
        Status
        Source
        Language