Update node packages and styling

With the update of some linting packages, several style fixes
were needed to conform with the updated style guidelines.

Change-Id: If73036a6d4a3a2f6e93b15d1fa6ed3d253fdc7b1
This commit is contained in:
Paul Van Eck 2017-12-18 13:53:06 -08:00
parent 33eb6586cf
commit 6d473eed7d
14 changed files with 264 additions and 299 deletions

View File

@ -57,6 +57,8 @@
"no-extra-boolean-cast": 0,
"operator-linebreak": 0,
"require-jsdoc": 2,
"quote-props": 0,
"valid-jsdoc": 0,
// Stylistic
"indent": [2, 4, {SwitchCase: 1}],

View File

@ -5,24 +5,22 @@
"description": "A user interface for RefStack",
"license": "Apache2",
"devDependencies": {
"bower": "1.3.12",
"eslint": "1.5.1",
"eslint-config-openstack": "1.2.1",
"eslint-plugin-angular": "0.12.0",
"http-server": "^0.6.1",
"karma": "^0.12.23",
"karma-chrome-launcher": "^0.1.5",
"karma-cli": "0.0.4",
"karma-jasmine": "^0.2.2",
"protractor": "~1.0.0"
"bower": "1.7.5",
"eslint": "^3.0.0",
"eslint-config-openstack": "4.0.1",
"eslint-plugin-angular": "1.4.0",
"jasmine-core": "2.8.0",
"karma": "^1.7.1",
"karma-chrome-launcher": "^2.2.0",
"karma-cli": "1.0.1",
"karma-jasmine": "^1.1.0"
},
"scripts": {
"postinstall": "bower install --config.interactive=false",
"prestart": "npm install",
"start": "http-server ./refstack-ui/app -a 0.0.0.0 -p 8080",
"pretest": "npm install",
"test": "karma start ./refstack-ui/tests/karma.conf.js --single-run",
"test-auto-watch": "karma start ./refstack-ui/tests/karma.conf.js --auto-watch",
"test": "if [ -z $CHROME_BIN ];then export CHROME_BIN=/usr/bin/chromium-browser;fi && karma start ./refstack-ui/tests/karma.conf.js --single-run",
"test-auto-watch": "if [ -z $CHROME_BIN ];then export CHROME_BIN=/usr/bin/chromium-browser;fi && karma start ./refstack-ui/tests/karma.conf.js --auto-watch",
"lint": "eslint -c ./.eslintrc --no-color ./refstack-ui"
}
}

View File

@ -74,8 +74,7 @@
var hash = $location.hash();
if (hash && hash in ctrl.options) {
ctrl.selectOption(hash);
}
else {
} else {
ctrl.selectOption('about');
}
}

View File

