Fixing codacy issues.
diff --git a/examples/api-proxy/app.js b/examples/api-proxy/app.js
index 76b3401..dde48f1 100644
--- a/examples/api-proxy/app.js
+++ b/examples/api-proxy/app.js
@@ -1,8 +1,7 @@
var express = require('express'),
app = express(),
Usergrid = require('usergrid'),
- async = require('async'),
- chance = require('chance')
+ async = require('async')
Usergrid.init()
diff --git a/helpers/config.js b/helpers/config.js
index 860d9e2..ee6e0b6 100644
--- a/helpers/config.js
+++ b/helpers/config.js
@@ -34,7 +34,7 @@
file.walkSync(appRoot, function(start, dirs, names) {
if (_.includes(names, "config.json") || _.includes(names, "usergrid.json")) {
var name = _.first(names.filter(function(name) {
- return name == "config.json" || name == "usergrid.json"
+ return name === "config.json" || name === "usergrid.json"
}).sort().reverse())
var configPath = util.format("%s/%s", start, name)
module.exports = require(configPath)
diff --git a/lib/entity.js b/lib/entity.js
index ef83770..b1452a6 100644
--- a/lib/entity.js
+++ b/lib/entity.js
@@ -55,6 +55,12 @@
writable: true
})
+ Object.defineProperty(self, 'asset', {
+ enumerable: false,
+ configurable: true,
+ writable: true
+ })
+
Object.defineProperty(self, 'isUser', {
get: function() {
return (self.type.toLowerCase() === 'user')
@@ -67,8 +73,6 @@
}
})
- self.asset
-
helpers.setReadOnly(self, ['uuid', 'name', 'type', 'created'])
return self
diff --git a/lib/request.js b/lib/request.js
index ba3d573..77c88a5 100644
--- a/lib/request.js
+++ b/lib/request.js
@@ -20,7 +20,6 @@
_ = require('lodash')
var UsergridRequest = function(options) {
- var self = this
var client = helpers.client.validate(options.client)
var callback = helpers.cb(helpers.args(arguments))
@@ -36,7 +35,7 @@
var formData = helpers.build.formData(options)
var body = ((formData !== undefined) ? undefined : options.body)
- var req = request(uri, {
+ request(uri, {
headers: helpers.build.headers(client, options),
body: body,
encoding: options.encoding || null,
diff --git a/lib/user.js b/lib/user.js
index fee89a1..90506b4 100644
--- a/lib/user.js
+++ b/lib/user.js
@@ -117,7 +117,7 @@
qs: (!revokeAll) ? {
token: self.auth.token
} : undefined
- }, function(error, usergridResponse, body) {
+ }, function(error, usergridResponse) {
self.auth.destroy()
callback(error, usergridResponse, usergridResponse.ok)
})
@@ -147,7 +147,7 @@
path: util.format('users/%s/password', helpers.user.uniqueId(self)),
method: 'PUT',
body: body
- }, function(error, usergridResponse, body) {
+ }, function(error, usergridResponse) {
callback(error, usergridResponse, usergridResponse.ok)
})
}
diff --git a/tests/lib/asset.test.js b/tests/lib/asset.test.js
index 2220d07..29cb5cd 100644
--- a/tests/lib/asset.test.js
+++ b/tests/lib/asset.test.js
@@ -1,14 +1,12 @@
'use strict'
-var should = require('should'),
- config = require('../../helpers').config,
+var config = require('../../helpers').config,
UsergridEntity = require('../../lib/entity'),
UsergridAsset = require('../../lib/asset'),
UsergridClient = require('../../lib/client'),
util = require('util'),
request = require('request'),
- fs = require('fs'),
- _ = require('lodash')
+ fs = require('fs')
var _slow = 6000,
_timeout = 12000,
@@ -103,7 +101,7 @@
it('should upload a binary asset to an existing entity', function(done) {
var entity = new UsergridEntity({
type: config.test.collection,
- name: "AssetTestPUT",
+ name: "AssetTestPUT"
})
var asset = new UsergridAsset(filename, file)
client.PUT(entity, function(err, entityResponse, createdEntity) {
diff --git a/tests/lib/client.auth.test.js b/tests/lib/client.auth.test.js
index ab9f0d0..6821184 100644
--- a/tests/lib/client.auth.test.js
+++ b/tests/lib/client.auth.test.js
@@ -8,11 +8,9 @@
UsergridAuth = require('../../lib/auth'),
UsergridAppAuth = require('../../lib/appAuth'),
UsergridUserAuth = require('../../lib/userAuth'),
- UsergridUser = require('../../lib/user'),
- _ = require('lodash')
+ UsergridUser = require('../../lib/user')
-var _uuid,
- _slow = 500,
+var _slow = 500,
_timeout = 4000
describe('authMode', function() {
@@ -62,7 +60,7 @@
client.authMode = UsergridAuth.AUTH_MODE_NONE
client.usingAuth(client.appAuth).POST('roles/guest/permissions', {
permission: "get,post,put,delete:/**"
- }, function(error, usergridResponse) {
+ }, function() {
done()
})
})
@@ -238,7 +236,7 @@
username: config.test.username,
password: config.test.password,
email: email
- }, false, function(err, r, t) {
+ }, false, function() {
should(noCurrentUserClient.currentUser).be.undefined()
done()
})
@@ -248,9 +246,9 @@
var newClient = new UsergridClient()
var ttlInMilliseconds = 500000
var userAuth = new UsergridUserAuth(config.test.username, config.test.password, ttlInMilliseconds)
- client.authenticateUser(userAuth, function(err, usergridResponse, token) {
+ newClient.authenticateUser(userAuth, function(err, usergridResponse, token) {
usergridResponse.ok.should.be.true()
- client.currentUser.auth.token.should.equal(token)
+ newClient.currentUser.auth.token.should.equal(token)
usergridResponse.body.expires_in.should.equal(ttlInMilliseconds / 1000)
done()
})
diff --git a/tests/lib/client.connections.test.js b/tests/lib/client.connections.test.js
index 98dcc68..acc19a2 100644
--- a/tests/lib/client.connections.test.js
+++ b/tests/lib/client.connections.test.js
@@ -5,11 +5,9 @@
config = require('../../helpers').config,
UsergridClient = require('../../lib/client'),
UsergridEntity = require('../../lib/entity'),
- UsergridQuery = require('../../lib/query'),
- _ = require('lodash')
+ UsergridQuery = require('../../lib/query')
-var _uuid,
- _slow = 500,
+var _slow = 500,
_timeout = 4000
describe('connect()', function() {
diff --git a/tests/lib/client.init.test.js b/tests/lib/client.init.test.js
index f1572d4..01702bd 100644
--- a/tests/lib/client.init.test.js
+++ b/tests/lib/client.init.test.js
@@ -1,10 +1,8 @@
'use strict'
var should = require('should'),
- urljoin = require('url-join'),
config = require('../../helpers').config,
- UsergridClient = require('../../lib/client'),
- _ = require('lodash')
+ UsergridClient = require('../../lib/client')
describe('initialization', function() {
it('should fail to initialize without an orgId and appId', function() {
diff --git a/tests/lib/client.rest.test.js b/tests/lib/client.rest.test.js
index 61d796b..017073e 100644
--- a/tests/lib/client.rest.test.js
+++ b/tests/lib/client.rest.test.js
@@ -1,7 +1,6 @@
'use strict'
-var should = require('should'),
- config = require('../../helpers').config,
+var config = require('../../helpers').config,
chance = new require('chance').Chance(),
UsergridClient = require('../../lib/client'),
UsergridEntity = require('../../lib/entity'),
diff --git a/tests/lib/entity.test.js b/tests/lib/entity.test.js
index c5018c8..8152f23 100644
--- a/tests/lib/entity.test.js
+++ b/tests/lib/entity.test.js
@@ -8,14 +8,12 @@
UsergridQuery = require('../../lib/query'),
UsergridAuth = require('../../lib/auth'),
UsergridAsset = require('../../lib/asset'),
- fs = require('fs'),
- _ = require('lodash')
+ fs = require('fs')
var _slow = 1500,
_timeout = 4000,
filename = 'old_man',
file = __dirname + '/image.jpg',
- testFile = __dirname + '/image_test.jpg',
expectedContentLength = 109055,
assetEntity = new UsergridEntity({
type: config.test.collection,
@@ -297,7 +295,7 @@
var entity = new UsergridEntity(getResponse.first)
var modified = entity.modified
getResponse.first.putProperty('reloadTest', now)
- client.PUT(getResponse.first, function(err, putResponse) {
+ client.PUT(getResponse.first, function() {
entity.reload(client, function() {
client.isSharedInstance.should.be.false()
entity.reloadTest.should.equal(now)
@@ -351,7 +349,7 @@
})
})
-describe('attachAsset()', function(done) {
+describe('attachAsset()', function() {
var asset = new UsergridAsset(filename, file),
entity = new UsergridEntity({
@@ -372,7 +370,7 @@
})
})
-describe('uploadAsset()', function(done) {
+describe('uploadAsset()', function() {
this.slow(_slow)
this.timeout(_timeout)
@@ -398,7 +396,7 @@
})
})
-describe('downloadAsset()', function(done) {
+describe('downloadAsset()', function() {
this.slow(_slow)
this.timeout(_timeout)
diff --git a/tests/lib/query.test.js b/tests/lib/query.test.js
index adbfab2..e92c34d 100644
--- a/tests/lib/query.test.js
+++ b/tests/lib/query.test.js
@@ -1,7 +1,6 @@
'use strict'
-var should = require('should'),
- UsergridQuery = require('../../lib/query')
+var UsergridQuery = require('../../lib/query')
describe('_type', function() {
it('_type should equal "cats" when passing "type" as a parameter to UsergridQuery', function() {
diff --git a/tests/lib/response.test.js b/tests/lib/response.test.js
index 5341e5e..685d132 100644
--- a/tests/lib/response.test.js
+++ b/tests/lib/response.test.js
@@ -74,7 +74,7 @@
it('response.users should be an array of UsergridUser objects', function(done) {
client.setAppAuth(config.clientId, config.clientSecret, config.tokenTtl)
- client.authenticateApp(function(err, response) {
+ client.authenticateApp(function(err) {
should(err).be.undefined()
client.GET('users', function(err, usergridResponse) {
usergridResponse.ok.should.be.true()
diff --git a/tests/lib/user.test.js b/tests/lib/user.test.js
index 28bb2c3..ef89a20 100644
--- a/tests/lib/user.test.js
+++ b/tests/lib/user.test.js
@@ -6,8 +6,7 @@
config = require('../../helpers').config,
UsergridClient = require('../../lib/client'),
UsergridUser = require('../../lib/user'),
- UsergridQuery = require('../../lib/query'),
- _ = require('lodash')
+ UsergridQuery = require('../../lib/query')
var _slow = 1500,
_timeout = 4000,
@@ -26,7 +25,7 @@
var query = new UsergridQuery('users').not.eq('username', config.test.username).limit(20)
// clean up old user entities as the UsergridResponse tests rely on this collection containing less than 10 entities
client.DELETE(query, function() {
- _user1.create(client, function(err, usergridResponse, user) {
+ _user1.create(client, function() {
done()
})
})
@@ -83,7 +82,7 @@
user.should.have.property('activated').true()
user.should.not.have.property('password')
// cleanup
- user.remove(client, function(err, response) {
+ user.remove(client, function() {
done()
})
})
@@ -112,7 +111,7 @@
this.timeout(_timeout)
it(util.format("it should log out '%s' and destroy the saved UsergridUserAuth instance", _username1), function(done) {
- _user1.logout(client, function(err, response, success) {
+ _user1.logout(client, function(err, response) {
response.ok.should.be.true()
response.body.action.should.equal("revoked user token")
_user1.auth.isValid.should.be.false()
@@ -121,7 +120,7 @@
})
it("it should return an error when attempting to log out a user that does not have a valid token", function(done) {
- _user1.logout(client, function(err, response, success) {
+ _user1.logout(client, function(err) {
err.should.containDeep({
name: 'no_valid_token'
})
@@ -133,8 +132,8 @@
describe('logoutAllSessions()', function() {
it(util.format("it should log out all tokens for the user '%s' destroy the saved UsergridUserAuth instance", _username1), function(done) {
_user1.password = config.test.password
- _user1.login(client, function(err, response, token) {
- _user1.logoutAllSessions(client, function(err, response, success) {
+ _user1.login(client, function() {
+ _user1.logoutAllSessions(client, function(err, response) {
response.ok.should.be.true()
response.body.action.should.equal("revoked user tokens")
_user1.auth.isValid.should.be.false()
@@ -150,7 +149,7 @@
this.timeout(_timeout)
it(util.format("it should reset the password for '%s' by passing parameters", _username1), function(done) {
- _user1.resetPassword(client, config.test.password, '2cool4u', function(err, response, success) {
+ _user1.resetPassword(client, config.test.password, '2cool4u', function(err, response) {
response.ok.should.be.true()
response.body.action.should.equal("set user password")
done()
@@ -161,7 +160,7 @@
_user1.resetPassword(client, {
oldPassword: '2cool4u',
newPassword: config.test.password
- }, function(err, response, success) {
+ }, function(err, response) {
response.ok.should.be.true()
response.body.action.should.equal("set user password")
done()
@@ -172,10 +171,10 @@
_user1.resetPassword(client, {
oldPassword: 'BADOLDPASSWORD',
newPassword: config.test.password
- }, function(err, response, success) {
+ }, function(err, response) {
response.ok.should.be.false()
err.name.should.equal('auth_invalid_username_or_password')
- _user1.remove(client, function(err, response) {
+ _user1.remove(client, function() {
done()
})
})
diff --git a/tests/lib/usergrid.init.test.js b/tests/lib/usergrid.init.test.js
index b8b29c2..b8a9fd9 100644
--- a/tests/lib/usergrid.init.test.js
+++ b/tests/lib/usergrid.init.test.js
@@ -1,7 +1,6 @@
'use strict'
-var should = require('should'),
- config = require('../../helpers').config,
+var config = require('../../helpers').config,
Usergrid = require('../../usergrid'),
UsergridClient = require('../../lib/client'),
util = require('util'),
diff --git a/tests/lib/usergrid.singleton.test.js b/tests/lib/usergrid.singleton.test.js
index 5a1a1ba..9f73bab 100644
--- a/tests/lib/usergrid.singleton.test.js
+++ b/tests/lib/usergrid.singleton.test.js
@@ -1,7 +1,6 @@
'use strict'
-var should = require('should'),
- Usergrid = require('../../usergrid')
+var Usergrid = require('../../usergrid')
it('should be initialized when defined in another module', function(done) {
Usergrid.should.have.property('isInitialized').which.is.true()
diff --git a/tests/main.test.js b/tests/main.test.js
index 581411e..22bbedd 100644
--- a/tests/main.test.js
+++ b/tests/main.test.js
@@ -2,7 +2,6 @@
// module config
var should = require('should'),
- validator = require('validator'),
_ = require('lodash')
_.mixin(require('lodash-uuid'))