weacast/weacast-probe

View on GitHub
src/services/probes/probes.service.js

Summary

Maintainability
C
1 day
Test Coverage
B
87%

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

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

            There are no issues that match your filters.

            Category
            Status