Showing 363 of 363 total issues
Function fetchMetadataForObject
has 28 lines of code (exceeds 25 allowed). Consider refactoring. 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
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
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
async getBucket(bucketId = undefined) {
try {
const data = { region: DEFAULTREGION };
if (bucketId) {
// Function scoped import to avoid circular dependencies
Function checkGrantPermissions
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
checkGrantPermissions: async (data, etrx = undefined) => {
let trx;
try {
trx = etrx ? etrx : await Bucket.startTransaction();
Function initializeConnections
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
function initializeConnections() {
// Initialize connections and exit if unsuccessful
dataConnection.checkAll()
.then(results => {
state.connections.data = results;
Similar blocks of code found in 2 locations. Consider refactoring. Open
const newTags = Object.entries({ ...req.query.tagset }).map(([k, v]) => ({ Key: k, Value: v }));
- 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 57.
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
const newTags = Object.entries({ ...req.query.tagset }).map(([k, v]) => ({ Key: k, Value: v }));
- 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 57.
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 modifiers
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
static get modifiers() {
return {
filterKey(query, value) {
const subqueries = [];
if (value.metadata && Object.keys(value.metadata).length) {
- 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 syncJob
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
syncJob: async (path, bucketId, full = false, userId = SYSTEM_USER) => {
try {
if (!path) throw new Error('Path must be defined');
return await utils.trxWrapper(async (trx) => {
- 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 replaceTags
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
replaceTags: async (versionId, tags, currentUserId = SYSTEM_USER, etrx = undefined) => {
let trx;
try {
trx = etrx ? etrx : await Tag.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 addPermissions
has a Cognitive Complexity of 10 (exceeds 5 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) {
- 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 addPermissions
has a Cognitive Complexity of 10 (exceeds 5 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) {
- 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 modifiers
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
static get modifiers() {
return {
filterKey(query, value) {
const subqueries = [];
if (value.tag && Object.keys(value.tag).length) {
- 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 updateIsLatest
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
updateIsLatest: async (objectId, etrx = undefined) => {
// TODO: consider having accepting a `userId` argument for version.updatedBy when a version becomes 'latest'
let trx;
try {
trx = etrx ? etrx : await Version.startTransaction();
Function associateTags
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
associateTags: async (versionId, tags, currentUserId = SYSTEM_USER, etrx = undefined) => {
let trx;
try {
trx = etrx ? etrx : await Tag.startTransaction();
let response = [];
Function errorToProblem
has 27 lines of code (exceeds 25 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) {
Function _processS3Headers
has 27 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);
Function down
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
exports.down = function (knex) {
return Promise.resolve()
// additional DB update: change user.identityId field back
// NOTE: Destructive change - removes all data in identityId column
.then(() => knex('user').update({ identityId: null }))
Function listAllObjectVersions
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
async listAllObjectVersions({
filePath = undefined, bucketId = undefined, precisePath = true, filterLatest = false
} = {}) {
const key = filePath ?? (await utils.getBucket(bucketId)).key;
const path = key !== DELIMITER ? key : '';