prebid/Prebid.js

View on GitHub
modules/mantisBidAdapter.js

Summary

Maintainability
D
2 days
Test Coverage

File mantisBidAdapter.js has 289 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import {registerBidder} from '../src/adapters/bidderFactory.js';
import { getStorageManager } from '../src/storageManager.js';
import { ajax } from '../src/ajax.js';

export const storage = getStorageManager({bidderCode: 'mantis'});
Severity: Minor
Found in modules/mantisBidAdapter.js - About 2 hrs to fix

    Function onVisible has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

    export function onVisible(win, element, doOnVisible, time, pct) {
      var started = null;
      var notified = false;
      var onNotVisible = null;
      var whenNotVisible = function () {
    Severity: Minor
    Found in modules/mantisBidAdapter.js - About 2 hrs 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 onVisible has 64 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export function onVisible(win, element, doOnVisible, time, pct) {
      var started = null;
      var notified = false;
      var onNotVisible = null;
      var whenNotVisible = function () {
    Severity: Major
    Found in modules/mantisBidAdapter.js - About 2 hrs to fix

      Function jsonToQuery has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

      function jsonToQuery(data, chain, form) {
        var parts = form || [];
        for (var key in data) {
          var queryKey = key;
          if (chain) {
      Severity: Minor
      Found in modules/mantisBidAdapter.js - About 2 hrs 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 buildMantisUrl has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

      function buildMantisUrl(path, data, domain) {
        var params = {
          referrer: document.referrer,
          tz: new Date().getTimezoneOffset(),
          buster: new Date().getTime(),
      Severity: Minor
      Found in modules/mantisBidAdapter.js - About 2 hrs 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 buildMantisUrl has 42 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      function buildMantisUrl(path, data, domain) {
        var params = {
          referrer: document.referrer,
          tz: new Date().getTimezoneOffset(),
          buster: new Date().getTime(),
      Severity: Minor
      Found in modules/mantisBidAdapter.js - About 1 hr to fix

        Function doCheck has 39 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          var doCheck = function (winWidth, winHeight, rect) {
            var hidden = typeof document.hidden !== 'undefined' && document.hidden;
            if (rect.width == 0 || rect.height == 0 || hidden) {
              return whenNotVisible();
            }
        Severity: Minor
        Found in modules/mantisBidAdapter.js - About 1 hr to fix

          Function buildRequests has 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            buildRequests: function (validBidRequests, bidderRequest) {
              var property = null;
              validBidRequests.some(function (bid) {
                if (bid.params.property) {
                  property = bid.params.property;
          Severity: Minor
          Found in modules/mantisBidAdapter.js - About 1 hr to fix

            Function onVisible has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

            export function onVisible(win, element, doOnVisible, time, pct) {
            Severity: Minor
            Found in modules/mantisBidAdapter.js - About 35 mins to fix

              Avoid too many return statements within this function.
              Open

                    return;
              Severity: Major
              Found in modules/mantisBidAdapter.js - About 30 mins to fix

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

                        (rect.left < 0 && rect.right >= minWidth) ||
                        (rect.left > 0 && (winWidth - rect.left) >= minWidth)
                Severity: Minor
                Found in modules/mantisBidAdapter.js and 1 other location - About 40 mins to fix
                modules/mantisBidAdapter.js on lines 36..37

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

                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

                        (rect.top < 0 && rect.bottom >= minHeight) ||
                        (rect.top > 0 && (winHeight - rect.top) >= minHeight)
                Severity: Minor
                Found in modules/mantisBidAdapter.js and 1 other location - About 40 mins to fix
                modules/mantisBidAdapter.js on lines 40..41

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

                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

                          sizes: bid.sizes.map(function (size) {
                            return {width: size[0], height: size[1]};
                          })
                Severity: Minor
                Found in modules/mantisBidAdapter.js and 1 other location - About 30 mins to fix
                modules/proxistoreBidAdapter.js on lines 15..20

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

                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

                There are no issues that match your filters.

                Category
                Status