Skip to content

Commit

Permalink
Cleaning minor errors ( semicolons, ... )
Browse files Browse the repository at this point in the history
  • Loading branch information
Pierre-Gilles committed Jul 14, 2015
1 parent 9ca282e commit a347c78
Show file tree
Hide file tree
Showing 43 changed files with 110 additions and 105 deletions.
2 changes: 1 addition & 1 deletion api/controllers/ActionController.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* @param {} callback
* @return
*/
var haveRights = function(action, user,callback){
function haveRights(action, user,callback){
Action.findOne({id : action, user: user}, function(err, action){
if(err) return callback(err);

Expand Down
2 changes: 1 addition & 1 deletion api/controllers/AlarmController.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ module.exports = {
AlarmService.destroyAlarm(req.param('id'), function(err,alarm){
if(err) return res.json(err);

res.json(alarm)
res.json(alarm);
});
}
};
6 changes: 3 additions & 3 deletions api/controllers/HouseController.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,17 +155,17 @@ module.exports = {
* @return
*/
getrelationhouse: function(req,res,next){
var request = "SELECT userhouserelation.id AS id, user.id AS userId, CONCAT(user.firstname, ' ', user.lastname) as userName, house.id as houseId, house.name as houseName, userhouserelationtype "
var request = "SELECT userhouserelation.id AS id, user.id AS userId, CONCAT(user.firstname, ' ', user.lastname) as userName, house.id as houseId, house.name as houseName, userhouserelationtype ";
request+= "FROM userhouserelation ";
request+= "JOIN user ON (userhouserelation.user = user.id) ";
request+= "JOIN house ON (userhouserelation.house = house.id) ";
request+= "WHERE house IN ( SELECT house FROM userhouserelation WHERE userhouserelationtype = 1 ";
request+= "AND user = ?) ";

UserHouseRelation.query(request,[req.session.User.id], function UserHouseRelation(err,UserHouseRelation){
UserHouseRelation.query(request,[req.session.User.id], function UserHouseRelation(err,userHouseRelation){
if(err) res.json(err);

res.json(UserHouseRelation);
res.json(userHouseRelation);
});
},

Expand Down
4 changes: 2 additions & 2 deletions api/controllers/LauncherController.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function haveRights(launcher, user,callback){
* @param {} callback
* @return
*/
var haveRightsAction = function(action, user,callback){
function haveRightsAction (action, user,callback){
Action.findOne({id : action, user: user}, function(err, action){
if(err) return callback(err);

Expand All @@ -53,7 +53,7 @@ var haveRightsAction = function(action, user,callback){
* @param {} callback
* @return
*/
var haveRightsState = function(state, user,callback){
function haveRightsState(state, user,callback){
State.findOne({id : state, user: user}, function(err, state){
if(err) return callback(err);

Expand Down
4 changes: 2 additions & 2 deletions api/controllers/RoomController.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@
* @param {} callback
* @return
*/
var haveRights = function (user,room,callback){
function haveRights (user,room,callback){
Room.findOne({id:room}, function(err, room){
if(err) callback(err);

if(!room){
callback(false,false)
callback(false,false);
}else{
UserHouseRelation.findOne({house: room.house, user: user, userhouserelationtype: sails.config.userhouserelationtype.Admin }, function(err, userHouseRelation){
if(err) callback(err);
Expand Down
2 changes: 1 addition & 1 deletion api/controllers/ScriptController.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/
function validFileName(name){
var reg = /[a-zA-Z0-9]+\.js$/;
return reg.test(name)
return reg.test(name);
}

function stringifyError (err, filter, space) {
Expand Down
6 changes: 3 additions & 3 deletions api/controllers/SessionController.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ module.exports = {
var usernamePasswordRequiredError = [{
name: 'usernamePasswordRequired',
message: 'You must enter both a username and password.'
}]
}];

req.flash('error', usernamePasswordRequiredError);
return res.redirect('/login');
Expand All @@ -97,7 +97,7 @@ module.exports = {
var noAccountError = [{
name: 'noAccount',
message: 'The email address ' + req.param('email') + ' not found.'
}]
}];

req.flash('error', noAccountError);

Expand All @@ -114,7 +114,7 @@ module.exports = {
var usernamePasswordMismatchError = [{
name: 'usernamePasswordMismatch',
message: 'Invalid username and password combination.'
}]
}];
req.flash('error', usernamePasswordMismatchError);
res.redirect('/login');
return;
Expand Down
2 changes: 1 addition & 1 deletion api/controllers/StateController.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* @param {} callback
* @return
*/
var haveRights = function(state, user,callback){
function haveRights(state, user,callback){
State.findOne({id : state, user: user}, function(err, state){
if(err) return callback(err);

Expand Down
2 changes: 1 addition & 1 deletion api/controllers/TimerController.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ module.exports = {
*/
create:function(req,res,next){
if(!req.param('duration'))
return res.json('Missing parametres')
return res.json('Missing parametres');

// defaults name
var name = 'Timer';
Expand Down
2 changes: 1 addition & 1 deletion api/models/Alarm.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module.exports = {
// new time type because time does not exist in sails
time: function(time){
var re = /^[0-2]\d:[0-5]\d$/ ;
return (time != '' && time.match(re));
return (time !== '' && time.match(re));
},
},

Expand Down
2 changes: 1 addition & 1 deletion api/models/Contact.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ module.exports = {
},

fullname: function() {
return this.firstname + ' ' + this.lastname
return this.firstname + ' ' + this.lastname;
},

email:{
Expand Down
4 changes: 2 additions & 2 deletions api/models/House.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ module.exports = {
var checkifAllDestroyed = function(){
if(nbOk == values.length*nbThingsToDestroy)
next();
}
};

if(values.length == 0)
if(values.length === 0)
return next();

for(i = 0; i<values.length;i++){
Expand Down
4 changes: 2 additions & 2 deletions api/models/Room.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ module.exports = {

if(nbOk == values.length*nbThingsToDestroy)
next();
}
};

if(values.length == 0)
if(values.length === 0)
return next();

for(i = 0; i<values.length;i++){
Expand Down
2 changes: 1 addition & 1 deletion api/models/Timer.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ module.exports = {
time: function(time){
re = /^[0-2]\d:[0-5]\d$/ ;

return (time != '' && time.match(re));
return (time !== '' && time.match(re));
},
},

Expand Down
2 changes: 1 addition & 1 deletion api/models/User.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ module.exports = {
},

fullname: function() {
return this.firstname + ' ' + this.lastname
return this.firstname + ' ' + this.lastname;
},

email:{
Expand Down
2 changes: 1 addition & 1 deletion api/policies/checkForeignActionToken.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ module.exports = function(req, res, next) {
return next();
else
res.forbidden('Foreign Action Token is not valid');
}
};
2 changes: 1 addition & 1 deletion api/policies/isMachineMaster.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ module.exports = function(req, res, next) {
return next();
else
res.forbidden('This is not a master, just a slave executing orders.');
}
};
2 changes: 1 addition & 1 deletion api/policies/sameNetwork.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ module.exports = function(req, res, next) {
callback(err, true);
});
}else
callback(null, false)
callback(null, false);
}
], function (err, result) {
if(err) sails.log.warn('sameNetworkPolicies : ' + err);
Expand Down
2 changes: 1 addition & 1 deletion api/services/AlarmService.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function getActualDate (){
month = twoDigit(month);
day = twoDigit(day);
return year + '-' + month + '-' + day;
};
}


/**
Expand Down
2 changes: 1 addition & 1 deletion api/services/CalendarService.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ module.exports = {
request += "JOIN calendarlist ON(calendarevent.calendar = calendarlist.id) ";
request += "WHERE user = ? ";
request += "AND start > SYSDATE() ";
request += "AND calendarlist.active = 1 "
request += "AND calendarlist.active = 1 ";
request += "ORDER BY start ";
request += "LIMIT 0,1 ";

Expand Down
2 changes: 1 addition & 1 deletion api/services/DistanceService.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* @return BinaryExpression
*/
function deg2rad (deg) {
return deg * (Math.PI/180)
return deg * (Math.PI/180);
}

module.exports = {
Expand Down
5 changes: 3 additions & 2 deletions api/services/GoogleMapsService.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@ module.exports = {
gm.directions(start, end ,
function(err, data){
if(err) return callback(err);

// calculate the duration in seconds
var duration = data['routes'][0]['legs'][0]['duration']['value'];
var duration = data.routes[0].legs[0].duration.value;
callback(null, duration);
});

}
}
};
8 changes: 4 additions & 4 deletions api/services/HouseService.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module.exports = {
*/
getHouseWhereUserAdmin: function(userId, callback){
var request = 'SELECT house FROM userhouserelation ';
request += 'WHERE user = ? '
request += 'WHERE user = ? ';
request += 'AND userhouserelationtype = ?';

UserHouseRelation.query(request, [userId, sails.config.userhouserelationtype.Admin], function(err, houses){
Expand Down Expand Up @@ -47,7 +47,7 @@ module.exports = {
Motion.query(request,[houseId], function(err, motions){
if(err) return callback(err);

callback(null, (motions.length == 0))
callback(null, (motions.length === 0));
});
},

Expand Down Expand Up @@ -203,7 +203,7 @@ module.exports = {
if(err) return callback(err);

// if the user has no houses.. he is not a home because he has no one, so callback false
if(userHouseRelations.length == 0) return callback(null, false);
if(userHouseRelations.length === 0) return callback(null, false);

// houseWhereHeIs will store the result
var houseWhereHeIs = null;
Expand All @@ -212,7 +212,7 @@ module.exports = {
async.each(userHouseRelations, function(userHouseRelation, callback){
HouseService.habitantsWhoCanBeAtHome(userHouseRelation.house.id, function(err, userPossiblyAtHome){
// if no user can possibly be at home, there is nobody there
if(userPossiblyAtHome.length == 0)
if(userPossiblyAtHome.length === 0)
callback();
// else if there is only one user at home
else if(userPossiblyAtHome.length == 1){
Expand Down
6 changes: 3 additions & 3 deletions api/services/InstallationService.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ module.exports = {
.exec(function(err, eventtypes){
if(err) return callback(err);

if(eventtypes.length == 0){
if(eventtypes.length === 0){
importAndInjectEventTypes(callback);
}else{
callback(null);
Expand All @@ -102,7 +102,7 @@ module.exports = {
.exec(function(err, actiontypes){
if(err) return callback(err);

if(actiontypes.length == 0){
if(actiontypes.length === 0){
importAndInjectActionTypes(callback);
}else{
callback(null);
Expand All @@ -121,7 +121,7 @@ module.exports = {
.exec(function(err, launchertypes){
if(err) return callback(err);

if(launchertypes.length == 0){
if(launchertypes.length === 0){
importAndInjectLauncherTypes(callback);
}else{
callback(null);
Expand Down
4 changes: 2 additions & 2 deletions api/services/MachineService.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ module.exports = {

if(machines.length == 1)
return callback(null, machines[0].house);
else if(machines.length == 0)
else if(machines.length === 0)
return callback('MachineService : getMyHouse : I don\'t know in which house I live :( ');
else
return callback('MachineService : getMyHouse : A machine can\'t be at multiple place at once ! :D ')
return callback('MachineService : getMyHouse : A machine can\'t be at multiple place at once ! :D ');
});
}

Expand Down
Loading

0 comments on commit a347c78

Please sign in to comment.