Skip to content
This repository has been archived by the owner on Feb 1, 2019. It is now read-only.

Integrate jscs style checking #81

Merged
merged 4 commits into from
Apr 27, 2015
Merged
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
66 changes: 66 additions & 0 deletions .jscsrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
{
"disallowSpacesInNamedFunctionExpression": {
"beforeOpeningRoundBrace": true
},
"disallowSpacesInFunctionExpression": {
"beforeOpeningRoundBrace": true
},
"disallowSpacesInAnonymousFunctionExpression": {
"beforeOpeningRoundBrace": true
},
"disallowSpacesInFunctionDeclaration": {
"beforeOpeningRoundBrace": true
},
"disallowEmptyBlocks": true,
"disallowSpacesInsideArrayBrackets": true,
"disallowSpacesInsideParentheses": true,
"disallowQuotedKeysInObjects": true,
"disallowSpaceAfterObjectKeys": true,
"disallowSpaceAfterPrefixUnaryOperators": true,
"disallowSpaceBeforePostfixUnaryOperators": true,
"disallowSpaceBeforeBinaryOperators": [
","
],
"disallowMixedSpacesAndTabs": true,
"disallowTrailingWhitespace": true,
"disallowTrailingComma": true,
"disallowYodaConditions": true,
"disallowKeywords": [ "with" ],
"disallowMultipleLineBreaks": true,
"requireSpaceBeforeBlockStatements": true,
"requireParenthesesAroundIIFE": true,
"requireSpacesInConditionalExpression": true,
"requireBlocksOnNewline": 1,
"requireCommaBeforeLineBreak": true,
"requireSpaceBeforeBinaryOperators": true,
"requireSpaceAfterBinaryOperators": true,
"requireCamelCaseOrUpperCaseIdentifiers": "ignoreProperties",
"requireLineFeedAtFileEnd": true,
"requireCapitalizedConstructors": true,
"requireDotNotation": true,
"requireSpacesInForStatement": true,
"requireSpaceBetweenArguments": true,
"requireCurlyBraces": [
"do"
],
"requireSpaceAfterKeywords": [
"if",
"else",
"for",
"while",
"do",
"switch",
"case",
"return",
"try",
"catch",
"typeof"
],
"requirePaddingNewLinesBeforeLineComments": {
"allExcept": "firstAfterCurly"
},
"safeContextKeyword": "_this",
"validateLineBreaks": "LF",
"validateQuoteMarks": "'",
"validateIndentation": 4
}
2 changes: 1 addition & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ module.exports = function (grunt) {
});

