Showing 131 of 363 total issues
Function up
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
exports.up = function (knex) {
return Promise.resolve()
.then(() => knex.schema.alterTable('bucket', table => {
table.timestamp('updatedAt', { useTz: true }).alter();
}))
Function searchObjects
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
async searchObjects(req, res, next) {
// TODO: Consider support for filtering by set of permissions?
// TODO: handle additional parameters. Eg: deleteMarker, latest
try {
const bucketIds = mixedQueryToArray(req.query.bucketId);
Function addPermissions
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
addPermissions: async (objId, data, currentUserId = SYSTEM_USER, etrx = undefined) => {
if (!objId) {
throw new Error('Invalid objId supplied');
}
if (!data || !Array.isArray(data) || !data.length) {
Function addPermissions
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
addPermissions: async (bucketId, data, currentUserId = SYSTEM_USER, etrx = undefined) => {
if (!bucketId) {
throw new Error('Invalid bucketId supplied');
}
if (!data || !Array.isArray(data) || !data.length) {
Function down
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
exports.down = function (knex) {
return Promise.resolve()
.then(() => knex.schema.alterTable('version_tag', table => {
table.timestamp('updatedAt', { useTz: true }).defaultTo(knex.fn.now()).alter();
}))
Function dbResponse
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const dbResponse = await utils.trxWrapper(async (trx) => {
// Update Object
const object = await objectService.update({
...data,
userId: userId,
Function createMetadata
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
createMetadata: async (metadata, etrx = undefined) => {
let trx;
let response = [];
try {
trx = etrx ? etrx : await Metadata.startTransaction();
Function up
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
exports.up = function (knex) {
return Promise.resolve()
// create version table
.then(() => knex.schema.createTable('version', table => {
table.uuid('id').primary();
Function createTags
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
createTags: async (tags, etrx = undefined) => {
let trx;
let response = [];
try {
trx = etrx ? etrx : await Tag.startTransaction();
Function updateUser
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
updateUser: async (userId, data, etrx = undefined) => {
let trx;
try {
// Check if any user values have changed
const oldUser = await service.readUser(userId);
Function filterMetadataTag
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
filterMetadataTag(query, value) {
const subqueries = [];
if (value.metadata && Object.keys(value.metadata).length) {
Object.entries(value.metadata).forEach(([key, val]) => {
Function create
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
create: async (data, etrx = undefined) => {
let trx;
try {
trx = etrx ? etrx : await Bucket.startTransaction();
Function relationMappings
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
static get relationMappings() {
const ObjectModel = require('./objectModel');
const Permission = require('./permission');
const User = require('./user');
Function relationMappings
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
static get relationMappings() {
const Bucket = require('./bucket');
const Permission = require('./permission');
const User = require('./user');
Function hasPermission
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
const hasPermission = (permission) => {
return async (req, _res, next) => {
const authMode = getAppAuthMode();
const authType = req.currentUser ? req.currentUser.authType : undefined;
Function _processS3Headers
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
_processS3Headers(s3Resp, res) {
// TODO: Consider adding 'x-coms-public' and 'x-coms-path' headers into API spec?
const exposedHeaders = [];
if (s3Resp.ContentLength) res.set('Content-Length', s3Resp.ContentLength);
Function fetchMetadataForObject
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
fetchMetadataForObject: (params) => {
return ObjectModel.query()
.select('object.id AS objectId', 'object.bucketId as bucketId')
.allowGraph('[bucketPermission, objectPermission, version.metadata]')
.withGraphJoined('version.metadata')
Function fetchTagsForObject
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
fetchTagsForObject: (params) => {
return ObjectModel.query()
.select('object.id AS objectId', 'object.bucketId as bucketId')
.allowGraph('[bucketPermission, objectPermission, version.tag]')
.withGraphJoined('version.tag')
Function searchPermissions
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
async searchPermissions(req, res, next) {
try {
const bucketIds = utils.mixedQueryToArray(req.query.bucketId);
const objIds = utils.mixedQueryToArray(req.query.objectId);
const permCodes = utils.mixedQueryToArray(req.query.permCode);
Function getBucket
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
async getBucket(bucketId = undefined) {
try {
const data = { region: DEFAULTREGION };
if (bucketId) {
// Function scoped import to avoid circular dependencies