Browse files

Makes the new jslint happy.

  • Loading branch information...
1 parent 77163e3 commit 278e6a08c7e0dd02bce3540fe232509ae3442900 @SaltwaterC committed Nov 8, 2013
View
13 lib/aws.js
@@ -4,6 +4,7 @@
// we aren't unescaping URLs in the first place, therefore there's no URL decoding to break
/*global unescape*/
/*jslint regexp: true*/
+/*jslint todo: true*/
// TODO: refactor
@@ -792,7 +793,7 @@ var client = function (config, httpOptions) {
* @param {Function} callback
*/
config.moveObject = function (source, destination, acl, headers, callback) {
- config.copyObject(source, destination, acl, headers, function(error, response) {
+ config.copyObject(source, destination, acl, headers, function(error) {
if (error) {
callback(error);
} else {
@@ -822,7 +823,7 @@ var client = function (config, httpOptions) {
}
absSource = '/' + config.useBucket + absSource;
- config.copyObject(absSource, destination, acl, headers, function (error, response) {
+ config.copyObject(absSource, destination, acl, headers, function (error) {
if (error) {
callback(error);
} else {
@@ -1140,7 +1141,7 @@ var client = function (config, httpOptions) {
errors[partNumber]++;
if (errors[partNumber] === 10) {
aborted = true;
- config.abortUpload(path, uploadId, function (err, res) {
+ config.abortUpload(path, uploadId, function (err) {
if ( ! err) {
err = new Error('Part ' + partNumber + ' failed the upload 10 times. Aborting the multipart upload.');
err.partNumber = partNumber;
@@ -1209,10 +1210,10 @@ var client = function (config, httpOptions) {
xml += '<Quiet>true</Quiet>';
}
- var idx;
+ var idx, object;
var count = objects.length;
for (idx = 0; idx < count; idx++) {
- var object = objects[idx];
+ object = objects[idx];
if (typeof object.key === 'string') {
xml += '<Object><Key>' + object.key + '</Key>';
@@ -1267,7 +1268,7 @@ exports.load = function (service, accessKeyId, secretAccessKey, sessionToken, ht
console.error('Warning: aws2js under node.js v0.8.4 and below is deprecated. Only node.js v0.8.5+ will be supported.');
}
- var clientTemplate = cfg.clients[service], key;
+ var clientTemplate = cfg.clients[service];
if ( ! clientTemplate) {
throw new Error('Invalid AWS client');
}
View
31 lib/internals.js
@@ -1,4 +1,5 @@
'use strict';
+/*jslint todo: true*/
/* the internally used modules */
var cfg = require('../config/aws.js');
@@ -138,7 +139,7 @@ exports.filterByteRange = filterByteRange;
*/
var makeRequest = function (config, options, body, handler, callback, requestId) {
var transfer = new EventEmitter();
- var file, json, haveBodyHandler, bfile;
+ var file, json, haveBodyHandler, bfile, error;
if (requestId === undefined) {
requestId = 0;
@@ -294,7 +295,7 @@ var makeRequest = function (config, options, body, handler, callback, requestId)
makeRequest(config, options, body, handler, callback, requestId);
}, 500 * requestId);
} else {
- var error = new Error('Redirect loop detected after 10 retries.');
+ error = new Error('Redirect loop detected after 10 retries.');
error.headers = response.headers;
error.code = response.statusCode;
callback(error);
@@ -311,11 +312,11 @@ var makeRequest = function (config, options, body, handler, callback, requestId)
aborted = true;
request.abort();
- var err = new Error('Buffer too large. node.js limits the SlowBuffer implementation to 1073741823 bytes.');
- err.headers = response.headers;
- err.code = response.statusCode;
+ error = new Error('Buffer too large. node.js limits the SlowBuffer implementation to 1073741823 bytes.');
+ error.headers = response.headers;
+ error.code = response.statusCode;
- callback(err);
+ callback(error);
}
};
@@ -377,11 +378,11 @@ var makeRequest = function (config, options, body, handler, callback, requestId)
case 'json':
try {
- var json = JSON.parse(Buffer.concat(data).toString());
+ json = JSON.parse(Buffer.concat(data).toString());
if (response.statusCode === 200) {
callback(null, json);
} else {
- var error = new Error('API error with HTTP Code: ' + response.statusCode);
+ error = new Error('API error with HTTP Code: ' + response.statusCode);
error.headers = response.headers;
error.code = response.statusCode;
error.document = json;
@@ -424,7 +425,7 @@ var makeRequest = function (config, options, body, handler, callback, requestId)
} else if (response.statusCode === 204) {
callback(null);
} else {
- var error = new Error('The server prematurely closed the connection and there was no data.');
+ error = new Error('The server prematurely closed the connection and there was no data.');
error.headers = response.headers;
error.code = response.statusCode;
callback(error);
@@ -619,14 +620,14 @@ var authorize = function (config, method, headers, path, query) {
toSign += '\n';
- var n, key, keys = [];
+ var n, key, keys = [], amzPrefix, type;
var sorted = {};
for (key in headers) {
if (headers.hasOwnProperty(key)) {
- var amzPrefix = key.substr(0, 5);
+ amzPrefix = key.substr(0, 5);
if (amzPrefix === 'x-amz') {
- var type = typeof headers[key];
+ type = typeof headers[key];
if (type === 'string' || type === 'number') {
keys.push(key);
} else {
@@ -691,12 +692,12 @@ var contentLength = function (file, config, method, headers, path, callback) {
* @returns {Object}
*/
var normalizeHeaders = function (headers) {
- var name;
+ var name, lowName, val;
for (name in headers) {
if (headers.hasOwnProperty(name)) {
- var lowName = name.toLowerCase();
- var val = headers[name];
+ lowName = name.toLowerCase();
+ val = headers[name];
delete (headers[name]);
headers[lowName] = val;
}
View
1 lib/tools.js
@@ -1,4 +1,5 @@
'use strict';
+/*jslint todo: true*/
/* core module */
var util = require('util');
View
6 tests/endpoints.js
@@ -13,11 +13,11 @@ var clients = {
sdb: config.clients.sdb.prefix
};
-var client;
+var client, prefix, cl;
for (client in clients) {
if (clients.hasOwnProperty(client)) {
- var prefix = clients[client];
- var cl = aws.load(client);
+ prefix = clients[client];
+ cl = aws.load(client);
assert.deepEqual(cl.getEndPoint(), prefix + suffix);
cl.setRegion('eu-west-1');
assert.deepEqual(cl.getEndPoint(), prefix + '.eu-west-1' + suffix);
View
8 tests/s3-copy-object.js
@@ -18,11 +18,11 @@ var callbacks = {
s3.setCredentials(process.env.AWS_ACCEESS_KEY_ID, process.env.AWS_SECRET_ACCESS_KEY);
s3.setBucket(process.env.AWS2JS_S3_BUCKET);
-s3.putFile(source, './data/foo.png', false, {}, function (err, res) {
+s3.putFile(source, './data/foo.png', false, {}, function (err) {
callbacks.putFile++;
assert.ifError(err);
- s3.copyObject(s3.getBucket() + '/' + source, destination, false, {}, function (err, res) {
+ s3.copyObject(s3.getBucket() + '/' + source, destination, false, {}, function (err) {
callbacks.copyObject++;
assert.ifError(err);
@@ -31,12 +31,12 @@ s3.putFile(source, './data/foo.png', false, {}, function (err, res) {
assert.ifError(err);
assert.deepEqual(res['content-type'], 'image/png');
- s3.del(source, function (err, res) {
+ s3.del(source, function (err) {
callbacks.delSource++;
assert.ifError(err);
});
- s3.del(destination, function (err, res) {
+ s3.del(destination, function (err) {
callbacks.delDestination++;
assert.ifError(err);
});
View
4 tests/s3-del-multi-objects.js
@@ -18,7 +18,7 @@ var callbacks = {
s3.setCredentials(process.env.AWS_ACCEESS_KEY_ID, process.env.AWS_SECRET_ACCESS_KEY);
s3.setBucket(process.env.AWS2JS_S3_BUCKET);
-s3.putFile(path1, './data/foo.png', false, {}, function (err, res) {
+s3.putFile(path1, './data/foo.png', false, {}, function (err) {
callbacks.put1++;
assert.ifError(err);
@@ -27,7 +27,7 @@ s3.putFile(path1, './data/foo.png', false, {}, function (err, res) {
assert.ifError(err);
assert.deepEqual(res['content-type'], 'image/png');
- s3.putFile(path2, './data/foo.png', false, {}, function (err, res) {
+ s3.putFile(path2, './data/foo.png', false, {}, function (err) {
callbacks.put2++;
assert.ifError(err);
View
2 tests/s3-get-stream.js
@@ -16,7 +16,7 @@ var callbacks = {
s3.setCredentials(process.env.AWS_ACCEESS_KEY_ID, process.env.AWS_SECRET_ACCESS_KEY);
s3.setBucket(process.env.AWS2JS_S3_BUCKET);
-s3.putFile(path, './data/foo.txt', false, {}, function (err, res) {
+s3.putFile(path, './data/foo.txt', false, {}, function (err) {
callbacks.put++;
assert.ifError(err);
s3.get(path, 'stream', function (err, res) {
View
4 tests/s3-get-subresource-request-parameter.js
@@ -3,15 +3,14 @@
var common = require('./includes/common.js');
var assert = require('assert');
-var s3 = require('../').load('s3');
+var s3 = require('../').load('s3', process.env.AWS_ACCEESS_KEY_ID, process.env.AWS_SECRET_ACCESS_KEY);
var callbacks = {
query: 0,
path: 0,
queryOnly: 0
};
-s3.setCredentials(process.env.AWS_ACCEESS_KEY_ID, process.env.AWS_SECRET_ACCESS_KEY);
s3.setBucket(process.env.AWS2JS_S3_BUCKET);
var s3ProcessResponse = function (err, res) {
@@ -25,7 +24,6 @@ s3.get('?uploads', {'max-uploads': 1}, 'xml', function (err, res) {
s3ProcessResponse(err, res);
});
-
s3.get('?uploads&max-uploads=1', 'xml', function (err, res) {
callbacks.path++;
s3ProcessResponse(err, res);
View
6 tests/s3-lifecycle.js
@@ -22,21 +22,21 @@ var showError = function (err) {
s3.setCredentials(process.env.AWS_ACCEESS_KEY_ID, process.env.AWS_SECRET_ACCESS_KEY);
s3.setBucket(process.env.AWS2JS_S3_BUCKET);
-s3.delLifeCycle(function (error, response) {
+s3.delLifeCycle(function (error) {
callbacks.delLifeCycle++;
console.log('s3.delLifeCycle');
showError(error);
assert.ifError(error);
- s3.putLifeCycleRule('id', 'prefix-' + timestamp, 5, function (error, response) {
+ s3.putLifeCycleRule('id', 'prefix-' + timestamp, 5, function (error) {
callbacks.putLifeCycleRule++;
console.log('s3.putLifeCycleRule: id, prefix-' + timestamp);
showError(error);
assert.ifError(error);
- s3.delLifeCycleRule('id', function(error, response) {
+ s3.delLifeCycleRule('id', function(error) {
callbacks.delLifeCycleRule++;
console.log('s3.delLifeCycleRule: id');
View
6 tests/s3-move-object.js
@@ -17,11 +17,11 @@ var callbacks = {
s3.setCredentials(process.env.AWS_ACCEESS_KEY_ID, process.env.AWS_SECRET_ACCESS_KEY);
s3.setBucket(process.env.AWS2JS_S3_BUCKET);
-s3.putFile(source, './data/foo.png', false, {}, function (err, res) {
+s3.putFile(source, './data/foo.png', false, {}, function (err) {
callbacks.putFile++;
assert.ifError(err);
- s3.moveObject(s3.getBucket() + '/' + source, destination, false, {}, function (err, res) {
+ s3.moveObject(s3.getBucket() + '/' + source, destination, false, {}, function (err) {
callbacks.renameObject++;
assert.ifError(err);
@@ -30,7 +30,7 @@ s3.putFile(source, './data/foo.png', false, {}, function (err, res) {
assert.ifError(err);
assert.deepEqual(res['content-type'], 'image/png');
- s3.del(destination, function (err, res) {
+ s3.del(destination, function (err) {
callbacks.delDestination++;
assert.ifError(err);
});
View
6 tests/s3-multipart-upload.js
@@ -32,13 +32,13 @@ crypto.randomBytes(6291456, function (err, buf) {
assert.ifError(err);
util.log('wrote the random data file');
- s3.putFileMultipart(file, file, false, {}, 5242880, function (err, res) {
+ s3.putFileMultipart(file, file, false, {}, 5242880, function (err) {
assert.ifError(err);
callbacks.putFileMultipart++;
util.log('uploaded the 6M.tmp file to S3');
- s3.get(file, {file: file}, function (err, res) {
+ s3.get(file, {file: file}, function (err) {
assert.ifError(err);
util.log('got the file back from S3');
@@ -57,7 +57,7 @@ crypto.randomBytes(6291456, function (err, buf) {
fs.unlink(file, function (err) {
assert.ifError(err);
- s3.del(file, function (err, res) {
+ s3.del(file, function (err) {
assert.ifError(err);
util.log('cleaned up the S3 remote');
});
View
2 tests/s3-put-buffer.js
@@ -19,7 +19,7 @@ s3.setBucket(process.env.AWS2JS_S3_BUCKET);
fs.readFile('./data/foo.txt', function (err, buffer) {
assert.ifError(err);
- s3.putBuffer(path, buffer, false, {'content-type': 'text/plain'}, function (err, res) {
+ s3.putBuffer(path, buffer, false, {'content-type': 'text/plain'}, function (err) {
callbacks.put++;
assert.ifError(err);
s3.get(path, 'buffer', function (err, res) {
View
2 tests/s3-put-file-special-chars.js
@@ -18,7 +18,7 @@ s3.setBucket(process.env.AWS2JS_S3_BUCKET);
s3.putFile(path, './data/foo.txt', false, {
'content-type': 'text/plain',
'content-length': 4
-}, function (err, res) {
+}, function (err) {
callbacks.put++;
assert.ifError(err);
s3.get(path, 'buffer', function (err, res) {
View
6 tests/s3-put-files.js
@@ -28,7 +28,7 @@ var files = [
}
];
-s3.putFiles(files, false, {}, function (errors, results) {
+s3.putFiles(files, false, {}, function (errors) {
callbacks.put++;
var idx;
@@ -50,15 +50,15 @@ s3.putFiles(files, false, {}, function (errors, results) {
key: 'm_foo.png'
}
];
- s3.delMultiObjects(objects, function (err, res) {
+ s3.delMultiObjects(objects, function (err) {
assert.ifError(err);
callbacks.del++;
});
}
};
files.forEach(function (element, index) {
- s3.head(element.path, function (err, res) {
+ s3.head(element.path, function (err) {
callbacks['idx' + index]++;
assert.ifError(err);
headCount--;
View
2 tests/s3-put-pdf.js
@@ -15,7 +15,7 @@ var callbacks = {
s3.setCredentials(process.env.AWS_ACCEESS_KEY_ID, process.env.AWS_SECRET_ACCESS_KEY);
s3.setBucket(process.env.AWS2JS_S3_BUCKET);
-s3.putFile(path, './data/foo.pdf', false, {}, function (err, res) {
+s3.putFile(path, './data/foo.pdf', false, {}, function (err) {
callbacks.put++;
assert.ifError(err);
s3.head(path, function (err, res) {
View
2 tests/s3-put-png-with-manual-content-type.js
@@ -17,7 +17,7 @@ s3.setBucket(process.env.AWS2JS_S3_BUCKET);
s3.putFile(path, './data/foo.png', false, {
'content-type': 'image/png'
-}, function (err, res) {
+}, function (err) {
callbacks.put++;
assert.ifError(err);
s3.head(path, function (err, res) {
View
2 tests/s3-put-png.js
@@ -15,7 +15,7 @@ var callbacks = {
s3.setCredentials(process.env.AWS_ACCEESS_KEY_ID, process.env.AWS_SECRET_ACCESS_KEY);
s3.setBucket(process.env.AWS2JS_S3_BUCKET);
-s3.putFile(path, './data/foo.png', false, {}, function (err, res) {
+s3.putFile(path, './data/foo.png', false, {}, function (err) {
callbacks.put++;
assert.ifError(err);
s3.head(path, function (err, res) {
View
2 tests/s3-put-stream.js
@@ -17,7 +17,7 @@ var callbacks = {
s3.setCredentials(process.env.AWS_ACCEESS_KEY_ID, process.env.AWS_SECRET_ACCESS_KEY);
s3.setBucket(process.env.AWS2JS_S3_BUCKET);
-s3.putStream(path, stream, false, {'content-length': 4, 'content-type': 'text/plain'}, function (err, res) {
+s3.putStream(path, stream, false, {'content-length': 4, 'content-type': 'text/plain'}, function (err) {
callbacks.put++;
assert.ifError(err);
s3.get(path, 'buffer', function (err, res) {
View
4 tests/s3-signurl.js
@@ -18,7 +18,7 @@ var callbacks = {
s3.setCredentials(process.env.AWS_ACCEESS_KEY_ID, process.env.AWS_SECRET_ACCESS_KEY);
s3.setBucket(process.env.AWS2JS_S3_BUCKET);
-s3.putFile(path, './data/foo.png', false, {}, function (err, res) {
+s3.putFile(path, './data/foo.png', false, {}, function (err) {
callbacks.put++;
assert.ifError(err);
console.log('s3.putFile');
@@ -34,7 +34,7 @@ s3.putFile(path, './data/foo.png', false, {}, function (err, res) {
assert.deepEqual(res.headers['content-type'], 'image/png');
- http.head({url: 'https://s3.amazonaws.com' + '/' + s3.getBucket() + '/' + path}, function (err, res) {
+ http.head({url: 'https://s3.amazonaws.com' + '/' + s3.getBucket() + '/' + path}, function (err) {
callbacks.headFail++;
assert.ok(err instanceof Error);
assert.deepEqual(err.code, 403);
View
2 tests/s3-x-amz-date.js
@@ -18,7 +18,7 @@ s3.setBucket(process.env.AWS2JS_S3_BUCKET);
s3.putFile(path, './data/foo.png', false, {'x-amz-date': new Date().toUTCString()}, function (err, res) {
callbacks.put++;
assert.ifError(err);
- s3.head(path, function (err, res) {
+ s3.head(path, function (err) {
callbacks.head++;
assert.ifError(err);
assert.deepEqual(res['content-type'], 'image/png');
View
2 tools/lint.sh
@@ -7,7 +7,7 @@ function lint
then
npm -g install jslint
fi
- output=$(find $1 -name "*.js" -print0 | xargs -0 jslint --plusplus --white --var --goodparts --node | grep -v "is OK." | grep '[^[:space:]]')
+ output=$(find $1 -name "*.js" -print0 | xargs -0 jslint --plusplus --white --var --goodparts --todo --node | grep -v "is OK." | grep '[^[:space:]]')
exit=$?
echo "$output"
if [ $exit -eq 0 ]

0 comments on commit 278e6a0

Please sign in to comment.