Kinvey/js-sdk

View on GitHub
packages/js-sdk/src/query.ts

Summary

Maintainability
F
5 days
Test Coverage

File query.ts has 457 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import { isString, isNumber, isPlainObject, isObject, isEmpty, isArray, cloneDeep, pick } from 'lodash-es';
import sift from 'sift';
import { QueryError } from './errors/query';

const UNSUPPORTED_CONDITIONS = ['$nearSphere'];
Severity: Minor
Found in packages/js-sdk/src/query.ts - About 7 hrs to fix

    Query has 39 functions (exceeds 20 allowed). Consider refactoring.
    Open

    export class Query {
      private _parent?: Query;
      public filter: any;
      private _fields?: string[];
      private _sort?: any;
    Severity: Minor
    Found in packages/js-sdk/src/query.ts - About 5 hrs to fix

      Function process has 59 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        process(docs: object[] = []) {
          const queryPlainObject = this.toPlainObject();
      
          if (!Array.isArray(docs)) {
            throw new Error('data argument must be of type: Array.');
      Severity: Major
      Found in packages/js-sdk/src/query.ts - About 2 hrs to fix

        Function process has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
        Open

          process(docs: object[] = []) {
            const queryPlainObject = this.toPlainObject();
        
            if (!Array.isArray(docs)) {
              throw new Error('data argument must be of type: Array.');
        Severity: Minor
        Found in packages/js-sdk/src/query.ts - About 2 hrs 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 matches has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

          matches(field: string, expression: any, options: { ignoreCase?: boolean, multiline?: boolean, extended?: boolean, dotMatchesAll?: boolean } = {}) {
            const flags = [];
            let regExp = expression;
        
            if (!(regExp instanceof RegExp)) {
        Severity: Minor
        Found in packages/js-sdk/src/query.ts - 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 matches has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          matches(field: string, expression: any, options: { ignoreCase?: boolean, multiline?: boolean, extended?: boolean, dotMatchesAll?: boolean } = {}) {
            const flags = [];
            let regExp = expression;
        
            if (!(regExp instanceof RegExp)) {
        Severity: Minor
        Found in packages/js-sdk/src/query.ts - About 1 hr to fix

          Function addFilter has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

            addFilter(field: string, ...args: any) {
              if (!isString(field)) {
                throw new QueryError('The field argument must be a string.');
              }
          
          
          Severity: Minor
          Found in packages/js-sdk/src/query.ts - About 35 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 join has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

            private join(operator: string, queries: any) {
              // Cast, validate, and parse arguments. If `queries` are supplied, obtain
              // the `filter` for joining. The eventual return function will be the
              // current query.
              let result = new Query(this);
          Severity: Minor
          Found in packages/js-sdk/src/query.ts - About 35 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

          Avoid too many return statements within this function.
          Open

                        return 0;
          Severity: Major
          Found in packages/js-sdk/src/query.ts - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                              return (aField < bField ? -1 : 1) * modifier;
            Severity: Major
            Found in packages/js-sdk/src/query.ts - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                                return 0;
              Severity: Major
              Found in packages/js-sdk/src/query.ts - About 30 mins to fix

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

                  containsAll(field: string, values: any) {
                    if (!values) {
                      throw new QueryError('You must supply a value.');
                    }
                
                
                Severity: Major
                Found in packages/js-sdk/src/query.ts and 2 other locations - About 2 hrs to fix
                packages/js-sdk/src/query.ts on lines 192..202
                packages/js-sdk/src/query.ts on lines 214..224

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

                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

                  contains(field: string, values: any) {
                    if (!values) {
                      throw new QueryError('You must supply a value.');
                    }
                
                
                Severity: Major
                Found in packages/js-sdk/src/query.ts and 2 other locations - About 2 hrs to fix
                packages/js-sdk/src/query.ts on lines 214..224
                packages/js-sdk/src/query.ts on lines 236..246

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

                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

                  notContainedIn(field: string, values: any) {
                    if (!values) {
                      throw new QueryError('You must supply a value.');
                    }
                
                
                Severity: Major
                Found in packages/js-sdk/src/query.ts and 2 other locations - About 2 hrs to fix
                packages/js-sdk/src/query.ts on lines 192..202
                packages/js-sdk/src/query.ts on lines 236..246

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

                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

                  set sort(sort) {
                    if (sort && !isPlainObject(sort)) {
                      throw new QueryError('sort must an Object');
                    }
                
                
                Severity: Major
                Found in packages/js-sdk/src/query.ts and 1 other location - About 1 hr to fix
                packages/js-sdk/src/query.ts on lines 102..112

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

                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

                  set limit(limit) {
                    if (limit && !isNumber(limit)) {
                      throw new QueryError('limit must be a number');
                    }
                
                
                Severity: Major
                Found in packages/js-sdk/src/query.ts and 1 other location - About 1 hr to fix
                packages/js-sdk/src/query.ts on lines 86..96

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

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

                  lessThan(field: string, value: any) {
                    if (!isNumber(value) && !isString(value)) {
                      throw new QueryError('You must supply a number or string.');
                    }
                
                
                Severity: Major
                Found in packages/js-sdk/src/query.ts and 3 other locations - About 1 hr to fix
                packages/js-sdk/src/query.ts on lines 258..264
                packages/js-sdk/src/query.ts on lines 276..282
                packages/js-sdk/src/query.ts on lines 312..318

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

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

                  lessThanOrEqualTo(field: string, value: any) {
                    if (!isNumber(value) && !isString(value)) {
                      throw new QueryError('You must supply a number or string.');
                    }
                
                
                Severity: Major
                Found in packages/js-sdk/src/query.ts and 3 other locations - About 1 hr to fix
                packages/js-sdk/src/query.ts on lines 258..264
                packages/js-sdk/src/query.ts on lines 276..282
                packages/js-sdk/src/query.ts on lines 294..300

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

                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

                  set fields(fields) {
                    if (!isArray(fields)) {
                      throw new QueryError('fields must be an Array');
                    }
                
                
                Severity: Major
                Found in packages/js-sdk/src/query.ts and 1 other location - About 1 hr to fix
                packages/js-sdk/src/query.ts on lines 118..128

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

                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

                  set skip(skip) {
                    if (!isNumber(skip)) {
                      throw new QueryError('skip must be a number');
                    }
                
                
                Severity: Major
                Found in packages/js-sdk/src/query.ts and 1 other location - About 1 hr to fix
                packages/js-sdk/src/query.ts on lines 70..80

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

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

                  greaterThanOrEqualTo(field: string, value: any) {
                    if (!isNumber(value) && !isString(value)) {
                      throw new QueryError('You must supply a number or string.');
                    }
                
                
                Severity: Major
                Found in packages/js-sdk/src/query.ts and 3 other locations - About 1 hr to fix
                packages/js-sdk/src/query.ts on lines 258..264
                packages/js-sdk/src/query.ts on lines 294..300
                packages/js-sdk/src/query.ts on lines 312..318

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

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

                  greaterThan(field: string, value: any) {
                    if (!isNumber(value) && !isString(value)) {
                      throw new QueryError('You must supply a number or string.');
                    }
                
                
                Severity: Major
                Found in packages/js-sdk/src/query.ts and 3 other locations - About 1 hr to fix
                packages/js-sdk/src/query.ts on lines 276..282
                packages/js-sdk/src/query.ts on lines 294..300
                packages/js-sdk/src/query.ts on lines 312..318

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

                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

                    if (!Array.isArray(bottomLeftCoord)
                      || !isNumber(bottomLeftCoord[0])
                      || !isNumber(bottomLeftCoord[1])) {
                      throw new QueryError('bottomLeftCoord must be a [number, number]');
                    }
                Severity: Major
                Found in packages/js-sdk/src/query.ts and 2 other locations - About 50 mins to fix
                packages/js-sdk/src/query.ts on lines 421..423
                packages/js-sdk/src/query.ts on lines 454..458

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

                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

                    if (!Array.isArray(upperRightCoord)
                      || !isNumber(upperRightCoord[0])
                      || !isNumber(upperRightCoord[1])) {
                      throw new QueryError('upperRightCoord must be a [number, number]');
                    }
                Severity: Major
                Found in packages/js-sdk/src/query.ts and 2 other locations - About 50 mins to fix
                packages/js-sdk/src/query.ts on lines 421..423
                packages/js-sdk/src/query.ts on lines 448..452

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

                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

                    if (!Array.isArray(coord) || !isNumber(coord[0]) || !isNumber(coord[1])) {
                      throw new QueryError('coord must be a [number, number]');
                    }
                Severity: Major
                Found in packages/js-sdk/src/query.ts and 2 other locations - About 50 mins to fix
                packages/js-sdk/src/query.ts on lines 448..452
                packages/js-sdk/src/query.ts on lines 454..458

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

                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

                There are no issues that match your filters.

                Category
                Status