prebid/Prebid.js

View on GitHub
modules/uid2IdSystem_shared.js

Summary

Maintainability
F
1 wk
Test Coverage

File uid2IdSystem_shared.js has 698 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/* eslint-disable no-console */
import { ajax } from '../src/ajax.js';
import { cyrb53Hash } from '../src/utils.js';

export const Uid2CodeVersion = '1.1';
Severity: Major
Found in modules/uid2IdSystem_shared.js - About 1 day to fix

    Function Uid2GetId has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
    Open

    export function Uid2GetId(config, prebidStorageManager, _logInfo, _logWarn) {
      let suppliedToken = null;
      const preferLocalStorage = (config.storage !== 'cookie');
      const storageManager = new Uid2StorageManager(prebidStorageManager, preferLocalStorage, config.internalStorage, _logInfo);
      _logInfo(`Module is using ${preferLocalStorage ? 'local storage' : 'cookies'} for internal storage.`);
    Severity: Minor
    Found in modules/uid2IdSystem_shared.js - About 4 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 callCstgApi has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
    Open

        async callCstgApi(requestBody, box) {
          const url = this._baseUrl + '/v2/token/client-generate';
          let resolvePromise;
          let rejectPromise;
          const promise = new Promise((resolve, reject) => {
    Severity: Minor
    Found in modules/uid2IdSystem_shared.js - About 3 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 Uid2GetId has 81 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export function Uid2GetId(config, prebidStorageManager, _logInfo, _logWarn) {
      let suppliedToken = null;
      const preferLocalStorage = (config.storage !== 'cookie');
      const storageManager = new Uid2StorageManager(prebidStorageManager, preferLocalStorage, config.internalStorage, _logInfo);
      _logInfo(`Module is using ${preferLocalStorage ? 'local storage' : 'cookies'} for internal storage.`);
    Severity: Major
    Found in modules/uid2IdSystem_shared.js - About 3 hrs to fix

      Function callCstgApi has 73 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          async callCstgApi(requestBody, box) {
            const url = this._baseUrl + '/v2/token/client-generate';
            let resolvePromise;
            let rejectPromise;
            const promise = new Promise((resolve, reject) => {
      Severity: Major
      Found in modules/uid2IdSystem_shared.js - About 2 hrs to fix

        Function getValidIdentity has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
        Open

            getValidIdentity(opts, _logWarn) {
              if (opts.emailHash) {
                if (!UID2DiiNormalization.isBase64Hash(opts.emailHash)) {
                  _logWarn('CSTG opts.emailHash is invalid');
                  return;
        Severity: Minor
        Found in modules/uid2IdSystem_shared.js - 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 callRefreshApi has 53 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          callRefreshApi(refreshDetails) {
            const url = this._baseUrl + '/v2/token/refresh';
            let resolvePromise;
            let rejectPromise;
            const promise = new Promise((resolve, reject) => {
        Severity: Major
        Found in modules/uid2IdSystem_shared.js - About 2 hrs to fix

          Consider simplifying this complex logical expression.
          Open

          if (FEATURES.UID2_CSTG) {
            const SERVER_PUBLIC_KEY_PREFIX_LENGTH = 9;
          
            clientSideTokenGenerator = {
              isCSTGOptionsValid(maybeOpts, _logWarn) {
          Severity: Critical
          Found in modules/uid2IdSystem_shared.js - About 2 hrs to fix

            Function callRefreshApi has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
            Open

              callRefreshApi(refreshDetails) {
                const url = this._baseUrl + '/v2/token/refresh';
                let resolvePromise;
                let rejectPromise;
                const promise = new Promise((resolve, reject) => {
            Severity: Minor
            Found in modules/uid2IdSystem_shared.js - About 1 hr to fix

            Cognitive Complexity

            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

            A method's cognitive complexity is based on a few simple rules:

            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
            • Code is considered more complex for each "break in the linear flow of the code"
            • Code is considered more complex when "flow breaking structures are nested"

            Further reading

            Function getStoredValueWithFallback has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
            Open

              getStoredValueWithFallback() {
                const preferredStorageLabel = this._preferLocalStorage ? 'local storage' : 'cookie';
                const preferredStorageGet = (this._preferLocalStorage ? this.readModuleStorage : this.readModuleCookie).bind(this);
                const preferredStorageSet = (this._preferLocalStorage ? this.writeModuleStorage : this.writeModuleCookie).bind(this);
                const fallbackStorageGet = (this._preferLocalStorage ? this.readModuleCookie : this.readModuleStorage).bind(this);
            Severity: Minor
            Found in modules/uid2IdSystem_shared.js - About 1 hr to fix

            Cognitive Complexity

            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

            A method's cognitive complexity is based on a few simple rules:

            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
            • Code is considered more complex for each "break in the linear flow of the code"
            • Code is considered more complex when "flow breaking structures are nested"

            Further reading

            Function isCSTGOptionsValid has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

                isCSTGOptionsValid(maybeOpts, _logWarn) {
                  if (typeof maybeOpts !== 'object' || maybeOpts === null) {
                    _logWarn('CSTG opts must be an object');
                    return false;
                  }
            Severity: Minor
            Found in modules/uid2IdSystem_shared.js - About 1 hr to fix

            Cognitive Complexity

            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

            A method's cognitive complexity is based on a few simple rules:

            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
            • Code is considered more complex for each "break in the linear flow of the code"
            • Code is considered more complex when "flow breaking structures are nested"

            Further reading

            Function getValidIdentity has 29 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                getValidIdentity(opts, _logWarn) {
                  if (opts.emailHash) {
                    if (!UID2DiiNormalization.isBase64Hash(opts.emailHash)) {
                      _logWarn('CSTG opts.emailHash is invalid');
                      return;
            Severity: Minor
            Found in modules/uid2IdSystem_shared.js - About 1 hr to fix

              Function success has 27 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                    success: (responseText) => {
                      try {
                        if (!refreshDetails.refresh_response_key) {
                          this._logInfo('No response decryption key available, assuming unencrypted JSON');
                          const response = JSON.parse(responseText);
              Severity: Minor
              Found in modules/uid2IdSystem_shared.js - About 1 hr to fix

                Function error has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                          error: (error, xhr) => {
                            try {
                              if (xhr.status === 400) {
                                const response = JSON.parse(xhr.responseText);
                                if (this.isCstgApiClientErrorResponse(response)) {
                Severity: Minor
                Found in modules/uid2IdSystem_shared.js - About 1 hr to fix

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

                            success: async (responseText, xhr) => {
                              try {
                                const encodedResp = UID2CstgCrypto.base64ToBytes(responseText);
                                const decrypted = await box.decrypt(
                                  encodedResp.slice(0, 12),
                  Severity: Minor
                  Found in modules/uid2IdSystem_shared.js - About 1 hr to fix

                    Function normalizeEmail has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                    Open

                        static normalizeEmail(email) {
                          if (!email || !email.length) return;
                    
                          const parsedEmail = email.trim().toLowerCase();
                          if (parsedEmail.indexOf(' ') > 0) return;
                    Severity: Minor
                    Found in modules/uid2IdSystem_shared.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 generateTokenAndStore has 6 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                          baseUrl,
                          cstgOpts,
                          cstgIdentity,
                          storageManager,
                          _logInfo,
                    Severity: Minor
                    Found in modules/uid2IdSystem_shared.js - About 45 mins to fix

                      Function refreshTokenAndStore has 6 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                      function refreshTokenAndStore(baseUrl, token, clientId, storageManager, _logInfo, _logWarn) {
                      Severity: Minor
                      Found in modules/uid2IdSystem_shared.js - About 45 mins to fix

                        Function isStoredTokenInvalid has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                        Open

                            isStoredTokenInvalid(cstgIdentity, storedTokens, _logInfo, _logWarn) {
                              if (storedTokens) {
                                if (storedTokens.latestToken === 'optout') {
                                  return true;
                                }
                        Severity: Minor
                        Found in modules/uid2IdSystem_shared.js - About 45 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 generateCstgRequest has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                        Open

                            async generateCstgRequest(cstgIdentity) {
                              if ('email_hash' in cstgIdentity || 'phone_hash' in cstgIdentity) {
                                return cstgIdentity;
                              }
                              if ('email' in cstgIdentity) {
                        Severity: Minor
                        Found in modules/uid2IdSystem_shared.js - 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 false;
                        Severity: Major
                        Found in modules/uid2IdSystem_shared.js - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                                  return { phone: opts.phone };
                          Severity: Major
                          Found in modules/uid2IdSystem_shared.js - About 30 mins to fix

                            Avoid too many return statements within this function.
                            Open

                                      return;
                            Severity: Major
                            Found in modules/uid2IdSystem_shared.js - About 30 mins to fix

                              Avoid too many return statements within this function.
                              Open

                                return { id: tokens };
                              Severity: Major
                              Found in modules/uid2IdSystem_shared.js - About 30 mins to fix

                                Avoid too many return statements within this function.
                                Open

                                          return;
                                Severity: Major
                                Found in modules/uid2IdSystem_shared.js - About 30 mins to fix

                                  Avoid too many return statements within this function.
                                  Open

                                        return true;
                                  Severity: Major
                                  Found in modules/uid2IdSystem_shared.js - About 30 mins to fix

                                    Avoid too many return statements within this function.
                                    Open

                                            return { email: normalizedEmail };
                                    Severity: Major
                                    Found in modules/uid2IdSystem_shared.js - About 30 mins to fix

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

                                                    } else if (xhr.status === 403) {
                                                      const response = JSON.parse(xhr.responseText);
                                                      if (this.isCstgApiForbiddenResponse(xhr)) {
                                                        rejectPromise(`Forbidden: ${response.message}`);
                                                      } else {
                                      Severity: Major
                                      Found in modules/uid2IdSystem_shared.js and 1 other location - About 2 hrs to fix
                                      modules/uid2IdSystem_shared.js on lines 523..549

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

                                      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 (xhr.status === 400) {
                                                      const response = JSON.parse(xhr.responseText);
                                                      if (this.isCstgApiClientErrorResponse(response)) {
                                                        rejectPromise(`Client error: ${response.message}`);
                                                      } else {
                                      Severity: Major
                                      Found in modules/uid2IdSystem_shared.js and 1 other location - About 2 hrs to fix
                                      modules/uid2IdSystem_shared.js on lines 534..549

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

                                      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 (opts.emailHash) {
                                              if (!UID2DiiNormalization.isBase64Hash(opts.emailHash)) {
                                                _logWarn('CSTG opts.emailHash is invalid');
                                                return;
                                              }
                                      Severity: Major
                                      Found in modules/uid2IdSystem_shared.js and 2 other locations - About 55 mins to fix
                                      modules/uid2IdSystem_shared.js on lines 229..235
                                      modules/uid2IdSystem_shared.js on lines 246..252

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

                                            if (opts.phone) {
                                              if (!UID2DiiNormalization.isNormalizedPhone(opts.phone)) {
                                                _logWarn('CSTG opts.phone is invalid');
                                                return;
                                              }
                                      Severity: Major
                                      Found in modules/uid2IdSystem_shared.js and 2 other locations - About 55 mins to fix
                                      modules/uid2IdSystem_shared.js on lines 221..227
                                      modules/uid2IdSystem_shared.js on lines 229..235

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

                                            if (opts.phoneHash) {
                                              if (!UID2DiiNormalization.isBase64Hash(opts.phoneHash)) {
                                                _logWarn('CSTG opts.phoneHash is invalid');
                                                return;
                                              }
                                      Severity: Major
                                      Found in modules/uid2IdSystem_shared.js and 2 other locations - About 55 mins to fix
                                      modules/uid2IdSystem_shared.js on lines 221..227
                                      modules/uid2IdSystem_shared.js on lines 246..252

                                      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

                                          return { callback: (cb) => {
                                            promise.then((result) => {
                                              _logInfo('Refresh reponded, passing the updated token on.', result);
                                              cb(result);
                                            });
                                      Severity: Minor
                                      Found in modules/uid2IdSystem_shared.js and 1 other location - About 35 mins to fix
                                      modules/uid2IdSystem_shared.js on lines 732..737

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

                                      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

                                              return { callback: (cb) => {
                                                promise.then((result) => {
                                                  _logInfo('Token generation responded, passing the new token on.', result);
                                                  cb(result);
                                                });
                                      Severity: Minor
                                      Found in modules/uid2IdSystem_shared.js and 1 other location - About 35 mins to fix
                                      modules/uid2IdSystem_shared.js on lines 752..757

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

                                      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

                                          isCstgApiClientErrorResponse(response) {
                                            return (
                                              this.hasStatusResponse(response) &&
                                              response.status === 'client_error' &&
                                              typeof response.message === 'string'
                                      Severity: Minor
                                      Found in modules/uid2IdSystem_shared.js and 1 other location - About 35 mins to fix
                                      modules/uid2IdSystem_shared.js on lines 423..429

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

                                      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

                                          isCstgApiForbiddenResponse(response) {
                                            return (
                                              this.hasStatusResponse(response) &&
                                              response.status === 'invalid_http_origin' &&
                                              typeof response.message === 'string'
                                      Severity: Minor
                                      Found in modules/uid2IdSystem_shared.js and 1 other location - About 35 mins to fix
                                      modules/uid2IdSystem_shared.js on lines 415..421

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

                                      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