MailOnline/videojs-vast-vpaid

View on GitHub

Showing 91 of 331 total issues

Function _getVASTAd has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

VASTClient.prototype._getVASTAd = function (adTagUrl, callback) {
  var that = this;

  getAdWaterfall(adTagUrl, function (error, vastTree) {
    var waterfallAds = vastTree && utilities.isArray(vastTree.ads) ? vastTree.ads : null;
Severity: Minor
Found in src/scripts/ads/vast/VASTClient.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 run has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

HttpRequest.prototype.run = function (method, url, callback, options) {
  sanityCheck(url, callback, options);
  var timeout, timeoutId;
  var xhr = this.createXhr();
  options = options || {};
Severity: Minor
Found in src/scripts/utils/http.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 trackProgress has 68 lines of code (exceeds 25 allowed). Consider refactoring.
Open

VASTTracker.prototype.trackProgress = function trackProgress(newProgressInMs) {
  var that = this;
  var events = [];
  var ONCE = true;
  var ALWAYS = false;
Severity: Major
Found in src/scripts/ads/vast/VASTTracker.js - About 2 hrs to fix

    File http.spec.js has 274 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    var HttpRequest = require('utils/http').HttpRequest;
    var HttpRequestError = require('utils/http').HttpRequestError;
    var utilities = require('utils/utilityFunctions');
    
    var testUtils = require('../test-utils');
    Severity: Minor
    Found in test/utils/http.spec.js - About 2 hrs to fix

      Function run has 64 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      HttpRequest.prototype.run = function (method, url, callback, options) {
        sanityCheck(url, callback, options);
        var timeout, timeoutId;
        var xhr = this.createXhr();
        options = options || {};
      Severity: Major
      Found in src/scripts/utils/http.js - About 2 hrs to fix

        Function playVPaidAd has 64 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        VPAIDIntegrator.prototype.playAd = function playVPaidAd(vastResponse, callback) {
          if (!(vastResponse instanceof VASTResponse)) {
            return callback(new VASTError('on VASTIntegrator.playAd, missing required VASTResponse'));
          }
        
        
        Severity: Major
        Found in src/scripts/ads/vpaid/VPAIDIntegrator.js - About 2 hrs to fix

          File VASTIntegrator.js has 273 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          'use strict';
          
          /**
           * Inner helper class that deals with the logic of the individual steps needed to setup an ad in the player.
           *
          Severity: Minor
          Found in src/scripts/ads/vast/VASTIntegrator.js - About 2 hrs to fix

            Function restorePlayerSnapshot has 60 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            playerUtils.restorePlayerSnapshot = function restorePlayerSnapshot(player, snapshot) {
              var tech = player.el().querySelector('.vjs-tech');
              var attempts = 20; // the number of remaining attempts to restore the snapshot
            
              if (snapshot.nativePoster) {
            Severity: Major
            Found in src/scripts/utils/playerUtils.js - About 2 hrs to fix

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

                function playAd(vastResponse, callback) {
                  //TODO: Find a better way to stop the play. The 'playPrerollWaterfall' ends in an inconsistent situation
                  //If the state is not 'preroll?' it means the ads were canceled therefore, we break the waterfall
                  if (adsCanceled) {
                    return;
              Severity: Major
              Found in src/scripts/plugin/videojs.vast.vpaid.js - About 2 hrs to fix

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

                function Linear(linearJTree) {
                  if (!(this instanceof Linear)) {
                    return new Linear(linearJTree);
                  }
                
                
                Severity: Minor
                Found in src/scripts/ads/vast/Linear.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 setupEvents has 56 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                VASTIntegrator.prototype._setupEvents = function setupEvents(adMediaFile, tracker, response, callback) {
                  var previouslyMuted;
                  var player = this.player;
                  player.on('fullscreenchange', trackFullscreenChange);
                  player.on('vast.adStart', trackImpressions);
                Severity: Major
                Found in src/scripts/ads/vast/VASTIntegrator.js - About 2 hrs to fix

                  File utilityFunctions.js has 256 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  /*jshint unused:false */
                  "use strict";
                  
                  var NODE_TYPE_ELEMENT = 1;
                  var SNAKE_CASE_REGEXP = /[A-Z]/g;
                  Severity: Minor
                  Found in src/scripts/utils/utilityFunctions.js - About 2 hrs to fix

                    Function Companion has 53 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    function Companion(companionJTree) {
                      if (!(this instanceof Companion)) {
                        return new Companion(companionJTree);
                      }
                    
                    
                    Severity: Major
                    Found in src/scripts/ads/vast/Companion.js - About 2 hrs to fix

                      Function addSkipButton has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      VASTIntegrator.prototype._addSkipButton = function addSkipButton(source, tracker, response, callback) {
                        var skipOffsetInSec;
                        var that = this;
                      
                        if (utilities.isNumber(response.skipoffset)) {
                      Severity: Minor
                      Found in src/scripts/ads/vast/VASTIntegrator.js - About 1 hr to fix

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

                        VASTIntegrator.prototype._addSkipButton = function addSkipButton(source, tracker, response, callback) {
                          var skipOffsetInSec;
                          var that = this;
                        
                          if (utilities.isNumber(response.skipoffset)) {
                        Severity: Minor
                        Found in src/scripts/ads/vast/VASTIntegrator.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 removeClass has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                        Open

                        dom.removeClass = function (el, cssClass) {
                          var classes;
                        
                          if (utilities.isNotEmptyString(cssClass)) {
                            if (el.classList) {
                        Severity: Minor
                        Found in src/scripts/utils/dom.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 addClickThrough has 42 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        VASTIntegrator.prototype._addClickThrough = function addClickThrough(mediaFile, tracker, response, callback) {
                          var player = this.player;
                          var blocker = createClickThroughBlocker(player, tracker, response);
                          var updateBlocker = updateBlockerURL.bind(this, blocker, response, player);
                        
                        
                        Severity: Minor
                        Found in src/scripts/ads/vast/VASTIntegrator.js - About 1 hr to fix

                          Function FakeAdUnit has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            function FakeAdUnit() {
                              var events = {};
                              this.options = {
                                src: 'fakeSrc'
                              };
                          Severity: Minor
                          Found in test/ads/vpaid/VPAIDIntegrator.spec.js - About 1 hr to fix

                            Function _addSkipButton has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            VPAIDIntegrator.prototype._addSkipButton = function (adUnit, vastResponse, next) {
                              var skipButton;
                              var player = this.player;
                            
                              adUnit.on('AdSkippableStateChange', updateSkipButtonState);
                            Severity: Minor
                            Found in src/scripts/ads/vpaid/VPAIDIntegrator.js - About 1 hr to fix

                              Function monkeyPatchPlayerApi has 40 lines of code (exceeds 25 allowed). Consider refactoring.
                              Open

                                function monkeyPatchPlayerApi() {
                              
                                  /**
                                   * Monkey patch needed to handle firstPlay and resume of playing ad.
                                   *
                              Severity: Minor
                              Found in src/scripts/utils/playerUtils.js - About 1 hr to fix
                                Severity
                                Category
                                Status
                                Source
                                Language