Showing 131 of 363 total issues
objectStorageService
has 24 functions (exceeds 20 allowed). Consider refactoring. Open
const objectStorageService = {
/**
* @private
* @function _getS3Client
* The AWS S3Client used for interacting with S3 compatible storage
Function up
has 66 lines of code (exceeds 25 allowed). Consider refactoring. Open
exports.up = function (knex) {
return Promise.resolve()
// create metadata table
.then(() => knex.schema.createTable('metadata', table => {
Function deleteMetadata
has 63 lines of code (exceeds 25 allowed). Consider refactoring. Open
async deleteMetadata(req, res, next) {
try {
const bucketId = req.currentObject?.bucketId;
const objId = addDashesToUuid(req.params.objectId);
const objPath = req.currentObject?.path;
Function addMetadata
has 62 lines of code (exceeds 25 allowed). Consider refactoring. Open
async addMetadata(req, res, next) {
try {
const bucketId = req.currentObject?.bucketId;
const objId = addDashesToUuid(req.params.objectId);
const objPath = req.currentObject?.path;
Function syncMetadata
has a Cognitive Complexity of 18 (exceeds 5 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 = [];
- 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 syncObject
has 57 lines of code (exceeds 25 allowed). Consider refactoring. Open
syncObject: async (path, bucketId, userId = SYSTEM_USER, etrx = undefined) => {
let trx;
try {
trx = etrx ? etrx : await ObjectModel.startTransaction();
Function associateMetadata
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
associateMetadata: async (versionId, metadata, currentUserId = SYSTEM_USER, etrx = undefined) => {
let trx;
try {
trx = etrx ? etrx : await Metadata.startTransaction();
let response = [];
- 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 replaceMetadata
has 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
async replaceMetadata(req, res, next) {
try {
const bucketId = req.currentObject?.bucketId;
const objId = addDashesToUuid(req.params.objectId);
const objPath = req.currentObject?.path;
Function useInvite
has 55 lines of code (exceeds 25 allowed). Consider refactoring. Open
async useInvite(req, res, next) {
const token = addDashesToUuid(req.params.token);
try {
const userId = await userService.getCurrentUserId(getCurrentIdentity(req.currentUser, SYSTEM_USER));
Function syncTags
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
syncTags: async (version, path, bucketId = undefined, userId = SYSTEM_USER, etrx = undefined) => {
let trx;
try {
trx = etrx ? etrx : await Version.startTransaction();
let response = [];
Function searchObjects
has 51 lines of code (exceeds 25 allowed). Consider refactoring. Open
searchObjects: async (params, etrx = undefined) => {
let trx;
let response = {};
try {
trx = etrx ? etrx : await ObjectModel.startTransaction();
Function errorToProblem
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
function errorToProblem(service, e) {
// If already problem type, just return as is
if (e instanceof Problem) {
return e;
} else if (e.response) {
- 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 _deriveObjectId
has a Cognitive Complexity of 15 (exceeds 5 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 })
- 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 updateUser
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
updateUser: async (userId, data, etrx = undefined) => {
let trx;
try {
// Check if any user values have changed
const oldUser = await service.readUser(userId);
- 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 up
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
exports.up = function (knex) {
return Promise.resolve()
// Create bucket tables
.then(() => knex.schema.createTable('bucket', table => {
table.uuid('bucketId').primary();
Function processNextJob
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
async processNextJob() {
let job;
try {
const response = await objectQueueService.dequeue();
Function createBucketChild
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
async createBucketChild(req, res, next) {
try {
// Get Parent bucket data
const parentBucketId = addDashesToUuid(req.params.bucketId);
const parentBucket = await bucketService.read(parentBucketId);
Function Encrypt
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
const Encrypt = opts => {
// Provide good default options if possible.
const options = Object.assign(
{
fields: []
Function modifiers
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
static get modifiers() {
return {
filterUserId(query, value) {
filterOneOrMany(query, value, 'userId');
},
Function addTags
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
async addTags(req, res, next) {
try {
const bucketId = req.currentObject?.bucketId;
const objId = addDashesToUuid(req.params.objectId);
const objPath = req.currentObject?.path;