grunt.registerTask('clean_all', [ 'clean:node_modules', 'clean:coverage', 'npm_install' ]);
grunt.registerTask('test', ['env:test', 'clean:coverage', 'jshint', 'mocha_istanbul']);
grunt.registerTask('test', ['env:test', 'clean:coverage', 'jscs:all', 'jshint', 'mocha_istanbul']);
grunt.registerTask('coverage', ['test', 'open_coverage']);
grunt.registerTask('generate-docs', ['apidoc']);
grunt.registerTask('dist', ['compress:hmda-edit-check-api']);
Expand Down
2 changes: 1 addition & 1 deletion controllers/getMetroAreasOnRespondentPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module.exports = function(router) {
* @apiParam {String} respondentId Ten-digit number used to identify a HMDA reporting institution
*/
router.get('/:activityYear/:agencyCode/:respondentId', function(req, res) {
MsaBranchesService.getMetroAreasOnRespondentPanel(req.params.activityYear, req.params.agencyCode,
MsaBranchesService.getMetroAreasOnRespondentPanel(req.params.activityYear, req.params.agencyCode,
req.params.respondentId, function(err, result) {
if (err) {
res.status(500).json(err);
Expand Down
9 changes: 2 additions & 7 deletions controllers/index.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
'use strict';


var IndexModel = require('../models/index');


module.exports = function (router) {
module.exports = function(router) {

var model = new IndexModel();


router.get('/', function (req, res) {

router.get('/', function(req, res) {
res.send('<code><pre>' + JSON.stringify(model, null, 2) + '</pre></code>');

});

};
2 changes: 1 addition & 1 deletion controllers/isChildFI.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module.exports = function(router) {

/**
* @api {get} /isChildFI/:activityYear/:agencyCode/:respondentId isChildFI
* @apiDescription checks whether or not the respondent has a valid parent organization
* @apiDescription checks whether or not the respondent has a valid parent organization
* @apiGroup Panel
* @apiParam {String} activityYear The year for which the HMDA data is being collected
* @apiParam {String} agencyCode Code to identify the supervisory/regulatory agency of the HMDA reporting institution
Expand Down
2 changes: 1 addition & 1 deletion controllers/isCraReporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module.exports = function(router) {

/**
* @api {get} /isCraReporter/:activityYear/:agencyCode/:respondentId isCraReporter
* @apiDescription checks whether or not the respondent is on the list of organizations required to file Community Reinvestment Act (CRA) information
* @apiDescription checks whether or not the respondent is on the list of organizations required to file Community Reinvestment Act (CRA) information
* @apiGroup CRA Reporters
* @apiParam {String} activityYear The year for which the HMDA data is being collected
* @apiParam {String} agencyCode Code to identify the supervisory/regulatory agency of the HMDA reporting institution
Expand Down
2 changes: 1 addition & 1 deletion controllers/isMetroAreaOnRespondentPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module.exports = function(router) {
* @apiParam {String} activityYear The year for which the HMDA data are being collected
* @apiParam {String} agencyCode Code to identify the supervisory/regulatory agency of the HMDA reporting institution
* @apiParam {String} respondentId Ten-digit number used to identify a HMDA reporting institution
* @apiParam {String} metroArea 5-digit code for the Metropolitan Statistical Authority/Metropolitan Division
* @apiParam {String} metroArea 5-digit code for the Metropolitan Statistical Authority/Metropolitan Division
*/
router.get('/:activityYear/:agencyCode/:respondentId/:metroArea', function(req, res) {
MsaBranchesService.isMetroAreaOnRespondentPanel(req.params.activityYear, req.params.agencyCode, req.params.respondentId, req.params.metroArea, function(err, result) {
Expand Down
2 changes: 1 addition & 1 deletion controllers/isValidCensusInMSA.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module.exports = function(router) {
censusparams.state_code = req.params.state;
censusparams.county_code = req.params.county;
censusparams.tract = req.params.tract;

CensusService.isValidCensusCombination(req.params.activityYear, censusparams, function(err, result) {
if (err) {
res.status(500).json(err);
Expand Down
2 changes: 1 addition & 1 deletion controllers/isValidCensusTractCombo.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module.exports = function(router) {
* @apiParam {String} activityYear The year for which the HMDA data is being collected
* @apiParam {String} state 2-digit FIPS code that identifies the state
* @apiParam {String} county 3-digit FIPS code that identifies the county
* @apiParam {String} metroArea 5-digit code to identify the Metropolitan Statistical Authority/Metropolitan Division
* @apiParam {String} metroArea 5-digit code to identify the Metropolitan Statistical Authority/Metropolitan Division
* @apiParam {String} tract 6-digit census tract number
*/
router.get('/:activityYear/:state/:county/:metroArea/:tract', function(req, res) {
Expand Down
2 changes: 1 addition & 1 deletion controllers/isValidLar/all.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ module.exports = function(router) {
}
});
});
};
};
4 changes: 2 additions & 2 deletions controllers/isValidLar/type.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module.exports = function(router) {
* @apiDescription runs all applicable checks of the supplied type against the supplied lar.
* @apiGroup Engine
* @apiParam {String} activityYear The year for which the HMDA data is being collected
* @apiParam {String} editType The type of edits to run
* @apiParam {String} editType The type of edits to run
*/
router.post('/:activityYear/:editType', function(req, res) {
EngineService.runLarType(req.params.activityYear, req.params.editType, req.body, function(err, result) {
Expand All @@ -20,4 +20,4 @@ module.exports = function(router) {
}
});
});
};
};
1 change: 0 additions & 1 deletion controllers/isValidStateCounty.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ module.exports = function(router) {
* @apiParam {String} county 3-digit FIPS code that identifies the county
*/
router.get('/:activityYear/:state/:county', function(req, res) {

CensusService.isValidStateCounty(req.params.activityYear, req.params.state, req.params.county, function(err, result) {
if (err) {
res.status(500).json(err);
Expand Down
18 changes: 9 additions & 9 deletions controllers/isValidTimestamp.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ module.exports = function(router) {
* @apiParam {String} agencyCode Code to identify the supervisory/regulatory agency of the HMDA reporting institution
* @apiParam {String} respondentId Ten-digit number used to identify a HMDA reporting institution
*/
router.get('/:activityYear/:agencyCode/:respondentID/:timestamp', function(req, res) {
TransmittalService.isValidTimestamp(req.params.activityYear, req.params.agencyCode, req.params.respondentID, req.params.timestamp, function(err, result) {
if (err) {
res.status(500).json(err);
} else {
res.json(result);
}
});
});
router.get('/:activityYear/:agencyCode/:respondentID/:timestamp', function(req, res) {
TransmittalService.isValidTimestamp(req.params.activityYear, req.params.agencyCode, req.params.respondentID, req.params.timestamp, function(err, result) {
if (err) {
res.status(500).json(err);
} else {
res.json(result);
}
});
});
};
5 changes: 2 additions & 3 deletions lib/404.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
'use strict';


module.exports = function (template) {
module.exports = function(template) {

return function fileNotFound(req, res, next) {
var globalError = { result: false };
res.status(200).send(globalError);
};

};
};
5 changes: 2 additions & 3 deletions lib/database.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
var mongoose = require('mongoose');

var db = {
configure: function (conf) {
configure: function(conf) {
var uri = 'mongodb://' + conf.host + ':' + conf.port + '/' + (conf.database ? conf.database : 'hmda');
var opts = {};
if (conf.username) {
Expand All @@ -21,5 +21,4 @@ var db = {
}
};


module.exports = db;
module.exports = db;
8 changes: 4 additions & 4 deletions lib/engine/engineCustomDataLookupConditions.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ var EngineCustomDataLookupConditions = (function() {

this.isValidMsaMdStateAndCountyCombo = function(metroArea, fipsState, fipsCounty) {
var censusParams = {
'msa_code': metroArea,
'state_code': fipsState,
'county_code': fipsCounty
msa_code: metroArea,
state_code: fipsState,
county_code: fipsCounty
};
return promisifyService(CensusService.isValidCensusCombination, [this.getRuleYear(), censusParams])
.then(function(response) {
Expand Down Expand Up @@ -78,4 +78,4 @@ var EngineCustomDataLookupConditions = (function() {
};
})();

module.exports = EngineCustomDataLookupConditions;
module.exports = EngineCustomDataLookupConditions;
2 changes: 1 addition & 1 deletion lib/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ var db = require('./database');
module.exports = function options(app) {

return {
onconfig: function (config, next) {
onconfig: function(config, next) {
db.configure(config.get('mongoConfig'));
next(null, config);
}
Expand Down
20 changes: 10 additions & 10 deletions models/census.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
var mongoose = require('mongoose');

var censusSchema = mongoose.Schema({
'activity_year': String,
'msa_code': String,
'msa_name': String,
'state_code': String,
'county_code': String,
'small_county': String,
'tract': String
activity_year: String,
msa_code: String,
msa_name: String,
state_code: String,
county_code: String,
small_county: String,
tract: String
});
censusSchema.index({'activity_year': 1, 'msa_code': 1, 'state_code': 1, 'county_code': 1, 'tract': 1});
censusSchema.index({'activity_year': 1, 'state_code': 1, 'county_code': 1, 'tract': 1});
censusSchema.index({'activity_year': 1, 'state_code': 1, 'county_code': 1, 'small_county': 1});
censusSchema.index({activity_year: 1, msa_code: 1, state_code: 1, county_code: 1, tract: 1});
censusSchema.index({activity_year: 1, state_code: 1, county_code: 1, tract: 1});
censusSchema.index({activity_year: 1, state_code: 1, county_code: 1, small_county: 1});
module.exports = mongoose.model('Census', censusSchema, 'census');
10 changes: 5 additions & 5 deletions models/craReporters.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
var mongoose = require('mongoose');

var craReportersSchema = mongoose.Schema({
'activity_year': String,
'respondent_id': String,
'agency_code': String,
'respondent_name': String
activity_year: String,
respondent_id: String,
agency_code: String,
respondent_name: String
});
craReportersSchema.index({'activity_year': 1, 'respondent_id': 1, 'agency_code': 1});
craReportersSchema.index({activity_year: 1, respondent_id: 1, agency_code: 1});
module.exports = mongoose.model('CraReporters', craReportersSchema, 'cra_reporters');
1 change: 0 additions & 1 deletion models/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
'use strict';


module.exports = function IndexModel() {
return {
name: 'index'
Expand Down
30 changes: 15 additions & 15 deletions models/lar.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@
var mongoose = require('mongoose');

var larSchema = mongoose.Schema({
'activity_year': String,
'agency_code': String,
'respondent_id': String,
'totalLoans' : String,
'totalHomePurchaseLoans' : String,
'soldHomePurchaseLoans' : String,
'totalRefinanceLoans' : String,
'soldRefinanceLoans' : String,
'totalQ70' : String,
'compareQ70' : String,
'totalQ71' : String,
'compareQ71' : String,
'totalQ72' : String,
'compareQ72' : String
activity_year: String,
agency_code: String,
respondent_id: String,
totalLoans: String,
totalHomePurchaseLoans: String,
soldHomePurchaseLoans: String,
totalRefinanceLoans: String,
soldRefinanceLoans: String,
totalQ70: String,
compareQ70: String,
totalQ71: String,
compareQ71: String,
totalQ72: String,
compareQ72: String
});
larSchema.index({'activity_year': 1, 'respondent_id': 1, 'agency_code': 1});
larSchema.index({activity_year: 1, respondent_id: 1, agency_code: 1});
module.exports = mongoose.model('Lar', larSchema, 'lar');
12 changes: 6 additions & 6 deletions models/msaBranches.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
var mongoose = require('mongoose');

var msaBranchesSchema = mongoose.Schema({
'activity_year': String,
'respondent_id': String,
'respondent_name': String,
'msa': [String],
'agency_code': String
activity_year: String,
respondent_id: String,
respondent_name: String,
msa: [String],
agency_code: String
});
msaBranchesSchema.index({'activity_year': 1, 'respondent_id': 1, 'agency_code': 1, 'msa': 1});
msaBranchesSchema.index({activity_year: 1, respondent_id: 1, agency_code: 1, msa: 1});
module.exports = mongoose.model('MsaBranches', msaBranchesSchema, 'msa_branches');
18 changes: 9 additions & 9 deletions models/panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
var mongoose = require('mongoose');

var panelSchema = mongoose.Schema({
'activity_year': String,
'respondent_id': String,
'agency_code': String,
'respondent_name': String,
'parent_name': String,
'parent_city': String,
'parent_state': String,
'other_lender_code': String
activity_year: String,
respondent_id: String,
agency_code: String,
respondent_name: String,
parent_name: String,
parent_city: String,
parent_state: String,
other_lender_code: String
});
panelSchema.index({'activity_year': 1, 'respondent_id': 1, 'agency_code': 1, 'other_lender_code': 1, 'parent_name': 1});
panelSchema.index({activity_year: 1, respondent_id: 1, agency_code: 1, other_lender_code: 1, parent_name: 1});
module.exports = mongoose.model('Panel', panelSchema, 'panel');
Loading