MailOnline/videojs-vast-vpaid

View on GitHub
src/scripts/plugin/videojs.vast.vpaid.js

Summary

Maintainability
F
3 days
Test Coverage

Function VASTPlugin has 237 lines of code (exceeds 25 allowed). Consider refactoring.
Open

module.exports = function VASTPlugin(options) {
  var snapshot;
  var player = this;
  var vast = new VASTClient();
  var adsCanceled = false;
Severity: Major
Found in src/scripts/plugin/videojs.vast.vpaid.js - About 1 day to fix

    Function VASTPlugin has a Cognitive Complexity of 60 (exceeds 5 allowed). Consider refactoring.
    Open

    module.exports = function VASTPlugin(options) {
      var snapshot;
      var player = this;
      var vast = new VASTClient();
      var adsCanceled = false;
    Severity: Minor
    Found in src/scripts/plugin/videojs.vast.vpaid.js - About 1 day 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 tryToPlayPrerollAd has 92 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      function tryToPlayPrerollAd() {
        //We remove the poster to prevent flickering whenever the content starts playing
        playerUtils.removeNativePoster(player);
    
        playerUtils.once(player, ['vast.adsCancel', 'vast.adEnd'], function () {
    Severity: Major
    Found in src/scripts/plugin/videojs.vast.vpaid.js - About 3 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 preventManualProgress has 30 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            function preventManualProgress() {
              //IOS video clock is very unreliable and we need a 3 seconds threshold to ensure that the user forwarded/rewound the ad
              var PROGRESS_THRESHOLD = 3;
              var previousTime = 0;
              var skipad_attempts = 0;
        Severity: Minor
        Found in src/scripts/plugin/videojs.vast.vpaid.js - About 1 hr to fix

          There are no issues that match your filters.

          Category
          Status