Skip to content

Commit

Permalink
update linter rules and fix linter violations
Browse files Browse the repository at this point in the history
  • Loading branch information
JDragovichAlertLogic committed Mar 25, 2019
1 parent e02e012 commit a5a2c42
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 21 deletions.
15 changes: 13 additions & 2 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
{
"eqeqeq": true,
"esversion": 6,
"mocha": true,
"node": true
"shadow": "outer",
"undef": true,
"unused": "vars",
"node": true,
"predef": [
"it",
"describe",
"before",
"after",
"beforeEach",
"afterEach"
],
"mocha": true
}
20 changes: 10 additions & 10 deletions al_log.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const PAYLOAD_BATCH_SIZE = 700000;
* For an AWS Lambda via kinesis trigger batch size configuration.
*/

var buildPayload = function (hostId, sourceId, hostmetaElems, content, parseCallback, callback) {
var buildPayload = function (hostId, sourceId, hostmetaElems, content, parseCallback, mainCallback) {
async.waterfall([
function(callback) {
buildMessages(content, parseCallback, function(err, msg) {
Expand Down Expand Up @@ -86,17 +86,17 @@ var buildPayload = function (hostId, sourceId, hostmetaElems, content, parseCall
}],
function(err, result) {
if (err) {
return callback(err);
return mainCallback(err);
} else {
zlib.deflate(result, function(err, compressed) {
if (err) {
return callback(err);
zlib.deflate(result, function(defalteErr, compressed) {
if (defalteErr) {
return mainCallback(defalteErr);
} else {
var payloadSize = compressed.byteLength;
if (payloadSize > PAYLOAD_BATCH_SIZE) {
return callback(`Maximum payload size exceeded: ${payloadSize}`, compressed);
return mainCallback(`Maximum payload size exceeded: ${payloadSize}`, compressed);
} else {
return callback(null, compressed);
return mainCallback(null, compressed);
}
}
});
Expand Down Expand Up @@ -189,15 +189,15 @@ function buildHostmeta(hostId, hostmetaElems, callback) {
*/

function buildMessages(content, parseContentFun, callback) {
async.reduce(content, [], function(memo, item, callback) {
async.reduce(content, [], function(memo, item, asyncCallback) {
var messageType = commonProtoPb.collected_message;
var messagePayload = parseContentFun(item);
buildType(messageType, messagePayload, function(err, buf) {
if (err) {
return callback(err);
return asyncCallback(err);
} else {
memo.push(buf);
return callback(err, memo);
return asyncCallback(err, memo);
}
});
},
Expand Down
18 changes: 9 additions & 9 deletions test/aimsc_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ describe('Unit Tests', function() {
var aimsc = new AimsC(m_alMock.AL_API, m_alMock.AIMS_CREDS);
assert.equal(aimsc.cid, null);
aimsc.authenticate()
.then(resp => {
.then(() => {
assert.equal(aimsc.cid, m_alMock.CID);
done();
});
Expand All @@ -86,21 +86,21 @@ describe('Unit Tests', function() {
assert_cache(aimsc, false, false);
assert.equal(aimsc.cid, undefined);
aimsc.authenticate()
.then(resp => {
.then(() => {
sinon.assert.calledWith(fakeRest,
'/aims/v1/authenticate', m_alMock.AIMS_AUTH
);
tk.travel(BEFORE_EXPIRED);
assert_cache(aimsc, true, true);
assert.equal(aimsc.cid, m_alMock.CID);
aimsc.authenticate()
.then(resp => {
.then(() => {
sinon.assert.callCount(fakeRest, 1);
tk.travel(AFTER_EXPIRED);
assert_cache(aimsc, false, false);
assert.equal(aimsc.cid, m_alMock.CID);
aimsc.authenticate()
.then(resp => {
.then(() => {
sinon.assert.callCount(fakeRest, 2);
assert_cache(aimsc, true, true);
assert.equal(aimsc.cid, m_alMock.CID);
Expand All @@ -116,7 +116,7 @@ describe('Unit Tests', function() {
assert_cache(aimsc1, false, false);
assert.equal(aimsc1.cid, undefined);
aimsc1.authenticate()
.then(resp => {
.then(() => {
sinon.assert.calledWith(fakeRest,
'/aims/v1/authenticate', m_alMock.AIMS_AUTH
);
Expand All @@ -127,7 +127,7 @@ describe('Unit Tests', function() {
assert.equal(aimsc1.cid, m_alMock.CID);
assert.equal(aimsc2.cid, m_alMock.CID);
aimsc2.authenticate()
.then(resp => {
.then(() => {
sinon.assert.callCount(fakeRest, 1);
assert_cache(aimsc2, true, true);
assert.equal(aimsc2.cid, m_alMock.CID);
Expand All @@ -137,7 +137,7 @@ describe('Unit Tests', function() {
assert_cache(aimsc3, false, false);
assert.equal(aimsc3.cid, undefined);
aimsc3.authenticate()
.then(resp => {
.then(() => {
sinon.assert.callCount(fakeRest, 2);
assert_cache(aimsc2, false, true);
assert_cache(aimsc3, true, true);
Expand All @@ -153,15 +153,15 @@ describe('Unit Tests', function() {
var aimsc1 = new AimsC(m_alMock.AL_API, m_alMock.AIMS_CREDS);
assert_cache(aimsc1, false, false);
aimsc1.authenticate()
.then(resp => {
.then(() => {
tk.travel(BEFORE_EXPIRED);
assert_cache(aimsc1, true, true);
malform_cache_file(m_alMock.CACHE_FILENAME);
var aimsc2 = new AimsC(m_alMock.AL_API, m_alMock.AIMS_CREDS);
assert_cache(aimsc1, true, false);
assert_cache(aimsc2, false, false);
aimsc2.authenticate()
.then(resp => {
.then(() => {
sinon.assert.callCount(fakeRest, 2);
assert_cache(aimsc1, true, true);
assert_cache(aimsc2, true, true);
Expand Down

0 comments on commit a5a2c42

Please sign in to comment.