Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

address var usage #534

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .deepsource.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ name = "javascript"
enabled = true

[analyzers.meta]
plugins = ["angular"]
plugins = ["angularjs"]

[[analyzers]]
name = "docker"
Expand Down
2 changes: 2 additions & 0 deletions lib/tasks/assets.rake
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ namespace :assets do
# Does this actually do anything for us?
desc 'Create .gz versions of assets'
task gzip: :environment do
if 1 == 2
zip_types = /\.(?:css|html|js|otf|svg|txt|xml)$/

public_assets = Rails.public_path.join(Rails.application.config.assets.prefix)
Expand All @@ -30,6 +31,7 @@ namespace :assets do

File.utime(mtime, mtime, gz_file)
end
end
end

desc 'Unpack Jupyterlite assets'
Expand Down
44 changes: 22 additions & 22 deletions spec/javascripts/angular/controllers/add_query_controller_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ describe('Controller: AddQueryCtrl', function () {
// load the controller's module
beforeEach(module('QuepidTest'));

var $rootScope;
var $q;
var ctrl;
let $rootScope;
let $q;
let ctrl;

var mockQueriesSvcBase = {
const mockQueriesSvcBase = {
createQuery: function(text) {
var lastCreatedQ = {
const lastCreatedQ = {
search: function() {
return {
then: function(success) {
Expand Down Expand Up @@ -46,15 +46,15 @@ describe('Controller: AddQueryCtrl', function () {
},
/*global Promise*/
persistQuery: function(q) {
var deferred = $q.defer();
const deferred = $q.defer();

this.persistPromises.push(deferred);
this.lastPersistedQs.push(q);
return deferred.promise;
},
persistQueries: function(qs) {
var that = this;
var deferred = $q.defer();
const that = this;
const deferred = $q.defer();

that.persistPromises.push(deferred);
angular.forEach(qs, function(q) {
Expand All @@ -64,7 +64,7 @@ describe('Controller: AddQueryCtrl', function () {
return deferred.promise;
},
searchAll: function() {
var promises = [];
const promises = [];

angular.forEach(this.queries, function(query) {
promises.push(query.search());
Expand All @@ -74,12 +74,12 @@ describe('Controller: AddQueryCtrl', function () {
}
};

var mockUser = {
const mockUser = {
isTrial: false,
completedCaseWizard: true
};

var mockQueriesSvc;
let mockQueriesSvc;

beforeEach(function() {
module(function($provide) {
Expand All @@ -96,7 +96,7 @@ describe('Controller: AddQueryCtrl', function () {
});

it('rejects empty or blank text', function() {
var newText;
let newText;
ctrl.text = newText;

expect(mockQueriesSvc.lastCreatedQ()).toBe(undefined);
Expand All @@ -111,31 +111,31 @@ describe('Controller: AddQueryCtrl', function () {
});

it('adds queries', function() {
var newText = 'foo';
const newText = 'foo';
ctrl.text = newText;

expect(mockQueriesSvc.lastCreatedQ()).toBe(undefined);
ctrl.submit();

var createdQ = mockQueriesSvc.lastCreatedQ();
var promise = mockQueriesSvc.lastPersistPromise();
let createdQ = mockQueriesSvc.lastCreatedQ();
let promise = mockQueriesSvc.lastPersistPromise();

expect(createdQ.queryText).toBe(newText);
promise.resolve();
$rootScope.$apply();

var persistedQ = mockQueriesSvc.lastPersistedQ();
let persistedQ = mockQueriesSvc.lastPersistedQ();

expect(persistedQ).toBe(createdQ);
});

it('adds multiple queries', function() {
var queries = ['gross tacos', 'funny pizzas', 'elmer fudd hats'];
var delim = ';';
let queries = ['gross tacos', 'funny pizzas', 'elmer fudd hats'];
let delim = ';';
ctrl.text = queries.join(delim);
ctrl.submit();

var createdQs = mockQueriesSvc.lastCreatedQs;
let createdQs = mockQueriesSvc.lastCreatedQs;

expect(createdQs.length).toBe(3);
expect(createdQs[0].queryText).toBe(queries[0]);
Expand All @@ -144,13 +144,13 @@ describe('Controller: AddQueryCtrl', function () {
});

it('trims away whitespace on queries', function() {
var queries = ['gross tacos', 'funny pizzas', ' elmer fudd hats ', ' '];
var delim = ';';
let queries = ['gross tacos', 'funny pizzas', ' elmer fudd hats ', ' '];
let delim = ';';

ctrl.text = queries.join(delim);
ctrl.submit();

var createdQs = mockQueriesSvc.lastCreatedQs;
let createdQs = mockQueriesSvc.lastCreatedQs;

expect(createdQs.length).toBe(3);
expect(createdQs[0].queryText).toBe('gross tacos');
Expand Down
10 changes: 5 additions & 5 deletions spec/javascripts/angular/controllers/promptSnapshot_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ describe('Controller: PromptSnapshotCtrl', function () {

beforeEach(module('QuepidTest'));

var Ctrl, scope, modalInstance, $httpBackend;
var querySnapshotSvc, settingsSvc, docResolverSvc;
let Ctrl, scope, modalInstance, $httpBackend;
let querySnapshotSvc, settingsSvc, docResolverSvc;

var basicExplain1 = {
let basicExplain1 = {
match: true,
value: 1.5,
description: 'weight(text:law in 1234)',
details: []
};
var rawExpl = angular.toJson(basicExplain1);
let rawExpl = angular.toJson(basicExplain1);

var addedSnapResp = {
let addedSnapResp = {
'snapshots': {
'5': {
id: '5',
Expand Down
8 changes: 4 additions & 4 deletions spec/javascripts/angular/controllers/queryParams_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ describe('Controller: QueryparamsCtrl', function () {
// load the controller's module
beforeEach(module('QuepidTest'));

var QueryparamsCtrl,
let QueryparamsCtrl,
scope,
testTry;


// Initialize the controller and a mock scope
beforeEach(inject(function ($controller, $rootScope, settingsSvc, TryFactory) {
beforeEach(inject(function ($controller, $rootScope, TryFactory) {
scope = $rootScope.$new();

var queryParams = 'q=#$query##';
var curatorVars = {};
let queryParams = 'q=#$query##';
let curatorVars = {};

testTry = new TryFactory({ try_number: 0, query_params: queryParams, curator_vars: curatorVars });
scope.settings = {selectedTry: testTry};
Expand Down
4 changes: 2 additions & 2 deletions spec/javascripts/angular/controllers/searchResult_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ describe('Controller: SearchResultCtrl', function () {
// load the controller's module
beforeEach(module('QuepidTest'));

var SearchResultCtrl,
let SearchResultCtrl,
scope;

var mockDoc = {
let mockDoc = {
subSnippets: function(hlPre, hlPost) {
return [];
}
Expand Down
43 changes: 22 additions & 21 deletions spec/javascripts/angular/controllers/wizardModal_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,26 @@ describe('Controller: WizardModalCtrl', function () {
// load the controller's module
beforeEach(module('QuepidTest'));

var WizardModalCtrl;
var $rootScope, scope;
var settingsSvc;
var $httpBackend;
let WizardModalCtrl;
let $rootScope, scope;
let settingsSvc;
let $httpBackend;

/*global jasmine*/
var mockModalInstance = {
let mockModalInstance = {
close: jasmine.createSpy(),
dismiss: jasmine.createSpy()
};



var mockWizardHandler = {
let mockWizardHandler = {
wizard: function(){
return {goTo: function(){}}
}
};

var bootstrappedSettingsData = {
let bootstrappedSettingsData = {
tries: [
{
search_url: 'http://quepid-solr.dev.o19s.com:8985/solr/tmdb/select',
Expand All @@ -39,7 +39,7 @@ describe('Controller: WizardModalCtrl', function () {
],
};

var mockTry = {
let mockTry = {
search_url: 'http://quepid-solr.dev.o19s.com:8985/solr/tmdb/select',
field_spec: 'catch_line',
curator_vars: {},
Expand All @@ -50,15 +50,15 @@ describe('Controller: WizardModalCtrl', function () {
try_number: 0
};

var mockUser = {
let mockUser = {
completedCaseWizard: true,
introWizardSeen: false,
shownIntroWizard: function() {
self.introWizardSeen=true;
}
};

var mockUserSvc = {
let mockUserSvc = {
getUser: function() {
return mockUser;
}
Expand Down Expand Up @@ -87,7 +87,7 @@ describe('Controller: WizardModalCtrl', function () {

describe('query adding', function() {
beforeEach(function() {
var settingsBootstrapped = 0;
let settingsBootstrapped = 0;
$httpBackend.expectGET('/api/cases/0/tries').respond(200, bootstrappedSettingsData);
settingsSvc.bootstrap()
.then(function() {
Expand All @@ -98,15 +98,16 @@ describe('Controller: WizardModalCtrl', function () {
$httpBackend.verifyNoOutstandingExpectation();
});

var newQueryResp = {
let newQueryResp = {
display_order: [2,3,1,0],
query: {
'query_text': 'foo',
'queryId': '3',
'deleted': 'false'
}
};
var mockFullQueriesResp = {

let mockFullQueriesResp = {
display_order: [2,1,0],
queries: [
{
Expand Down Expand Up @@ -145,32 +146,32 @@ describe('Controller: WizardModalCtrl', function () {

it ('gets title field for autocomplete', function() {
scope.searchFields = ['title', 'body', 'image'];
var autocompleteList = scope.loadFields('ti');
let autocompleteList = scope.loadFields('ti');
expect(autocompleteList.length).toBe(1);
});

it ('gets all fields for media: autocomplete', function() {
scope.searchFields = ['title', 'body', 'image'];
var autocompleteList = scope.loadFields('media:');
let autocompleteList = scope.loadFields('media:');
expect(autocompleteList.length).toBe(3);
});

it ('gets all fields for thumb: autocomplete', function() {
scope.searchFields = ['title', 'body', 'image'];
var autocompleteList = scope.loadFields('thumb:');
let autocompleteList = scope.loadFields('thumb:');
expect(autocompleteList.length).toBe(3);
});

it ('gets subset without modifier prefix', function() {
scope.searchFields = ['title', 'body', 'image', 'imageAlt'];
var autocompleteList = scope.loadFields('im');
let autocompleteList = scope.loadFields('im');
expect(autocompleteList.length).toBe(2);
expect(autocompleteList).toEqual([{'text': 'image'}, {'text': 'imageAlt'}]);
});

it ('gets subset with modifier prefix', function() {
scope.searchFields = ['title', 'body', 'image', 'imageAlt'];
var autocompleteList = scope.loadFields('thumb:im');
let autocompleteList = scope.loadFields('thumb:im');
expect(autocompleteList.length).toBe(2);
expect(autocompleteList).toEqual([{'text': 'thumb:image'}, {'text': 'thumb:imageAlt'}]);
});
Expand All @@ -180,13 +181,13 @@ describe('Controller: WizardModalCtrl', function () {
$httpBackend.expectGET('/api/cases/0/scorers').respond(200, {});
$httpBackend.expectGET('/api/cases/0/queries?bootstrap=true').respond(200, mockFullQueriesResp);

for (var i = 0; i < 10; i++) {
var testQuery = 'foo ' + i;
for (let i = 0; i < 10; i++) {
let testQuery = 'foo ' + i;
scope.pendingWizardSettings.addQuery(testQuery);

expect(scope.pendingWizardSettings.newQueries).toContain({queryString: testQuery});

var newQueryRespIth = angular.copy(newQueryResp);
let newQueryRespIth = angular.copy(newQueryResp);
newQueryRespIth.query['query_text'] = testQuery;

$httpBackend.whenPOST('/api/cases/0/queries').respond(200, newQueryRespIth);
Expand Down
10 changes: 5 additions & 5 deletions spec/javascripts/angular/filters/scorerType_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ describe('Filter: scorerType', function () {
// load the filter's module
beforeEach(module('QuepidTest'));

var mockScorers = [
let mockScorers = [
{
'scorerId': 1,
'name': 'Scorer 1 Communal Scorer',
Expand All @@ -28,25 +28,25 @@ describe('Filter: scorerType', function () {
];

// initialize a new instance of the filter before each test
var scorerType;
let scorerType;
beforeEach(inject(function ($filter) {
scorerType = $filter('scorerType');
}));

it('filters to just the communal scorers"', function () {
var results = scorerType(mockScorers, "communal");
let results = scorerType(mockScorers, "communal");
expect(results.length).toBe(1);
expect(results[0].name).toBe('Scorer 1 Communal Scorer');
});

it('filters to just the custom scorers"', function () {
var results = scorerType(mockScorers, "custom");
let results = scorerType(mockScorers, "custom");
expect(results.length).toBe(1);
expect(results[0].name).toBe('Scorer 2 Custom Scorer');
});

it('returns everything if you have a bogus filter"', function () {
var results = scorerType(mockScorers, "fake-filter");
let results = scorerType(mockScorers, "fake-filter");
expect(results.length).toBe(2);
});

Expand Down