File insticatorBidAdapter.js
has 576 lines of code (exceeds 250 allowed). Consider refactoring. Open
import {config} from '../src/config.js';
import {BANNER, VIDEO} from '../src/mediaTypes.js';
import {registerBidder} from '../src/adapters/bidderFactory.js';
import {deepAccess, generateUUID, logError, isArray, isInteger, isArrayOfNums, deepSetValue, isFn, logWarn} from '../src/utils.js';
import {getStorageManager} from '../src/storageManager.js';
Function buildImpression
has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring. Open
function buildImpression(bidRequest) {
const imp = {
id: bidRequest.bidId,
tagid: bidRequest.adUnitCode,
instl: deepAccess(bidRequest, 'ortb2Imp.instl'),
- Read upRead up
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 buildImpression
has 73 lines of code (exceeds 25 allowed). Consider refactoring. Open
function buildImpression(bidRequest) {
const imp = {
id: bidRequest.bidId,
tagid: bidRequest.adUnitCode,
instl: deepAccess(bidRequest, 'ortb2Imp.instl'),
Function buildRequest
has 55 lines of code (exceeds 25 allowed). Consider refactoring. Open
function buildRequest(validBidRequests, bidderRequest) {
const req = {
id: bidderRequest.bidderRequestId,
tmax: bidderRequest.timeout,
source: {
Function validateVideo
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
function validateVideo(bid) {
const videoParams = deepAccess(bid, 'mediaTypes.video');
const videoBidderParams = deepAccess(bid, 'params.video');
let video = {
...videoParams,
Function validateVideo
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
function validateVideo(bid) {
const videoParams = deepAccess(bid, 'mediaTypes.video');
const videoBidderParams = deepAccess(bid, 'params.video');
let video = {
...videoParams,
- Read upRead up
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 buildBid
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
function buildBid(bid, bidderRequest) {
const originalBid = find(bidderRequest.bids, (b) => b.bidId === bid.impid);
let meta = {}
if (bid.ext && bid.ext.meta) {
Function buildVideo
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
function buildVideo(bidRequest) {
let w = deepAccess(bidRequest, 'mediaTypes.video.w');
let h = deepAccess(bidRequest, 'mediaTypes.video.h');
const mimes = deepAccess(bidRequest, 'mediaTypes.video.mimes');
const placement = deepAccess(bidRequest, 'mediaTypes.video.placement');
Function buildRequest
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
function buildRequest(validBidRequests, bidderRequest) {
const req = {
id: bidderRequest.bidderRequestId,
tmax: bidderRequest.timeout,
source: {
- Read upRead up
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 buildVideo
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
function buildVideo(bidRequest) {
let w = deepAccess(bidRequest, 'mediaTypes.video.w');
let h = deepAccess(bidRequest, 'mediaTypes.video.h');
const mimes = deepAccess(bidRequest, 'mediaTypes.video.mimes');
const placement = deepAccess(bidRequest, 'mediaTypes.video.placement');
- Read upRead up
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 buildUser
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
function buildUser(bid) {
const userId = getUserId() || generateUUID();
const yob = deepAccess(bid, 'params.user.yob')
const gender = deepAccess(bid, 'params.user.gender')
const keywords = deepAccess(bid, 'params.user.keywords')
Function buildBid
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
function buildBid(bid, bidderRequest) {
const originalBid = find(bidderRequest.bids, (b) => b.bidId === bid.impid);
let meta = {}
if (bid.ext && bid.ext.meta) {
- Read upRead up
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
Avoid deeply nested control flow statements. Open
if (sizes && sizes.length > 0) {
const {w: width, h: height} = sizes[0];
_size = [width, height];
}
Function parsePlayerSizeToWidthHeight
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
function parsePlayerSizeToWidthHeight(playerSize, w, h) {
if (!w && playerSize) {
if (Array.isArray(playerSize[0])) {
w = parseInt(playerSize[0][0], 10);
} else if (typeof playerSize[0] === 'number' && !isNaN(playerSize[0])) {
- Read upRead up
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 buildRegs
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
function buildRegs(bidderRequest) {
let regs = {
ext: {},
};
if (bidderRequest.gdprConsent) {
- Read upRead up
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
Avoid too many return
statements within this function. Open
return false;
Avoid too many return
statements within this function. Open
return true;
Similar blocks of code found in 2 locations. Consider refactoring. Open
if (!w && playerSize) {
if (Array.isArray(playerSize[0])) {
w = parseInt(playerSize[0][0], 10);
} else if (typeof playerSize[0] === 'number' && !isNaN(playerSize[0])) {
w = parseInt(playerSize[0], 10);
- Read upRead up
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 100.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
if (!h && playerSize) {
if (Array.isArray(playerSize[0])) {
h = parseInt(playerSize[0][1], 10);
} else if (typeof playerSize[1] === 'number' && !isNaN(playerSize[1])) {
h = parseInt(playerSize[1], 10);
- Read upRead up
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 100.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
if (!bidResponse.vastUrl && bidResponse.vastXml) {
bidResponse.vastUrl = 'data:text/xml;charset=utf-8;base64,' + window.btoa(bidResponse.vastXml.replace(/\\"/g, '"'));
}
- Read upRead up
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 59.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
if (storage.cookiesAreEnabled()) {
const expires = new Date(Date.now() + USER_ID_COOKIE_EXP).toUTCString();
storage.setCookie(USER_ID_KEY, userId, expires);
}
- Read upRead up
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 56.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76