MailOnline/VPAIDHTML5Client

View on GitHub

Showing 29 of 29 total issues

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

        it('must still be able to timeout if handler returns false', function () {
            var handler = sinon.spy(function () {
                return false;
            });
            var onTimeout = sinon.spy();
Severity: Major
Found in test/unit/utils.spec.js and 1 other location - About 3 hrs to fix
test/unit/utils.spec.js on lines 53..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 110.

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 not timeout if handler returns true', function () {
            var handler = sinon.spy(function () {
                return true;
            });
            var onTimeout = sinon.spy();
Severity: Major
Found in test/unit/utils.spec.js and 1 other location - About 3 hrs to fix
test/unit/utils.spec.js on lines 38..51

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

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

LinearAd.prototype.subscribe = function subscribe(handler, event, context) {
    if (!this._subscribers[event]) {
        this._subscribers[event] = [];
    }
    this._subscribers[event].push({callback: handler, context: context});
Severity: Major
Found in test/fixtures/simpleVPAIDAd.js and 1 other location - About 2 hrs to fix
demo/VPAIDAdLinear.js on lines 189..194

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

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

VPAIDAdLinear.prototype.subscribe = function subscribe(handler, event, context) {
    if (!this._subscribers[event]) {
        this._subscribers[event] = [];
    }
    this._subscribers[event].push({callback: handler, context: context});
Severity: Major
Found in demo/VPAIDAdLinear.js and 1 other location - About 2 hrs to fix
test/fixtures/simpleVPAIDAd.js on lines 16..21

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

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

'use strict';


(function() {

Severity: Minor
Found in demo/VPAIDAdLinear.js - About 2 hrs to fix

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

            beforeEach(function () {
                el = document.createElement('div');
                frame = document.createElement('iframe');
                document.body.appendChild(el);
                document.body.appendChild(frame);
    Severity: Major
    Found in test/unit/utils.spec.js and 2 other locations - About 1 hr to fix
    test/integration/VPAIDHTML5Client.spec.js on lines 23..28
    test/unit/VPAIDHTML5Client.spec.js on lines 19..24

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

    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

        beforeEach(function () {
            el = document.createElement('iframe');
            video = document.createElement('video');
            document.body.appendChild(el);
            document.body.appendChild(video);
    Severity: Major
    Found in test/unit/VPAIDHTML5Client.spec.js and 2 other locations - About 1 hr to fix
    test/integration/VPAIDHTML5Client.spec.js on lines 23..28
    test/unit/utils.spec.js on lines 98..103

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

    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

            beforeEach(function () {
                el = document.createElement('div');
                video = document.createElement('video');
                document.body.appendChild(el);
                document.body.appendChild(video);
    Severity: Major
    Found in test/integration/VPAIDHTML5Client.spec.js and 2 other locations - About 1 hr to fix
    test/unit/VPAIDHTML5Client.spec.js on lines 19..24
    test/unit/utils.spec.js on lines 98..103

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

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

    VPAIDHTML5Client.prototype.loadAdUnit = function loadAdUnit(adURL, callback) {
        if(this._onLoad){ return }
    
        $throwIfDestroyed.call(this);
        $unloadPreviousAdUnit.call(this);
    Severity: Minor
    Found in js/VPAIDHTML5Client.js - About 1 hr to fix

      Function loadAdUnit has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

      VPAIDHTML5Client.prototype.loadAdUnit = function loadAdUnit(adURL, callback) {
          if(this._onLoad){ return }
      
          $throwIfDestroyed.call(this);
          $unloadPreviousAdUnit.call(this);
      Severity: Minor
      Found in js/VPAIDHTML5Client.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

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

                  var onLoad = sinon.spy(function (err, adUnit) {
                      assert(onLoad.calledOnce);
                      assert.isNull(err, 'error must be null');
                      assert.isNotNull(adUnit);
                      done();
      Severity: Major
      Found in test/unit/VPAIDHTML5Client.spec.js and 1 other location - About 1 hr to fix
      test/unit/VPAIDHTML5Client.spec.js on lines 84..89

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

      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

                  var onLoad = sinon.spy(function (err, adUnit) {
                      assert(onLoad.calledOnce);
                      assert.isNull(err, 'error must be null');
                      assert.isNotNull(adUnit);
                      done();
      Severity: Major
      Found in test/unit/VPAIDHTML5Client.spec.js and 1 other location - About 1 hr to fix
      test/unit/VPAIDHTML5Client.spec.js on lines 53..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 62.

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

      var VPAIDAdLinear = function VPAIDAdLinear() {
          this._slot = null;
          this._videoSlot = null;
      
          this._subscribers = {};
      Severity: Minor
      Found in demo/VPAIDAdLinear.js - About 1 hr to fix

        Function exports has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        module.exports = function (karma) {
          karma.set({
            /**
             * From where to look for files, starting with the location of this file.
             */
        Severity: Minor
        Found in karma.conf.js - About 1 hr to fix

          Function jsBuilds has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          ].map(function (entry, index) {
          
              var build = watchify(
                  browserify(
                      assign(
          Severity: Minor
          Found in gulpfile.js - About 1 hr to fix

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

                            assert.sameDeepMembers(subscriber.get('test'), [{handler: f1, context: this, eventName: 'test'}, {handler: f2, context: this, eventName: 'test'}]);
            Severity: Major
            Found in test/unit/subscriber.spec.js and 1 other location - About 1 hr to fix
            test/unit/subscriber.spec.js on lines 83..83

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

            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

                            assert.sameDeepMembers(subscriber.get('test'), [{handler: f1, context: this, eventName: 'test'}, {handler: f2, context: this, eventName: 'test'}]);
            Severity: Major
            Found in test/unit/subscriber.spec.js and 1 other location - About 1 hr to fix
            test/unit/subscriber.spec.js on lines 51..51

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

            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

            gulp.task('test:deploy', function (done) {
                new KarmaServer({
                    configFile: __dirname + '/karma.conf.js'
                }, function () {
                    done();
            Severity: Minor
            Found in gulpfile.js and 1 other location - About 55 mins to fix
            gulpfile.js on lines 114..120

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

            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

            gulp.task('test:dev', function (done) {
                new KarmaServer({
                    configFile: __dirname + '/karma.conf.js'
                }, function () {
                    done();
            Severity: Minor
            Found in gulpfile.js and 1 other location - About 55 mins to fix
            gulpfile.js on lines 106..112

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

            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 initAd has 7 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            IVPAIDAdUnit.prototype.initAd = function(width, height, viewMode, desiredBitrate, creativeData, environmentVars, callback) {};
            Severity: Major
            Found in js/IVPAIDAdUnit.js - About 50 mins to fix
              Severity
              Category
              Status
              Source
              Language