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')
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 = []
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 = []
- Read upRead up
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
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')
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')
- Read upRead up
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) {
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)
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
Function pushTime
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
pushTime (feature, timeName, elementName, time, value) {
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')
- Read upRead up
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) {
- Read upRead up
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"