gfw-api/fw-contextual-layers

View on GitHub

Showing 13 of 23 total issues

Function exports has 64 lines of code (exceeds 25 allowed). Consider refactoring.
Open

module.exports = (grunt) => {

    grunt.file.setBase('..');
    // eslint-disable-next-line import/no-extraneous-dependencies
    require('load-grunt-tasks')(grunt);
Severity: Major
Found in app/Gruntfile.js - About 2 hrs to fix

    Function exports has 42 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    module.exports = (() => {
    
        const loadAPI = (app, path, pathApi) => {
            const routesFiles = fs.readdirSync(path);
            let existIndexRouter = false;
    Severity: Minor
    Found in app/src/loader.js - About 1 hr to fix

      Function filterImgData has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          static filterImgData(data, {
              w, h, z, startYear, endYear
          }) {
              const components = 4;
              const exp = z < 11 ? 0.3 + ((z - 3) / 20) : 1;
      Severity: Minor
      Found in app/src/lossLayer.protocol.js - About 1 hr 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 loadAPI has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          const loadAPI = (app, path, pathApi) => {
              const routesFiles = fs.readdirSync(path);
              let existIndexRouter = false;
              routesFiles.forEach((file) => {
                  const newPath = path ? (`${path}/${file}`) : file;
      Severity: Minor
      Found in app/src/loader.js - About 1 hr to fix

        Function deleteLayer has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            static async deleteLayer(ctx) {
                const { layerId } = ctx.params;
                logger.info(`Delete layer with id ${layerId}`);
                let layer = null;
                try {
        Severity: Minor
        Found in app/src/routes/api/v1/layer.router.js - About 1 hr to fix

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

              static async patchLayer(ctx) {
                  logger.info('Patch layer by id');
                  const { layerId } = ctx.params;
                  const { body } = ctx.request;
                  let layer = null;
          Severity: Minor
          Found in app/src/routes/api/v1/layer.router.js - About 1 hr to fix

            Function createTeamLayer has 29 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                static async createTeamLayer(ctx) {
                    logger.info('Create team layer');
                    const owner = { type: LayerService.type.TEAM, id: ctx.params.teamId };
                    let team = null;
                    try {
            Severity: Minor
            Found in app/src/routes/api/v1/layer.router.js - About 1 hr to fix

              Function getCanvasTile has 28 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  async getCanvasTile({
                      z, x, y, startYear, endYear
                  }) {
                      'use asm';
              
              
              Severity: Minor
              Found in app/src/lossLayer.protocol.js - About 1 hr to fix

                Function getAll has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    static async getAll(ctx) {
                        logger.info('Get all layers');
                        const userId = ctx.request.body.user.id;
                        const enabled = typeof ctx.request.query.enabled !== 'undefined'
                            ? { enabled: ctx.request.query.enabled }
                Severity: Minor
                Found in app/src/routes/api/v1/layer.router.js - About 1 hr to fix

                  Function deleteLayer has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                  Open

                      static async deleteLayer(ctx) {
                          const { layerId } = ctx.params;
                          logger.info(`Delete layer with id ${layerId}`);
                          let layer = null;
                          try {
                  Severity: Minor
                  Found in app/src/routes/api/v1/layer.router.js - About 55 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 exports has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                  Open

                  module.exports = (() => {
                  
                      const loadAPI = (app, path, pathApi) => {
                          const routesFiles = fs.readdirSync(path);
                          let existIndexRouter = false;
                  Severity: Minor
                  Found in app/src/loader.js - About 55 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 createTeamLayer has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                  Open

                      static async createTeamLayer(ctx) {
                          logger.info('Create team layer');
                          const owner = { type: LayerService.type.TEAM, id: ctx.params.teamId };
                          let team = null;
                          try {
                  Severity: Minor
                  Found in app/src/routes/api/v1/layer.router.js - About 55 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 patchLayer has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                      static async patchLayer(ctx) {
                          logger.info('Patch layer by id');
                          const { layerId } = ctx.params;
                          const { body } = ctx.request;
                          let layer = null;
                  Severity: Minor
                  Found in app/src/routes/api/v1/layer.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