Skip to content

Commit

Permalink
update/fix cases of undefined variables (#4661)
Browse files Browse the repository at this point in the history
  • Loading branch information
jsnellbaker authored Dec 20, 2019
1 parent 861e0bd commit 141118e
Show file tree
Hide file tree
Showing 18 changed files with 48 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ module.exports = {
"eqeqeq": "off",
"no-return-assign": "off",
"no-throw-literal": "off",
"no-undef": "off",
"no-undef": 2,
"no-useless-escape": "off",
},
"overrides": Object.keys(allowedModules).map((key) => ({
Expand Down
1 change: 1 addition & 0 deletions modules/33acrossBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ function _getViewability(element, topWin, { w, h } = {}) {

function _mapAdUnitPathToElementId(adUnitCode) {
if (utils.isGptPubadsDefined()) {
// eslint-disable-next-line no-undef
const adSlots = googletag.pubads().getSlots();
const isMatchingAdSlot = utils.isSlotMatchingAdUnitCode(adUnitCode);

Expand Down
2 changes: 1 addition & 1 deletion modules/aolBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ export const spec = {
cpm = bidData.price;

if (cpm === null || isNaN(cpm)) {
utils.logError('Invalid price in bid response', AOL_BIDDERS_CODES.AOL, bid);
utils.logError('Invalid price in bid response', AOL_BIDDERS_CODES.AOL, bidData);
return;
}
}
Expand Down
3 changes: 2 additions & 1 deletion modules/appierAnalyticsAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {ajax} from '../src/ajax';
import adapter from '../src/AnalyticsAdapter';
import CONSTANTS from '../src/constants.json';
import adapterManager from '../src/adapterManager';
import {getGlobal} from '../src/prebidGlobal';
import {logError, logInfo, deepClone} from '../src/utils';

const analyticsType = 'endpoint';
Expand Down Expand Up @@ -189,7 +190,7 @@ export const appierAnalyticsAdapter = Object.assign(adapter({DEFAULT_SERVER, ana
},
handleAuctionEnd(auctionEndArgs) {
const cachedAuction = this.getCachedAuction(auctionEndArgs.auctionId);
const highestCpmBids = pbjs.getHighestCpmBids();
const highestCpmBids = getGlobal().getHighestCpmBids();
this.sendEventMessage('bid',
this.createBidMessage(auctionEndArgs, highestCpmBids, cachedAuction.timeoutBids)
);
Expand Down
2 changes: 1 addition & 1 deletion modules/britepoolIdSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export const britepoolIdSubmodule = {
if (params.getter) {
// Custom getter will not require other params
if (typeof params.getter !== 'function') {
errors.push(`${MODULE_NAME} - britepoolId submodule requires getter to be a function`);
errors.push(`userIdTargeting - britepoolId submodule requires getter to be a function`);
return { errors };
}
} else {
Expand Down
6 changes: 6 additions & 0 deletions modules/criteoBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export const spec = {
}

if (publisherTagAvailable()) {
// eslint-disable-next-line no-undef
const adapter = new Criteo.PubTag.Adapters.Prebid(PROFILE_ID_PUBLISHERTAG, ADAPTER_VERSION, bidRequests, bidderRequest, '$prebid.version$');
url = adapter.buildCdbUrl();
data = adapter.buildCdbRequest();
Expand All @@ -93,6 +94,7 @@ export const spec = {
const body = response.body || response;

if (publisherTagAvailable()) {
// eslint-disable-next-line no-undef
const adapter = Criteo.PubTag.Adapters.Prebid.GetAdapter(request);
if (adapter) {
return adapter.interpretResponse(body, request);
Expand Down Expand Up @@ -137,6 +139,7 @@ export const spec = {
*/
onTimeout: (timeoutData) => {
if (publisherTagAvailable()) {
// eslint-disable-next-line no-undef
const adapter = Criteo.PubTag.Adapters.Prebid.GetAdapter(timeoutData.auctionId);
adapter.handleBidTimeout();
}
Expand All @@ -147,6 +150,7 @@ export const spec = {
*/
onBidWon: (bid) => {
if (publisherTagAvailable()) {
// eslint-disable-next-line no-undef
const adapter = Criteo.PubTag.Adapters.Prebid.GetAdapter(bid.auctionId);
adapter.handleBidWon(bid);
}
Expand All @@ -157,6 +161,7 @@ export const spec = {
*/
onSetTargeting: (bid) => {
if (publisherTagAvailable()) {
// eslint-disable-next-line no-undef
const adapter = Criteo.PubTag.Adapters.Prebid.GetAdapter(bid.auctionId);
adapter.handleSetTargeting(bid);
}
Expand All @@ -167,6 +172,7 @@ export const spec = {
* @return {boolean}
*/
function publisherTagAvailable() {
// eslint-disable-next-line no-undef
return typeof Criteo !== 'undefined' && Criteo.PubTag && Criteo.PubTag.Adapters && Criteo.PubTag.Adapters.Prebid;
}

Expand Down
2 changes: 2 additions & 0 deletions modules/digiTrustIdSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ function isInitialized() {
if (window.DigiTrust == null) {
return false;
}
// eslint-disable-next-line no-undef
return DigiTrust.isClient; // this is set to true after init
}

Expand Down Expand Up @@ -240,6 +241,7 @@ var ResultWrapper = function (opts) {
this.retryId = 0;

this.executeIdRequest = function (configParams) {
// eslint-disable-next-line no-undef
DigiTrust.getUser({ member: 'prebid' }, function (idResult) {
me.idObj = idResult;
var cb = function () {
Expand Down
2 changes: 2 additions & 0 deletions modules/express.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ $$PREBID_GLOBAL$$.express = function(adUnits = $$PREBID_GLOBAL$$.adUnits) {
function defaultSlots(slots) {
return Array.isArray(slots)
? slots.slice()
// eslint-disable-next-line no-undef
: googletag.pubads().getSlots().slice();
}

Expand Down Expand Up @@ -116,6 +117,7 @@ $$PREBID_GLOBAL$$.express = function(adUnits = $$PREBID_GLOBAL$$.adUnits) {
// if not SRA mode, get only the gpt slot corresponding to sEementId
var aGptSlots;
if (!bEnabledSRA) {
// eslint-disable-next-line no-undef
aGptSlots = googletag.pubads().getSlots().filter(function (oGptSlot) {
return oGptSlot.getSlotElementId() === sElementId;
});
Expand Down
2 changes: 2 additions & 0 deletions modules/mantisBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,9 @@ const spec = {
onMessage('iframe', function (data) {
if (window.$sf) {
var viewed = false;
// eslint-disable-next-line no-undef
$sf.ext.register(data.width, data.height, function () {
// eslint-disable-next-line no-undef
if ($sf.ext.inViewPercentage() < 50 || viewed) {
return;
}
Expand Down
24 changes: 12 additions & 12 deletions modules/nobidBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ function nobidInterpretResponse(response, bidRequest) {
for (var i = 0; response.bids && i < response.bids.length; i++) {
var bid = response.bids[i];
if (bid.bdrid < 100 || !bidRequest || !bidRequest.bidderRequest || !bidRequest.bidderRequest.bids) continue;
nobid.bidResponses['' + bid.id] = bid;
window.nobid.bidResponses['' + bid.id] = bid;
var reqBid = findBid(bid.divid, bidRequest.bidderRequest.bids);
if (!reqBid) continue;
const bidResponse = {
Expand All @@ -184,12 +184,12 @@ function nobidInterpretResponse(response, bidRequest) {
return bidResponses;
};
window.nobid = window.nobid || {};
nobid.bidResponses = nobid.bidResponses || {};
nobid.timeoutTotal = 0;
nobid.bidWonTotal = 0;
nobid.renderTag = function(doc, id, win) {
window.nobid.bidResponses = window.nobid.bidResponses || {};
window.nobid.timeoutTotal = 0;
window.nobid.bidWonTotal = 0;
window.nobid.renderTag = function(doc, id, win) {
log('nobid.renderTag()', id);
var bid = nobid.bidResponses['' + id];
var bid = window.nobid.bidResponses['' + id];
if (bid && bid.adm2) {
log('nobid.renderTag() found tag', id);
var markup = bid.adm2;
Expand Down Expand Up @@ -292,14 +292,14 @@ export const spec = {
* @param {data} Containing timeout specific data
*/
onTimeout: function(data) {
nobid.timeoutTotal++;
log('Timeout total: ' + nobid.timeoutTotal, data);
return nobid.timeoutTotal;
window.nobid.timeoutTotal++;
log('Timeout total: ' + window.nobid.timeoutTotal, data);
return window.nobid.timeoutTotal;
},
onBidWon: function(data) {
nobid.bidWonTotal++;
log('BidWon total: ' + nobid.bidWonTotal, data);
return nobid.bidWonTotal;
window.nobid.bidWonTotal++;
log('BidWon total: ' + window.nobid.bidWonTotal, data);
return window.nobid.bidWonTotal;
}
}
registerBidder(spec);
1 change: 1 addition & 0 deletions modules/oneVideoBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ function newRenderer(bidRequest, bid) {
bidRequest.renderer.url = 'https://cdn.vidible.tv/prod/hb-outstream-renderer/renderer.js';
bidRequest.renderer.render = function(bid) {
setTimeout(function () {
// eslint-disable-next-line no-undef
o2PlayerRender(bid);
}, 700)
};
Expand Down
1 change: 1 addition & 0 deletions modules/pubmaticBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -883,6 +883,7 @@ export const spec = {
payload.ext.wrapper.profile = parseInt(conf.profId) || UNDEFINED;
payload.ext.wrapper.version = parseInt(conf.verId) || UNDEFINED;
payload.ext.wrapper.wiid = conf.wiid || UNDEFINED;
// eslint-disable-next-line no-undef
payload.ext.wrapper.wv = $$REPO_AND_VERSION$$;
payload.ext.wrapper.transactionId = conf.transactionId;
payload.ext.wrapper.wp = 'pbjs';
Expand Down
4 changes: 4 additions & 0 deletions modules/sigmoidAnalyticsAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,18 +232,22 @@ sigmoidAdapter.buildUtmTagData = function () {
};

function send(eventType, data, sendDataType) {
// eslint-disable-next-line no-undef
AWS.config.credentials = new AWS.Credentials({
accessKeyId: 'accesskey', secretAccessKey: 'secretkey'
});

// eslint-disable-next-line no-undef
AWS.config.region = 'us-east-1';
// eslint-disable-next-line no-undef
AWS.config.credentials.get(function(err) {
// attach event listener
if (err) {
utils.logError(err);
return;
}
// create kinesis service object
// eslint-disable-next-line no-undef
var kinesis = new AWS.Kinesis({
apiVersion: '2013-12-02'
});
Expand Down
1 change: 1 addition & 0 deletions modules/smmsBidAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export const spec = {
refererInfo = bidderRequest.refererInfo;
}

// eslint-disable-next-line no-undef
const g = (typeof (geparams) !== 'undefined' && typeof (geparams) == 'object' && geparams) ? geparams : {};
validBidRequests.forEach((bid, i) => {
let endpoint = ENDPOINT_BANNER;
Expand Down
9 changes: 6 additions & 3 deletions modules/sovrnAnalyticsAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const getClosestTop = () => {
}
}
} catch (e) {
bException = true;
// bException = true;
}

return {
Expand Down Expand Up @@ -136,6 +136,7 @@ class BidWinner {
*/
constructor(sovrnId, event) {
this.body = {}
// eslint-disable-next-line no-undef
this.body.prebidVersion = $$REPO_AND_VERSION$$
this.body.sovrnId = sovrnId
this.body.winningBid = JSON.parse(JSON.stringify(event))
Expand Down Expand Up @@ -170,6 +171,7 @@ class AuctionData {
*/
constructor(sovrnId, auctionId) {
this.auction = {}
// eslint-disable-next-line no-undef
this.auction.prebidVersion = $$REPO_AND_VERSION$$
this.auction.sovrnId = sovrnId
this.auction.auctionId = auctionId
Expand Down Expand Up @@ -288,6 +290,7 @@ class LogError {
this.error.message = e.message
this.error.stack = e.stack
this.error.data = data
// eslint-disable-next-line no-undef
this.error.prebidVersion = $$REPO_AND_VERSION$$
this.error.sovrnId = sovrnId
this.error.url = rootURL
Expand All @@ -305,8 +308,8 @@ class LogError {
}
})
}
if (ErrorEvent.data && error.data.ad) {
delete error.data.ad
if (ErrorEvent.data && this.error.data.ad) {
delete this.error.data.ad
}
this.error.ts = utils.timestamp()
ajax(
Expand Down
3 changes: 2 additions & 1 deletion modules/ucfunnelAnalyticsAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {ajax} from '../src/ajax';
import adapter from '../src/AnalyticsAdapter';
import CONSTANTS from '../src/constants.json';
import adapterManager from '../src/adapterManager';
import {getGlobal} from '../src/prebidGlobal';
import {logError, logInfo, deepClone} from '../src/utils';

const analyticsType = 'endpoint';
Expand Down Expand Up @@ -148,7 +149,7 @@ export const ucfunnelAnalyticsAdapter = Object.assign(adapter({ANALYTICS_SERVER,
},
handleAuctionEnd(auctionEndArgs) {
const cachedAuction = this.getCachedAuction(auctionEndArgs.auctionId);
const highestCpmBids = pbjs.getHighestCpmBids();
const highestCpmBids = getGlobal().getHighestCpmBids();
this.sendEventMessage('bid',
this.createBidMessage(auctionEndArgs, highestCpmBids, cachedAuction.timeoutBids)
);
Expand Down
1 change: 1 addition & 0 deletions modules/yieldoneAnalyticsAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ let pubId = '';

function makeAdUnitNameMap() {
if (window.googletag && window.googletag.pubads) {
// eslint-disable-next-line no-undef
const p = googletag.pubads();
if (p && p.getSlots) {
const slots = p.getSlots();
Expand Down
4 changes: 2 additions & 2 deletions src/auctionManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* @property {function(): Object} getStandardBidderAdServerTargeting - returns standard bidder targeting for all the adapters. Refer http://prebid.org/dev-docs/publisher-api-reference.html#module_pbjs.bidderSettings for more details
*/

import { uniques, flatten } from './utils';
import { uniques, flatten, logWarn } from './utils';
import { newAuction, getStandardBidderSettings, AUCTION_COMPLETED } from './auction';
import find from 'core-js/library/fn/array/find';

Expand All @@ -38,7 +38,7 @@ export function newAuctionManager() {
bid.status = CONSTANTS.BID_STATUS.RENDERED;
auction.addWinningBid(bid);
} else {
utils.logWarn(`Auction not found when adding winning bid`);
logWarn(`Auction not found when adding winning bid`);
}
};

Expand Down

0 comments on commit 141118e

Please sign in to comment.