MailOnline/videojs-vast-vpaid

View on GitHub

Showing 331 of 331 total issues

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

  describe("clickTrackings", function () {
    it("must be an array", function () {
      assert.isArray(videoClicks.clickTrackings);
    });

Severity: Major
Found in test/ads/vast/VideoClicks.spec.js and 1 other location - About 7 hrs to fix
test/ads/vast/VideoClicks.spec.js on lines 47..68

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

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 VPAIDIntegrator.js has 449 lines of code (exceeds 250 allowed). Consider refactoring.
Open

'use strict';

var MimeTypes = require('../../utils/mimetypes');
var VASTError = require('../vast/VASTError');
var VASTResponse = require('../vast/VASTResponse');
Severity: Minor
Found in src/scripts/ads/vpaid/VPAIDIntegrator.js - About 6 hrs to fix

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

          it("must return a 101 error to the callback and track it if one of the ads in the chain is a wrapper with no VASTAdTagURI", function(){
            var adTagUrl = 'http://foo.bar/';
            vast._getVASTAd(adTagUrl, callback);
            this.clock.tick();
    
    
    Severity: Major
    Found in test/ads/vast/VASTClient.spec.js and 3 other locations - About 5 hrs to fix
    test/ads/vast/VASTClient.spec.js on lines 491..506
    test/ads/vast/VASTClient.spec.js on lines 508..523
    test/ads/vast/VASTClient.spec.js on lines 525..540

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

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

          it("must pass a 101 error to the callback and track it if one of the ads on the adChain returned an inline and a wrapper on the same ad", function(){
            var adTagUrl = 'http://foo.bar/';
            vast._getVASTAd(adTagUrl, callback);
            this.clock.tick();
    
    
    Severity: Major
    Found in test/ads/vast/VASTClient.spec.js and 3 other locations - About 5 hrs to fix
    test/ads/vast/VASTClient.spec.js on lines 508..523
    test/ads/vast/VASTClient.spec.js on lines 525..540
    test/ads/vast/VASTClient.spec.js on lines 542..557

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

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

          it("must pass a 101 error to the callback and track it if the ad in the chain had neither a wrapper nor an inline", function(){
            var adTagUrl = 'http://foo.bar/';
            vast._getVASTAd(adTagUrl, callback);
            this.clock.tick();
    
    
    Severity: Major
    Found in test/ads/vast/VASTClient.spec.js and 3 other locations - About 5 hrs to fix
    test/ads/vast/VASTClient.spec.js on lines 491..506
    test/ads/vast/VASTClient.spec.js on lines 525..540
    test/ads/vast/VASTClient.spec.js on lines 542..557

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

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

          it("must return a 101 error to the callback and track it if one of the ads in the chain contains an inline with no creative", function(){
            var adTagUrl = 'http://foo.bar/';
            vast._getVASTAd(adTagUrl, callback);
            this.clock.tick();
    
    
    Severity: Major
    Found in test/ads/vast/VASTClient.spec.js and 3 other locations - About 5 hrs to fix
    test/ads/vast/VASTClient.spec.js on lines 491..506
    test/ads/vast/VASTClient.spec.js on lines 508..523
    test/ads/vast/VASTClient.spec.js on lines 542..557

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

    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 _setupEvents has 136 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    VPAIDIntegrator.prototype._setupEvents = function (adUnit, vastResponse, next) {
      var adUnitSrc = adUnit.options.src;
      var tracker = this._createVASTTracker(adUnitSrc, vastResponse);
      var player = this.player;
      var that = this;
    Severity: Major
    Found in src/scripts/ads/vpaid/VPAIDIntegrator.js - About 5 hrs to fix

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

        parseOffset: function parseOffset(offset, duration) {
          if (isPercentage(offset)) {
            return calculatePercentage(offset, duration);
          }
          return vastUtil.parseDuration(offset);
      Severity: Major
      Found in src/scripts/ads/vast/vastUtil.js and 1 other location - About 5 hrs to fix
      src/scripts/ads/vast/parsers.js on lines 36..58

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

      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

        offset: function parseOffset(offset, duration) {
          if(isPercentage(offset)){
            return calculatePercentage(offset, duration);
          }
          return parsers.duration(offset);
      Severity: Major
      Found in src/scripts/ads/vast/parsers.js and 1 other location - About 5 hrs to fix
      src/scripts/ads/vast/vastUtil.js on lines 111..133

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

      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 VASTTracker.spec.js has 378 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      'use strict';
      
      describe("VASTTracker", function () {
      
        var TrackingEvent = require('ads/vast/TrackingEvent');
      Severity: Minor
      Found in test/ads/vast/VASTTracker.spec.js - About 5 hrs to fix

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

        var dom = require('utils/dom');
        var testUtils = require('../test-utils');
        
        describe("dom", function () {
          var testDiv;
        Severity: Minor
        Found in test/utils/dom.spec.js - About 4 hrs to fix

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

              describe("_addCustomClicks", function () {
                it("must not add any customClick unless you pass an array with them inside", function () {
                  response._addCustomClicks();
                  response._addCustomClicks({});
                  response._addCustomClicks('');
          Severity: Major
          Found in test/ads/vast/VASTResponse.spec.js and 1 other location - About 4 hrs to fix
          test/ads/vast/VASTResponse.spec.js on lines 224..244

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

          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

              describe("_addClickTrackings", function () {
                it("must not add any clickTracking if you don't pass an array of tracking urls", function () {
                  response._addClickTrackings();
                  response._addClickTrackings({});
                  response._addClickTrackings('');
          Severity: Major
          Found in test/ads/vast/VASTResponse.spec.js and 1 other location - About 4 hrs to fix
          test/ads/vast/VASTResponse.spec.js on lines 246..266

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

          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 _getVASTAd has 120 lines of code (exceeds 25 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: Major
          Found in src/scripts/ads/vast/VASTClient.js - About 4 hrs to fix

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

                   it("must remove the adUnit but not restore the video content on 'vast.reset' evt", function(){
                    player.vast.adUnit = {
                      type: 'FAKE',
                      pauseAd: utilities.noop,
                      resumeAd: utilities.noop,
            Severity: Major
            Found in test/plugin/videojs.vast.spec.js and 1 other location - About 4 hrs to fix
            test/plugin/videojs.vast.spec.js on lines 442..454

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

            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 pass an error to the callback if the VPAID version is bigger than 2.x.x", function () {
                    vpaidIntegrator._handshake(adUnitWrapper, response, next);
                    sinon.assert.calledWith(vpaidAdUnit.handshakeVersion, '2.0');
                    var respond = testUtils.secondArg(vpaidAdUnit.handshakeVersion);
                    respond(null, '3.0.0');
            Severity: Major
            Found in test/ads/vpaid/VPAIDIntegrator.spec.js and 1 other location - About 4 hrs to fix
            test/ads/vpaid/VPAIDIntegrator.spec.js on lines 391..400

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

            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 pass an error to the callback if the VPAID version is smaller than 1.0", function () {
                    vpaidIntegrator._handshake(adUnitWrapper, response, next);
                    sinon.assert.calledWith(vpaidAdUnit.handshakeVersion, '2.0');
                    var respond = testUtils.secondArg(vpaidAdUnit.handshakeVersion);
                    respond(null, '0.0.0');
            Severity: Major
            Found in test/ads/vpaid/VPAIDIntegrator.spec.js and 1 other location - About 4 hrs to fix
            test/ads/vpaid/VPAIDIntegrator.spec.js on lines 402..411

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

            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 remove the adUnit and restore the video content on 'vast.adsCancel' evt", function(){
                    player.vast.adUnit = {
                      type: 'FAKE',
                      pauseAd: utilities.noop,
                      resumeAd: utilities.noop,
            Severity: Major
            Found in test/plugin/videojs.vast.spec.js and 1 other location - About 4 hrs to fix
            test/plugin/videojs.vast.spec.js on lines 456..468

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

            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

                  it("must not trigger vast.adStart or call the callback if the ad was canceled before the playing evt", function () {
                    var spy = sinon.spy();
                    player.on('vast.adStart', spy);
                    vastIntegrator._playSelectedAd(mediaFile, response, callback);
                    player.trigger('durationchange');
            Severity: Major
            Found in test/ads/vast/VASTIntegrator.spec.js and 2 other locations - About 4 hrs to fix
            test/ads/vast/VASTIntegrator.spec.js on lines 472..482
            test/ads/vast/VASTIntegrator.spec.js on lines 484..494

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

            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

                  it("must not call the callback if the ad was canceled before the ended evt", function () {
                    var spy = sinon.spy();
                    player.on('vast.adStart', spy);
                    vastIntegrator._playSelectedAd(mediaFile, response, callback);
                    player.trigger('durationchange');
            Severity: Major
            Found in test/ads/vast/VASTIntegrator.spec.js and 2 other locations - About 4 hrs to fix
            test/ads/vast/VASTIntegrator.spec.js on lines 460..470
            test/ads/vast/VASTIntegrator.spec.js on lines 484..494

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

            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