Add jshint validation to travis and cleanup existing jshint issues
diff --git a/.jshintrc b/.jshintrc
new file mode 100644
index 0000000..f8e9dc9
--- /dev/null
+++ b/.jshintrc
@@ -0,0 +1,5 @@
+{
+ "esversion" : 6,
+ "module" : true,
+ "node" : true
+}
diff --git a/actions/database-actions/create-document.js b/actions/database-actions/create-document.js
index a935790..92aafd5 100755
--- a/actions/database-actions/create-document.js
+++ b/actions/database-actions/create-document.js
@@ -13,10 +13,10 @@
var doc = message.doc;
var params = {};
- if(!dbName) {
+ if (!dbName) {
return Promise.reject('dbname is required.');
}
- if(!doc) {
+ if (!doc) {
return Promise.reject('doc is required.');
}
@@ -56,7 +56,7 @@
console.log("success", response);
resolve(response);
} else {
- console.log("error", error)
+ console.log("error", error);
reject(error);
}
});
diff --git a/actions/database-actions/create-query-index.js b/actions/database-actions/create-query-index.js
index 1bcec17..cda3e4e 100755
--- a/actions/database-actions/create-query-index.js
+++ b/actions/database-actions/create-query-index.js
@@ -11,11 +11,12 @@
var cloudant = cloudantOrError;
var dbName = message.dbname;
var index = message.index;
+ var params = {};
- if(!dbName) {
+ if (!dbName) {
return Promise.reject('dbname is required.');
}
- if(!index) {
+ if (!index) {
return Promise.reject('index is required.');
}
var cloudantDb = cloudant.use(dbName);
diff --git a/actions/database-actions/delete-query-index.js b/actions/database-actions/delete-query-index.js
index bd95c79..a03deba 100755
--- a/actions/database-actions/delete-query-index.js
+++ b/actions/database-actions/delete-query-index.js
@@ -16,16 +16,16 @@
var indexName = message.indexname;
var indexType = message.indextype;
- if(!dbName) {
+ if (!dbName) {
return Promise.reject('dbname is required.');
}
- if(!docId) {
+ if (!docId) {
return Promise.reject('docid is required.');
}
- if(!indexName) {
+ if (!indexName) {
return Promise.reject('indexname is required.');
}
- if(!indexType) {
+ if (!indexType) {
return Promise.reject('indextype is required.');
}
@@ -35,9 +35,8 @@
function deleteIndexFromDesignDoc(cloudant, docId, indexName, indexType, dbName) {
return new Promise(function(resolve, reject) {
- var path = "_index/" + encodeURIComponent(docId)
- + '/' + encodeURIComponent(indexType)
- + '/' + encodeURIComponent(indexName);
+ var path = "_index/" + encodeURIComponent(docId) + '/' + encodeURIComponent(indexType) +
+ '/' + encodeURIComponent(indexName);
cloudant.request({ db: encodeURIComponent(dbName),
method : 'delete',
diff --git a/actions/database-actions/read-attachment.js b/actions/database-actions/read-attachment.js
index bcff416..f831e4d 100755
--- a/actions/database-actions/read-attachment.js
+++ b/actions/database-actions/read-attachment.js
@@ -14,13 +14,13 @@
var attName = message.attachmentname;
var params = {};
- if(!dbName) {
+ if (!dbName) {
return Promise.reject('dbname is required.');
}
- if(!docId) {
+ if (!docId) {
return Promise.reject('docid is required.');
}
- if(!attName) {
+ if (!attName) {
return Promise.reject('attachmentname is required.');
}
var cloudantDb = cloudant.use(dbName);
@@ -53,7 +53,7 @@
console.log("success", response);
resolve(response);
} else {
- console.log("error", error)
+ console.log("error", error);
reject(error);
}
});
diff --git a/provider/app.js b/provider/app.js
index 1198cf6..28787e0 100644
--- a/provider/app.js
+++ b/provider/app.js
@@ -97,7 +97,7 @@
var nanoDb = createTriggerDb();
if (nanoDb === null) {
- logger.error(tid, 'init', 'found an error creating database: ');
+ logger.error(tid, 'init', 'an error occurred creating database');
} else {
logger.info(tid, 'init', 'trigger storage database details: ', nanoDb);
diff --git a/tools/travis/build.sh b/tools/travis/build.sh
index c328ea2..6a45e86 100755
--- a/tools/travis/build.sh
+++ b/tools/travis/build.sh
@@ -7,7 +7,10 @@
ROOTDIR="$SCRIPTDIR/../.."
WHISKDIR="$ROOTDIR/../openwhisk"
-# Install OpenWhisk
-
+# run scancode
cd $WHISKDIR
-tools/build/scanCode.py $ROOTDIR
\ No newline at end of file
+tools/build/scanCode.py $ROOTDIR
+
+# run jshint
+cd $ROOTDIR
+jshint --exclude tests .
\ No newline at end of file
diff --git a/tools/travis/setup.sh b/tools/travis/setup.sh
index 7675a2f..bfc9f00 100755
--- a/tools/travis/setup.sh
+++ b/tools/travis/setup.sh
@@ -22,7 +22,10 @@
# Ansible
pip install --user ansible==2.1.2.0
-# OpenWhisk stuff
+# jshint support
+sudo apt-get -y install nodejs npm
+sudo npm install -g jshint
+# OpenWhisk stuff
cd $HOMEDIR
git clone https://github.com/openwhisk/openwhisk.git