File lemmaDigitalBidAdapter.js
has 452 lines of code (exceeds 250 allowed). Consider refactoring. Open
import * as utils from '../src/utils.js';
import { config } from '../src/config.js';
import { registerBidder } from '../src/adapters/bidderFactory.js';
import { BANNER, VIDEO } from '../src/mediaTypes.js';
Function _getImpressionObject
has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring. Open
_getImpressionObject: (bid) => {
var impression = {};
var bObj;
var vObj;
var sizes = bid.hasOwnProperty('sizes') ? bid.sizes : [];
- 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 _getBannerRequest
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
_getBannerRequest: (bid) => {
var bObj;
var adFormat = [];
if (utils.deepAccess(bid, 'mediaTypes.banner')) {
var params = bid ? bid.params : null;
- 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
spec
has 23 functions (exceeds 20 allowed). Consider refactoring. Open
export var spec = {
code: BIDDER_CODE,
supportedMediaTypes: [BANNER, VIDEO],
Function _getImpressionObject
has 54 lines of code (exceeds 25 allowed). Consider refactoring. Open
_getImpressionObject: (bid) => {
var impression = {};
var bObj;
var vObj;
var sizes = bid.hasOwnProperty('sizes') ? bid.sizes : [];
Function _parseRTBResponse
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
_parseRTBResponse: (request, response) => {
var bidResponses = [];
try {
if (response.seatbid) {
var currency = response.curr || DEFAULT_CURRENCY;
Function _createoRTBRequest
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
_createoRTBRequest: (bidRequests, conf) => {
var oRTBObject = {};
try {
oRTBObject = {
id: spec._createUUID(),
Function _getBannerRequest
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
_getBannerRequest: (bid) => {
var bObj;
var adFormat = [];
if (utils.deepAccess(bid, 'mediaTypes.banner')) {
var params = bid ? bid.params : null;
Function _getVideoRequest
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
_getVideoRequest: (bid) => {
var vObj;
if (utils.deepAccess(bid, 'mediaTypes.video')) {
var params = bid ? bid.params : null;
var videoData = utils.mergeDeep(utils.deepAccess(bid.mediaTypes, 'video'), params.video);
- 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 _createoRTBRequest
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
_createoRTBRequest: (bidRequests, conf) => {
var oRTBObject = {};
try {
oRTBObject = {
id: spec._createUUID(),
- 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 _getDeviceObject
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
_getDeviceObject: (request) => {
var params = request && request.params ? request.params : null;
if (params) {
return {
dnt: utils.getDNT() ? 1 : 0,
Function isBidRequestValid
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
isBidRequestValid: (bid) => {
if (!bid || !bid.params) {
utils.logError(LOG_WARN_PREFIX, 'nil/empty bid object');
return false;
}
- 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 _getSiteObject
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
_getSiteObject: (request, conf) => {
var params = request && request.params ? request.params : null;
if (params) {
pubId = params.pubId ? params.pubId : '0';
var siteId = params.siteId ? params.siteId : '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
Consider simplifying this complex logical expression. Open
if (params) {
return {
dnt: utils.getDNT() ? 1 : 0,
ua: navigator.userAgent,
language: (navigator.language || navigator.browserLanguage || navigator.userLanguage || navigator.systemLanguage),
Function _endPointURL
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
_endPointURL: (request) => {
var params = request && request[0].params ? request[0].params : null;
if (params) {
pubId = params.pubId ? params.pubId : 0;
adunitId = params.adunitId ? params.adunitId : 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 _getAppObject
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
_getAppObject: (request) => {
var params = request && request.params ? request.params : null;
if (params) {
pubId = params.pubId ? params.pubId : 0;
var appParams = params.app;
- 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 true;
Function _getDeviceObject
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
_getDeviceObject: (request) => {
var params = request && request.params ? request.params : null;
if (params) {
return {
dnt: utils.getDNT() ? 1 : 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
Similar blocks of code found in 2 locations. Consider refactoring. Open
[BANNER, VIDEO].forEach(mediaType => {
if (impObj.hasOwnProperty(mediaType)) {
let floorInfo = bid.getFloor({ currency: impObj.bidfloorcur, mediaType: mediaType, size: '*' });
if (typeof floorInfo === 'object' && floorInfo.currency === impObj.bidfloorcur && !isNaN(parseInt(floorInfo.floor))) {
let mediaTypeFloor = parseFloat(floorInfo.floor);
- 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 148.
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