@ -94,8 +94,7 @@
data.metadata.os_trademark_approval.releases;
ctrl.guidelineStatus =
data.metadata.os_trademark_approval.status;
}
else {
} else {
ctrl.schema = data.schema;
ctrl.criteria = data.criteria;
ctrl.releases = data.releases;
@ -121,6 +120,7 @@
ctrl.targetCapabilities = {};
var components = ctrl.guidelines.components;
var targetCaps = ctrl.targetCapabilities;
var targetComponents = null;
// The 'platform' target is comprised of multiple components, so
// we need to get the capabilities belonging to each of its
@ -133,15 +133,14 @@
'object': 'OpenStack Powered Storage'
};
var targetComponents = ctrl.guidelines.platforms[
targetComponents = ctrl.guidelines.platforms[
platformsMap[ctrl.target]].components.map(
function(c) {
return c.name;
}
);
}
else {
var targetComponents = ctrl.guidelines.platform.required;
} else {
targetComponents = ctrl.guidelines.platform.required;
}
// This will contain status priority values, where lower
@ -173,15 +172,13 @@
statusMap[targetCaps[cap]]) {
targetCaps[cap] = status;
}
}
else {
} else {
targetCaps[cap] = status;
}
});
});
});
}
else {
} else {
angular.forEach(components[ctrl.target],
function (caps, status) {
angular.forEach(caps, function(cap) {
@ -200,14 +197,14 @@
*/
function filterStatus(capability) {
var caps = ctrl.targetCapabilities;
return (ctrl.status.required &&
caps[capability.id] === 'required') ||
(ctrl.status.advisory &&
caps[capability.id] === 'advisory') ||
(ctrl.status.deprecated &&
caps[capability.id] === 'deprecated') ||
(ctrl.status.removed &&
caps[capability.id] === 'removed');
return ctrl.status.required &&
caps[capability.id] === 'required' ||
ctrl.status.advisory &&
caps[capability.id] === 'advisory' ||
ctrl.status.deprecated &&
caps[capability.id] === 'deprecated' ||
ctrl.status.removed &&
caps[capability.id] === 'removed';
}
/**
@ -282,8 +279,7 @@
// Check if the API URL is absolute or relative.
if (refstackApiUrl.indexOf('http') > -1) {
ctrl.url = refstackApiUrl;
}
else {
} else {
ctrl.url = location.protocol + '//' + location.host +
refstackApiUrl;
}
@ -333,8 +329,7 @@
ctrl.testListString = response.data;
if (!ctrl.testListString) {
ctrl.testListCount = 0;
}
else {
} else {
ctrl.testListCount =
ctrl.testListString.split('\n').length;
}
@ -345,8 +340,7 @@
response.data.message) {
ctrl.error = 'Error retrieving test list: ' +
response.data.message;
}
else {
} else {
ctrl.error = 'Unknown error retrieving test list.';
}
});

View File

@ -232,8 +232,7 @@
}).error(function (error) {
raiseAlert('danger', error.title, error.detail);
});
}
else {
} else {
ctrl.unassociateRequest = $http.delete(metaUrl)
.success(function () {
ctrl.testsData[index][editFlag] = false;
@ -447,7 +446,7 @@
var properties = propertiesToJson();
var content = {'description': ctrl.product.description,
'properties': properties};
if (ctrl.productName != ctrl.product.name) {
if (ctrl.productName !== ctrl.product.name) {
content.name = ctrl.product.name;
}
@ -468,8 +467,7 @@
ctrl.showError = true;
ctrl.error = error.detail;
});
}
else {
} else {
ctrl.showSuccess = true;
$state.reload();
}

View File

@ -20,15 +20,14 @@
.controller('ProductsController', ProductsController);
ProductsController.$inject = [
'$rootScope', '$scope', '$http', '$state',
'refstackApiUrl','raiseAlert'
'$rootScope', '$scope', '$http', '$state', 'refstackApiUrl'
];
/**
* RefStack Products Controller
*/
function ProductsController($rootScope, $scope, $http, $state,
refstackApiUrl, raiseAlert) {
refstackApiUrl) {
var ctrl = this;
ctrl.update = update;
@ -82,7 +81,7 @@
ctrl.showError = false;
// Construct the API URL based on user-specified filters.
var contentUrl = refstackApiUrl + '/products';
if (typeof ctrl.rawData == 'undefined'
if (typeof ctrl.rawData === 'undefined'
|| ctrl.rawData === null) {
ctrl.productsRequest =
$http.get(contentUrl).success(function (data) {
@ -106,7 +105,8 @@
function updateData() {
ctrl.data = {};
ctrl.data.products = ctrl.rawData.products.filter(function(s) {
return ctrl._filterProduct(s); });
return ctrl._filterProduct(s);
});
ctrl.data.products.sort(function(a, b) {
return a.name.localeCompare(b.name);
});
@ -165,7 +165,7 @@
ctrl.vendors.sort(function(a, b) {
return a.name.localeCompare(b.name);
});
if (ctrl.vendors.length == 0) {
if (ctrl.vendors.length === 0) {
ctrl.vendors.push({name: 'Create New...', id: ''});
}
ctrl.organizationId = ctrl.vendors[0].id;
@ -189,9 +189,9 @@
name: ctrl.name,
description: ctrl.description,
organization_id: ctrl.organizationId,
product_type: parseInt(ctrl.productType)
product_type: parseInt(ctrl.productType, 10)
};
$http.post(url, data).success(function (data) {
$http.post(url, data).success(function () {
ctrl.rawData = null;
ctrl.showSuccess = true;
ctrl.name = '';

View File

@ -234,8 +234,7 @@
data.metadata.os_trademark_approval.status;
ctrl.releases =
data.metadata.os_trademark_approval.releases;
}
else {
} else {
ctrl.schemaVersion = data.schema;
ctrl.guidelineStatus = data.status;
ctrl.releases = data.releases;
@ -257,6 +256,7 @@
function getTargetCapabilities() {
var components = ctrl.guidelineData.components;
var targetCaps = {};
var targetComponents = null;
// The 'platform' target is comprised of multiple components, so
// we need to get the capabilities belonging to each of its
@ -269,15 +269,14 @@
'object': 'OpenStack Powered Storage'
};
var targetComponents = ctrl.guidelineData.platforms[
targetComponents = ctrl.guidelineData.platforms[
platformsMap[ctrl.target]].components.map(
function(c) {
return c.name;
}
);
}
else {
var targetComponents = ctrl.guidelineData.platform.required;
} else {
targetComponents = ctrl.guidelineData.platform.required;
}
// This will contain status priority values, where lower
@ -309,15 +308,13 @@
statusMap[targetCaps[cap]]) {
targetCaps[cap] = status;
}
}
else {
} else {
targetCaps[cap] = status;
}
});
});
});
}
else {
} else {
angular.forEach(components[ctrl.target],
function (caps, status) {
angular.forEach(caps, function(cap) {
@ -353,8 +350,7 @@
if (capDetails.flagged.indexOf(testId) > -1) {
cap.passedFlagged.push(testId);
}
}
else {
} else {
cap.notPassedTests.push(testId);
if (capDetails.flagged.indexOf(testId) > -1) {
cap.notPassedFlagged.push(testId);
@ -393,8 +389,7 @@
// If the test ID is in the results' test list.
if (ctrl.resultsData.results.indexOf(testId) > -1) {
passed = true;
}
else if ('aliases' in details) {
} else if ('aliases' in details) {
var len = details.aliases.length;
for (var i = 0; i < len; i++) {
var alias = details.aliases[i];
@ -412,8 +407,7 @@
if ('flagged' in details) {
cap.passedFlagged.push(testId);
}
}
else {
} else {
cap.notPassedTests.push(testId);
if ('flagged' in details) {
cap.notPassedFlagged.push(testId);
@ -443,10 +437,11 @@
'removed': {'caps': [], 'count': 0, 'passedCount': 0,
'flagFailCount': 0, 'flagPassCount': 0}
};
var capMethod = null;
switch (ctrl.schemaVersion) {
case '1.2':
var capMethod = 'buildCapabilityV1_2';
capMethod = 'buildCapabilityV1_2';
break;
case '1.3':
case '1.4':
@ -478,8 +473,8 @@
ctrl.caps[status].caps.push(cap);
});
ctrl.requiredPassPercent = (ctrl.caps.required.passedCount *
100 / ctrl.caps.required.count);
ctrl.requiredPassPercent = ctrl.caps.required.passedCount *
100 / ctrl.caps.required.count;
ctrl.totalRequiredFailCount = ctrl.caps.required.count -
ctrl.caps.required.passedCount;
@ -492,8 +487,8 @@
(ctrl.totalRequiredFailCount -
ctrl.caps.required.flagFailCount);
ctrl.nonFlagRequiredPassPercent = (ctrl.nonFlagPassCount *
100 / ctrl.totalNonFlagCount);
ctrl.nonFlagRequiredPassPercent = ctrl.nonFlagPassCount *
100 / ctrl.totalNonFlagCount;
}
/**
@ -506,10 +501,10 @@
if (!capObj) {
return false;
}
return (((ctrl.schemaVersion === '1.2') &&
(capObj.flagged.indexOf(test) > -1)) ||
((ctrl.schemaVersion >= '1.3') &&
(capObj.tests[test].flagged)));
return ctrl.schemaVersion === '1.2' &&
capObj.flagged.indexOf(test) > -1 ||
ctrl.schemaVersion >= '1.3' &&
capObj.tests[test].flagged;
}
/**
@ -520,19 +515,17 @@
* @returns {String} reason
*/
function getFlaggedReason(test, capObj) {
if ((ctrl.schemaVersion === '1.2') &&
(ctrl.isTestFlagged(test, capObj))) {
if (ctrl.schemaVersion === '1.2' &&
ctrl.isTestFlagged(test, capObj)) {
// Return a generic message since schema 1.2 does not
// provide flag reasons.
return 'Interop Working Group has flagged this test.';
}
else if ((ctrl.schemaVersion >= '1.3') &&
(ctrl.isTestFlagged(test, capObj))) {
} else if (ctrl.schemaVersion >= '1.3' &&
ctrl.isTestFlagged(test, capObj)) {
return capObj.tests[test].flagged.reason;
}
else {
} else {
return '';
}
}
@ -545,14 +538,14 @@
* @returns {Boolean} true if capability should be shown
*/
function isCapabilityShown(capability) {
return ((ctrl.testStatus === 'total') ||
(ctrl.testStatus === 'passed' &&
capability.passedTests.length > 0) ||
(ctrl.testStatus === 'not passed' &&
capability.notPassedTests.length > 0) ||
(ctrl.testStatus === 'flagged' &&
(capability.passedFlagged.length +
capability.notPassedFlagged.length > 0)));
return ctrl.testStatus === 'total' ||
ctrl.testStatus === 'passed' &&
capability.passedTests.length > 0 ||
ctrl.testStatus === 'not passed' &&
capability.notPassedTests.length > 0 ||
ctrl.testStatus === 'flagged' &&
capability.passedFlagged.length +
capability.notPassedFlagged.length > 0;
}
/**
@ -563,14 +556,14 @@
* @return {Boolean} true if test should be shown
*/
function isTestShown(test, capability) {
return ((ctrl.testStatus === 'total') ||
(ctrl.testStatus === 'passed' &&
capability.passedTests.indexOf(test) > -1) ||
(ctrl.testStatus === 'not passed' &&
capability.notPassedTests.indexOf(test) > -1) ||
(ctrl.testStatus === 'flagged' &&
return ctrl.testStatus === 'total' ||
ctrl.testStatus === 'passed' &&
capability.passedTests.indexOf(test) > -1 ||
ctrl.testStatus === 'not passed' &&
capability.notPassedTests.indexOf(test) > -1 ||
ctrl.testStatus === 'flagged' &&
(capability.passedFlagged.indexOf(test) > -1 ||
capability.notPassedFlagged.indexOf(test) > -1)));
capability.notPassedFlagged.indexOf(test) > -1);
}
/**
@ -583,18 +576,14 @@
if (ctrl.testStatus === 'total') {
return capability.passedTests.length +
capability.notPassedTests.length;
}
else if (ctrl.testStatus === 'passed') {
} else if (ctrl.testStatus === 'passed') {
return capability.passedTests.length;
}
else if (ctrl.testStatus === 'not passed') {
} else if (ctrl.testStatus === 'not passed') {
return capability.notPassedTests.length;
}
else if (ctrl.testStatus === 'flagged') {
} else if (ctrl.testStatus === 'flagged') {
return capability.passedFlagged.length +
capability.notPassedFlagged.length;
}
else {
} else {
return 0;
}
}
@ -608,22 +597,17 @@
function getStatusTestCount(status) {
if (!ctrl.caps) {
return -1;
}
else if (ctrl.testStatus === 'total') {
} else if (ctrl.testStatus === 'total') {
return ctrl.caps[status].count;
}
else if (ctrl.testStatus === 'passed') {
} else if (ctrl.testStatus === 'passed') {
return ctrl.caps[status].passedCount;
}
else if (ctrl.testStatus === 'not passed') {
} else if (ctrl.testStatus === 'not passed') {
return ctrl.caps[status].count -
ctrl.caps[status].passedCount;
}
else if (ctrl.testStatus === 'flagged') {
} else if (ctrl.testStatus === 'flagged') {
return ctrl.caps[status].flagFailCount +
ctrl.caps[status].flagPassCount;
}
else {
} else {
return -1;
}
}
@ -791,8 +775,8 @@
* a test result.
*/
function associateProductVersion() {
var verId = (ctrl.selectedVersion ?
ctrl.selectedVersion.id : null);
var verId = ctrl.selectedVersion ?
ctrl.selectedVersion.id : null;
var testId = resultsData.id;
var url = refstackApiUrl + '/results/' + testId;
ctrl.associateRequest = $http.put(url, {'product_version_id':
@ -822,11 +806,10 @@
.success(function (data) {
ctrl.productVersions = data;
if (ctrl.prodVersionCopy &&
ctrl.prodVersionCopy.product_info.id ==
ctrl.prodVersionCopy.product_info.id ===
ctrl.selectedProduct.id) {
ctrl.selectedVersion = ctrl.prodVersionCopy;
}
else {
} else {
angular.forEach(data, function(ver) {
if (!ver.version) {
ctrl.selectedVersion = ver;
@ -850,13 +833,13 @@
var metaFields = ['target', 'guideline', 'shared'];
var meta = ctrl.metaCopy;
angular.forEach(metaFields, function(field) {
var oldMetaValue = (field in ctrl.resultsData.meta) ?
var oldMetaValue = field in ctrl.resultsData.meta ?
ctrl.resultsData.meta[field] : '';
if (field in meta && oldMetaValue != meta[field]) {
if (field in meta && oldMetaValue !== meta[field]) {
var metaUrl = metaBaseUrl + field;
if (meta[field]) {
ctrl.assocRequest = $http.post(metaUrl, meta[field])
.success(function(data) {
.success(function() {
ctrl.resultsData.meta[field] = meta[field];
})
.error(function (error) {
@ -866,10 +849,9 @@
'Error associating metadata with ' +
'test run: ' + angular.toJson(error);
});
}
else {
} else {
ctrl.unassocRequest = $http.delete(metaUrl)
.success(function (data) {
.success(function () {
delete ctrl.resultsData.meta[field];
delete meta[field];
})

View File

@ -183,18 +183,16 @@
}).error(function (error) {
raiseAlert('danger', error.title, error.detail);
});
}
else {
} else {
ctrl.unassociateRequest = $http.delete(metaUrl)
.success(function () {
ctrl.data.results[index][editFlag] = false;
}).error(function (error) {
if (error.code == 404) {
if (error.code === 404) {
// Key doesn't exist, so count it as a success,
// and don't raise an alert.
ctrl.data.results[index][editFlag] = false;
}
else {
} else {
raiseAlert('danger', error.title, error.detail);
}
});
@ -273,13 +271,13 @@
* a test result.
*/
function associateProductVersion(result) {
var verId = (result.selectedVersion ?
result.selectedVersion.id : null);
var verId = result.selectedVersion ?
result.selectedVersion.id : null;
var testId = result.id;
var url = refstackApiUrl + '/results/' + testId;
ctrl.associateRequest = $http.put(url, {'product_version_id':
verId})
.success(function (data) {
.success(function () {
result.product_version = result.selectedVersion;
if (result.selectedVersion) {
result.product_version.product_info =

View File

@ -70,10 +70,10 @@
ctrl.vendor = data;
var isAdmin = $rootScope.auth.currentUser.is_admin;
ctrl.vendor.canDelete = ctrl.vendor.canEdit =
ctrl.vendor.type != 0
ctrl.vendor.type !== 0
&& (ctrl.vendor.can_manage || isAdmin);
ctrl.vendor.canRegister =
ctrl.vendor.type == 1;
ctrl.vendor.type === 1;
ctrl.vendor.canApprove = isAdmin;
ctrl.vendorProperties = angular.fromJson(data.properties);
}).error(function(error) {
@ -299,7 +299,7 @@
var properties = propertiesToJson();
var content = {'description': ctrl.vendor.description,
'properties': properties};
if (ctrl.vendorName != ctrl.vendor.name) {
if (ctrl.vendorName !== ctrl.vendor.name) {
content.name = ctrl.vendor.name;
}
$http.put(url, content).success(function() {

View File

@ -20,9 +20,7 @@
.controller('VendorsController', VendorsController);
VendorsController.$inject = [
'$rootScope', '$scope', '$http', '$state',
'refstackApiUrl','raiseAlert'
];
'$rootScope', '$scope', '$http', '$state', 'refstackApiUrl'];
/**
* RefStack Vendors Controller
@ -30,7 +28,7 @@
* where a user can browse a listing of his/her vendors or public vendors.
*/
function VendorsController($rootScope, $scope, $http, $state,
refstackApiUrl, raiseAlert) {
refstackApiUrl) {
var ctrl = this;
ctrl.update = update;
@ -81,7 +79,7 @@
ctrl.data = null;
// Construct the API URL based on user-specified filters.
var contentUrl = refstackApiUrl + '/vendors';
if (typeof ctrl.rawData == 'undefined'
if (typeof ctrl.rawData === 'undefined'
|| ctrl.rawData === null) {
ctrl.vendorsRequest =
$http.get(contentUrl).success(function (data) {
@ -123,7 +121,7 @@
*/
function _filterVendor(vendor) {
if (!ctrl.isUserVendors) {
return (vendor.type == 0 || vendor.type == 3);
return vendor.type === 0 || vendor.type === 3;
}
if (!$rootScope.auth || !$rootScope.auth.currentUser) {
@ -131,7 +129,7 @@
}
if ($rootScope.auth.currentUser.is_admin) {
return vendor.type != 1 || ctrl.withPrivate;
return vendor.type !== 1 || ctrl.withPrivate;
}
return vendor.can_manage;
@ -148,7 +146,7 @@
name: ctrl.name,
description: ctrl.description
};
$http.post(url, data).success(function (data) {
$http.post(url, data).success(function () {
ctrl.showSuccess = true;
ctrl.name = '';
ctrl.description = '';

View File

@ -19,7 +19,6 @@ module.exports = function (config) {
'app/components/**/*.js',
'app/shared/*.js',
'app/shared/**/*.js',
'app/assets/js/*.js',
// Test Specs.
'tests/unit/*.js'

View File

@ -280,13 +280,12 @@ describe('Refstack controllers', function () {
});
describe('TestListModalController', function () {
var modalInstance, ctrl, $window;
var modalInstance, ctrl;
beforeEach(inject(function ($controller, _$window_) {
beforeEach(inject(function ($controller) {
modalInstance = {
dismiss: jasmine.createSpy('modalInstance.dismiss')
};
$window = _$window_;
ctrl = $controller('TestListModalController',
{$uibModalInstance: modalInstance,
target: 'platform',
@ -423,10 +422,9 @@ describe('Refstack controllers', function () {
it('should have a function to get products manageable by a user',
function () {
var prodResp = {'products': [{'id': 'abc',
'can_manage': true},
{'id': 'foo',
'can_manage': false}]};
var prodResp = {'products': [
{'id': 'abc', 'can_manage': true},
{'id': 'foo', 'can_manage': false}]};
ctrl.products = null;
$httpBackend.expectGET(fakeApiUrl + '/products')
.respond(200, prodResp);
@ -984,7 +982,6 @@ describe('Refstack controllers', function () {
'target': 'object'
}
};
var fakeProdResp = {'products': [{'id': 1234}]};
var fakeVersionResp = [{'id': 'ver1', 'version': '1.0'},
{'id': 'ver2', 'version': null}];