bcgov/common-object-management-service

View on GitHub

Showing 363 of 363 total issues

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

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

          decryptFields() {
            options.fields.forEach(field => {
              const value = this[field];
              if (value) this[field] = decrypt(value);
            });
    Severity: Major
    Found in app/src/db/models/mixins/encrypt.js and 1 other location - About 1 hr to fix
    app/src/db/models/mixins/encrypt.js on lines 50..55

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

    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

          encryptFields() {
            options.fields.forEach(field => {
              const value = this[field];
              if (value) this[field] = encrypt(value);
            });
    Severity: Major
    Found in app/src/db/models/mixins/encrypt.js and 1 other location - About 1 hr to fix
    app/src/db/models/mixins/encrypt.js on lines 60..65

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

    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 3 locations. Consider refactoring.
    Open

          const sourceTags = Object.assign({},
            ...(sourceObject.TagSet?.map(item => ({ [item.Key]: item.Value })) ?? [])
          );
    Severity: Major
    Found in app/src/controllers/object.js and 2 other locations - About 55 mins to fix
    app/src/controllers/object.js on lines 127..129
    app/src/controllers/object.js on lines 825..827

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

    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 3 locations. Consider refactoring.
    Open

          const sourceTags = Object.assign({},
            ...(sourceObject.TagSet?.map(item => ({ [item.Key]: item.Value })) ?? [])
          );
    Severity: Major
    Found in app/src/controllers/object.js and 2 other locations - About 55 mins to fix
    app/src/controllers/object.js on lines 435..437
    app/src/controllers/object.js on lines 825..827

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

    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 3 locations. Consider refactoring.
    Open

          const sourceTags = Object.assign({},
            ...(sourceObject.TagSet?.map(item => ({ [item.Key]: item.Value })) ?? [])
          );
    Severity: Major
    Found in app/src/controllers/object.js and 2 other locations - About 55 mins to fix
    app/src/controllers/object.js on lines 127..129
    app/src/controllers/object.js on lines 435..437

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

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

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

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

    router.get('/:objectId/sync', requireSomeAuth, objectValidator.syncObject,
      currentObject, hasPermission(Permissions.READ), (req, res, next) => {
        syncController.syncObject(req, res, next);
      }
    );
    Severity: Major
    Found in app/src/routes/v1/object.js and 8 other locations - About 55 mins to fix
    app/src/routes/v1/object.js on lines 57..61
    app/src/routes/v1/object.js on lines 64..68
    app/src/routes/v1/object.js on lines 71..75
    app/src/routes/v1/object.js on lines 78..82
    app/src/routes/v1/object.js on lines 85..89
    app/src/routes/v1/object.js on lines 92..96
    app/src/routes/v1/object.js on lines 106..110
    app/src/routes/v1/object.js on lines 113..117

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

    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

              await VersionTag.query(trx)
                .insert(newJoins.map(({ id }) => ({
                  versionId: versionId,
                  tagId: id,
                  createdBy: currentUserId
    Severity: Minor
    Found in app/src/services/tag.js and 1 other location - About 55 mins to fix
    app/src/services/metadata.js on lines 54..59

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

    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 9 locations. Consider refactoring.
    Open

    router.patch('/:objectId/metadata', requireSomeAuth, objectValidator.addMetadata,
      currentObject, hasPermission(Permissions.UPDATE), (req, res, next) => {
        objectController.addMetadata(req, res, next);
      }
    );
    Severity: Major
    Found in app/src/routes/v1/object.js and 8 other locations - About 55 mins to fix
    app/src/routes/v1/object.js on lines 57..61
    app/src/routes/v1/object.js on lines 64..68
    app/src/routes/v1/object.js on lines 71..75
    app/src/routes/v1/object.js on lines 85..89
    app/src/routes/v1/object.js on lines 92..96
    app/src/routes/v1/object.js on lines 99..103
    app/src/routes/v1/object.js on lines 106..110
    app/src/routes/v1/object.js on lines 113..117

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

    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

          const s3Head = await storageService.headObject({
            filePath: joinPath(bucketKey, req.currentUpload.filename),
            bucketId: bucketId
          }).catch(() => ({}));
    Severity: Minor
    Found in app/src/controllers/object.js and 1 other location - About 55 mins to fix
    app/src/controllers/object.js on lines 1096..1099

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

    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

              const dissociateMetadata = associatedMetadata.filter(({ metadataId }) => {
                return !dbMetadata.some(({ id }) => id === metadataId);
              });
    Severity: Minor
    Found in app/src/services/metadata.js and 1 other location - About 55 mins to fix
    app/src/services/tag.js on lines 76..78

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

    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

              response = await VersionMetadata.query(trx)
                .insert(newJoins.map(({ id }) => ({
                  versionId: versionId,
                  metadataId: id,
                  createdBy: currentUserId
    Severity: Minor
    Found in app/src/services/metadata.js and 1 other location - About 55 mins to fix
    app/src/services/tag.js on lines 81..86

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

    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

        try {
          const tables = Object.values(models).map(model => model.tableName);
          return Promise
            .all(tables.map(table => Promise
              .all(schemas.map(schema => this._knex.schema.withSchema(schema).hasTable(table)))))
    Severity: Minor
    Found in app/src/db/dataConnection.js and 1 other location - About 55 mins to fix
    app/src/db/dataConnection.js on lines 134..142

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

    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 9 locations. Consider refactoring.
    Open

    router.delete('/:objectId/metadata', requireSomeAuth, objectValidator.deleteMetadata,
      currentObject, hasPermission(Permissions.UPDATE), (req, res, next) => {
        objectController.deleteMetadata(req, res, next);
      }
    );
    Severity: Major
    Found in app/src/routes/v1/object.js and 8 other locations - About 55 mins to fix
    app/src/routes/v1/object.js on lines 57..61
    app/src/routes/v1/object.js on lines 64..68
    app/src/routes/v1/object.js on lines 71..75
    app/src/routes/v1/object.js on lines 78..82
    app/src/routes/v1/object.js on lines 85..89
    app/src/routes/v1/object.js on lines 99..103
    app/src/routes/v1/object.js on lines 106..110
    app/src/routes/v1/object.js on lines 113..117

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

    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 9 locations. Consider refactoring.
    Open

    router.put('/:objectId/tagging', requireSomeAuth, objectValidator.replaceTags,
      currentObject, hasPermission(Permissions.UPDATE), (req, res, next) => {
        objectController.replaceTags(req, res, next);
      }
    );
    Severity: Major
    Found in app/src/routes/v1/object.js and 8 other locations - About 55 mins to fix
    app/src/routes/v1/object.js on lines 57..61
    app/src/routes/v1/object.js on lines 64..68
    app/src/routes/v1/object.js on lines 71..75
    app/src/routes/v1/object.js on lines 78..82
    app/src/routes/v1/object.js on lines 85..89
    app/src/routes/v1/object.js on lines 92..96
    app/src/routes/v1/object.js on lines 99..103
    app/src/routes/v1/object.js on lines 106..110

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

    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

    Severity
    Category
    Status
    Source
    Language