From cd542e76bc554002e7c669cc98075fbae2f5e0d6 Mon Sep 17 00:00:00 2001 From: michaelawyu Date: Wed, 7 Mar 2018 15:20:17 -0800 Subject: [PATCH] Lint --- functions/imagemagick/index.js | 8 ++++---- functions/imagemagick/test/index.test.js | 26 ++++++++++++------------ 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/functions/imagemagick/index.js b/functions/imagemagick/index.js index 7b3940bbcb0..bd09affdc3c 100644 --- a/functions/imagemagick/index.js +++ b/functions/imagemagick/index.js @@ -41,18 +41,18 @@ exports.blurOffensiveImages = (event) => { } const file = storage.bucket(object.bucket).file(object.name); - const file_uri = `gs://${object.bucket}/${object.name}`; + const fileUri = `gs://${object.bucket}/${object.name}`; console.log(`Analyzing ${file.name}.`); - return client.safeSearchDetection(file_uri) + return client.safeSearchDetection(fileUri) .catch((err) => { console.error(`Failed to analyze ${file.name}.`, err); return Promise.reject(err); }) .then(([result]) => { - if (result.safeSearchAnnotation.adult == 'VERY_LIKELY' || - result.safeSearchAnnotation.violence == 'VERY_LIKELY') { + if (result.safeSearchAnnotation.adult === 'VERY_LIKELY' || + result.safeSearchAnnotation.violence === 'VERY_LIKELY') { console.log(`The image ${file.name} has been detected as inappropriate.`); return blurImage(file, result); } else { diff --git a/functions/imagemagick/test/index.test.js b/functions/imagemagick/test/index.test.js index a67814f1899..2bc757f270f 100644 --- a/functions/imagemagick/test/index.test.js +++ b/functions/imagemagick/test/index.test.js @@ -42,20 +42,20 @@ function getSample (filename) { bucket: sinon.stub().returns(bucket) }; const StorageMock = sinon.stub().returns(storageMock); - var safeSearchDetectionStub = sinon.stub() + var safeSearchDetectionStub = sinon.stub(); safeSearchDetectionStub.withArgs(`gs://${bucketName}/${safeFilename}`).returns(Promise.resolve([{ - safeSearchAnnotation: { - adult: 'VERY_LIKELY', - violence: 'VERY_LIKELY' - } + safeSearchAnnotation: { + adult: 'VERY_LIKELY', + violence: 'VERY_LIKELY' + } }])); safeSearchDetectionStub.withArgs(`gs://${bucketName}/${unsafeFilename}`).returns(Promise.resolve([{ - safeSearchAnnotation: { - adult: 'VERY_UNLIKELY', - violence: 'VERY_UNLIKELY' - } + safeSearchAnnotation: { + adult: 'VERY_UNLIKELY', + violence: 'VERY_UNLIKELY' + } }])); - var imageAnnotatorClientStub = sinon.stub(vision, "ImageAnnotatorClient"); + var imageAnnotatorClientStub = sinon.stub(vision, 'ImageAnnotatorClient'); imageAnnotatorClientStub.returns({ safeSearchDetection: safeSearchDetectionStub }); @@ -84,7 +84,7 @@ function getSample (filename) { test.beforeEach(tools.stubConsole); test.afterEach.always(tools.restoreConsole); -test.afterEach.always(function() { +test.afterEach.always(function () { vision.ImageAnnotatorClient.restore(); }); @@ -114,9 +114,9 @@ test.serial(`blurOffensiveImages blurs images`, async (t) => { test.serial(`blurOffensiveImages ignores safe images`, async (t) => { const sample = getSample(unsafeFilename); await sample.program.blurOffensiveImages({ - data: { + data: { bucket: bucketName, - name: unsafeFilename + name: unsafeFilename } }); t.is(console.log.callCount, 2);