weacast/weacast-core

View on GitHub

Showing 15 of 15 total issues

Function initializeElements has 64 lines of code (exceeds 50 allowed). Consider refactoring.
Open

export default async function initializeElements (app, forecast, servicesPath) {
  logger.info('Initializing ' + forecast.name + ' forecast')
  const forecastsService = app.getService('forecasts')
  // Register the forecast model if not already done
  const result = await forecastsService.find({
Severity: Major
Found in src/elements.js - About 1 hr to fix

    Function auth has 54 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

    function auth () {
      const app = this
      const config = app.get('authentication')
      if (!config) return
    
    Severity: Major
    Found in src/application.js - About 1 hr to fix

      Function marshallSpatialQuery has 54 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      export function marshallSpatialQuery (hook) {
        let query = hook.params.query
        if (query) {
          marshallGeometryQuery(query)
          // Resampling is used by hooks only, do not send it to DB
      Severity: Major
      Found in src/hooks/query.js - About 1 hr to fix

        Function processData has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring.
        Open

        export async function processData (hook) {
          let params = hook.params
          let query = params.query
          let service = hook.service
          let items = getItems(hook)
        Severity: Minor
        Found in src/hooks/query.js - About 45 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

        Consider simplifying this complex logical expression.
        Open

            if (!_.isNil(query.oLon) && !_.isNil(query.oLat) && !_.isNil(query.sLon) && !_.isNil(query.sLat) && !_.isNil(query.dLon) && !_.isNil(query.dLat)) {
              // Convert when required from query strings
              hook.params.oLat = _.toNumber(query.oLat)
              hook.params.oLon = _.toNumber(query.oLon)
              hook.params.sLat = _.toNumber(query.sLat)
        Severity: Major
        Found in src/hooks/query.js - About 40 mins to fix

          Consider simplifying this complex logical expression.
          Open

              if (!_.isNil(params.oLon) && !_.isNil(params.oLat) && !_.isNil(params.sLon) && !_.isNil(params.sLat) && !_.isNil(params.dLon) && !_.isNil(params.dLat)) {
                items.forEach(item => {
                  let grid = new Grid({
                    bounds: service.forecast.bounds,
                    origin: service.forecast.origin,
          Severity: Major
          Found in src/hooks/query.js - About 40 mins to fix

            Function createService has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            export function createService (name, app, modelsPath, servicesPath, options) {
            Severity: Minor
            Found in src/application.js - About 35 mins to fix

              Function createElementService has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

              export function createElementService (forecast, element, app, servicesPath, options) {
              Severity: Minor
              Found in src/application.js - About 35 mins to fix

                Avoid too many return statements within this function.
                Open

                      return undefined
                Severity: Major
                Found in src/common/grid.js - About 30 mins to fix

                  FIXME found
                  Open

                          // FIXME : when fixed in weacast, for now temporary files are removed before each update
                  Severity: Minor
                  Found in test/element.service.test.js by fixme

                  FIXME found
                  Open

                          // FIXME : when fixed in weacast, for now temporary files are removed before each update
                  Severity: Minor
                  Found in test/element.service.test.js by fixme

                  FIXME found
                  Open

                          // FIXME : when fixed in weacast, for now temporary files are removed before each update
                  Severity: Minor
                  Found in test/element.service.test.js by fixme

                  FIXME found
                  Open

                      // FIXME: need to let some time to proceed with log file
                  Severity: Minor
                  Found in test/index.test.js by fixme

                  FIXME found
                  Open

                      // FIXME: trying to remove temporary files as soon as possible raises "EBUSY: resource busy or locked" because there is probably some async operation still running
                  Severity: Minor
                  Found in src/mixins/mixin.refresh.js by fixme

                  FIXME found
                  Open

                          // FIXME : when fixed in weacast, for now temporary files are removed before each update
                  Severity: Minor
                  Found in test/element.service.test.js by fixme
                  Severity
                  Category
                  Status
                  Source
                  Language