bcgov/common-object-management-service

View on GitHub

Showing 131 of 360 total issues

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

      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.metadata && Object.keys(value.metadata).length) {
      Severity: Minor
      Found in app/src/db/models/tables/metadata.js - About 1 hr to fix

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

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

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

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

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

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

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

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

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

                Function create has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  create: async (data, etrx = undefined) => {
                    let trx;
                    try {
                      trx = etrx ? etrx : await ObjectModel.startTransaction();
                
                
                Severity: Minor
                Found in app/src/services/object.js - About 1 hr to fix

                  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 }))
                  Severity: Minor
                  Found in app/src/db/migrations/20220627000000_002-metadata-tags.js - About 1 hr to fix

                    Function useInvite has a Cognitive Complexity of 9 (exceeds 5 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));
                    Severity: Minor
                    Found in app/src/controllers/invite.js - About 55 mins to fix

                    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 _processS3Headers has a Cognitive Complexity of 9 (exceeds 5 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 55 mins to fix

                    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 removePermissions has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                    Open

                      removePermissions: async (bucketId, userIds = undefined, permissions = undefined, etrx = undefined) => {
                        if (!bucketId) {
                          throw new Error('Invalid bucketId supplied');
                        }
                    
                    
                    Severity: Minor
                    Found in app/src/services/bucketPermission.js - About 55 mins to fix

                    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 readObject has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                    Open

                      async readObject(req, res, next) {
                        try {
                          const objId = addDashesToUuid(req.params.objectId);
                    
                          // target S3 version
                    Severity: Minor
                    Found in app/src/controllers/object.js - About 55 mins to fix

                    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 removePermissions has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                    Open

                      removePermissions: async (objId, userIds = undefined, permissions = undefined, etrx = undefined) => {
                        if (!objId) {
                          throw new Error('Invalid objId supplied');
                        }
                    
                    
                    Severity: Minor
                    Found in app/src/services/objectPermission.js - About 55 mins to fix

                    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

                    Severity
                    Category
                    Status
                    Source
                    Language