weacast/weacast-probe

View on GitHub

Showing 12 of 12 total issues

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 src/services/probes/probes.service.js - About 2 hrs to fix

    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
        let resultService = this.app.getService('probe-results')
        let operations = []
    Severity: Major
    Found in src/services/probes/probes.service.js - About 2 hrs 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
          let resultService = this.app.getService('probe-results')
          let operations = []
      Severity: Minor
      Found in 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 src/services/probes/probes.service.js - About 1 hr to fix

        Function init has 53 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        export default async function init () {
          debug('Initializing weacast-probe')
        
          let app = this
          const syncConfig = app.get('sync')
        Severity: Major
        Found in src/index.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 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) {
            let query = hook.params.query
            if (query) {
              // Perform aggregation
              if (query.$aggregate) {
          Severity: Major
          Found in src/hooks/probing.js - About 1 hr to fix

            Avoid deeply nested control flow statements.
            Open

                      if (options.elements.length > 0) {
                        let geojson = fs.readJsonSync(defaultProbe.fileName)
                        Object.assign(geojson, options)
                        const probe = await probesService.create(geojson)
                        logger.info('Initialized default probe ' + defaultProbe.fileName + ' for forecast model ' + forecast.name)
            Severity: Major
            Found in src/index.js - About 45 mins to fix

              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 src/services/probes/probes.service.js - About 45 mins to fix

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

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

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

                  export default async function init () {
                    debug('Initializing weacast-probe')
                  
                    let app = this
                    const syncConfig = app.get('sync')
                  Severity: Minor
                  Found in src/index.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

                  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 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

                  Severity
                  Category
                  Status
                  Source
                  Language