From 43cab1fddcce601b1011cb8a37743dd283bc1480 Mon Sep 17 00:00:00 2001 From: Brian Gough Date: Tue, 3 Aug 2021 10:08:17 +0100 Subject: [PATCH 1/3] remove unnecessary returns and callbacks --- .../acceptance/js/helpers/DocstoreClient.js | 46 +++---------------- 1 file changed, 6 insertions(+), 40 deletions(-) diff --git a/services/docstore/test/acceptance/js/helpers/DocstoreClient.js b/services/docstore/test/acceptance/js/helpers/DocstoreClient.js index 1af9f10ce7..7bd6bd6618 100644 --- a/services/docstore/test/acceptance/js/helpers/DocstoreClient.js +++ b/services/docstore/test/acceptance/js/helpers/DocstoreClient.js @@ -1,16 +1,6 @@ /* eslint-disable camelcase, - handle-callback-err, - no-unused-vars, */ -// TODO: This file was created by bulk-decaffeinate. -// Fix any style issues and re-enable lint. -/* - * decaffeinate suggestions: - * DS102: Remove unnecessary code created because of implicit returns - * DS207: Consider shorter variations of null checks - * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md - */ let DocstoreClient const request = require('request').defaults({ jar: false }) const settings = require('@overleaf/settings') @@ -33,9 +23,6 @@ async function getStringFromPersistor(persistor, bucket, key) { module.exports = DocstoreClient = { createDoc(project_id, doc_id, lines, version, ranges, callback) { - if (callback == null) { - callback = function (error) {} - } return DocstoreClient.updateDoc( project_id, doc_id, @@ -47,10 +34,7 @@ module.exports = DocstoreClient = { }, getDoc(project_id, doc_id, qs, callback) { - if (callback == null) { - callback = function (error, res, body) {} - } - return request.get( + request.get( { url: `http://localhost:${settings.internal.docstore.port}/project/${project_id}/doc/${doc_id}`, json: true, @@ -82,10 +66,7 @@ module.exports = DocstoreClient = { }, getAllDocs(project_id, callback) { - if (callback == null) { - callback = function (error, res, body) {} - } - return request.get( + request.get( { url: `http://localhost:${settings.internal.docstore.port}/project/${project_id}/doc`, json: true, @@ -113,10 +94,7 @@ module.exports = DocstoreClient = { }, getAllRanges(project_id, callback) { - if (callback == null) { - callback = function (error, res, body) {} - } - return request.get( + request.get( { url: `http://localhost:${settings.internal.docstore.port}/project/${project_id}/ranges`, json: true, @@ -126,9 +104,6 @@ module.exports = DocstoreClient = { }, updateDoc(project_id, doc_id, lines, version, ranges, callback) { - if (callback == null) { - callback = function (error, res, body) {} - } return request.post( { url: `http://localhost:${settings.internal.docstore.port}/project/${project_id}/doc/${doc_id}`, @@ -183,10 +158,7 @@ module.exports = DocstoreClient = { }, archiveAllDoc(project_id, callback) { - if (callback == null) { - callback = function (error, res, body) {} - } - return request.post( + request.post( { url: `http://localhost:${settings.internal.docstore.port}/project/${project_id}/archive`, }, @@ -195,10 +167,7 @@ module.exports = DocstoreClient = { }, archiveDocById(project_id, doc_id, callback) { - if (callback == null) { - callback = function (error, res, body) {} - } - return request.post( + request.post( { url: `http://localhost:${settings.internal.docstore.port}/project/${project_id}/doc/${doc_id}/archive`, }, @@ -207,10 +176,7 @@ module.exports = DocstoreClient = { }, destroyAllDoc(project_id, callback) { - if (callback == null) { - callback = function (error, res, body) {} - } - return request.post( + request.post( { url: `http://localhost:${settings.internal.docstore.port}/project/${project_id}/destroy`, }, From 9a14d015170e264710becdfebcbd20a85fca70ba Mon Sep 17 00:00:00 2001 From: Brian Gough Date: Tue, 3 Aug 2021 10:12:00 +0100 Subject: [PATCH 2/3] remove decaff headers --- .../test/acceptance/js/helpers/DocstoreApp.js | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/services/docstore/test/acceptance/js/helpers/DocstoreApp.js b/services/docstore/test/acceptance/js/helpers/DocstoreApp.js index 4a45a7e6d6..dd63eeb211 100644 --- a/services/docstore/test/acceptance/js/helpers/DocstoreApp.js +++ b/services/docstore/test/acceptance/js/helpers/DocstoreApp.js @@ -1,16 +1,3 @@ -/* eslint-disable - handle-callback-err, -*/ -// TODO: This file was created by bulk-decaffeinate. -// Fix any style issues and re-enable lint. -/* - * decaffeinate suggestions: - * DS101: Remove unnecessary use of Array.from - * DS102: Remove unnecessary code created because of implicit returns - * DS205: Consider reworking code to avoid use of IIFEs - * DS207: Consider shorter variations of null checks - * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md - */ const app = require('../../../../app') const { waitForDb } = require('../../../../app/js/mongodb') require('logger-sharelatex').logger.level('error') From 9c50a2488fdb5d1fb8cdc60d1a8f86331910f830 Mon Sep 17 00:00:00 2001 From: Brian Gough Date: Tue, 3 Aug 2021 10:12:16 +0100 Subject: [PATCH 3/3] remove decaff headers, fix camelcase --- .../acceptance/js/helpers/DocstoreClient.js | 75 +++++++++---------- 1 file changed, 36 insertions(+), 39 deletions(-) diff --git a/services/docstore/test/acceptance/js/helpers/DocstoreClient.js b/services/docstore/test/acceptance/js/helpers/DocstoreClient.js index 7bd6bd6618..e2c2706fbc 100644 --- a/services/docstore/test/acceptance/js/helpers/DocstoreClient.js +++ b/services/docstore/test/acceptance/js/helpers/DocstoreClient.js @@ -1,6 +1,3 @@ -/* eslint-disable - camelcase, -*/ let DocstoreClient const request = require('request').defaults({ jar: false }) const settings = require('@overleaf/settings') @@ -22,10 +19,10 @@ async function getStringFromPersistor(persistor, bucket, key) { } module.exports = DocstoreClient = { - createDoc(project_id, doc_id, lines, version, ranges, callback) { + createDoc(projectId, docId, lines, version, ranges, callback) { return DocstoreClient.updateDoc( - project_id, - doc_id, + projectId, + docId, lines, version, ranges, @@ -33,10 +30,10 @@ module.exports = DocstoreClient = { ) }, - getDoc(project_id, doc_id, qs, callback) { + getDoc(projectId, docId, qs, callback) { request.get( { - url: `http://localhost:${settings.internal.docstore.port}/project/${project_id}/doc/${doc_id}`, + url: `http://localhost:${settings.internal.docstore.port}/project/${projectId}/doc/${docId}`, json: true, qs, }, @@ -44,10 +41,10 @@ module.exports = DocstoreClient = { ) }, - peekDoc(project_id, doc_id, qs, callback) { + peekDoc(projectId, docId, qs, callback) { request.get( { - url: `http://localhost:${settings.internal.docstore.port}/project/${project_id}/doc/${doc_id}/peek`, + url: `http://localhost:${settings.internal.docstore.port}/project/${projectId}/doc/${docId}/peek`, json: true, qs, }, @@ -55,20 +52,20 @@ module.exports = DocstoreClient = { ) }, - isDocDeleted(project_id, doc_id, callback) { + isDocDeleted(projectId, docId, callback) { request.get( { - url: `http://localhost:${settings.internal.docstore.port}/project/${project_id}/doc/${doc_id}/deleted`, + url: `http://localhost:${settings.internal.docstore.port}/project/${projectId}/doc/${docId}/deleted`, json: true, }, callback ) }, - getAllDocs(project_id, callback) { + getAllDocs(projectId, callback) { request.get( { - url: `http://localhost:${settings.internal.docstore.port}/project/${project_id}/doc`, + url: `http://localhost:${settings.internal.docstore.port}/project/${projectId}/doc`, json: true, }, (req, res, body) => { @@ -77,10 +74,10 @@ module.exports = DocstoreClient = { ) }, - getAllDeletedDocs(project_id, callback) { + getAllDeletedDocs(projectId, callback) { request.get( { - url: `http://localhost:${settings.internal.docstore.port}/project/${project_id}/doc-deleted`, + url: `http://localhost:${settings.internal.docstore.port}/project/${projectId}/doc-deleted`, json: true, }, (error, res, body) => { @@ -93,20 +90,20 @@ module.exports = DocstoreClient = { ) }, - getAllRanges(project_id, callback) { + getAllRanges(projectId, callback) { request.get( { - url: `http://localhost:${settings.internal.docstore.port}/project/${project_id}/ranges`, + url: `http://localhost:${settings.internal.docstore.port}/project/${projectId}/ranges`, json: true, }, callback ) }, - updateDoc(project_id, doc_id, lines, version, ranges, callback) { + updateDoc(projectId, docId, lines, version, ranges, callback) { return request.post( { - url: `http://localhost:${settings.internal.docstore.port}/project/${project_id}/doc/${doc_id}`, + url: `http://localhost:${settings.internal.docstore.port}/project/${projectId}/doc/${docId}`, json: { lines, version, @@ -117,78 +114,78 @@ module.exports = DocstoreClient = { ) }, - deleteDoc(project_id, doc_id, callback) { + deleteDoc(projectId, docId, callback) { DocstoreClient.deleteDocWithDateAndName( - project_id, - doc_id, + projectId, + docId, new Date(), 'main.tex', callback ) }, - deleteDocWithDate(project_id, doc_id, date, callback) { + deleteDocWithDate(projectId, docId, date, callback) { DocstoreClient.deleteDocWithDateAndName( - project_id, - doc_id, + projectId, + docId, date, 'main.tex', callback ) }, - deleteDocWithName(project_id, doc_id, name, callback) { + deleteDocWithName(projectId, docId, name, callback) { DocstoreClient.deleteDocWithDateAndName( - project_id, - doc_id, + projectId, + docId, new Date(), name, callback ) }, - deleteDocWithDateAndName(project_id, doc_id, deletedAt, name, callback) { + deleteDocWithDateAndName(projectId, docId, deletedAt, name, callback) { request.patch( { - url: `http://localhost:${settings.internal.docstore.port}/project/${project_id}/doc/${doc_id}`, + url: `http://localhost:${settings.internal.docstore.port}/project/${projectId}/doc/${docId}`, json: { name, deleted: true, deletedAt }, }, callback ) }, - archiveAllDoc(project_id, callback) { + archiveAllDoc(projectId, callback) { request.post( { - url: `http://localhost:${settings.internal.docstore.port}/project/${project_id}/archive`, + url: `http://localhost:${settings.internal.docstore.port}/project/${projectId}/archive`, }, callback ) }, - archiveDocById(project_id, doc_id, callback) { + archiveDocById(projectId, docId, callback) { request.post( { - url: `http://localhost:${settings.internal.docstore.port}/project/${project_id}/doc/${doc_id}/archive`, + url: `http://localhost:${settings.internal.docstore.port}/project/${projectId}/doc/${docId}/archive`, }, callback ) }, - destroyAllDoc(project_id, callback) { + destroyAllDoc(projectId, callback) { request.post( { - url: `http://localhost:${settings.internal.docstore.port}/project/${project_id}/destroy`, + url: `http://localhost:${settings.internal.docstore.port}/project/${projectId}/destroy`, }, callback ) }, - getS3Doc(project_id, doc_id, callback) { + getS3Doc(projectId, docId, callback) { getStringFromPersistor( Persistor, settings.docstore.bucket, - `${project_id}/${doc_id}` + `${projectId}/${docId}` ) .then(data => { callback(null, JSON.parse(data))