Fix all lint warnings

* Resolve all npm lint warnings so we don't hide new ones.
* Any functionality changes from this change are unintentional
  and should be fixed.

Change-Id: Ief1433bbe7e873999c94ca763f93a443d4234739
This commit is contained in:
Dale Smith 2024-05-03 11:56:24 +12:00
parent e85d41fd8b
commit 8680420c34
20 changed files with 87 additions and 87 deletions

View File

@ -49,9 +49,7 @@
return list.filter(matchesId).length === 1; return list.filter(matchesId).length === 1;
function matchesId(action) { function matchesId(action) {
if (action.id === value) { return action.id === value;
return true;
}
} }
} }

View File

@ -56,7 +56,7 @@
/** /**
* @ngdoc constant * @ngdoc constant
* @name distros * @name distros
* @return [distros] available image distros * @returns {String[]} List of available image distros
* @description A list available image distros for magnum * @description A list available image distros for magnum
*/ */
function distros() { function distros() {

View File

@ -40,12 +40,14 @@
* @name delete.service * @name delete.service
* @param {Object} $location * @param {Object} $location
* @param {Object} $q * @param {Object} $q
* @param {Object} $rootScope
* @param {Object} magnum service * @param {Object} magnum service
* @param {Object} policy * @param {Object} policy
* @param {Object} actionResult * @param {Object} actionResult
* @param {Object} gettext * @param {Object} gettext
* @param {Object} $qExtensions * @param {Object} $qExtensions
* @param {Object} deleteModal * @param {Object} deleteModal
* @param {Object} tableEvents
* @param {Object} toast * @param {Object} toast
* @param {Object} resourceType * @param {Object} resourceType
* @param {Object} events * @param {Object} events
@ -143,6 +145,7 @@
if (result.result.failed.length === 0 && result.result.deleted.length > 0 && if (result.result.failed.length === 0 && result.result.deleted.length > 0 &&
currentPath !== indexPath) { currentPath !== indexPath) {
$location.path(indexPath); $location.path(indexPath);
return null;
} else { } else {
$rootScope.$broadcast(tableEvents.CLEAR_SELECTIONS); $rootScope.$broadcast(tableEvents.CLEAR_SELECTIONS);
return result.result; return result.result;

View File

@ -36,7 +36,7 @@
function objLen(obj) { function objLen(obj) {
var length = 0; var length = 0;
if (typeof obj === 'object') { if (obj && typeof obj === 'object') {
length = Object.keys(obj).length; length = Object.keys(obj).length;
} }
return length; return length;

View File

@ -27,7 +27,9 @@
})); }));
it('objLen returns number of attributes of object', inject(function() { it('objLen returns number of attributes of object', inject(function() {
expect(ctrl.objLen(undefined)).toBe(0); expect(ctrl.objLen()).toBe(0);
expect(ctrl.objLen(null)).toBe(0);
expect(ctrl.objLen({})).toBe(0);
expect(ctrl.objLen({a: 0})).toBe(1); expect(ctrl.objLen({a: 0})).toBe(1);
})); }));
}); });

View File

@ -49,7 +49,7 @@
function objLen(obj) { function objLen(obj) {
var length = 0; var length = 0;
if (typeof obj === 'object') { if (obj && typeof obj === 'object') {
length = Object.keys(obj).length; length = Object.keys(obj).length;
} }
return length; return length;

View File

@ -42,7 +42,9 @@
})); }));
it('objLen returns number of attributes of object', inject(function() { it('objLen returns number of attributes of object', inject(function() {
expect(ctrl.objLen(undefined)).toBe(0); expect(ctrl.objLen()).toBe(0);
expect(ctrl.objLen(null)).toBe(0);
expect(ctrl.objLen({})).toBe(0);
expect(ctrl.objLen({a: 0})).toBe(1); expect(ctrl.objLen({a: 0})).toBe(1);
})); }));
}); });

View File

