bcgov/common-object-management-service

View on GitHub

Showing 131 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();
    }))
Severity: Minor
Found in app/src/db/migrations/20230503000000_007-default-updatedat.js - About 1 hr to fix

    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);
    Severity: Minor
    Found in app/src/controllers/object.js - About 1 hr to fix

      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) {
      Severity: Minor
      Found in app/src/services/objectPermission.js - About 1 hr to fix

        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) {
        Severity: Minor
        Found in app/src/services/bucketPermission.js - About 1 hr to fix

          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();
              }))
          Severity: Minor
          Found in app/src/db/migrations/20230503000000_007-default-updatedat.js - About 1 hr to fix

            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,
            Severity: Minor
            Found in app/src/controllers/object.js - About 1 hr to fix

              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();
              Severity: Minor
              Found in app/src/services/metadata.js - About 1 hr to fix

                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();
                Severity: Minor
                Found in app/src/db/migrations/20220516000000_001-version.js - About 1 hr to fix

                  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();
                  Severity: Minor
                  Found in app/src/services/tag.js - About 1 hr to fix

                    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);
                    Severity: Minor
                    Found in app/src/services/user.js - About 1 hr to fix

                      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]) => {
                      Severity: Minor
                      Found in app/src/db/models/tables/objectModel.js - About 1 hr to fix

                        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();
                        
                        
                        Severity: Minor
                        Found in app/src/services/bucket.js - About 1 hr to fix

                          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');
                          
                          
                          Severity: Minor
                          Found in app/src/db/models/tables/objectPermission.js - About 1 hr to fix

                            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');
                            
                            
                            Severity: Minor
                            Found in app/src/db/models/tables/bucketPermission.js - About 1 hr to fix

                              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;
                              
                              
                              Severity: Minor
                              Found in app/src/middleware/authorization.js - About 1 hr to fix

                                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);
                                Severity: Minor
                                Found in app/src/controllers/bucket.js - About 1 hr to fix

                                  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')
                                  Severity: Minor
                                  Found in app/src/services/metadata.js - About 1 hr to fix

                                    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')
                                    Severity: Minor
                                    Found in app/src/services/tag.js - About 1 hr to fix

                                      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);
                                      Severity: Minor
                                      Found in app/src/controllers/objectPermission.js - About 1 hr to fix

                                        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
                                        Severity: Minor
                                        Found in app/src/components/utils.js - About 1 hr to fix
                                          Severity
                                          Category
                                          Status
                                          Source
                                          Language