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
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 _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
- 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 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 = []
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({
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 = []
- 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 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
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) {
const query = hook.params.query
if (query) {
// Perform aggregation
if (query.$aggregate) {
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)
- 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
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 linearize
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
function linearize (blocks, blockWidth, blocksPerRow, blockHeight, blocksPerCol, verbose) {
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)
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,
Function pushTime
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
pushTime (feature, timeName, elementName, time, value) {
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"
Further reading
Avoid too many return
statements within this function. Open
return undefined
Avoid too many return
statements within this function. Open
return true
FIXME found Open
// FIXME : make this dynamic, ie relative mode based on min/max when data are set
- Exclude checks