@ -63,56 +63,42 @@
// load current data // load current data
magnum.getClusterTemplate(selected.id).then(onLoad); magnum.getClusterTemplate(selected.id).then(onLoad);
function onLoad(response) { function onLoad(response) {
config.model.name = response.data.name
? response.data.name : ""; function setModelFromResponse(key, defaultValue) {
config.model.coe = response.data.coe if (response.data[key]) {
? response.data.coe : ""; config.model[key] = response.data[key];
config.model.server_type = response.data.server_type } else {
? response.data.server_type : ""; config.model[key] = defaultValue;
config.model.public = response.data.public }
? response.data.public : false;
config.model.hidden = response.data.hidden }
? response.data.hidden : false;
config.model.registry_enabled = response.data.registry_enabled setModelFromResponse('name', "");
? response.data.registry_enabled : false; setModelFromResponse('coe', "");
config.model.tls_disabled = response.data.tls_disabled setModelFromResponse('server_type', "");
? response.data.tls_disabled : false; setModelFromResponse('public', false);
config.model.image_id = response.data.image_id setModelFromResponse('hidden', false);
? response.data.image_id : ""; setModelFromResponse('registry_enabled', false);
config.model.flavor_id = response.data.flavor_id setModelFromResponse('tls_disabled', false);
? response.data.flavor_id : ""; setModelFromResponse('image_id', "");
config.model.master_flavor_id = response.data.master_flavor_id setModelFromResponse('flavor_id', "");
? response.data.master_flavor_id : ""; setModelFromResponse('master_flavor_id', "");
config.model.docker_volume_size = response.data.docker_volume_size setModelFromResponse('docker_volume_size', "");
? response.data.docker_volume_size : ""; setModelFromResponse('docker_storage_driver', "");
config.model.docker_storage_driver = response.data.docker_storage_driver setModelFromResponse('keypair_id', "");
? response.data.docker_storage_driver : ""; setModelFromResponse('network_driver', "");
config.model.keypair_id = response.data.keypair_id setModelFromResponse('volume_driver', "");
? response.data.keypair_id : ""; setModelFromResponse('insecure_registry', "");
config.model.network_driver = response.data.network_driver setModelFromResponse('http_proxy', "");
? response.data.network_driver : ""; setModelFromResponse('https_proxy', "");
config.model.volume_driver = response.data.volume_driver setModelFromResponse('no_proxy', "");
? response.data.volume_driver : ""; setModelFromResponse('external_network_id', "");
config.model.insecure_registry = response.data.insecure_registry setModelFromResponse('fixed_network', "");
? response.data.insecure_registry : ""; setModelFromResponse('fixed_subnet', "");
config.model.http_proxy = response.data.http_proxy setModelFromResponse('dns_nameserver', "");
? response.data.http_proxy : ""; setModelFromResponse('master_lb_enabled', false);
config.model.https_proxy = response.data.https_proxy setModelFromResponse('floating_ip_enabled', false);
? response.data.https_proxy : "";
config.model.no_proxy = response.data.no_proxy
? response.data.no_proxy : "";
config.model.external_network_id = response.data.external_network_id
? response.data.external_network_id : "";
config.model.fixed_network = response.data.fixed_network
? response.data.fixed_network : "";
config.model.fixed_subnet = response.data.fixed_subnet
? response.data.fixed_subnet : "";
config.model.dns_nameserver = response.data.dns_nameserver
? response.data.dns_nameserver : "";
config.model.master_lb_enabled = response.data.master_lb_enabled
? response.data.master_lb_enabled : false;
config.model.floating_ip_enabled = response.data.floating_ip_enabled
? response.data.floating_ip_enabled : false;
var labels = ""; var labels = "";
for (var key in response.data.labels) { for (var key in response.data.labels) {
if (response.data.labels.hasOwnProperty(key)) { if (response.data.labels.hasOwnProperty(key)) {

View File

@ -69,9 +69,7 @@
return list.filter(matchesId).length === 1; return list.filter(matchesId).length === 1;
function matchesId(action) { function matchesId(action) {
if (action.id === value) { return action.id === value;
return true;
}
} }
} }

View File

@ -54,7 +54,7 @@
function perform(selected) { function perform(selected) {
// get config // get config
return magnum.getClusterConfig(selected.id).then(function(response) { return magnum.getClusterConfig(selected.id).then(function(response) {
if ( response.data.key !== undefined ) { if (typeof response.data.key !== "undefined") {
textDownload.downloadTextFile(response.data.key, selected.name + "_key.pem"); textDownload.downloadTextFile(response.data.key, selected.name + "_key.pem");
textDownload.downloadTextFile(response.data.ca, selected.name + "_ca.pem"); textDownload.downloadTextFile(response.data.ca, selected.name + "_ca.pem");
textDownload.downloadTextFile(response.data.cert, selected.name + "_cert.pem"); textDownload.downloadTextFile(response.data.cert, selected.name + "_cert.pem");

View File

@ -40,12 +40,14 @@
* @name clusters.delete.service * @name clusters.delete.service
* @param {Object} $location * @param {Object} $location
* @param {Object} $q * @param {Object} $q
* @param {Object} $rootScope
* @param {Object} magnum * @param {Object} magnum
* @param {Object} policy * @param {Object} policy
* @param {Object} actionResult * @param {Object} actionResult
* @param {Object} gettext * @param {Object} gettext
* @param {Object} $qExtensions * @param {Object} $qExtensions
* @param {Object} deleteModal * @param {Object} deleteModal
* @param {Object} tableEvents
* @param {Object} toast * @param {Object} toast
* @param {Object} resourceType * @param {Object} resourceType
* @param {Object} events * @param {Object} events
@ -143,6 +145,7 @@
if (result.result.failed.length === 0 && result.result.deleted.length > 0 && if (result.result.failed.length === 0 && result.result.deleted.length > 0 &&
currentPath !== indexPath) { currentPath !== indexPath) {
$location.path(indexPath); $location.path(indexPath);
return null;
} else { } else {
$rootScope.$broadcast(tableEvents.CLEAR_SELECTIONS); $rootScope.$broadcast(tableEvents.CLEAR_SELECTIONS);
return result.result; return result.result;

View File

@ -36,7 +36,7 @@
function objLen(obj) { function objLen(obj) {
var length = 0; var length = 0;
if (typeof obj === 'object') { if (obj && typeof obj === 'object') {
length = Object.keys(obj).length; length = Object.keys(obj).length;
} }
return length; return length;

View File

@ -26,7 +26,9 @@
})); }));
it('objLen returns number of attributes of object', inject(function() { it('objLen returns number of attributes of object', inject(function() {
expect(ctrl.objLen(undefined)).toBe(0); expect(ctrl.objLen()).toBe(0);
expect(ctrl.objLen(null)).toBe(0);
expect(ctrl.objLen({})).toBe(0);
expect(ctrl.objLen({a: 0})).toBe(1); expect(ctrl.objLen({a: 0})).toBe(1);
})); }));
}); });

View File

@ -45,7 +45,7 @@
function objLen(obj) { function objLen(obj) {
var length = 0; var length = 0;
if (typeof obj === 'object') { if (obj && typeof obj === 'object') {
length = Object.keys(obj).length; length = Object.keys(obj).length;
} }
return length; return length;

View File

@ -42,7 +42,9 @@
})); }));
it('objLen returns number of attributes of object', inject(function() { it('objLen returns number of attributes of object', inject(function() {
expect(ctrl.objLen(undefined)).toBe(0); expect(ctrl.objLen()).toBe(0);
expect(ctrl.objLen(null)).toBe(0);
expect(ctrl.objLen({})).toBe(0);
expect(ctrl.objLen({a: 0})).toBe(1); expect(ctrl.objLen({a: 0})).toBe(1);
})); }));
}); });

