Enable no-unused-vars

This enables the no-unused-vars rule from the upstream
eslint-config-openstack, and corrects all linting errors found.

Change-Id: I9f5fb29cd9b2429698819ecf556ced933378b081
This commit is contained in:
Michael Krotscheck 2015-11-12 15:03:06 -08:00
parent 74a57b7b43
commit 2aa78ad0b7
22 changed files with 34 additions and 40 deletions

View File

@ -28,7 +28,6 @@ rules:
valid-jsdoc: 1 valid-jsdoc: 1
no-undefined: 1 no-undefined: 1
brace-style: 1 brace-style: 1
no-unused-vars: 1
strict: 1 strict: 1
no-extra-parens: 1 no-extra-parens: 1
eqeqeq: 1 eqeqeq: 1

View File

@ -164,7 +164,7 @@
/** /**
* Get the HTML for a `menu` * Get the HTML for a `menu`
*/ */
function getMenu(actionList, scope) { function getMenu(actionList) {
var menuElem = angular.element('<menu>'); var menuElem = angular.element('<menu>');
menuElem.append(actionList); menuElem.append(actionList);
return menuElem; return menuElem;

View File

@ -26,7 +26,7 @@
describe('pie chart directive', function () { describe('pie chart directive', function () {
var $scope, $elementMax, $elementTotal, $elementOverMax, var $scope, $elementMax, $elementTotal, $elementOverMax,
$elementNoQuota, donutChartSettings, quotaChartDefaults; $elementNoQuota, quotaChartDefaults;
beforeEach(module('templates')); beforeEach(module('templates'));
beforeEach(module('horizon.framework')); beforeEach(module('horizon.framework'));
@ -38,7 +38,6 @@
beforeEach(inject(function ($injector) { beforeEach(inject(function ($injector) {
var $compile = $injector.get('$compile'); var $compile = $injector.get('$compile');
$scope = $injector.get('$rootScope').$new(); $scope = $injector.get('$rootScope').$new();
donutChartSettings = $injector.get('horizon.framework.widgets.charts.donutChartSettings');
quotaChartDefaults = $injector.get('horizon.framework.widgets.charts.quotaChartDefaults'); quotaChartDefaults = $injector.get('horizon.framework.widgets.charts.quotaChartDefaults');
$scope.testDataTotal = { $scope.testDataTotal = {

View File

@ -100,7 +100,7 @@
scope.filterStrings = scope.filterStrings ? scope.filterStrings : defaultFilterStrings; scope.filterStrings = scope.filterStrings ? scope.filterStrings : defaultFilterStrings;
} }
function compile(element, attrs) { function compile(element) {
/** /**
* Need to set template here since MagicSearch template * Need to set template here since MagicSearch template
* attribute is not interpolated. Can't hardcode the * attribute is not interpolated. Can't hardcode the

View File

@ -27,7 +27,7 @@
}); });
describe('magic-overrides directive', function () { describe('magic-overrides directive', function () {
var $window, $scope, $magicScope, $element, $timeout; var $window, $scope, $magicScope, $timeout;
beforeEach(module('templates')); beforeEach(module('templates'));
beforeEach(module('MagicSearch')); beforeEach(module('MagicSearch'));
@ -88,7 +88,7 @@
'</magic-search>'; '</magic-search>';
/* eslint-enable angular/ng_window_service */ /* eslint-enable angular/ng_window_service */
$element = $compile(angular.element(markup))($scope); $compile(angular.element(markup))($scope);
$scope.$apply(); $scope.$apply();

View File

@ -21,7 +21,7 @@
var ctrl; var ctrl;
beforeEach(module('horizon.framework.widgets.metadata.tree')); beforeEach(module('horizon.framework.widgets.metadata.tree'));
beforeEach(inject(function ($controller, $injector) { beforeEach(inject(function ($controller) {
ctrl = $controller('MetadataTreeItemController'); ctrl = $controller('MetadataTreeItemController');
})); }));

View File

@ -18,13 +18,12 @@
describe('Wait Spinner Tests', function() { describe('Wait Spinner Tests', function() {
var service, modal; var service;
beforeEach(module('ui.bootstrap')); beforeEach(module('ui.bootstrap'));
beforeEach(module('horizon.framework')); beforeEach(module('horizon.framework'));
beforeEach(inject(function($injector, $modal) { beforeEach(inject(function($injector) {
service = $injector.get('horizon.framework.widgets.modal-wait-spinner.service'); service = $injector.get('horizon.framework.widgets.modal-wait-spinner.service');
modal = $modal;
})); }));
it('returns the service', function() { it('returns the service', function() {
@ -71,7 +70,7 @@
}); });
describe('Wait Spinner Directive', function() { describe('Wait Spinner Directive', function() {
var $scope, $element, $timeout; var $scope, $element;
beforeEach(module('ui.bootstrap')); beforeEach(module('ui.bootstrap'));
beforeEach(module('horizon.framework')); beforeEach(module('horizon.framework'));
@ -79,7 +78,6 @@
beforeEach(inject(function($injector) { beforeEach(inject(function($injector) {
var $compile = $injector.get('$compile'); var $compile = $injector.get('$compile');
$scope = $injector.get('$rootScope').$new(); $scope = $injector.get('$rootScope').$new();
$timeout = $injector.get('$timeout');
var markup = '<div wait-spinner text="hello!"></div>'; var markup = '<div wait-spinner text="hello!"></div>';
$element = angular.element(markup); $element = angular.element(markup);

View File

@ -54,7 +54,7 @@
add: function() {} add: function() {}
}; };
var $scope, $q, service, events; var $scope, $q, service;
function getContext() { function getContext() {
return { return {
@ -84,7 +84,7 @@
it('should open the modal with correct message', function() { it('should open the modal with correct message', function() {
var fakeModalService = { var fakeModalService = {
result: { result: {
then: function (callback) {} then: function () {}
} }
}; };

View File

@ -93,13 +93,13 @@
describe('Maximal Values Passed to the Modal', function() { describe('Maximal Values Passed to the Modal', function() {
var returned, passed, passedContext; var passed, passedContext;
beforeEach(function() { beforeEach(function() {
var opts = { title: 'my title', body: 'my body', submit: 'Yes', var opts = { title: 'my title', body: 'my body', submit: 'Yes',
cancel: 'No' }; cancel: 'No' };
spyOn(modal, 'open'); spyOn(modal, 'open');
returned = service.modal(opts); service.modal(opts);
passed = modal.open.calls.argsFor(0)[0]; passed = modal.open.calls.argsFor(0)[0];
passedContext = passed.resolve.context(); passedContext = passed.resolve.context();
}); });
@ -132,12 +132,12 @@
describe('Minimal Values Passed to the Modal', function() { describe('Minimal Values Passed to the Modal', function() {
var returned, passed, passedContext; var passed, passedContext;
beforeEach(function() { beforeEach(function() {
var opts = { title: 'my title', body: 'my body' }; var opts = { title: 'my title', body: 'my body' };
spyOn(modal, 'open'); spyOn(modal, 'open');
returned = service.modal(opts); service.modal(opts);
passed = modal.open.calls.argsFor(0)[0]; passed = modal.open.calls.argsFor(0)[0];
passedContext = passed.resolve.context(); passedContext = passed.resolve.context();
}); });

View File

@ -24,7 +24,7 @@
describe('toast factory', function() { describe('toast factory', function() {
var $compile, $scope, $timeout, service; var $timeout, service;
var successMsg = "I am success."; var successMsg = "I am success.";
var dangerMsg = "I am danger."; var dangerMsg = "I am danger.";
@ -34,8 +34,6 @@
beforeEach(module('horizon.framework')); beforeEach(module('horizon.framework'));
beforeEach(inject(function ($injector) { beforeEach(inject(function ($injector) {
service = $injector.get('horizon.framework.widgets.toast.service'); service = $injector.get('horizon.framework.widgets.toast.service');
$scope = $injector.get('$rootScope').$new();
$compile = $injector.get('$compile');
$timeout = $injector.get('$timeout'); $timeout = $injector.get('$timeout');
})); }));

View File

@ -36,7 +36,7 @@
log = { error: function() {} }; log = { error: function() {} };
var attrs = angular.noop; var attrs = angular.noop;
var parse = function(attr) { var parse = function(attr) {
return function(scope) { return function() {
return attr ? attr : {}; return attr ? attr : {};
}; };
}; };

View File

@ -47,7 +47,7 @@
describe('render with allocated and available tags', function() { describe('render with allocated and available tags', function() {
var $element; var $element;
beforeEach(inject(function($injector) { beforeEach(inject(function() {
var path = 'transfer-table/transfer-table.basic.mock.html'; var path = 'transfer-table/transfer-table.basic.mock.html';
var markup = $templateCache.get(basePath + path); var markup = $templateCache.get(basePath + path);
$element = angular.element(markup); $element = angular.element(markup);
@ -80,7 +80,7 @@
describe('clone content', function() { describe('clone content', function() {
var $element; var $element;
beforeEach(inject(function($injector) { beforeEach(inject(function() {
var path = 'transfer-table/transfer-table.clone.mock.html'; var path = 'transfer-table/transfer-table.clone.mock.html';
var markup = $templateCache.get(basePath + path); var markup = $templateCache.get(basePath + path);
$element = angular.element(markup); $element = angular.element(markup);

View File

@ -57,7 +57,7 @@ horizon.forms = {
}, },
handle_subnet_address_source: function() { handle_subnet_address_source: function() {
$("div.table_wrapper, #modal_wrapper").on("change", "select#id_address_source", function(evt) { $("div.table_wrapper, #modal_wrapper").on("change", "select#id_address_source", function() {
var $option = $(this).find("option:selected"); var $option = $(this).find("option:selected");
var $form = $(this).closest("form"); var $form = $(this).closest("form");
var $ipVersion = $form.find("select#id_ip_version"); var $ipVersion = $form.find("select#id_ip_version");
@ -79,12 +79,11 @@ horizon.forms = {
}, },
handle_subnet_subnetpool: function() { handle_subnet_subnetpool: function() {
$("div.table_wrapper, #modal_wrapper").on("change", "select#id_subnetpool", function(evt) { $("div.table_wrapper, #modal_wrapper").on("change", "select#id_subnetpool", function() {
var $option = $(this).find("option:selected"); var $option = $(this).find("option:selected");
var $form = $(this).closest("form"); var $form = $(this).closest("form");
var $ipVersion = $form.find("select#id_ip_version"); var $ipVersion = $form.find("select#id_ip_version");
var $prefixLength = $form.find("select#id_prefixlen"); var $prefixLength = $form.find("select#id_prefixlen");
var $ipv6Modes = $form.find("select#id_ipv6_modes");
var subnetpoolIpVersion = parseInt($option.data("ip_version"), 10) || 4; var subnetpoolIpVersion = parseInt($option.data("ip_version"), 10) || 4;
var minPrefixLen = parseInt($option.data("min_prefixlen"), 10) || 1; var minPrefixLen = parseInt($option.data("min_prefixlen"), 10) || 1;
var maxPrefixLen = parseInt($option.data("max_prefixlen"), 10); var maxPrefixLen = parseInt($option.data("max_prefixlen"), 10);

View File

@ -47,4 +47,6 @@ var Horizon = function () {
}; };
// Create the one and only horizon object. // Create the one and only horizon object.
/*eslint-disable no-unused-vars */
var horizon = new Horizon(); var horizon = new Horizon();
/*eslint-enable no-unused-vars */

View File

@ -72,10 +72,9 @@ horizon.membership = {
init_current_membership: function(step_slug) { init_current_membership: function(step_slug) {
horizon.membership.current_membership[step_slug] = []; horizon.membership.current_membership[step_slug] = [];
var members_list = []; var members_list = [];
var role_name, role_id, selected_members; var role_id, selected_members;
angular.forEach(this.get_role_element(step_slug, ''), function(value) { angular.forEach(this.get_role_element(step_slug, ''), function(value) {
role_id = horizon.membership.get_field_id($(value).attr('id')); role_id = horizon.membership.get_field_id($(value).attr('id'));
role_name = $('label[for="id_' + step_slug + '_role_' + role_id + '"]').text();
// get the array of members who are selected in this list // get the array of members who are selected in this list
selected_members = $(value).find("option:selected"); selected_members = $(value).find("option:selected");

View File

@ -242,7 +242,7 @@ horizon.network_topology = {
.attr('width', '100%') .attr('width', '100%')
.attr('height', '100%') .attr('height', '100%')
.attr('fill', 'white') .attr('fill', 'white')
.on('click', function(d) { .on('click', function() {
self.delete_balloon(); self.delete_balloon();
}); });

View File

@ -1,5 +1,5 @@
describe("Messages (horizon.messages.js)", function () { describe("Messages (horizon.messages.js)", function () {
var message, message2; var message;
it("Basic Alert", function () { it("Basic Alert", function () {
message = horizon.alert("success", "A message!"); message = horizon.alert("success", "A message!");
@ -14,7 +14,7 @@ describe("Messages (horizon.messages.js)", function () {
message = horizon.alert("error", "An error!"); message = horizon.alert("error", "An error!");
expect(message.hasClass("alert-danger")).toBe(true); expect(message.hasClass("alert-danger")).toBe(true);
message2 = horizon.alert("success", "Another message"); horizon.alert("success", "Another message");
expect($('#main_content .messages .alert').length).toEqual(2); expect($('#main_content .messages .alert').length).toEqual(2);
horizon.clearErrorMessages(); horizon.clearErrorMessages();

View File

@ -28,7 +28,7 @@
* If input is defined and has more than one property return 'Yes' else return 'No' * If input is defined and has more than one property return 'Yes' else return 'No'
* *
*/ */
function hasExtrasFilter(gettext) { function hasExtrasFilter() {
return function check(input) { return function check(input) {
if (input && if (input &&
angular.isObject(input) && angular.isObject(input) &&

View File

@ -20,7 +20,7 @@
var flavors = [{id: '1'}, {id: '2'}]; var flavors = [{id: '1'}, {id: '2'}];
var novaAPI = { var novaAPI = {
getFlavors: function(params) { getFlavors: function() {
var deferred = $q.defer(); var deferred = $q.defer();
deferred.resolve({data: {items: flavors}}); deferred.resolve({data: {items: flavors}});
return deferred.promise; return deferred.promise;

View File

@ -21,7 +21,7 @@
var $scope, deferred, element; var $scope, deferred, element;
var policyService = { var policyService = {
ifAllowed: function(policyRules) { ifAllowed: function() {
return deferred.promise; return deferred.promise;
} }
}; };

View File

@ -57,7 +57,7 @@
it('should get aggregate namespace', function() { it('should get aggregate namespace', function() {
spyOn(glance, 'getNamespaces'); spyOn(glance, 'getNamespaces');
var actual = metadataService.getNamespaces('aggregate'); metadataService.getNamespaces('aggregate');
expect(glance.getNamespaces) expect(glance.getNamespaces)
.toHaveBeenCalledWith({ resource_type: 'OS::Nova::Aggregate' }, false); .toHaveBeenCalledWith({ resource_type: 'OS::Nova::Aggregate' }, false);
}); });
@ -77,7 +77,7 @@
it('should get flavor namespace', function() { it('should get flavor namespace', function() {
spyOn(glance, 'getNamespaces'); spyOn(glance, 'getNamespaces');
var actual = metadataService.getNamespaces('flavor'); metadataService.getNamespaces('flavor');
expect(glance.getNamespaces) expect(glance.getNamespaces)
.toHaveBeenCalledWith({ resource_type: 'OS::Nova::Flavor' }, false); .toHaveBeenCalledWith({ resource_type: 'OS::Nova::Flavor' }, false);
}); });
@ -97,7 +97,7 @@
it('should get image namespace', function() { it('should get image namespace', function() {
spyOn(glance, 'getNamespaces'); spyOn(glance, 'getNamespaces');
var actual = metadataService.getNamespaces('image'); metadataService.getNamespaces('image');
expect(glance.getNamespaces) expect(glance.getNamespaces)
.toHaveBeenCalledWith({ resource_type: 'OS::Glance::Image' }, false); .toHaveBeenCalledWith({ resource_type: 'OS::Glance::Image' }, false);
}); });

View File

@ -50,7 +50,7 @@
var controller = createController(modalInstance); var controller = createController(modalInstance);
metadataService.editMetadata = function() { metadataService.editMetadata = function() {
return { return {
then: function(success, fail) { then: function(success) {
success(); success();
} }
}; };