prebid/Prebid.js

View on GitHub
modules/lemmaDigitalBidAdapter.js

Summary

Maintainability
F
4 days
Test Coverage

File lemmaDigitalBidAdapter.js has 452 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import * as utils from '../src/utils.js';
import { config } from '../src/config.js';
import { registerBidder } from '../src/adapters/bidderFactory.js';
import { BANNER, VIDEO } from '../src/mediaTypes.js';

Severity: Minor
Found in modules/lemmaDigitalBidAdapter.js - About 6 hrs to fix

    Function _getImpressionObject has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
    Open

      _getImpressionObject: (bid) => {
        var impression = {};
        var bObj;
        var vObj;
        var sizes = bid.hasOwnProperty('sizes') ? bid.sizes : [];
    Severity: Minor
    Found in modules/lemmaDigitalBidAdapter.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 _getBannerRequest has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

      _getBannerRequest: (bid) => {
        var bObj;
        var adFormat = [];
        if (utils.deepAccess(bid, 'mediaTypes.banner')) {
          var params = bid ? bid.params : null;
    Severity: Minor
    Found in modules/lemmaDigitalBidAdapter.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

    spec has 23 functions (exceeds 20 allowed). Consider refactoring.
    Open

    export var spec = {
    
      code: BIDDER_CODE,
      supportedMediaTypes: [BANNER, VIDEO],
    
    
    Severity: Minor
    Found in modules/lemmaDigitalBidAdapter.js - About 2 hrs to fix

      Function _getImpressionObject has 54 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        _getImpressionObject: (bid) => {
          var impression = {};
          var bObj;
          var vObj;
          var sizes = bid.hasOwnProperty('sizes') ? bid.sizes : [];
      Severity: Major
      Found in modules/lemmaDigitalBidAdapter.js - About 2 hrs to fix

        Function _parseRTBResponse has 48 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          _parseRTBResponse: (request, response) => {
            var bidResponses = [];
            try {
              if (response.seatbid) {
                var currency = response.curr || DEFAULT_CURRENCY;
        Severity: Minor
        Found in modules/lemmaDigitalBidAdapter.js - About 1 hr to fix

          Function _createoRTBRequest has 39 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            _createoRTBRequest: (bidRequests, conf) => {
              var oRTBObject = {};
              try {
                oRTBObject = {
                  id: spec._createUUID(),
          Severity: Minor
          Found in modules/lemmaDigitalBidAdapter.js - About 1 hr to fix

            Function _getBannerRequest has 34 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              _getBannerRequest: (bid) => {
                var bObj;
                var adFormat = [];
                if (utils.deepAccess(bid, 'mediaTypes.banner')) {
                  var params = bid ? bid.params : null;
            Severity: Minor
            Found in modules/lemmaDigitalBidAdapter.js - About 1 hr to fix

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

                _getVideoRequest: (bid) => {
                  var vObj;
                  if (utils.deepAccess(bid, 'mediaTypes.video')) {
                    var params = bid ? bid.params : null;
                    var videoData = utils.mergeDeep(utils.deepAccess(bid.mediaTypes, 'video'), params.video);
              Severity: Minor
              Found in modules/lemmaDigitalBidAdapter.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 _createoRTBRequest has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

                _createoRTBRequest: (bidRequests, conf) => {
                  var oRTBObject = {};
                  try {
                    oRTBObject = {
                      id: spec._createUUID(),
              Severity: Minor
              Found in modules/lemmaDigitalBidAdapter.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 _getDeviceObject has 27 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                _getDeviceObject: (request) => {
                  var params = request && request.params ? request.params : null;
                  if (params) {
                    return {
                      dnt: utils.getDNT() ? 1 : 0,
              Severity: Minor
              Found in modules/lemmaDigitalBidAdapter.js - About 1 hr to fix

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

                  isBidRequestValid: (bid) => {
                    if (!bid || !bid.params) {
                      utils.logError(LOG_WARN_PREFIX, 'nil/empty bid object');
                      return false;
                    }
                Severity: Minor
                Found in modules/lemmaDigitalBidAdapter.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 _getSiteObject has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                  _getSiteObject: (request, conf) => {
                    var params = request && request.params ? request.params : null;
                    if (params) {
                      pubId = params.pubId ? params.pubId : '0';
                      var siteId = params.siteId ? params.siteId : '0';
                Severity: Minor
                Found in modules/lemmaDigitalBidAdapter.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

                Consider simplifying this complex logical expression.
                Open

                    if (params) {
                      return {
                        dnt: utils.getDNT() ? 1 : 0,
                        ua: navigator.userAgent,
                        language: (navigator.language || navigator.browserLanguage || navigator.userLanguage || navigator.systemLanguage),
                Severity: Major
                Found in modules/lemmaDigitalBidAdapter.js - About 40 mins to fix

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

                    _endPointURL: (request) => {
                      var params = request && request[0].params ? request[0].params : null;
                      if (params) {
                        pubId = params.pubId ? params.pubId : 0;
                        adunitId = params.adunitId ? params.adunitId : 0;
                  Severity: Minor
                  Found in modules/lemmaDigitalBidAdapter.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

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

                    _getAppObject: (request) => {
                      var params = request && request.params ? request.params : null;
                      if (params) {
                        pubId = params.pubId ? params.pubId : 0;
                        var appParams = params.app;
                  Severity: Minor
                  Found in modules/lemmaDigitalBidAdapter.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 true;
                  Severity: Major
                  Found in modules/lemmaDigitalBidAdapter.js - About 30 mins to fix

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

                      _getDeviceObject: (request) => {
                        var params = request && request.params ? request.params : null;
                        if (params) {
                          return {
                            dnt: utils.getDNT() ? 1 : 0,
                    Severity: Minor
                    Found in modules/lemmaDigitalBidAdapter.js - About 25 mins to fix

                    Cognitive Complexity

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

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

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

                    Further reading

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

                          [BANNER, VIDEO].forEach(mediaType => {
                            if (impObj.hasOwnProperty(mediaType)) {
                              let floorInfo = bid.getFloor({ currency: impObj.bidfloorcur, mediaType: mediaType, size: '*' });
                              if (typeof floorInfo === 'object' && floorInfo.currency === impObj.bidfloorcur && !isNaN(parseInt(floorInfo.floor))) {
                                let mediaTypeFloor = parseFloat(floorInfo.floor);
                    Severity: Major
                    Found in modules/lemmaDigitalBidAdapter.js and 1 other location - About 5 hrs to fix
                    modules/pubwiseBidAdapter.js on lines 667..675

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

                    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