resource-watch/converter

View on GitHub

Showing 31 of 41 total issues

Function obtainFSFromAST has a Cognitive Complexity of 55 (exceeds 5 allowed). Consider refactoring.
Open

    static obtainFSFromAST(parsed) {
        logger.info('Generating FeatureService object from ast object');
        let fs = {};

        if (parsed.select && parsed.select.length > 0) {
Severity: Minor
Found in app/src/services/converterService.js - About 1 day 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 converterService.js has 408 lines of code (exceeds 250 allowed). Consider refactoring.
Open

const logger = require('logger');
const SQLService = require('services/sqlService');
const { geojsonToArcGIS } = require('arcgis-to-geojson-utils');
const { arcgisToGeoJSON } = require('arcgis-to-geojson-utils');
const Sql2json = require('sql2json').sql2json;
Severity: Minor
Found in app/src/services/converterService.js - About 5 hrs to fix

    Function sql2SQL has 94 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        static async sql2SQL(data, apiKey, isRaster = false, experimental = false) {
            logger.debug('Converting sql to sql', data);
            const parsed = new Sql2json(data.sql, experimental).toJSON();
            if (!parsed) {
                return SQLService.generateError('Malformed query');
    Severity: Major
    Found in app/src/services/sqlService.js - About 3 hrs to fix

      Function obtainFSFromAST has 85 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          static obtainFSFromAST(parsed) {
              logger.info('Generating FeatureService object from ast object');
              let fs = {};
      
              if (parsed.select && parsed.select.length > 0) {
      Severity: Major
      Found in app/src/services/converterService.js - About 3 hrs to fix

        Function obtainSelect has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
        Open

            static obtainSelect(fs) {
                let result = '';
                if (!fs.outFields && !fs.outStatistics) {
                    return '*';
                }
        Severity: Minor
        Found in app/src/services/converterService.js - About 3 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

        Function findIntersect has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
        Open

            static findIntersect(node, found, result) {
                if (node && node.type === 'string' && node.value && found) {
                    try {
                        const geojson = JSON.parse(node.value);
                        if (!result) {
        Severity: Minor
        Found in app/src/services/converterService.js - 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

        Function exports has 70 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 obtainWhere has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
          Open

              static async obtainWhere(params, apiKey) {
                  const fs = params;
                  let where = '';
                  if (fs.where) {
                      if (!where) {
          Severity: Minor
          Found in app/src/services/converterService.js - 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

          Function sql2SQL has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

              static async sql2SQL(data, apiKey, isRaster = false, experimental = false) {
                  logger.debug('Converting sql to sql', data);
                  const parsed = new Sql2json(data.sql, experimental).toJSON();
                  if (!parsed) {
                      return SQLService.generateError('Malformed query');
          Severity: Minor
          Found in app/src/services/sqlService.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 init has 42 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          async function init() {
              return new Promise((resolve) => {
          
                  const app = new Koa();
          
          
          Severity: Minor
          Found in app/src/app.js - About 1 hr 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 obtainWhere has 38 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  static async obtainWhere(params, apiKey) {
                      const fs = params;
                      let where = '';
                      if (fs.where) {
                          if (!where) {
              Severity: Minor
              Found in app/src/services/converterService.js - About 1 hr to fix

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

                    static findIntersect(node, found, result) {
                        if (node && node.type === 'string' && node.value && found) {
                            try {
                                const geojson = JSON.parse(node.value);
                                if (!result) {
                Severity: Minor
                Found in app/src/services/converterService.js - About 1 hr to fix

                  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 obtainSelect has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        static obtainSelect(fs) {
                            let result = '';
                            if (!fs.outFields && !fs.outStatistics) {
                                return '*';
                            }
                    Severity: Minor
                    Found in app/src/services/converterService.js - About 1 hr to fix

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

                          static async sql2FS(params, apiKey) {
                              const sql = params.sql.trim();
                              logger.info('Creating featureservice from sql', sql);
                              const parsed = new Sql2json(sql).toJSON();
                              if (!parsed) {
                      Severity: Minor
                      Found in app/src/services/converterService.js - About 1 hr to fix

                        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

                        Avoid deeply nested control flow statements.
                        Open

                                                if (node.alias) {
                                                    obj.outStatisticFieldName = node.alias;
                                                }
                        Severity: Major
                        Found in app/src/services/converterService.js - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                              if (outFields !== '') {
                                                  outFields += ',';
                                              }
                          Severity: Major
                          Found in app/src/services/converterService.js - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                                for (let j = 0, { length: argumentsLength } = node.arguments; j < argumentsLength; j++) {
                                                    const argument = node.arguments[j];
                                                    if (outFields !== '') {
                                                        outFields += ',';
                                                    }
                            Severity: Major
                            Found in app/src/services/converterService.js - About 45 mins to fix
                              Severity
                              Category
                              Status
                              Source
                              Language