Showing 363 of 363 total issues
Function up
has 31 lines of code (exceeds 25 allowed). Consider refactoring. 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
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
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
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
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
const dbResponse = await utils.trxWrapper(async (trx) => {
// Update Object
const object = await objectService.update({
...data,
userId: userId,
Similar blocks of code found in 2 locations. Consider refactoring. Open
router.patch('/:bucketId', express.json(), bucketValidator.updateBucket, hasPermission(Permissions.MANAGE),
(req, res, next) => {
bucketController.updateBucket(req, res, next);
}
);
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 59.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Function createMetadata
has 30 lines of code (exceeds 25 allowed). Consider refactoring. 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
exports.up = function (knex) {
return Promise.resolve()
// create version table
.then(() => knex.schema.createTable('version', table => {
table.uuid('id').primary();
Similar blocks of code found in 2 locations. Consider refactoring. Open
router.put('/:bucketId/child', express.json(), bucketValidator.createBucketChild, hasPermission(Permissions.MANAGE),
(req, res, next) => {
bucketController.createBucketChild(req, res, next);
}
);
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 59.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Function createTags
has 30 lines of code (exceeds 25 allowed). Consider refactoring. 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
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
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
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
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
static get relationMappings() {
const Bucket = require('./bucket');
const Permission = require('./permission');
const User = require('./user');
Similar blocks of code found in 2 locations. Consider refactoring. Open
process.on('unhandledRejection', err => {
log.error(`Unhandled Rejection: ${err.message ?? err}`, { function: 'onUnhandledRejection' });
fatalErrorHandler();
});
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 58.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
process.on('uncaughtException', err => {
log.error(`Unhandled Exception: ${err.message ?? err}`, { function: 'onUncaughtException' });
fatalErrorHandler();
});
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 58.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Function hasPermission
has 28 lines of code (exceeds 25 allowed). Consider refactoring. 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
_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);