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;
function matchesId(action) {
if (action.id === value) {
return true;
}
return action.id === value;
}
}

View File

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

View File

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

View File

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

View File

@ -27,7 +27,9 @@
}));
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);
}));
});

View File

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

View File

@ -42,7 +42,9 @@
}));
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);
}));
});

View File

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

View File

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

View File

@ -54,7 +54,7 @@
function perform(selected) {
// get config
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.ca, selected.name + "_ca.pem");
textDownload.downloadTextFile(response.data.cert, selected.name + "_cert.pem");

View File

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

View File

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

View File

@ -26,7 +26,9 @@
}));
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);
}));
});

View File

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

View File

@ -42,7 +42,9 @@
}));
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);
}));
});

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) {
return apiService.delete('/api/container_infra/clusters/', ids)
.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) {
return apiService.delete('/api/container_infra/cluster_templates/', ids)
.catch(function onError() {

View File

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

View File

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

View File

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

View File

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