bcgov/common-object-management-service

View on GitHub

Showing 363 of 363 total issues

Similar blocks of code found in 6 locations. Consider refactoring.
Open

    if (s3Resp.ServerSideEncryption) {
      const sse = 'x-amz-server-side-encryption';
      res.set(sse, s3Resp.ServerSideEncryption);
      exposedHeaders.push(sse);
    }
Severity: Major
Found in app/src/controllers/object.js and 5 other locations - About 30 mins to fix
app/src/controllers/bucket.js on lines 41..45
app/src/controllers/bucket.js on lines 56..60
app/src/controllers/bucket.js on lines 61..65
app/src/controllers/object.js on lines 62..66
app/src/controllers/object.js on lines 81..85

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 45.

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

Further Reading

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

    Similar blocks of code found in 6 locations. Consider refactoring.
    Open

        if (s3Resp.ETag) {
          const etag = 'ETag';
          res.set(etag, s3Resp.ETag);
          exposedHeaders.push(etag);
        }
    Severity: Major
    Found in app/src/controllers/object.js and 5 other locations - About 30 mins to fix
    app/src/controllers/bucket.js on lines 41..45
    app/src/controllers/bucket.js on lines 56..60
    app/src/controllers/bucket.js on lines 61..65
    app/src/controllers/object.js on lines 76..80
    app/src/controllers/object.js on lines 81..85

    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 45.

    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

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

              if (!objectPermissions.length && !bucketPermissions.length) {
                throw new Problem(403, {
                  detail: `User lacks ${Permissions.MANAGE} permission for the object`,
                  instance: req.originalUrl,
                  objectId: resource
    Severity: Minor
    Found in app/src/controllers/invite.js and 1 other location - About 30 mins to fix
    app/src/controllers/invite.js on lines 107..113

    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 45.

    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

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

              if (!bucketPermissions.length) {
                throw new Problem(403, {
                  detail: `User lacks ${Permissions.MANAGE} permission for the bucket`,
                  instance: req.originalUrl,
                  bucketId: resource
    Severity: Minor
    Found in app/src/controllers/invite.js and 1 other location - About 30 mins to fix
    app/src/controllers/invite.js on lines 84..90

    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 45.

    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

    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 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

    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 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 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 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 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

    Parsing error: 'import' and 'export' may appear only with 'sourceType: module'
    Open

    import http from 'k6/http';
    Severity: Minor
    Found in k6/readObject.js by eslint

    For more information visit Source: http://eslint.org/docs/rules/

    Headers should be surrounded by blank lines
    Open

    #### Is your feature request related to a problem? Please describe.

    MD022 - Headers should be surrounded by blank lines

    Tags: headers, blank_lines

    Aliases: blanks-around-headers

    This rule is triggered when headers (any style) are either not preceded or not followed by a blank line:

    # Header 1
    Some text
    
    Some more text
    ## Header 2

    To fix this, ensure that all headers have a blank line both before and after (except where the header is at the beginning or end of the document):

    # Header 1
    
    Some text
    
    Some more text
    
    ## Header 2

    Rationale: Aside from aesthetic reasons, some parsers, including kramdown, will not parse headers that don't have a blank line before, and will parse them as regular text.

    Headers should be surrounded by blank lines
    Open

    #### Version Number

    MD022 - Headers should be surrounded by blank lines

    Tags: headers, blank_lines

    Aliases: blanks-around-headers

    This rule is triggered when headers (any style) are either not preceded or not followed by a blank line:

    # Header 1
    Some text
    
    Some more text
    ## Header 2

    To fix this, ensure that all headers have a blank line both before and after (except where the header is at the beginning or end of the document):

    # Header 1
    
    Some text
    
    Some more text
    
    ## Header 2

    Rationale: Aside from aesthetic reasons, some parsers, including kramdown, will not parse headers that don't have a blank line before, and will parse them as regular text.

    Headers should be surrounded by blank lines
    Open

    #### Additional context

    MD022 - Headers should be surrounded by blank lines

    Tags: headers, blank_lines

    Aliases: blanks-around-headers

    This rule is triggered when headers (any style) are either not preceded or not followed by a blank line:

    # Header 1
    Some text
    
    Some more text
    ## Header 2

    To fix this, ensure that all headers have a blank line both before and after (except where the header is at the beginning or end of the document):

    # Header 1
    
    Some text
    
    Some more text
    
    ## Header 2

    Rationale: Aside from aesthetic reasons, some parsers, including kramdown, will not parse headers that don't have a blank line before, and will parse them as regular text.

    Parsing error: 'import' and 'export' may appear only with 'sourceType: module'
    Open

    import http from 'k6/http';
    Severity: Minor
    Found in k6/createObject.js by eslint

    For more information visit Source: http://eslint.org/docs/rules/

    Trailing punctuation in header
    Open

    #### Smartphone (please complete the following information):

    MD026 - Trailing punctuation in header

    Tags: headers

    Aliases: no-trailing-punctuation

    Parameters: punctuation (string; default ".,;:!?")

    This rule is triggered on any header that has a punctuation character as the last character in the line:

    # This is a header.

    To fix this, remove any trailing punctuation:

    # This is a header

    Note: The punctuation parameter can be used to specify what characters class as punctuation at the end of the header. For example, you can set it to '.,;:!' to allow headers with question marks in them, such as might be used in an FAQ.

    Severity
    Category
    Status
    Source
    Language