Permalink
Browse files

Better QA

  • Loading branch information...
1 parent 0609cb2 commit 0ad2108ce369c8bcd2c5cf9ac8162821cc62f3cc @serby committed Nov 4, 2013
Showing with 18 additions and 22 deletions.
  1. +2 −0 .jshintignore
  2. +0 −14 Makefile
  3. +6 −3 lib/schemata.js
  4. +10 −5 package.json
View
@@ -0,0 +1,2 @@
+node_modules
+coverage
View
@@ -1,14 +0,0 @@
-default: test lint
-
-test:
- @./node_modules/.bin/mocha \
- -r should \
- -R spec
-
-lint-changed:
- @jshint `git status --porcelain | sed -e "s/^...//g"`
-
-lint:
- @jshint lib test
-
-.PHONY: default test lint lint-changed
View
@@ -130,22 +130,24 @@ module.exports = function(schema) {
* @api public
*/
function stripUnknownProperties(entityObject, tag, ignoreTagForSubSchemas) {
+ /* jshint maxcomplexity: 7 */
var newEntity = {}
- ;
+ , subSchemaTag
Object.keys(entityObject).forEach(function(key) {
+
if ((typeof schema[key] !== 'undefined') && (hasTag(schema, key, tag))) {
if (typeof schema[key].type !== 'undefined') {
// This infers that there is a sub-schema
if (typeof schema[key].type.stripUnknownProperties === 'function') {
- var subSchemaTag = ignoreTagForSubSchemas ? undefined : tag
+ subSchemaTag = ignoreTagForSubSchemas ? undefined : tag
return newEntity[key] = schema[key].type.stripUnknownProperties(
entityObject[key], subSchemaTag, ignoreTagForSubSchemas);
} else if ((typeof schema[key].type.arraySchema !== 'undefined')
&& (typeof schema[key].type.arraySchema.stripUnknownProperties === 'function')
&& (Array.isArray(entityObject[key]))) {
// Here the property must be an array schema
- var subSchemaTag = ignoreTagForSubSchemas ? undefined : tag
+ subSchemaTag = ignoreTagForSubSchemas ? undefined : tag
entityObject[key].forEach(function(arrayItem, index) {
entityObject[key][index] =
schema[key].type.arraySchema.stripUnknownProperties(arrayItem, subSchemaTag, ignoreTagForSubSchemas);
@@ -172,6 +174,7 @@ module.exports = function(schema) {
* @api public
*/
function castProperty(type, value) {
+ /* jshint maxcomplexity:32 */
if (type === undefined) {
throw new Error('Missing type');
}
View
@@ -23,8 +23,10 @@
"piton-string-utils": "~0.3"
},
"devDependencies": {
- "mocha": "*",
- "should": "*"
+ "mocha": "1",
+ "should": "2",
+ "istanbul": "0",
+ "jshint": "2"
},
"keywords": [
"entity",
@@ -34,10 +36,13 @@
"repository": "git://github.com/serby/schemata.git",
"main": "lib/schemata",
"scripts": {
- "test": "./node_modules/.bin/mocha -r should",
- "prepublish": "npm prune"
+ "lint": "./node_modules/.bin/jshint .",
+ "pretest": "npm run-script lint",
+ "test": "./node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha -- -R spec -r should",
+ "posttest": "./node_modules/.bin/istanbul check-coverage && rm -rf coverage",
+ "prepublish": "npm test && npm prune"
},
"engines": {
- "node": ">= 0.6"
+ "node": ">= 0.8"
}
}

0 comments on commit 0ad2108

Please sign in to comment.