bcgov/common-object-management-service

View on GitHub

Showing 131 of 360 total issues

Avoid too many return statements within this function.
Open

    return new Problem(500, { detail: message });
Severity: Major
Found in app/src/components/errorToProblem.js - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

        return new Problem(e.$metadata.httpStatusCode, { detail: e });
    Severity: Major
    Found in app/src/components/errorToProblem.js - About 30 mins to fix

      Function removeDuplicateLatest has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        removeDuplicateLatest: async (versionId, objectId, etrx = undefined) => {
          let trx;
          try {
            trx = etrx ? etrx : await Version.startTransaction();
      
      
      Severity: Minor
      Found in app/src/services/version.js - About 25 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 fetchMetadata has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        async fetchMetadata(req, res, next) {
          try {
            const versionIds = mixedQueryToArray(req.query.versionId);
            const s3VersionIds = mixedQueryToArray(req.query.s3VersionId);
            const metadata = getMetadata(req.headers);
      Severity: Minor
      Found in app/src/controllers/version.js - About 25 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 dequeue has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        async dequeue(etrx = undefined) {
          let trx;
          try {
            trx = etrx ? etrx : await ObjectQueue.startTransaction();
      
      
      Severity: Minor
      Found in app/src/services/objectQueue.js - About 25 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 listInheritedObjectIds has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        listInheritedObjectIds: async (userIds = [], bucketIds = [], permCodes = []) => {
          return BucketPermission.query()
            .distinct('object.id AS objectId')
            .rightJoin('object', 'bucket_permission.bucketId', '=', 'object.bucketId')
            .modify((query) => {
      Severity: Minor
      Found in app/src/services/objectPermission.js - About 25 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 listAllObjectVersions has a Cognitive Complexity of 6 (exceeds 5 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 25 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 fetchTags has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        async fetchTags(req, res, next) {
          try {
            const versionIds = mixedQueryToArray(req.query.versionId);
            const s3VersionIds = mixedQueryToArray(req.query.s3VersionId);
            const tagging = req.query.tagset;
      Severity: Minor
      Found in app/src/controllers/version.js - About 25 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 modifiers has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        static get modifiers() {
          return {
            filterDeleteMarker(query, value) {
              if (value !== undefined) query.where('version.deleteMarker', value);
            },
      Severity: Minor
      Found in app/src/db/models/tables/version.js - About 25 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 createIdp has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        createIdp: async (idp, etrx = undefined) => {
          let trx;
          try {
            trx = etrx ? etrx : await IdentityProvider.startTransaction();
      
      
      Severity: Minor
      Found in app/src/services/user.js - About 25 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 update has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        update: async (data = {}, userId = SYSTEM_USER, etrx = undefined) => {
          let trx;
          try {
            trx = etrx ? etrx : await Version.startTransaction();
            // update version record
      Severity: Minor
      Found in app/src/services/version.js - About 25 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