MailOnline/videojs-vast-vpaid

View on GitHub

Showing 331 of 331 total issues

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

      it("must not trigger vast.contentEnd if there is a vast.firstPlay after restoring the content", function(){
        player.trigger('playing');
        player.trigger('vast.firstPlay');
        player.trigger('ended');
        sinon.assert.calledOnce(contentStartSpy);
Severity: Major
Found in test/plugin/videojs.vast.spec.js and 3 other locations - About 2 hrs to fix
test/plugin/videojs.vast.spec.js on lines 368..374
test/plugin/videojs.vast.spec.js on lines 376..382
test/plugin/videojs.vast.spec.js on lines 384..390

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

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 a string that contains the numbers with the fixed number of digits", function(){
    assert.equal(utilities.toFixedDigits(3, 2), '03');
    assert.equal(utilities.toFixedDigits(11, 2), '11');
    assert.equal(utilities.toFixedDigits(111,5), '00111');
  });
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 562..566

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

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 not trigger vast.contentEnd if there is a vast.reset after restoring the content", function(){
        player.trigger('playing');
        player.trigger('vast.reset');
        player.trigger('ended');
        sinon.assert.calledOnce(contentStartSpy);
Severity: Major
Found in test/plugin/videojs.vast.spec.js and 3 other locations - About 2 hrs to fix
test/plugin/videojs.vast.spec.js on lines 368..374
test/plugin/videojs.vast.spec.js on lines 376..382
test/plugin/videojs.vast.spec.js on lines 392..398

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

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

    describe("port", function () {
      it("must return the port of the url if specified", function () {
        assert.equal(urlUtils.urlParts('http://www.google.com').port, '80');
        assert.equal(urlUtils.urlParts('http://www.google.com:8080').port, '8080');
      });
Severity: Major
Found in test/utils/urlUtils.spec.js and 2 other locations - About 1 hr to fix
test/utils/urlUtils.spec.js on lines 47..52
test/utils/urlUtils.spec.js on lines 54..59

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

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

    describe("hostName", function () {
      it("must return the hostname of the url", function () {
        assert.equal(urlUtils.urlParts('http://www.google.com:8080').hostname, 'www.google.com');
        assert.equal(urlUtils.urlParts('http://gmail.com').hostname, 'gmail.com');
      });
Severity: Major
Found in test/utils/urlUtils.spec.js and 2 other locations - About 1 hr to fix
test/utils/urlUtils.spec.js on lines 47..52
test/utils/urlUtils.spec.js on lines 61..66

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

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

    describe("hash", function () {
      it("must return the hash part of a url without the #", function () {
        assert.equal(urlUtils.urlParts('http://www.google.com').hash, '');
        assert.equal(urlUtils.urlParts('http://google.com#nose').hash, 'nose');
      });
Severity: Major
Found in test/utils/urlUtils.spec.js and 2 other locations - About 1 hr to fix
test/utils/urlUtils.spec.js on lines 54..59
test/utils/urlUtils.spec.js on lines 61..66

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

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 none of the mediaFiles are supported", function () {
      linear.mediaFiles = [
        {
          isSupported: function () {
            return false;
Severity: Major
Found in test/ads/vast/Linear.spec.js and 1 other location - About 1 hr to fix
test/ads/vast/Linear.spec.js on lines 187..202

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

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 true if at least one of the mediaFiles is supported", function () {
      linear.mediaFiles = [
        {
          isSupported: function () {
            return false;
Severity: Major
Found in test/ads/vast/Linear.spec.js and 1 other location - About 1 hr to fix
test/ads/vast/Linear.spec.js on lines 204..219

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

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

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

      it("must return true for YYYY-MM-DD and YYYYMMDD and YYYYMMD date formats (complete date)", function(){
        assert.isTrue(utilities.isISO8601("1983-12-01"));
        assert.isTrue(utilities.isISO8601("19831201"));
        assert.isTrue(utilities.isISO8601("1983121"));
      });
    Severity: Major
    Found in test/utils/utilityFunctions.spec.js and 1 other location - About 1 hr to fix
    test/utils/utilityFunctions.spec.js on lines 362..366

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

    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 true if you pass a valid email", function () {
        assert.isTrue(utilities.isValidEmail('carlos@carlos.com'));
        assert.isTrue(utilities.isValidEmail('  carlos@carlos.com  '));
        assert.isTrue(utilities.isValidEmail('1ca123a#=.rlos@carlos.com'));
      });
    Severity: Major
    Found in test/utils/utilityFunctions.spec.js and 1 other location - About 1 hr to fix
    test/utils/utilityFunctions.spec.js on lines 669..673

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

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

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

            it("must remove the anchor on ad cancel", function(){
              vastIntegrator._addClickThrough(mediaFile, tracker, response, callback);
              assert.isNotNull(clickThroughAnchor(player));
              player.trigger('vast.adsCancel');
              assert.isNull(clickThroughAnchor(player));
      Severity: Major
      Found in test/ads/vast/VASTIntegrator.spec.js and 1 other location - About 1 hr to fix
      test/ads/vast/VASTIntegrator.spec.js on lines 703..708

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

      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 anchor when the ad ends", function(){
              vastIntegrator._addClickThrough(mediaFile, tracker, response, callback);
              assert.isNotNull(clickThroughAnchor(player));
              player.trigger('vast.adEnd');
              assert.isNull(clickThroughAnchor(player));
      Severity: Major
      Found in test/ads/vast/VASTIntegrator.spec.js and 1 other location - About 1 hr to fix
      test/ads/vast/VASTIntegrator.spec.js on lines 710..715

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

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

          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

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

                  it("must contain the name of the advertiser", function () {
                    inlineXML = '<?xml version="1.0" encoding="UTF-8"?>' +
                      '<InLine>' +
                      '<Advertiser>AdvertiserName</Advertiser>' +
                      '</InLine>';
            Severity: Major
            Found in test/ads/vast/Inline.spec.js and 1 other location - About 1 hr to fix
            test/ads/vast/Inline.spec.js on lines 121..128

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

            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