[IMP] test_lint, *: add caughtErrors option to no-unused-vars

All named arguments on the catch block must be used. If for some motive
the named argument on the catch block is not used, its name must begin
with '_'.

closes odoo/odoo#85569

Related: odoo/enterprise#24867
Related: odoo/design-themes#552
Signed-off-by: Géry Debongnie <ged@odoo.com>
This commit is contained in:
Jorge Pinna Puissant
2022-03-02 13:05:42 +00:00
parent bc20eb4790
commit cac3ba62e5
71 changed files with 125 additions and 125 deletions
+1 -1
View File
@@ -78,7 +78,7 @@ class TaxGroupComponent extends LegacyComponent {
newValue = fieldUtils.parse.float(newValue); // Need a float for format the value
newValue = fieldUtils.format.float(newValue, null, {digits: currency.digits}); // Return a string rounded to currency precision
newValue = fieldUtils.parse.float(newValue); // Convert back to Float to compare with oldValue to know if value has changed
} catch (err) {
} catch (_err) {
$(this.inputTax.el).addClass('o_field_invalid');
this.setState('edit');
return;
@@ -47,7 +47,7 @@ const ReCaptcha = Class.extend({
return {
token: await window.grecaptcha.execute(this._publicKey, {action: action})
};
} catch (e) {
} catch (_e) {
return {
error: _t("The recaptcha site key is invalid."),
};
@@ -262,7 +262,7 @@ var LivechatButton = Widget.extend({
message: _t("No available collaborator, please try again later."),
sticky: true,
});
} catch (err) {
} catch (_err) {
/**
* Failure in displaying notification happens when
* notification service doesn't exist, which is the case in
@@ -368,7 +368,7 @@ var LivechatButton = Widget.extend({
message: _t("Session expired... Please refresh and try again."),
sticky: true,
});
} catch (err) {
} catch (_err) {
/**
* Failure in displaying notification happens when
* notification service doesn't exist, which is the case
@@ -346,7 +346,7 @@ QUnit.test('[technical] does not crash when the viewer is closed before image lo
try {
imageEl.dispatchEvent(new Event('load', { bubbles: true }));
successfulLoad = true;
} catch (err) {
} catch (_err) {
successfulLoad = false;
} finally {
assert.ok(successfulLoad, 'should not crash when the image is loaded');
+2 -2
View File
@@ -20,7 +20,7 @@ function parseAndTransform(htmlString, transformFunction) {
var children;
try {
children = $('<div>').html(string).contents();
} catch (e) {
} catch (_e) {
children = $('<div>').html('<pre>' + string + '</pre>').contents();
}
return _parseAndTransform(children, transformFunction)
@@ -99,7 +99,7 @@ function htmlToTextContentInline(htmlString) {
htmlString = htmlString.replace(/<br\s*\/?>/gi,' ');
try {
div.innerHTML = htmlString;
} catch (e) {
} catch (_e) {
div.innerHTML = `<pre>${htmlString}</pre>`;
}
return div
+7 -7
View File
@@ -288,7 +288,7 @@ registerModel({
try {
const audioStream = await browser.navigator.mediaDevices.getUserMedia({ audio: this.messaging.userSetting.getAudioConstraints() });
audioTrack = audioStream.getAudioTracks()[0];
} catch (e) {
} catch (_e) {
this.env.services.notification.notify({
message: _.str.sprintf(
this.env._t(`"%s" requires microphone access`),
@@ -348,7 +348,7 @@ registerModel({
},
volumeThreshold: this.messaging.userSetting.voiceActivationThreshold,
});
} catch (e) {
} catch (_e) {
/**
* The browser is probably missing audioContext,
* in that case, voice activation is not enabled
@@ -773,14 +773,14 @@ registerModel({
for (const sender of RTCRtpSenders) {
try {
peerConnection.removeTrack(sender);
} catch (e) {
} catch (_e) {
// ignore error
}
}
for (const transceiver of peerConnection.getTransceivers()) {
try {
transceiver.stop();
} catch (e) {
} catch (_e) {
// transceiver may already be stopped by the remote.
}
}
@@ -1016,7 +1016,7 @@ registerModel({
videoStream = await browser.navigator.mediaDevices.getDisplayMedia({ video: this.videoConfig });
this.messaging.soundEffects.screenSharing.play();
}
} catch (e) {
} catch (_e) {
this.env.services.notification.notify({
message: _.str.sprintf(
this.env._t(`"%s" requires "%s" access`),
@@ -1075,7 +1075,7 @@ registerModel({
try {
await transceiver.sender.replaceTrack(track);
transceiver.direction = transceiverDirection;
} catch (e) {
} catch (_e) {
// ignored, the track is probably already on the peerConnection.
}
return;
@@ -1083,7 +1083,7 @@ registerModel({
try {
await transceiver.sender.replaceTrack(null);
transceiver.direction = transceiverDirection;
} catch (e) {
} catch (_e) {
// ignored, the transceiver is probably already removed
}
if (trackKind === 'video') {
@@ -78,7 +78,7 @@ registerModel({
if (this.exists()) {
this.update({ isFullScreen: true });
}
} catch (e) {
} catch (_e) {
if (this.exists()) {
this.update({ isFullScreen: false });
}
@@ -263,7 +263,7 @@ registerModel({
this.audioElement.pause();
try {
this.audioElement.srcObject = undefined;
} catch (error) {
} catch (_error) {
// ignore error during remove, the value will be overwritten at next usage anyway
}
}
@@ -25,7 +25,7 @@ registerModel({
try {
fetchedMessages = await this._loadMessages({ limit, maxId: Math.min(...messageIds) });
success = true;
} catch (e) {
} catch (_e) {
success = false;
}
if (!this.exists()) {
@@ -37,7 +37,7 @@ export async function monitorAudio(track, processorOptions) {
let processor;
try {
processor = await _loadAudioWorkletProcessor(source, audioContext, processorOptions);
} catch (e) {
} catch (_e) {
// In case Worklets are not supported by the browser (eg: Safari)
processor = _loadScriptProcessor(source, audioContext, processorOptions);
}
@@ -44,7 +44,7 @@ odoo.define('point_of_sale.AbstractReceiptScreen', function (require) {
try {
window.print();
return true;
} catch (err) {
} catch (_err) {
await this.showPopup('ErrorPopup', {
title: this.env._t('Printing is not supported on some browsers'),
body: this.env._t(
@@ -22,7 +22,7 @@ odoo.define('point_of_sale.CashMovePopup', function (require) {
confirm() {
try {
parse.float(this.state.inputAmount);
} catch (error) {
} catch (_error) {
this.state.inputHasError = true;
this.errorMessage = this.env._t('Invalid amount');
return;
@@ -48,7 +48,7 @@ odoo.define('point_of_sale.ReceiptScreen', function (require) {
await this._sendReceiptToCustomer();
this.orderUiState.emailSuccessful = true;
this.orderUiState.emailNotice = this.env._t('Email sent.');
} catch (error) {
} catch (_error) {
this.orderUiState.emailSuccessful = false;
this.orderUiState.emailNotice = this.env._t('Sending email failed. Please try again.');
}
+2 -2
View File
@@ -335,7 +335,7 @@ var PosDB = core.Class.extend({
query = query.replace(/[\[\]\(\)\+\*\?\.\-\!\&\^\$\|\~\_\{\}\:\,\\\/]/g,'.');
query = query.replace(/ /g,'.+');
var re = RegExp("([0-9]+):.*?"+utils.unaccent(query),"gi");
}catch(e){
}catch(_e){
return [];
}
var results = [];
@@ -398,7 +398,7 @@ var PosDB = core.Class.extend({
query = query.replace(/[\[\]\(\)\+\*\?\.\-\!\&\^\$\|\~\_\{\}\:\,\\\/]/g,'.');
query = query.replace(/ /g,'.+');
var re = RegExp("([0-9]+):.*?"+utils.unaccent(query),"gi");
}catch(e){
}catch(_e){
return [];
}
var results = [];
+1 -1
View File
@@ -1147,7 +1147,7 @@ class Orderline extends PosModel {
if (options.json) {
try {
this.init_from_JSON(options.json);
} catch(error) {
} catch(_error) {
console.error('ERROR: attempting to recover product ID', options.json.product_id,
'not available in the point of sale. Correct the product or clean the browser cache.');
}
@@ -64,7 +64,7 @@ var PrinterMixin = {
image = await this.htmlToImg(receipt);
try {
sendPrintResult = await this.send_printing_job(image);
} catch (error) {
} catch (_error) {
// Error in communicating to the IoT box.
this.receipt_queue.length = 0;
return this.printResultGenerator.IoTActionError();
@@ -47,7 +47,7 @@ odoo.define('pos_gift_card.PaymentScreen', function(require) {
}
}
}
} catch (e) {
} catch (_e) {
// do nothing with the error
}
}
@@ -48,7 +48,7 @@ const PosMercuryPosGlobalState = (PosGlobalState) => class PosMercuryPosGlobalSt
magtek_generated.shift(); // reader enc status
return to_return;
} catch (e) {
} catch (_e) {
return 0;
}
}
@@ -109,7 +109,7 @@ odoo.define('pos_restaurant.TicketScreen', function (require) {
}
order.finalize();
return true;
} catch (error) {
} catch (_error) {
const { confirmed } = await this.showPopup('ConfirmPopup', {
title: 'Failed to set tip',
body: `Failed to set tip to ${order.name}. Do you want to proceed on setting the tips of the remaining?`,
@@ -140,7 +140,7 @@ odoo.define('pos_restaurant.TipScreen', function (require) {
try {
$(this.el).find('.pos-receipt-container').html(receipt);
window.print();
} catch (err) {
} catch (_err) {
await this.showPopup('ErrorPopup', {
title: this.env._t('Printing is not supported on some browsers'),
body: this.env._t(
@@ -88,7 +88,7 @@ odoo.define('pos_sale.SaleOrderManagementScreen', function (require) {
try {
await this.env.pos.load_new_partners();
}
catch (error){
catch (_error){
}
currentPOSOrder.set_partner(this.env.pos.db.get_partner_by_id(sale_order.partner_id[0]));
let orderFiscalPos = sale_order.fiscal_position_id ? this.env.pos.fiscal_positions.find(
@@ -95,7 +95,7 @@ var GeneratePriceList = AbstractAction.extend(StandaloneFieldManagerMixin, {
try {
this.context.active_ids = params.params.active_ids.split(',').map(id => parseInt(id));
this.context.active_model = params.params.active_model;
} catch(e) {
} catch(_e) {
console.log('unable to load ids from the url fragment 🙁');
}
}
@@ -156,7 +156,7 @@ const LazyColumnListRenderer = ListRenderer.extend({
if (JSON.parse(node.attrs.options).lazy) {
return true;
}
} catch (e) {
} catch (_e) {
return false;
}
return false;
@@ -15,7 +15,7 @@ try {
// Safari crashes in Private Browsing
localStorage.setItem("__localStorage__", "true");
localStorage.removeItem("__localStorage__");
} catch (e) {
} catch (_e) {
localStorage = makeRAMLocalStorage();
sessionStorage = makeRAMLocalStorage();
}
@@ -140,7 +140,7 @@ export class DatePicker extends LegacyComponent {
updateInput() {
try {
this.inputRef.el.value = this.format(this.date, this.options);
} catch (err) {
} catch (_err) {
// Do nothing
}
}
@@ -192,7 +192,7 @@ export class DatePicker extends LegacyComponent {
this.state.warning = date > DateTime.local();
this.props.onDateTimeChanged(date);
}
} catch (err) {
} catch (_err) {
// Reset to default (= given) date.
this.updateInput();
}
@@ -52,7 +52,7 @@ export async function annotateTraceback(error) {
await loadAssets({
jsLibs: ["/web/static/lib/stacktracejs/stacktrace.js"],
});
} catch (e) {
} catch (_e) {
return traceback;
}
// In Firefox, the error stack generated by anonymous code (example: invalid
@@ -423,7 +423,7 @@ function _download(data, filename, mimetype) {
if (typeof blob === "string" || blob.constructor === toString) {
try {
return saver(`data:${mimeType};base64,${self.btoa(blob)}`);
} catch (y) {
} catch (_y) {
return saver(`data:${mimeType},${encodeURIComponent(blob)}`);
}
}
@@ -505,7 +505,7 @@ download._download = (options) => {
// a Serialized python Error
const node = nodes[1] || nodes[0];
error = JSON.parse(node.textContent);
} catch (e) {
} catch (_e) {
error = {
message: "Arbitrary Uncaught Python Exception",
data: {
@@ -38,7 +38,7 @@ export const scrollerService = {
let matchingEl = null;
try {
matchingEl = document.querySelector(`.o_content #${href.value.substr(1)}`);
} catch (e) {
} catch (_e) {
// Invalid selector: not an anchor anyway
}
const triggerEv = new CustomEvent("anchor-link-clicked", {
@@ -170,7 +170,7 @@ export function searchModelStateToLegacy(state) {
let context = item.context;
try {
context = makeContext([context]);
} catch (e) {}
} catch (_e) {}
filter.context = context;
}
filters[item.id] = filter;
@@ -111,7 +111,7 @@ odoo.define('web.DatePickerOwl', function (require) {
_formatDate(date) {
try {
return field_utils.format[this.typeOfDate](date, null, { timezone: false });
} catch (err) {
} catch (_err) {
return false;
}
}
@@ -124,7 +124,7 @@ odoo.define('web.DatePickerOwl', function (require) {
_parseInput(inputValue) {
try {
return field_utils.parse[this.typeOfDate](inputValue, null, { timezone: false });
} catch (err) {
} catch (_err) {
return false;
}
}
@@ -84,7 +84,7 @@ odoo.define('web.Pager', function (require) {
async _changeSelection(direction) {
try {
await this.props.validate();
} catch (err) {
} catch (_err) {
return;
}
const { limit, size } = this.props;
@@ -115,7 +115,7 @@ odoo.define('web.Pager', function (require) {
async _saveValue(value) {
try {
await this.props.validate();
} catch (err) {
} catch (_err) {
return;
}
const [min, max] = value.trim().split(/\s*[\-\s,;]\s*/);
@@ -899,7 +899,7 @@ odoo.define("web/static/src/js/control_panel/control_panel_model_extension.js",
child.attrs.defaultInterval = context.group_by.split(':')[1];
child.tag = 'groupBy';
}
} catch (e) { }
} catch (_e) { }
}
if (child.attrs.name in this.searchDefaults) {
child.attrs.isDefault = true;
@@ -260,7 +260,7 @@ odoo.define('web.CustomFilterItem', function (require) {
condition.value = field_utils.parse[type](ev.target.value);
// Write displayed value in the input and 'displayedValue' property
condition.displayedValue = ev.target.value;
} catch (err) {
} catch (_err) {
// Parsing error: reverts to previous value
ev.target.value = condition.displayedValue;
}
@@ -163,7 +163,7 @@ odoo.define('web.SearchBar', function (require) {
if (typeof args === 'string') {
try {
args = Domain.prototype.stringToArray(args);
} catch (err) {
} catch (_err) {
args = [];
}
}
@@ -295,7 +295,7 @@ odoo.define('web.SearchBar', function (require) {
_validateSource(query, source) {
try {
this._parseWithSource(query, source);
} catch (err) {
} catch (_err) {
return false;
}
return true;
+1 -1
View File
@@ -288,7 +288,7 @@ function get_file(options) {
try { // Case of a serialized Odoo Exception: It is Json Parsable
var node = nodes[1] || nodes[0];
err = JSON.parse(node.textContent);
} catch (e) { // Arbitrary uncaught python side exception
} catch (_e) { // Arbitrary uncaught python side exception
err = {
message: nodes.length > 1 ? nodes[1].textContent : '',
data: {
@@ -39,12 +39,12 @@ try {
key: key,
newValue: newValue,
});
} catch (error) {}
} catch (_error) {}
});
return storage;
})();
} catch (exception) {
} catch (_exception) {
console.warn('Fail to load localStorage');
storage = new RamStorage();
}
@@ -156,7 +156,7 @@ var Session = core.Class.extend(mixins.EventDispatcherMixin, {
if(cookie.indexOf(nameEQ) === 0) {
try {
return JSON.parse(decodeURIComponent(cookie.substring(nameEQ.length)));
} catch(err) {
} catch(_err) {
// wrong cookie, delete it
this.set_cookie(name, '', -1);
}
@@ -41,12 +41,12 @@ try {
newValue: newValue,
});
}
} catch (error) {}
} catch (_error) {}
});
return storage;
})();
} catch (exception) {
} catch (_exception) {
console.warn('Fail to load sessionStorage');
storage = new RamStorage();
}
+3 -3
View File
@@ -183,13 +183,13 @@ function time_to_str (obj) {
function auto_str_to_date (value) {
try {
return str_to_datetime(value);
} catch(e) {}
} catch(_e) {}
try {
return str_to_date(value);
} catch(e) {}
} catch(_e) {}
try {
return str_to_time(value);
} catch(e) {}
} catch(_e) {}
throw new Error(_.str.sprintf(_t("'%s' is not a correct date, datetime nor time"), value));
}
@@ -568,7 +568,7 @@ var AbstractField = Widget.extend({
try {
value = this._parseValue(value);
this._isValid = true;
} catch (e) {
} catch (_e) {
this._isValid = false;
this.trigger_up('set_dirty', {dataPointID: this.dataPointID});
return Promise.reject({message: "Value set is not valid"});
@@ -537,7 +537,7 @@ odoo.define('web.AbstractFieldOwl', function (require) {
try {
value = this._parseValue(value);
this._isValid = true;
} catch (e) {
} catch (_e) {
this._isValid = false;
this.trigger('set-dirty', {dataPointID: this.dataPointId});
return Promise.reject({message: "Value set is not valid"});
@@ -517,7 +517,7 @@ var NumericField = InputField.extend({
value = this._formatValue(value);
// Set the computed value in the input
this.$input.val(value);
} catch (err) {
} catch (_err) {
// in case of exception, set value as the original value
// that way the Webclient will show an error as
// it is expecting a numeric value.
@@ -711,7 +711,7 @@ var FieldDateRange = InputField.extend({
const value = this.mode === "readonly" ? this.value : this.$input.val();
try {
return field_utils.parse[this.formatType](value, this.field, { timezone: true }) || true;
} catch (error) {
} catch (_error) {
return false;
}
},
@@ -731,7 +731,7 @@ var FieldDateRange = InputField.extend({
// user may enter manual value in input and it may not be parsed as date/datetime value
this.removeInvalidClass();
return field_utils.parse[this.formatType](this.$input.val(), this.field, { timezone: true });
} catch (error) {
} catch (_error) {
this.setInvalidClass();
return false;
}
@@ -3194,7 +3194,7 @@ var FieldProgressBar = AbstractField.extend({
try {
// Cover all numbers with parseFloat
parsedValue = field_utils.parse.float($input.val());
} catch (error) {
} catch (_error) {
this.displayNotification({ message: _t("Please enter a numerical value"), type: 'danger' });
}
@@ -4138,7 +4138,7 @@ var FieldColorPicker = FieldInteger.extend({
_highlightSelectedColor: function(){
try{
$(this.$('li')[parseInt(this.value)]).css('border', '2px solid teal');
} catch(err) {
} catch(_err) {
}
},
@@ -183,7 +183,7 @@ var KanbanController = BasicController.extend({
}
try {
var visible = new Domain(domain).compute(data.evalContext);
} catch (e) {
} catch (_e) {
return;
}
if (!visible) {
@@ -155,7 +155,7 @@ var DateWidget = Widget.extend({
try {
this._parseClient(value);
return true;
} catch (e) {
} catch (_e) {
return false;
}
}
@@ -396,7 +396,7 @@ var DomainTree = DomainNode.extend({
try {
parsedDomain = Domain.prototype.stringToArray(domain);
this.invalidDomain = false;
} catch (err) {
} catch (_err) {
// TODO: domain could contain `parent` for example, which is
// currently not handled by the DomainSelector
this.invalidDomain = true;
@@ -603,7 +603,7 @@ var DomainSelector = DomainTree.extend({
const rawDomain = e.currentTarget.value;
try {
Domain.prototype.stringToArray(rawDomain);
} catch (err) { // If there is a syntax error, just ignore the change
} catch (_err) { // If there is a syntax error, just ignore the change
this.displayNotification({ title: _t("Syntax error"), message: _t("Domain not properly formed"), type: 'danger' });
return;
}
@@ -712,7 +712,7 @@ var DomainLeaf = DomainNode.extend({
if (selectedField && !selectedField.relation && !_.isArray(this.value)) {
this.displayValue = field_utils.format[selectedField.type](this.value, selectedField);
}
} catch (err) {/**/}
} catch (_err) {/**/}
this.displayOperator = this.operator;
if (selectedField.type === "boolean") {
this.displayValue = this.value ? "1" : "0";
@@ -846,7 +846,7 @@ var DomainLeaf = DomainNode.extend({
var selectedField = this.fieldSelector.getSelectedField() || {};
try {
this.value = field_utils.parse[selectedField.type](value, selectedField);
} catch (err) {
} catch (_err) {
this.value = value;
couldNotParse = true;
}
@@ -306,7 +306,7 @@ export class CustomFilterItem extends Component {
// Only updates values if it can be correctly parsed and formatted.
condition.value = parsed;
condition.displayedValue = formatted;
} catch (err) {
} catch (_err) {
// Parsing error: nothing is done
}
ev.target.value = condition.displayedValue;
@@ -20,7 +20,7 @@ const DEFAULT_VIEWS_WITH_SEARCH_PANEL = ["kanban", "list"];
const getContextGroubBy = (context) => {
try {
return makeContext([context]).group_by.split(":");
} catch (err) {
} catch (_err) {
return [];
}
};
@@ -144,7 +144,7 @@ export class SearchBar extends LegacyComponent {
value = parser(trimmedQuery);
}
}
} catch (e) {
} catch (_e) {
continue;
}
@@ -183,7 +183,7 @@ export class SearchBar extends LegacyComponent {
if (searchItem.domain) {
try {
domain = new Domain(searchItem.domain).toList();
} catch (e) {
} catch (_e) {
// Pass
}
}
@@ -1168,7 +1168,7 @@ function makeActionManager(env) {
// warning: quotes and double quotes problem due to json and xml clash
// maybe we should force escaping in xml or do a better parse of the args array
additionalArgs = JSON.parse(params.args.replace(/'/g, '"'));
} catch (e) {
} catch (_e) {
browser.console.error("Could not JSON.parse arguments", params.args);
}
args = args.concat(additionalArgs);
@@ -42,11 +42,11 @@ function runTestSet(assert, testSet, options) {
let res2;
try {
res1 = options.newFn(input);
} catch (e) {}
} catch (_e) {}
try {
res2 = options.legacyFn(input);
} catch (e) {}
} catch (_e) {}
const expect =
expected.length === 1
@@ -109,7 +109,7 @@ QUnit.test("trigger an error when response has 'error' key", async (assert) => {
});
try {
await env.services.rpc("/test/");
} catch (error) {
} catch (_error) {
assert.ok(true);
}
unpatch(browser, "mock.xhr");
@@ -235,7 +235,7 @@ QUnit.test("check trigger RPC:REQUEST and RPC:RESPONSE for a rpc with an error",
});
try {
await env.services.rpc("/test/");
} catch (e) {
} catch (_e) {
assert.ok(true);
}
assert.strictEqual(rpcIdsRequest.toString(), rpcIdsResponse.toString());
@@ -95,11 +95,11 @@ export function makeMockXHR(response, sendCb, def) {
if (typeof data === "string") {
try {
data = JSON.parse(data);
} catch (e) {}
} catch (_e) {}
}
try {
await sendCb.call(this, data);
} catch (e) {
} catch (_e) {
listener = this._errorListener;
}
}
@@ -135,7 +135,7 @@ export function makeMockFetch(mockRPC) {
try {
res = await _rpc(route, params);
status = 200;
} catch (e) {
} catch (_e) {
status = 500;
}
const blob = new Blob([JSON.stringify(res || {})], { type: "application/json" });
@@ -8254,7 +8254,7 @@ QUnit.module('basic_fields', {
var left = $progressBarEl.offset().left + 5;
try {
testUtils.dom.triggerPositionalMouseEvent(left, top, "click");
} catch (e) {
} catch (_e) {
form.destroy();
$view.remove();
throw new Error('The test fails to simulate a click in the screen. Your screen is probably too small or your dev tools is open.');
@@ -8301,7 +8301,7 @@ QUnit.module('basic_fields', {
var left = $progressBarEl.offset().left + 5;
try {
testUtils.dom.triggerPositionalMouseEvent(left, top, "click");
} catch (e) {
} catch (_e) {
form.destroy();
$view.remove();
throw new Error('The test fails to simulate a click in the screen. Your screen is probably too small or your dev tools is open.');
@@ -114,7 +114,7 @@ QUnit.module("Legacy MockServer", {
args: [],
kwargs: {},
});
} catch (error) {
} catch (_error) {
assert.step("name_get failed")
}
assert.verifySteps(["name_get failed"])
@@ -166,7 +166,7 @@ QUnit.module("Legacy MockServer", {
args: [11111],
kwargs: {},
});
} catch (error) {
} catch (_error) {
assert.step("name_get failed")
}
assert.verifySteps(["name_get failed"])
@@ -247,7 +247,7 @@ odoo.define('web.basic_model_tests', function (require) {
try {
await model.load(this.params);
}
catch (e) {
catch (_e) {
assert.ok("load should return a rejected deferred for an invalid id");
}
@@ -731,7 +731,7 @@ QUnit.module('Views', {
try {
testUtils.dom.triggerPositionalMouseEvent(left, top, "mousedown");
} catch (e) {
} catch (_e) {
calendar.destroy();
throw new Error('The test fails to simulate a click in the screen. Your screen is probably too small or your dev tools is open.');
}
@@ -1107,7 +1107,7 @@ QUnit.module('Views', {
try {
testUtils.dom.triggerPositionalMouseEvent(left, top, "mousedown");
} catch (e) {
} catch (_e) {
calendar.destroy();
throw new Error('The test fails to simulate a click in the screen. Your screen is probably too small or your dev tools is open.');
}
@@ -1242,7 +1242,7 @@ QUnit.module('Views', {
try {
testUtils.dom.triggerPositionalMouseEvent(left, top, "mousedown");
} catch (e) {
} catch (_e) {
calendar.destroy();
throw new Error('The test fails to simulate a click in the screen. Your screen is probably too small or your dev tools is open.');
}
@@ -1391,7 +1391,7 @@ QUnit.module('Views', {
try {
testUtils.dom.triggerPositionalMouseEvent(left, top, "mousedown");
} catch (e) {
} catch (_e) {
calendar.destroy();
throw new Error('The test fails to simulate a click in the screen. Your screen is probably too small or your dev tools is open.');
}
@@ -1533,7 +1533,7 @@ QUnit.module('Views', {
var pos = calendar.$('.fc-bg td:eq(4)').offset();
try {
testUtils.dom.triggerPositionalMouseEvent(pos.left+15, pos.top+15, "mousedown");
} catch (e) {
} catch (_e) {
calendar.destroy();
throw new Error('The test fails to simulate a click in the screen. Your screen is probably too small or your dev tools is open.');
}
@@ -1611,7 +1611,7 @@ QUnit.module('Views', {
var pos = calendar.$('.fc-bg td:eq(4)').offset();
try {
testUtils.dom.triggerPositionalMouseEvent(pos.left + 15, pos.top + 15, "mousedown");
} catch (e) {
} catch (_e) {
calendar.destroy();
throw new Error('The test fails to simulate a click in the screen. Your screen is probably too small or your dev tools is open.');
}
@@ -1663,7 +1663,7 @@ QUnit.module('Views', {
var pos = calendar.$('.fc-bg td:eq(4)').offset();
try {
testUtils.dom.triggerPositionalMouseEvent(pos.left+15, pos.top+15, "mousedown");
} catch (e) {
} catch (_e) {
calendar.destroy();
throw new Error('The test fails to simulate a click in the screen. Your screen is probably too small or your dev tools is open.');
}
@@ -1716,7 +1716,7 @@ QUnit.module('Views', {
var pos = calendar.$('.fc-bg td:eq(17)').offset();
try {
testUtils.dom.triggerPositionalMouseEvent(pos.left+15, pos.top+15, "mousedown");
} catch (e) {
} catch (_e) {
calendar.destroy();
throw new Error('The test fails to simulate a click in the screen. Your screen is probably too small or your dev tools is open.');
}
@@ -2327,7 +2327,7 @@ QUnit.module('Views', {
var top = calendar.$('.fc-slats tr:eq(12) td:first').offset().top+15;
try {
testUtils.dom.triggerPositionalMouseEvent(left, top, "mousedown");
} catch (e) {
} catch (_e) {
calendar.destroy();
throw new Error('The test fails to simulate a click in the screen. Your screen is probably too small or your dev tools is open.');
}
@@ -2427,7 +2427,7 @@ QUnit.module('Views', {
var top = calendar.$('.fc-slats tr:eq(12) td:first').offset().top+15;
try {
testUtils.dom.triggerPositionalMouseEvent(left, top, "mousedown");
} catch (e) {
} catch (_e) {
calendar.destroy();
throw new Error('The test fails to simulate a click in the screen. Your screen is probably too small or your dev tools is open.');
}
@@ -2657,7 +2657,7 @@ QUnit.module('Views', {
testUtils.dom.triggerPositionalMouseEvent(left, top, "mousedown");
testUtils.dom.triggerPositionalMouseEvent(left, top, "mouseup");
await testUtils.nextTick();
} catch (e) {
} catch (_e) {
calendar.destroy();
throw new Error('The test failed to simulate a click on the screen.' +
'Your screen is probably too small or your dev tools are open.');
@@ -3778,7 +3778,7 @@ QUnit.module('Views', {
try {
testUtils.dom.triggerPositionalMouseEvent(left, top, "mousedown");
} catch (e) {
} catch (_e) {
calendar.destroy();
throw new Error('The test fails to simulate a click in the screen. Your screen is probably too small or your dev tools is open.');
}
@@ -5626,7 +5626,7 @@ QUnit.module('Views', {
try {
await testUtils.dom.click(kanban.$('.o_kanban_record:contains(yop) button[data-name="toggle_action"]'));
assert.strictEqual(true, true, 'Everything went fine');
} catch (e) {
} catch (_e) {
assert.strictEqual(true, false, 'Error triggered at action execution');
}
kanban.destroy();
@@ -34,12 +34,12 @@ QUnit.module("GroupBy Class", {}, () => {
assert.expect(3);
try {
getGroupBy(":day");
} catch (e) {
} catch (_e) {
assert.step("Error 1");
}
try {
getGroupBy("diay_name:yar");
} catch (e) {
} catch (_e) {
assert.step("Error 2");
}
assert.verifySteps(["Error 1", "Error 2"]);
@@ -56,22 +56,22 @@ QUnit.module("GroupBy Class", {}, () => {
assert.expect(5);
try {
getGroupBy("", fields);
} catch (e) {
} catch (_e) {
assert.step("Error 1");
}
try {
getGroupBy("display_name:day", fields);
} catch (e) {
} catch (_e) {
assert.step("Error 2");
}
try {
getGroupBy("diay_name:year", fields);
} catch (e) {
} catch (_e) {
assert.step("Error 3");
}
try {
getGroupBy("diay_name:yar", fields);
} catch (e) {
} catch (_e) {
assert.step("Error 4");
}
assert.verifySteps(["Error 1", "Error 2", "Error 3", "Error 4"]);
@@ -91,7 +91,7 @@ QUnit.module("GroupBy Class", {}, () => {
assert.expect(2);
try {
getGroupBy("date_field:yar", fields);
} catch (e) {
} catch (_e) {
assert.step("Error");
}
assert.verifySteps(["Error"]);
@@ -253,7 +253,7 @@ QUnit.module("ActionManager", (hooks) => {
await doAction(webClient, 7);
try {
await doAction(webClient, 7);
} catch (e) {
} catch (_e) {
assert.step("error caught");
}
assert.verifySteps([
+1 -1
View File
@@ -19,7 +19,7 @@
"no-unsafe-negation": ["error"],
"no-duplicate-imports": ["error"],
"valid-typeof": ["error"],
"no-unused-vars": ["error", { "vars": "all", "args": "none", "ignoreRestSiblings": false, "caughtErrors": "none" }]
"no-unused-vars": ["error", { "vars": "all", "args": "none", "ignoreRestSiblings": false, "caughtErrors": "all", "caughtErrorsIgnorePattern": "^_" }]
},
"globals": {
"odoo": "writable",
@@ -335,7 +335,7 @@ var FieldHtml = basic_fields.DebouncedField.extend(TranslatableFieldMixin, {
var cwindow = self.$iframe[0].contentWindow;
try {
cwindow.document;
} catch (e) {
} catch (_e) {
return;
}
cwindow.document
@@ -399,7 +399,7 @@ var FieldHtml = basic_fields.DebouncedField.extend(TranslatableFieldMixin, {
var value = text || "";
try {
$(text)[0].innerHTML; // crashes if text isn't html
} catch (e) {
} catch (_e) {
if (value.match(/^\s*$/)) {
value = '<p><br/></p>';
} else {
@@ -35,7 +35,7 @@ return {
// document.styleSheets[].cssRules[] for cross-domain
// stylesheets.
rules = sheets[i].rules || sheets[i].cssRules;
} catch (e) {
} catch (_e) {
continue;
}
if (!rules) {
@@ -125,7 +125,7 @@ const _DialogLinkWidget = Link.extend({
const Url = URL || window.URL || window.webkitURL;
const urlObj = url.startsWith('/') ? new Url(url, window.location.origin) : new Url(url);
return (urlObj.origin !== window.location.origin);
} catch (ignored) {
} catch (_ignored) {
return true;
}
},
@@ -156,7 +156,7 @@ const LinkPopoverWidget = Widget.extend({
let url;
try {
url = new URL(this.target.href); // relative to absolute
} catch (e) {
} catch (_e) {
// Invalid URL, might happen with editor unsuported protocol. eg type
// `geo:37.786971,-122.399677`, become `http://geo:37.786971,-122.399677`
this.displayNotification({
@@ -822,7 +822,7 @@ var ImageWidget = FileWidget.extend({
const newMedia = response.media;
this.nbMediaResults = response.results;
this.libraryMedia.push(...newMedia);
} catch (e) {
} catch (_e) {
// Either API endpoint doesn't exist or is misconfigured.
console.error(`Couldn't reach API endpoint.`);
}
@@ -958,7 +958,7 @@ var ImageWidget = FileWidget.extend({
return;
}
}
} catch (e) {
} catch (_e) {
console.error('CORS is misconfigured on the API server, image will be treated as non-dynamic.');
}
}
@@ -1342,7 +1342,7 @@ var VideoWidget = MediaWidget.extend({
if (this.media.dataset.src) {
try {
delete this.media.dataset.src;
} catch (e) {
} catch (_e) {
this.media.dataset.src = undefined;
}
}
@@ -130,7 +130,7 @@ weSnippetEditor.SnippetsMenu.include({
class: 'ml-1',
}));
}
} catch (e) {
} catch (_e) {
$apiKeyHelp.text(_t("Check your connection and try again"));
} finally {
$button.prop("disabled", false);
@@ -342,7 +342,7 @@ weSnippetEditor.SnippetsMenu.include({
try {
range.surroundContents(animatedTextEl);
$snippet = $(animatedTextEl);
} catch (e) {
} catch (_e) {
// This try catch is needed because 'surroundContents' may
// fail when the range has partially selected a non-Text node.
if (range.commonAncestorContainer.textContent === range.toString()) {
@@ -160,7 +160,7 @@ options.registry.SocialMedia = options.Class.extend({
const domain = new URL(url).hostname.split('.').slice(-2)[0];
fonts.computeFonts();
return fonts.fontIcons[0].alias.find(el => el.includes(domain)).split('fa-').pop();
} catch (error) {
} catch (_error) {
return false;
}
},
@@ -171,7 +171,7 @@ options.registry.SocialMedia = options.Class.extend({
_isValidURL(str) {
try {
new URL(str);
} catch (error) {
} catch (_error) {
return false;
}
return true;
@@ -403,7 +403,7 @@ odoo.define('website.s_website_form', function (require) {
try {
this.parse_date(value, type_of_date);
return true;
} catch (e) {
} catch (_e) {
return false;
}
}
@@ -59,7 +59,7 @@ publicWidget.registry.websiteEventSearchSponsor = publicWidget.Widget.extend({
const ids = JSON.parse(params.get(name));
params.set(name, JSON.stringify(ids.filter(id => id !== data.value)));
this.form.attr('action', `${window.location.href.split('?')[0]}?${params.toString()}`);
} catch (e) {
} catch (_e) {
return;
}
},
@@ -371,7 +371,7 @@ var BaseSettingController = FormController.extend({
dialog.close();
},
});
} catch (e) {
} catch (_e) {
cancel();
dialog.close();
}
+1 -1
View File
@@ -17,7 +17,7 @@
"no-unsafe-negation": ["error"],
"no-duplicate-imports": ["error"],
"valid-typeof": ["error"],
"no-unused-vars": ["error", { "vars": "all", "args": "none", "ignoreRestSiblings": false, "caughtErrors": "none" }]
"no-unused-vars": ["error", { "vars": "all", "args": "none", "ignoreRestSiblings": false, "caughtErrors": "all", "caughtErrorsIgnorePattern": "^_" }]
},
"globals": {
"owl": "readonly",