Skip to content

Commit

Permalink
Lint undefined variables
Browse files Browse the repository at this point in the history
This will help us catch cases where a dependency from
the tests masks the fact that it's not required correctly
in the application code.
  • Loading branch information
alexmuller committed Nov 2, 2017
1 parent 0e8be88 commit dea164b
Show file tree
Hide file tree
Showing 32 changed files with 110 additions and 60 deletions.
8 changes: 8 additions & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
{
"globals": {
"beforeEach": true,
"describe": true,
"go": true,
"it": true
},
"laxbreak": true,
"laxcomma": true,
"expr": true,
"node": true,
"undef": true,
"unused": "vars"
}
6 changes: 5 additions & 1 deletion go-app-sms_inbound.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ go.app = function() {

self.attach_session_length_helper(self.im);

mh = new MetricsHelper(self.im);
var mh = new MetricsHelper(self.im);
mh
// Total unique users for app
// This adds <env>.sms_inbound.sum.unique_users 'last' metric
Expand Down Expand Up @@ -405,6 +405,8 @@ go.app = function() {
});

self.states.add("state_default", function(name) {
var text;

var out_of_hours_text =
$("The helpdesk operates from 8am to 6pm Mon to Fri. " +
"Responses will be delayed outside of these hrs. In an " +
Expand Down Expand Up @@ -441,6 +443,8 @@ go.app = function() {
};
}();

/* globals api */

go.init = function() {
var vumigo = require('vumigo_v02');
var InteractionMachine = vumigo.InteractionMachine;
Expand Down
6 changes: 5 additions & 1 deletion go-app-sms_nurse.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ go.app = function() {
self.metric_prefix = [self.env, self.im.config.name].join('.');
self.store_name = [self.env, self.im.config.name].join('.');

mh = new MetricsHelper(self.im);
var mh = new MetricsHelper(self.im);
mh
// Total unique users for app
// This adds <env>.sms_nurse.sum.unique_users 'last' metric
Expand Down Expand Up @@ -386,6 +386,8 @@ go.app = function() {
});

self.states.add("states_default", function(name) {
var text;

var out_of_hours_text =
$("The helpdesk operates from 8am to 4pm Mon to Fri. " +
"Responses will be delayed outside of these hrs.");
Expand Down Expand Up @@ -420,6 +422,8 @@ go.app = function() {
};
}();

/* globals api */

go.init = function() {
var vumigo = require('vumigo_v02');
var InteractionMachine = vumigo.InteractionMachine;
Expand Down
2 changes: 2 additions & 0 deletions go-app-sms_pmtct.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,8 @@ go.app = function() {
};
}();

/* globals api */

go.init = function() {
var vumigo = require('vumigo_v02');
var InteractionMachine = vumigo.InteractionMachine;
Expand Down
2 changes: 2 additions & 0 deletions go-app-sms_pmtct_seed.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ go.app = function() {
};
}();

/* globals api */

go.init = function() {
var vumigo = require('vumigo_v02');
var InteractionMachine = vumigo.InteractionMachine;
Expand Down
4 changes: 3 additions & 1 deletion go-app-ussd_chw.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ go.app = function() {

self.attach_session_length_helper(self.im);

mh = new MetricsHelper(self.im);
var mh = new MetricsHelper(self.im);
mh
// Total unique users
// This adds <env>.ussd_chw.sum.unique_users 'last' metric
Expand Down Expand Up @@ -810,6 +810,8 @@ go.app = function() {
};
}();

/* globals api */

go.init = function() {
var vumigo = require('vumigo_v02');
var InteractionMachine = vumigo.InteractionMachine;
Expand Down
6 changes: 4 additions & 2 deletions go-app-ussd_clinic.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ go.app = function() {

self.attach_session_length_helper(self.im);

mh = new MetricsHelper(self.im);
var mh = new MetricsHelper(self.im);
mh
// Total unique users for app
// This adds <env>.ussd_clinic.sum.unique_users 'last' metric
Expand Down Expand Up @@ -728,7 +728,7 @@ go.app = function() {
params: params,
})
.then(function(response) {
existing = _.filter(response.data, function(obj) { return obj.exists === true; });
var existing = _.filter(response.data, function(obj) { return obj.exists === true; });
var allowed = !_.isEmpty(existing);
return self.im
.log('valid pilot recipient returning ' + allowed + ' for ' + JSON.stringify(params))
Expand Down Expand Up @@ -1138,6 +1138,8 @@ go.app = function() {
};
}();

/* globals api */

go.init = function() {
var vumigo = require('vumigo_v02');
var InteractionMachine = vumigo.InteractionMachine;
Expand Down
7 changes: 5 additions & 2 deletions go-app-ussd_nurse.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ var go = {};
go;

go.app = function() {
var _ = require('lodash');
var vumigo = require("vumigo_v02");
var moment = require('moment');
var SeedJsboxUtils = require('seed-jsbox-utils');
Expand Down Expand Up @@ -54,7 +55,7 @@ go.app = function() {
self.env = self.im.config.env;
self.metric_prefix = [self.env, self.im.config.name].join('.');

mh = new MetricsHelper(self.im);
var mh = new MetricsHelper(self.im);
mh
// Total unique users for app
// This adds <env>.ussd_nurse.sum.unique_users 'last' metric
Expand Down Expand Up @@ -188,7 +189,7 @@ go.app = function() {
params: params,
})
.then(function(response) {
existing_users = _.filter(response.data, function(obj) { return obj.exists === true; });
var existing_users = _.filter(response.data, function(obj) { return obj.exists === true; });
var is_user = !_.isEmpty(existing_users);
return self.im
.log('WhatsApp recipient ' + is_user + ' for ' + JSON.stringify(params))
Expand Down Expand Up @@ -1087,6 +1088,8 @@ go.app = function() {
};
}();

/* globals api */

go.init = function() {
var vumigo = require('vumigo_v02');
var InteractionMachine = vumigo.InteractionMachine;
Expand Down
4 changes: 3 additions & 1 deletion go-app-ussd_optout.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ go.app = function() {
self.env = self.im.config.env;
self.metric_prefix = [self.env, self.im.config.name].join('.');

mh = new MetricsHelper(self.im);
var mh = new MetricsHelper(self.im);
mh
// Total unique users for app
// This adds <env>.ussd_optout.sum.unique_users 'last' metric
Expand Down Expand Up @@ -212,6 +212,8 @@ go.app = function() {
};
}();

/* globals api */

go.init = function() {
var vumigo = require('vumigo_v02');
var InteractionMachine = vumigo.InteractionMachine;
Expand Down
6 changes: 4 additions & 2 deletions go-app-ussd_pmtct.js
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ go.app = function() {
self.add = function(name, creator) {
self.states.add(name, function(name, opts) {
/*if (!interrupt || !go.utils.timed_out(self.im))*/
log_mode = self.im.config.logging;
var log_mode = self.im.config.logging;
if (log_mode === 'prod') {
return self.im
.log("Running: " + name)
Expand Down Expand Up @@ -438,7 +438,7 @@ go.app = function() {
.then(function(active_subscriptions) {
if (active_subscriptions.length > 0) {
// check that current active subscription is to momconnect
subscription_type = self.get_valid_active_subscription(active_subscriptions);
var subscription_type = self.get_valid_active_subscription(active_subscriptions);
if (subscription_type !== false) {
// save contact data (set_answer's) - lang, consent, dob, edd
self.im.user.set_answer("lang_code",
Expand Down Expand Up @@ -794,6 +794,8 @@ go.app = function() {
};
}();

/* globals api */

go.init = function() {
var vumigo = require('vumigo_v02');
var InteractionMachine = vumigo.InteractionMachine;
Expand Down
6 changes: 4 additions & 2 deletions go-app-ussd_pmtct_seed.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ go.app = function() {
params: params,
})
.then(function(response) {
existing = _.filter(response.data, function(obj) { return obj.exists === true; });
var existing = _.filter(response.data, function(obj) { return obj.exists === true; });
var allowed = !_.isEmpty(existing);
return self.im
.log('valid pilot recipient returning ' + allowed + ' for ' + JSON.stringify(params))
Expand All @@ -165,7 +165,7 @@ go.app = function() {
// override normal state adding
self.add = function(name, creator) {
self.states.add(name, function(name, opts) {
log_mode = self.im.config.logging;
var log_mode = self.im.config.logging;
if (log_mode === 'prod') {
return self.im
.log("Running: " + name)
Expand Down Expand Up @@ -638,6 +638,8 @@ go.app = function() {
};
}();

/* globals api */

go.init = function() {
var vumigo = require('vumigo_v02');
var InteractionMachine = vumigo.InteractionMachine;
Expand Down
4 changes: 3 additions & 1 deletion go-app-ussd_popi_faq.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ go.app = function() {
self.metric_prefix = [self.env, self.im.config.name].join('.');
self.store_name = [self.env, self.im.config.name].join('.');

mh = new MetricsHelper(self.im);
var mh = new MetricsHelper(self.im);
mh
// Total unique users
// This adds <env>.ussd_public.sum.unique_users 'last' metric
Expand Down Expand Up @@ -236,6 +236,8 @@ go.app = function() {
};
}();

/* globals api */

go.init = function() {
var vumigo = require('vumigo_v02');
var InteractionMachine = vumigo.InteractionMachine;
Expand Down
8 changes: 5 additions & 3 deletions go-app-ussd_popi_user_data.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ go.app = function() {
self.metric_prefix = [self.env, self.im.config.name].join('.');
self.store_name = [self.env, self.im.config.name].join('.');

mh = new MetricsHelper(self.im);
var mh = new MetricsHelper(self.im);
mh
// Total unique users
// This adds <env>.ussd_public.sum.unique_users 'last' metric
Expand Down Expand Up @@ -189,8 +189,8 @@ go.app = function() {
var sets = '';
return Q.all(promises)
.then(function(allmset){
for(j = 0; j < allmset.length; j++){
message_set = allmset[j].short_name;
for(var j = 0; j < allmset.length; j++){
var message_set = allmset[j].short_name;
sets += " " + message_set;
}
self.im.user.set_answer("message_sets", sets.substring(1,sets.length));
Expand Down Expand Up @@ -557,6 +557,8 @@ go.app = function() {
};
}();

/* globals api */

go.init = function() {
var vumigo = require('vumigo_v02');
var InteractionMachine = vumigo.InteractionMachine;
Expand Down
6 changes: 4 additions & 2 deletions go-app-ussd_public.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ go.app = function() {

self.attach_session_length_helper(self.im);

mh = new MetricsHelper(self.im);
var mh = new MetricsHelper(self.im);
mh
// Total unique users
// This adds <env>.ussd_public.sum.unique_users 'last' metric
Expand Down Expand Up @@ -778,7 +778,7 @@ go.app = function() {
params: default_params,
})
.then(function(response) {
existing = _.filter(response.data, function(obj) { return obj.exists === true; });
var existing = _.filter(response.data, function(obj) { return obj.exists === true; });
if(_.isEmpty(existing)) {
// If they're not eligible then return false
return self.im
Expand Down Expand Up @@ -926,6 +926,8 @@ go.app = function() {
};
}();

/* globals api */

go.init = function() {
var vumigo = require('vumigo_v02');
var InteractionMachine = vumigo.InteractionMachine;
Expand Down
4 changes: 3 additions & 1 deletion go-app-ussd_servicerating.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ go.app = function() {

self.attach_session_length_helper(self.im);

mh = new MetricsHelper(self.im);
var mh = new MetricsHelper(self.im);
mh
// Total unique users
// This adds <env>.servicerating.sum.unique_users 'last' metric
Expand Down Expand Up @@ -482,6 +482,8 @@ go.app = function() {
};
}();

/* globals api */

go.init = function() {
var vumigo = require('vumigo_v02');
var InteractionMachine = vumigo.InteractionMachine;
Expand Down
2 changes: 2 additions & 0 deletions src/init.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* globals api */

go.init = function() {
var vumigo = require('vumigo_v02');
var InteractionMachine = vumigo.InteractionMachine;
Expand Down
4 changes: 3 additions & 1 deletion src/sms_inbound.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ go.app = function() {

self.attach_session_length_helper(self.im);

mh = new MetricsHelper(self.im);
var mh = new MetricsHelper(self.im);
mh
// Total unique users for app
// This adds <env>.sms_inbound.sum.unique_users 'last' metric
Expand Down Expand Up @@ -255,6 +255,8 @@ go.app = function() {
});

self.states.add("state_default", function(name) {
var text;

var out_of_hours_text =
$("The helpdesk operates from 8am to 6pm Mon to Fri. " +
"Responses will be delayed outside of these hrs. In an " +
Expand Down
4 changes: 3 additions & 1 deletion src/sms_nurse.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ go.app = function() {
self.metric_prefix = [self.env, self.im.config.name].join('.');
self.store_name = [self.env, self.im.config.name].join('.');

mh = new MetricsHelper(self.im);
var mh = new MetricsHelper(self.im);
mh
// Total unique users for app
// This adds <env>.sms_nurse.sum.unique_users 'last' metric
Expand Down Expand Up @@ -236,6 +236,8 @@ go.app = function() {
});

self.states.add("states_default", function(name) {
var text;

var out_of_hours_text =
$("The helpdesk operates from 8am to 4pm Mon to Fri. " +
"Responses will be delayed outside of these hrs.");
Expand Down
2 changes: 1 addition & 1 deletion src/ussd_chw.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ go.app = function() {

self.attach_session_length_helper(self.im);

mh = new MetricsHelper(self.im);
var mh = new MetricsHelper(self.im);
mh
// Total unique users
// This adds <env>.ussd_chw.sum.unique_users 'last' metric
Expand Down
4 changes: 2 additions & 2 deletions src/ussd_clinic.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ go.app = function() {

self.attach_session_length_helper(self.im);

mh = new MetricsHelper(self.im);
var mh = new MetricsHelper(self.im);
mh
// Total unique users for app
// This adds <env>.ussd_clinic.sum.unique_users 'last' metric
Expand Down Expand Up @@ -578,7 +578,7 @@ go.app = function() {
params: params,
})
.then(function(response) {
existing = _.filter(response.data, function(obj) { return obj.exists === true; });
var existing = _.filter(response.data, function(obj) { return obj.exists === true; });
var allowed = !_.isEmpty(existing);
return self.im
.log('valid pilot recipient returning ' + allowed + ' for ' + JSON.stringify(params))
Expand Down
Loading

0 comments on commit dea164b

Please sign in to comment.