Showing 28 of 43 total issues
Function postgresql
has 214 lines of code (exceeds 25 allowed). Consider refactoring. Open
export default function postgresql() {
const configs = {
user: config.get('postgresql.user'),
database: config.get('postgresql.database'),
password: config.get('postgresql.password'),
Function magic
has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring. Open
export async function magic(params, method, response, stats = undefined, metric = undefined, shouldBeFresh = false) {
if (params === null) {
// Invalid, hence reject
response.status(400).end();
if (metric) {
- 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 magic
has 104 lines of code (exceeds 25 allowed). Consider refactoring. Open
export async function magic(params, method, response, stats = undefined, metric = undefined, shouldBeFresh = false) {
if (params === null) {
// Invalid, hence reject
response.status(400).end();
if (metric) {
Function postgresql
has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open
export default function postgresql() {
const configs = {
user: config.get('postgresql.user'),
database: config.get('postgresql.database'),
password: config.get('postgresql.password'),
- 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 redis
has 63 lines of code (exceeds 25 allowed). Consider refactoring. Open
export default function redis() {
const url = config.get('redis.url');
const client = redisClient.createClient({url, prefix: 'iaas--'});
const get = promisify(client.get).bind(client);
Function uploadImage
has 62 lines of code (exceeds 25 allowed). Consider refactoring. Open
const uploadImage = async (req, res) => {
const sentToken = req.headers['x-token'];
const name = req.params.name;
log('info', `Requested image upload for image_id ${name} with token ${sentToken}`);
const metric = timingMetric(UPLOAD, {fields: {name: name}});
File index.js
has 258 lines of code (exceeds 250 allowed). Consider refactoring. Open
import "babel-polyfill";
import express from "express";
import config from "config";
import bodyParser from "body-parser";
Function setup
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
function setup() {
const influxConnection = config.get("metrics.influx.dsn");
const influx = new InfluxDB(influxConnection);
log('debug', `Connecting influx to ${influxConnection}`);
Function urlToParams
has 47 lines of code (exceeds 25 allowed). Consider refactoring. Open
export default function urlToParams(req, requireDimensions = true) {
// The default settings
const result = {
name: null,
width: undefined,
Function urlToParams
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
export default function urlToParams(req, requireDimensions = true) {
// The default settings
const result = {
name: null,
width: undefined,
- 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 writeOriented
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
export async function writeOriented(source, destination, cropParameters) {
// if possible, crop first (since the UA had that orientation), then orient
if (cropParameters) {
const cropped = im(source).options(gmOptions)
.crop(cropParameters.width, cropParameters.height, cropParameters.xOffset, cropParameters.yOffset);
Function integerCounter
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
export default function integerCounter() {
let i = 0;
function incrementAndGet() {
i = i + 1;
Function uploadImage
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
const uploadImage = async (req, res) => {
const sentToken = req.headers['x-token'];
const name = req.params.name;
log('info', `Requested image upload for image_id ${name} with token ${sentToken}`);
const metric = timingMetric(UPLOAD, {fields: {name: name}});
- 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 addToCache
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
async function addToCache(params, url, renderedAt) {
const vars = [params.name,
params.width,
params.height,
params.fit,
Function populateUploadedAt
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
export default async function populateUploadedAt() {
// eslint-disable-next-line no-constant-condition
while (true) {
const toEnrich = await database.getTokensWithoutUploadedAt();
- 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 deleteTokensWithoutAssociatedFile
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
export default async function deleteTokensWithoutAssociatedFile() {
// eslint-disable-next-line no-constant-condition
while (true) {
const toEnrich = await database.getTokensWithoutUploadedAt();
- 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 calculateNewBounds
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
const calculateNewBounds = async (params) => {
// Resize the parameters
// If no params are set then we load them from the actual image before calculating new bounds
if (!params.width || !params.height) {
const fileSize = await image.imageSize(imagePath(params.name));
- 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 magic
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
export async function magic(params, method, response, stats = undefined, metric = undefined, shouldBeFresh = false) {
Avoid too many return
statements within this function. Open
return;
Avoid too many return
statements within this function. Open
return cover(client, params);