Showing 131 of 363 total issues
Function currentUser
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
const currentUser = async (req, res, next) => {
const authorization = req.get('Authorization');
const currentUser = {
authType: AuthType.NONE
};
Function createUser
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
createUser: async (data, etrx = undefined) => {
let trx;
try {
let response;
trx = etrx ? etrx : await User.startTransaction();
- 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 syncMetadata
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
syncMetadata: async (version, path, bucketId = undefined, userId = SYSTEM_USER, etrx = undefined) => {
let trx;
try {
trx = etrx ? etrx : await Version.startTransaction();
let response = [];
Function copy
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
copy: async (sourceVersionId, targetVersionId, objectId, targetEtag, targetLastModified,
userId = SYSTEM_USER, etrx = undefined) => {
let trx;
try {
trx = etrx ? etrx : await Version.startTransaction();
Function deleteTags
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
async deleteTags(req, res, next) {
try {
const bucketId = req.currentObject?.bucketId;
const objId = addDashesToUuid(req.params.objectId);
const objPath = req.currentObject?.path;
Function relationMappings
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
static get relationMappings() {
const Bucket = require('./bucket');
const ObjectPermission = require('./objectPermission');
const BucketPermission = require('./bucketPermission');
const Version = require('./version');
Function associateMetadata
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
associateMetadata: async (versionId, metadata, currentUserId = SYSTEM_USER, etrx = undefined) => {
let trx;
try {
trx = etrx ? etrx : await Metadata.startTransaction();
let response = [];
Function relationMappings
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
static get relationMappings() {
const ObjectModel = require('./objectModel');
const Metadata = require('./metadata');
const Tag = require('./tag');
Function fetchMetadataForVersion
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
fetchMetadataForVersion: async (params, etrx = undefined) => {
let trx;
try {
trx = etrx ? etrx : await Metadata.startTransaction();
Function deleteObject
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
async deleteObject(req, res, next) {
try {
const objId = addDashesToUuid(req.params.objectId);
const userId = await userService.getCurrentUserId(getCurrentIdentity(req.currentUser, SYSTEM_USER));
Function fetchTagsForVersion
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
fetchTagsForVersion: async (params, etrx = undefined) => {
let trx;
try {
trx = etrx ? etrx : await Tag.startTransaction();
Function down
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
exports.down = function (knex) {
return Promise.resolve()
// re-add columns originalName and mimeType to object table
.then(() => knex.schema.alterTable('object', table => {
table.string('originalName', 255);
Function checkGrantPermissions
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
checkGrantPermissions: async (data, etrx = undefined) => {
let trx;
try {
trx = etrx ? etrx : await Bucket.startTransaction();
- 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 readObject
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
async readObject(req, res, next) {
try {
const objId = addDashesToUuid(req.params.objectId);
// target S3 version
Function currentUpload
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
const currentUpload = (strict = false) => {
return (req, _res, next) => {
// Check Content-Length Header
const contentLength = parseInt(req.get('Content-Length'));
// TODO: Figure out what's killing and returning a 400 in response stack
Function _deriveObjectId
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
_deriveObjectId: async (s3Object, path, bucketId) => {
let objId = uuidv4();
if (typeof s3Object === 'object') { // If regular S3 Object
const TagSet = await storageService.getObjectTagging({ filePath: path, bucketId: bucketId })
Function createUser
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
createUser: async (data, etrx = undefined) => {
let trx;
try {
let response;
trx = etrx ? etrx : await User.startTransaction();
Function modifiers
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
static get modifiers() {
return {
filterKey(query, value) {
const subqueries = [];
if (value.tag && Object.keys(value.tag).length) {
Function modifiers
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
static get modifiers() {
return {
filterKey(query, value) {
const subqueries = [];
if (value.metadata && Object.keys(value.metadata).length) {
Function hasPermission
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
const hasPermission = (permission) => {
return async (req, _res, next) => {
const authMode = getAppAuthMode();
const authType = req.currentUser ? req.currentUser.authType : 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"