View File

@ -130,7 +130,7 @@
}); });
} }
// FIXME(shu-mutou): Unused for batch-delete in Horizon framework in Feb, 2016. // NOTE(shu-mutou): Unused for batch-delete in Horizon framework in Feb, 2016.
function deleteClusters(ids) { function deleteClusters(ids) {
return apiService.delete('/api/container_infra/clusters/', ids) return apiService.delete('/api/container_infra/clusters/', ids)
.catch(function onError() { .catch(function onError() {
@ -179,7 +179,7 @@
}); });
} }
// FIXME(shu-mutou): Unused for batch-delete in Horizon framework in Feb, 2016. // NOTE(shu-mutou): Unused for batch-delete in Horizon framework in Feb, 2016.
function deleteClusterTemplates(ids) { function deleteClusterTemplates(ids) {
return apiService.delete('/api/container_infra/cluster_templates/', ids) return apiService.delete('/api/container_infra/cluster_templates/', ids)
.catch(function onError() { .catch(function onError() {

View File

@ -32,9 +32,7 @@
return list.filter(matchesId).length === 1; return list.filter(matchesId).length === 1;
function matchesId(action) { function matchesId(action) {
if (action.id === value) { return action.id === value;
return true;
}
} }
} }
}); });

View File

@ -40,12 +40,14 @@
* @name quotas.delete.service * @name quotas.delete.service
* @param {Object} $location * @param {Object} $location
* @param {Object} $q * @param {Object} $q
* @param {Object} $rootScope
* @param {Object} magnum * @param {Object} magnum
* @param {Object} policy * @param {Object} policy
* @param {Object} actionResult * @param {Object} actionResult
* @param {Object} gettext * @param {Object} gettext
* @param {Object} $qExtensions * @param {Object} $qExtensions
* @param {Object} deleteModal * @param {Object} deleteModal
* @param {Object} tableEvents
* @param {Object} toast * @param {Object} toast
* @param {Object} resourceType * @param {Object} resourceType
* @param {Object} events * @param {Object} events
@ -143,6 +145,7 @@
if (result.result.failed.length === 0 && result.result.deleted.length > 0 && if (result.result.failed.length === 0 && result.result.deleted.length > 0 &&
currentPath !== indexPath) { currentPath !== indexPath) {
$location.path(indexPath); $location.path(indexPath);
return null;
} else { } else {
$rootScope.$broadcast(tableEvents.CLEAR_SELECTIONS); $rootScope.$broadcast(tableEvents.CLEAR_SELECTIONS);
return result.result; return result.result;

View File

@ -37,36 +37,39 @@
var v1parts = v1.split('.'); var v1parts = v1.split('.');
var v2parts = v2.split('.'); var v2parts = v2.split('.');
// Step 1: Validation
function isValidPart(x) { function isValidPart(x) {
return (lexicographical ? /^\d+[A-Za-z]*$/ : /^\d+$/).test(x); return (lexicographical ? /^\d+[A-Za-z]*$/ : /^\d+$/).test(x);
} }
if (!v1parts.every(isValidPart) || !v2parts.every(isValidPart)) { if (!v1parts.every(isValidPart) || !v2parts.every(isValidPart)) {
return NaN; return NaN;
} }
if (zeroExtend) { // Step 2: Normalise
while (v1parts.length < v2parts.length) { v1parts.push("0"); } function normaliseParts(parts) {
while (v2parts.length < v1parts.length) { v2parts.push("0"); } if (zeroExtend) {
} while (parts.length < parts.length) { parts.push("0"); }
}
if (!lexicographical) { if (!lexicographical) {
v1parts = v1parts.map(Number); parts = parts.map(Number);
v2parts = v2parts.map(Number); }
return parts;
} }
v1parts = normaliseParts(v1parts);
v2parts = normaliseParts(v2parts);
// Step 3: Comparison
for (var i = 0; i < v1parts.length; ++i) { for (var i = 0; i < v1parts.length; ++i) {
if (v2parts.length === i) { return 1; } if (v2parts.length === i) { return 1; }
if (v1parts[i] === v2parts[i]) { if (v1parts[i] === v2parts[i]) {
continue; continue;
} else if (v1parts[i] > v2parts[i]) {
return 1;
} else {
return -1;
} }
if (v1parts[i] > v2parts[i]) {
return 1;
}
return -1;
} }
if (v1parts.length !== v2parts.length) { return -1; } if (v1parts.length !== v2parts.length) { return -1; }
return 0; return 0;

View File

@ -10,14 +10,14 @@
"license": "Apache 2.0", "license": "Apache 2.0",
"author": "Openstack <openstack-discuss@lists.openstack.org>", "author": "Openstack <openstack-discuss@lists.openstack.org>",
"devDependencies": { "devDependencies": {
"eslint": "3.19.x", "eslint": "^3.19.0",
"eslint-config-openstack": "^4.0.1", "eslint-config-openstack": "^4.0.1",
"eslint-plugin-angular": "3.1.x", "eslint-plugin-angular": "3.1.x",
"jasmine-core": "2.8.x", "jasmine-core": "2.8.x",
"karma": "1.7.x", "karma": "1.7.x",
"karma-firefox-launcher": "2.1.0",
"karma-cli": "1.0.x", "karma-cli": "1.0.x",
"karma-coverage": "1.1.x", "karma-coverage": "1.1.x",
"karma-firefox-launcher": "2.1.0",
"karma-jasmine": "1.1.x", "karma-jasmine": "1.1.x",
"karma-ng-html2js-preprocessor": "1.0.x", "karma-ng-html2js-preprocessor": "1.0.x",
"karma-threshold-reporter": "0.1.x" "karma-threshold-reporter": "0.1.x"