Showing 76 of 129 total issues
Function getBBoxQuery
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
async function getBBoxQuery(client, subscription) {
if (subscription.params.iso && subscription.params.iso.country) {
if (!subscription.params.iso.region) {
const data = await executeThunk(client, geoQuery.ISO_BBOX, {
- 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 transform
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
static async transform(results, layer, subscription, begin, end) {
const alerts = await analysisService.execute(subscription, layer.slug, begin, end, true);
if (alerts && alerts.length && alerts.length > 0) {
const alertsFormat = [];
let length = 10;
- 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 getQuery
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
async function getQuery(subscription) {
if (subscription.params.iso && subscription.params.iso.country) {
if (!subscription.params.iso.region) {
return Mustache.render(geoQuery.ISO, {
iso: subscription.params.iso.country
- 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 exports
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
module.exports = (() => {
const loadAPI = (app, path = routersPath, pathApi) => {
const routesFiles = fs.readdirSync(path);
let existIndexRouter = false;
routesFiles.forEach((file) => {
- 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 (res && res.statusCode < 400) {
logger.info(`Successfully POSTed to subscription web-hook with status code ${res.statusCode}:`, subscription, body);
return;
}
Avoid deeply nested control flow statements. Open
if (!data[i].params.geom) {
// eslint-disable-next-line no-continue
continue;
}
Avoid deeply nested control flow statements. Open
if (!geostore.body.data) {
logger.error('Is not correct');
logger.error(data[i].params.geom);
// eslint-disable-next-line no-continue
continue;
Function getGeostoreIdFromSubscriptionParams
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
static async getGeostoreIdFromSubscriptionParams(params) {
if (params.geostore) {
return params.geostore;
}
- 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 (subscription.env && subscription.env !== 'production') {
template += `-${subscription.env}`;
}
Consider simplifying this complex logical expression. Open
if (
task.dataset !== 'viirs-active-fires'
&& task.dataset !== 'story'
&& task.dataset !== 'forma-alerts'
&& task.dataset !== 'forma250GFW'
Consider simplifying this complex logical expression. Open
if (result.data && result.data.length === 1 && result.data[0].value && result.data[0].value > 0) {
// getting metadata first
const metadata = await DatasetService.getMetadata(datasetQuery.id, subscription.application, subscription.language);
const areaName = subscription.params.area ? await DatasetService.getAreaName(subscription.params.area) : '';
const datasetName = metadata[0].attributes.info.name || dataset.attributes.name || dataset.name;
Function getTask
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
const getTask = async (task) => {
logger.info(`[cronLoader] Publishing ${task.dataset}`);
if (task.dataset === 'dataset') {
redisClient.publish(CHANNEL, JSON.stringify({
layer_slug: task.dataset
- 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 subscriptionExists
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
const subscriptionExists = (isForUser) => async (ctx, next) => {
const { id } = ctx.params;
if (!mongoose.Types.ObjectId.isValid(id)) {
ctx.throw(400, 'ID is not valid');
- 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 transform
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
static async transform(results, layer, subscription, begin, end) {
results.alert_count_degradation = 0;
results.alert_count_deforestation = 0;
if (results.value) {
- 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 getAllSubscriptions
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
static async getAllSubscriptions(
link,
application = undefined,
env = undefined,
page = 1,
- 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 transform
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
transform() {
const stories = [];
if (this.results && this.results.length > 0) {
for (let i = 0, { length } = this.results; i < length; i++) {
stories.push({
- 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 null;
Avoid too many return
statements within this function. Open
return `/wdpa/${params.wdpaid}`;
Avoid too many return
statements within this function. Open
return null;
Avoid too many return
statements within this function. Open
return data.rows[0].bbox;