MailOnline/videojs-vast-vpaid

View on GitHub

Showing 331 of 331 total issues

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

      it("must add the InLine to the response if the passed ad has an InLine", function(){
        var vastJTree = xml.toJXONTree('<VAST><Ad><InLine></InLine></Ad></VAST>');
        var ad = new Ad(vastJTree.ad);
        sinon.stub(response, '_addInLine');
        response.addAd(ad);
Severity: Major
Found in test/ads/vast/VASTResponse.spec.js and 1 other location - About 2 hrs to fix
test/ads/vast/VASTResponse.spec.js on lines 128..134

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

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

  it("must return false if you don't pass a valid string", function () {
    assert.isFalse(utilities.isNotEmptyString());
    assert.isFalse(utilities.isNotEmptyString({}));
    assert.isFalse(utilities.isNotEmptyString([]));
    assert.isFalse(utilities.isNotEmptyString(0));
Severity: Major
Found in test/utils/utilityFunctions.spec.js and 1 other location - About 2 hrs to fix
test/utils/utilityFunctions.spec.js on lines 177..182

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

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

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

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

          it("must not cancel the ads", function(){
            var adsCanceled = sinon.spy();
            player.on('vast.adsCancel', adsCanceled);
            player.vast.enable();
            player.trigger('vast.firstPlay');
    Severity: Major
    Found in test/plugin/videojs.vast.spec.js and 1 other location - About 2 hrs to fix
    test/plugin/videojs.vast.spec.js on lines 221..228

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

    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

        it("must cancel the ads if the ads are not enabled", function(){
          var adsCanceled = sinon.spy();
          player.on('vast.adsCancel', adsCanceled);
          player.vast.disable();
          player.trigger('vast.firstPlay');
    Severity: Major
    Found in test/plugin/videojs.vast.spec.js and 1 other location - About 2 hrs to fix
    test/plugin/videojs.vast.spec.js on lines 273..281

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

    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

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

        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

          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

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

                  it("must add the impressions to the response", function () {
                    var wrapperXML = '<Wrapper>' +
                      '<Impression id="1234"><![CDATA[http://Impression.url.track.com]]></Impression>' +
                      '<Impression><![CDATA[http://Impression2.url.track.com]]></Impression>' +
                      '<Impression id="1111"></Impression>' +
            Severity: Major
            Found in test/ads/vast/VASTResponse.spec.js and 1 other location - About 2 hrs to fix
            test/ads/vast/VASTResponse.spec.js on lines 502..516

            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

                  it("must add the impressions to the response", function () {
                    var impressionXML = '<Inline>' +
                      '<Impression id="1234"><![CDATA[http://Impression.url.track.com]]></Impression>' +
                      '<Impression><![CDATA[http://Impression2.url.track.com]]></Impression>' +
                      '<Impression id="1111"></Impression>' +
            Severity: Major
            Found in test/ads/vast/VASTResponse.spec.js and 1 other location - About 2 hrs to fix
            test/ads/vast/VASTResponse.spec.js on lines 541..555

            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

              function parseTrackingEvents(trackingEvents) {
                var trackings = [];
                if (utilities.isDefined(trackingEvents)) {
                  trackingEvents = utilities.isArray(trackingEvents) ? trackingEvents : [trackingEvents];
                  trackingEvents.forEach(function (trackingData) {
            Severity: Major
            Found in src/scripts/ads/vast/Companion.js and 1 other location - About 2 hrs to fix
            src/scripts/ads/vast/Linear.js on lines 50..60

            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

              function parseMediaFiles(mediaFilesJxonTree) {
                var mediaFiles = [];
                if (utilities.isDefined(mediaFilesJxonTree)) {
                  mediaFilesJxonTree = utilities.isArray(mediaFilesJxonTree) ? mediaFilesJxonTree : [mediaFilesJxonTree];
            
            
            Severity: Major
            Found in src/scripts/ads/vast/Linear.js and 1 other location - About 2 hrs to fix
            src/scripts/ads/vast/Companion.js on lines 73..82

            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

            xml.encode = function encodeXML(str) {
              if (!utilities.isString(str)) return undefined;
            
              return str.replace(/&/g, '&amp;')
                .replace(/</g, '&lt;')
            Severity: Major
            Found in src/scripts/utils/xml.js and 1 other location - About 2 hrs to fix
            src/scripts/utils/xml.js on lines 140..148

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

            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

            xml.decode = function decodeXML(str) {
              if (!utilities.isString(str)) return undefined;
            
              return str.replace(/&apos;/g, "'")
                .replace(/&quot;/g, '"')
            Severity: Major
            Found in src/scripts/utils/xml.js and 1 other location - About 2 hrs to fix
            src/scripts/utils/xml.js on lines 130..138

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

            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

            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

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

                        it("must add the trackingEvents", function(){
                          var wrapperXML = '<Wrapper><Creatives><Creative><Linear><TrackingEvents>' +
                            '<Tracking event="firstQuartile"><![CDATA[ http://www.tracking1.com ]]></Tracking>' +
                            '</TrackingEvents></Linear></Creative></Creatives></Wrapper>';
                
                
                Severity: Major
                Found in test/ads/vast/VASTResponse.spec.js and 1 other location - About 2 hrs to fix
                test/ads/vast/VASTResponse.spec.js on lines 422..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 82.

                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

                      it("must add the trackings to the response", function () {
                        var linearXML = '<Linear><TrackingEvents>' +
                          '<Tracking event="firstQuartile"><![CDATA[ http://www.tracking1.com ]]></Tracking>' +
                          '</TrackingEvents></Linear>';
                        var linear = new Linear(xml.toJXONTree(linearXML));
                Severity: Major
                Found in test/ads/vast/VASTResponse.spec.js and 1 other location - About 2 hrs to fix
                test/ads/vast/VASTResponse.spec.js on lines 573..581

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

                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

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

                  function assertError(callback, msg, code) {
                    var error = testUtils.firstArg(callback);
                    assert.instanceOf(error, VASTError);
                    assert.equal(error.message, "VAST Error: " + msg);
                    if (code) {
                Severity: Major
                Found in test/ads/vast/VASTIntegrator.spec.js and 1 other location - About 2 hrs to fix
                test/ads/vast/VASTClient.spec.js on lines 18..25

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

                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

                Severity
                Category
                Status
                Source
                Language