Skip to content

Commit 2783245

Browse files
authored
refactor: clean code (#7542)
* add issue bot for prs * Update CHANGELOG.md * Update issue-bot.yml * reformat code
1 parent 6ad3e6f commit 2783245

File tree

3 files changed

+23
-17
lines changed

3 files changed

+23
-17
lines changed

src/Routers/SecurityRouter.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ import CheckRunner from '../Security/CheckRunner';
44

55
export class SecurityRouter extends PromiseRouter {
66
mountRoutes() {
7-
this.route('GET', '/security',
7+
this.route(
8+
'GET',
9+
'/security',
810
middleware.promiseEnforceMasterKeyAccess,
911
this._enforceSecurityCheckEnabled,
10-
async (req) => {
12+
async req => {
1113
const report = await new CheckRunner(req.config.security).run();
1214
return {
1315
status: 200,

src/Security/Check.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@ class Check {
7373
* The check state.
7474
*/
7575
const CheckState = Object.freeze({
76-
none: "none",
77-
fail: "fail",
78-
success: "success",
76+
none: 'none',
77+
fail: 'fail',
78+
success: 'success',
7979
});
8080

8181
export default Check;

src/Security/CheckRunner.js

+16-12
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class CheckRunner {
4646

4747
// If report should be written to logs
4848
if (this.enableCheckLog) {
49-
this._logReport(report)
49+
this._logReport(report);
5050
}
5151
return report;
5252
}
@@ -85,8 +85,8 @@ class CheckRunner {
8585
report: {
8686
version,
8787
state: CheckState.success,
88-
groups: []
89-
}
88+
groups: [],
89+
},
9090
};
9191

9292
// Identify report version
@@ -95,13 +95,12 @@ class CheckRunner {
9595
default:
9696
// For each check group
9797
for (const group of groups) {
98-
9998
// Create group report
10099
const groupReport = {
101100
name: group.name(),
102101
state: CheckState.success,
103102
checks: [],
104-
}
103+
};
105104

106105
// Create check reports
107106
groupReport.checks = group.checks().map(check => {
@@ -129,9 +128,9 @@ class CheckRunner {
129128
* @param {Object} report The report to log.
130129
*/
131130
_logReport(report) {
132-
133131
// Determine log level depending on whether any check failed
134-
const log = report.report.state == CheckState.success ? (s) => logger.info(s) : (s) => logger.warn(s);
132+
const log =
133+
report.report.state == CheckState.success ? s => logger.info(s) : s => logger.warn(s);
135134

136135
// Declare output
137136
const indent = ' ';
@@ -142,7 +141,7 @@ class CheckRunner {
142141

143142
// Traverse all groups and checks for compose output
144143
for (const group of report.report.groups) {
145-
output += `\n- ${group.name}`
144+
output += `\n- ${group.name}`;
146145

147146
for (const check of group.checks) {
148147
checksCount++;
@@ -166,7 +165,9 @@ class CheckRunner {
166165
`\n# #` +
167166
`\n###################################` +
168167
`\n` +
169-
`\n${failedChecksCount > 0 ? 'Warning: ' : ''}${failedChecksCount} weak security setting(s) found${failedChecksCount > 0 ? '!' : ''}` +
168+
`\n${
169+
failedChecksCount > 0 ? 'Warning: ' : ''
170+
}${failedChecksCount} weak security setting(s) found${failedChecksCount > 0 ? '!' : ''}` +
170171
`\n${checksCount} check(s) executed` +
171172
`\n${skippedCheckCount} check(s) skipped` +
172173
`\n` +
@@ -183,9 +184,12 @@ class CheckRunner {
183184
*/
184185
_getLogIconForState(state) {
185186
switch (state) {
186-
case CheckState.success: return '✅';
187-
case CheckState.fail: return '❌';
188-
default: return 'ℹ️';
187+
case CheckState.success:
188+
return '✅';
189+
case CheckState.fail:
190+
return '❌';
191+
default:
192+
return 'ℹ️';
189193
}
190194
}
191195

0 commit comments

Comments
 (0)