Skip to content

Commit

Permalink
refactor: Fix simpler code structure/linting issues
Browse files Browse the repository at this point in the history
Fixes #761
  • Loading branch information
mountaindude committed Aug 21, 2023
1 parent a0761cb commit c24c446
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/lib/msteams_notification.js
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ function sendReloadTaskFailureNotificationTeams(reloadParams) {
scriptLogData.scriptLogHeadCount = globals.config.get('Butler.teamsNotification.reloadTaskFailure.headScriptLogLines');
scriptLogData.scriptLogTailCount = globals.config.get('Butler.teamsNotification.reloadTaskFailure.tailScriptLogLines');

scriptLogData.scriptLogHead = scriptLogData.scriptLogFull.slice(0, scriptLogData.scriptLogHeadCount).join('\r\n');;
scriptLogData.scriptLogHead = scriptLogData.scriptLogFull.slice(0, scriptLogData.scriptLogHeadCount).join('\r\n');
scriptLogData.scriptLogTail = scriptLogData.scriptLogFull
.slice(Math.max(scriptLogData.scriptLogFull.length - scriptLogData.scriptLogTailCount, 0))
.join('\r\n');
Expand Down Expand Up @@ -573,7 +573,7 @@ function sendReloadTaskAbortedNotificationTeams(reloadParams) {
scriptLogData.scriptLogHeadCount = globals.config.get('Butler.teamsNotification.reloadTaskAborted.headScriptLogLines');
scriptLogData.scriptLogTailCount = globals.config.get('Butler.teamsNotification.reloadTaskAborted.tailScriptLogLines');

scriptLogData.scriptLogHead = scriptLogData.scriptLogFull.slice(0, scriptLogData.scriptLogHeadCount).join('\r\n');;
scriptLogData.scriptLogHead = scriptLogData.scriptLogFull.slice(0, scriptLogData.scriptLogHeadCount).join('\r\n');
scriptLogData.scriptLogTail = scriptLogData.scriptLogFull
.slice(Math.max(scriptLogData.scriptLogFull.length - scriptLogData.scriptLogTailCount, 0))
.join('\r\n');
Expand Down
1 change: 1 addition & 0 deletions src/lib/scriptlog.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ function compareTaskDetails(a, b) {
return 0;
}

// eslint-disable-next-line no-unused-vars
function delay(milliseconds) {
return new Promise((resolve) => {
setTimeout(resolve, milliseconds);
Expand Down
1 change: 0 additions & 1 deletion src/lib/slack_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ async function slackSend(slackConfig, logger) {

const res = await axios.post(slackConfig.webhookUrl, JSON.stringify(body));
logger.debug(`SLACKSEND: Result from POST to Slack webhook: ${res.statusText} (${res.status}): ${res.data}`);
return res;
} catch (err) {
logger.error(`SLACKSEND: ${err}"`);
}
Expand Down
4 changes: 2 additions & 2 deletions src/lib/smtp.js
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ async function sendReloadTaskFailureNotificationEmail(reloadParams) {
scriptLogData.scriptLogHeadCount = globals.config.get('Butler.emailNotification.reloadTaskFailure.headScriptLogLines');
scriptLogData.scriptLogTailCount = globals.config.get('Butler.emailNotification.reloadTaskFailure.tailScriptLogLines');

scriptLogData.scriptLogHead = scriptLogData.scriptLogFull.slice(0, scriptLogData.scriptLogHeadCount).join('\r\n');;
scriptLogData.scriptLogHead = scriptLogData.scriptLogFull.slice(0, scriptLogData.scriptLogHeadCount).join('\r\n');
scriptLogData.scriptLogTail = scriptLogData.scriptLogFull
.slice(Math.max(scriptLogData.scriptLogFull.length - scriptLogData.scriptLogTailCount, 0))
.join('\r\n');
Expand Down Expand Up @@ -723,7 +723,7 @@ async function sendReloadTaskAbortedNotificationEmail(reloadParams) {
scriptLogData.scriptLogHeadCount = globals.config.get('Butler.emailNotification.reloadTaskAborted.headScriptLogLines');
scriptLogData.scriptLogTailCount = globals.config.get('Butler.emailNotification.reloadTaskAborted.tailScriptLogLines');

scriptLogData.scriptLogHead = scriptLogData.scriptLogFull.slice(0, scriptLogData.scriptLogHeadCount).join('\r\n');;
scriptLogData.scriptLogHead = scriptLogData.scriptLogFull.slice(0, scriptLogData.scriptLogHeadCount).join('\r\n');
scriptLogData.scriptLogTail = scriptLogData.scriptLogFull
.slice(Math.max(scriptLogData.scriptLogFull.length - scriptLogData.scriptLogTailCount, 0))
.join('\r\n');
Expand Down
4 changes: 3 additions & 1 deletion src/lib/winsvc.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,12 @@ function exists(serviceName, host = null) {
// On success, check
(allServices) => {
// Find provided name
for (let i = 0; i < allServices.length; i++) {
for (let i = 0; i < allServices.length; ) {
if (allServices[i] === serviceName) {
resolve(true);
}

i += 1;
}

// Not found, resolve false
Expand Down
3 changes: 2 additions & 1 deletion src/plugins/sensible.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ const fp = require('fastify-plugin');
*
* @see https://github.com/fastify/fastify-sensible
*/
module.exports = fp(async (fastify, opts) => {
// eslint-disable-next-line no-unused-vars
module.exports = fp(async (fastify, _opts) => {
// eslint-disable-next-line global-require
await fastify.register(require('@fastify/sensible'), {
errorHandler: false,
Expand Down
3 changes: 2 additions & 1 deletion src/plugins/support.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ const fp = require('fastify-plugin');
// the use of fastify-plugin is required to be able
// to export the decorators to the outer scope

module.exports = fp(async (fastify, opts) => {
// eslint-disable-next-line no-unused-vars
module.exports = fp(async (fastify, _opts) => {
// eslint-disable-next-line arrow-body-style
fastify.decorate('someSupport', () => {
return 'hugs';
Expand Down
1 change: 0 additions & 1 deletion src/udp/udp_handlers.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Load global variables and functions
const globals = require('../globals');
const QrsInteract = require('qrs-interact');
const smtp = require('../lib/smtp');
const slack = require('../lib/slack_notification');
const webhookOut = require('../lib/webhook_notification');
Expand Down

0 comments on commit c24c446

Please sign in to comment.