weacast/weacast

View on GitHub

Showing 22 of 22 total issues

Function _createBarbs has 148 lines of code (exceeds 50 allowed). Consider refactoring.
Open

  _createBarbs: function (speed) {
    // We expect speed in m/s and not knots
    let s = speed / 0.514
    const b = { 5: 0, 10: 0, 50: 0 }
    const bs = this.options.barbSpaceing
Severity: Major
Found in packages/leaflet/src/layers/windbarb.js - About 4 hrs to fix

    Function probe has 94 lines of code (exceeds 50 allowed). Consider refactoring.
    Open

      async probe (probe, query = {}) {
        const forecastTime = query.forecastTime
        const isTimeRange = (forecastTime && (forecastTime.$lt || forecastTime.$lte || forecastTime.$gt || forecastTime.$gte))
        const aggregate = _.get(query, 'aggregate', true)
        const geometry = _.get(query, 'geometry.$geoIntersects.$geometry')
    Severity: Major
    Found in packages/probe/src/services/probes/probes.service.js - About 2 hrs to fix

      Function _createBarbs has a Cognitive Complexity of 33 (exceeds 20 allowed). Consider refactoring.
      Open

        _createBarbs: function (speed) {
          // We expect speed in m/s and not knots
          let s = speed / 0.514
          const b = { 5: 0, 10: 0, 50: 0 }
          const bs = this.options.barbSpaceing
      Severity: Minor
      Found in packages/leaflet/src/layers/windbarb.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 updateFeaturesInDatabase has 81 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

        async updateFeaturesInDatabase (features, probe, elementService, forecast) {
          const { runTime, forecastTime } = forecast
          // Get the service to store results in
          const resultService = this.app.getService('probe-results')
          const operations = []
      Severity: Major
      Found in packages/probe/src/services/probes/probes.service.js - About 2 hrs to fix

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

        export default async function initializeElements (app, forecast, servicesPath) {
          app.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 packages/core/src/elements.js - About 1 hr to fix

          Function updateFeaturesInDatabase has a Cognitive Complexity of 28 (exceeds 20 allowed). Consider refactoring.
          Open

            async updateFeaturesInDatabase (features, probe, elementService, forecast) {
              const { runTime, forecastTime } = forecast
              // Get the service to store results in
              const resultService = this.app.getService('probe-results')
              const operations = []
          Severity: Minor
          Found in packages/probe/src/services/probes/probes.service.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 updateFeatures has 63 lines of code (exceeds 50 allowed). Consider refactoring.
          Open

            async updateFeatures (features, probe, elementService, forecast) {
              const { runTime, forecastTime, grid } = forecast
          
              // Check if we have to manage a direction composed from two axis components
              const elementName = elementService.element.name
          Severity: Major
          Found in packages/probe/src/services/probes/probes.service.js - About 1 hr to fix

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

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

              Function probe has a Cognitive Complexity of 25 (exceeds 20 allowed). Consider refactoring.
              Open

                async probe (probe, query = {}) {
                  const forecastTime = query.forecastTime
                  const isTimeRange = (forecastTime && (forecastTime.$lt || forecastTime.$lte || forecastTime.$gt || forecastTime.$gte))
                  const aggregate = _.get(query, 'aggregate', true)
                  const geometry = _.get(query, 'geometry.$geoIntersects.$geometry')
              Severity: Minor
              Found in packages/probe/src/services/probes/probes.service.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 aggregateResultsQuery has 51 lines of code (exceeds 50 allowed). Consider refactoring.
              Open

              export async function aggregateResultsQuery (hook) {
                const query = hook.params.query
                if (query) {
                  // Perform aggregation
                  if (query.$aggregate) {
              Severity: Major
              Found in packages/probe/src/hooks/probing.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) {
                  const params = hook.params
                  const query = params.query
                  const service = hook.service
                  let items = getItems(hook)
                Severity: Minor
                Found in packages/core/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

                Avoid deeply nested control flow statements.
                Open

                              if (isFinite(bearing)) {
                                // Take care that bearing uses the geographical convention, i.e. angle toward which the element goes,
                                // we need to convert from meteorological convention, i.e. angle from which the flow comes
                                direction += 180
                                if (direction >= 360) direction -= 360
                Severity: Major
                Found in packages/probe/src/services/probes/probes.service.js - About 45 mins to fix

                  Function linearize has 6 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                  function linearize (blocks, blockWidth, blocksPerRow, blockHeight, blocksPerCol, verbose) {
                  Severity: Minor
                  Found in packages/gtiff2json/index.js - About 45 mins to fix

                    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 packages/core/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 => {
                              const grid = new Grid({
                                bounds: service.forecast.bounds,
                                origin: service.forecast.origin,
                      Severity: Major
                      Found in packages/core/src/hooks/query.js - About 40 mins to fix

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

                          pushTime (feature, timeName, elementName, time, value) {
                        Severity: Minor
                        Found in packages/probe/src/services/probes/probes.service.js - About 35 mins to fix

                          Function probeForecastTime has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring.
                          Open

                            async probeForecastTime (features, probe, elementService, forecast) {
                              const { _id, x, y, runTime, forecastTime, data } = forecast
                              // Retrieve forecast data if required
                              let forecastData = data
                              if (!forecastData) {
                          Severity: Minor
                          Found in packages/probe/src/services/probes/probes.service.js - About 35 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 too many return statements within this function.
                          Open

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

                            Avoid too many return statements within this function.
                            Open

                                    return true
                            Severity: Major
                            Found in packages/api/src/hooks.js - About 30 mins to fix

                              FIXME found
                              Open

                                  // FIXME : make this dynamic, ie relative mode based on min/max when data are set
                              Severity
                              Category
                              Status
                              Source
                              Language