Skip to content

Commit 55a06c2

Browse files
committed
refactor: Refactor of code smells
1 parent 504a0f3 commit 55a06c2

File tree

2 files changed

+8
-15
lines changed

2 files changed

+8
-15
lines changed

nodejs-functions/src/handlers/automatic-clock-outs/clock_out.js

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@ const SlackClient = require('./slack_client');
88
const { CLOCK_OUT_MESSAGE, CLOCK_OUT_MESSAGE_MIDNIGHT } = require('./constants');
99

1010
const doClockOut = async (context) => {
11-
context.log(
12-
`I am going to check how many entries were not clocked out ${new Date()}`
13-
);
11+
context.log(`I am going to check how many entries were not clocked out ${new Date()}`);
1412

1513
const { endpoint, key, databaseId } = config;
1614
const client = new CosmosClient({ endpoint, key });
@@ -52,21 +50,17 @@ const doClockOut = async (context) => {
5250
})
5351
);
5452

55-
context.log(
56-
`I just clocked out ${totalClockOutsExecuted} entries, thanks are not needed...`
57-
);
53+
context.log(`I just clocked out ${totalClockOutsExecuted} entries, thanks are not needed...`);
5854
};
5955

6056
const findUserData = (users, id) => {
61-
const user = users.find((user) => user.id === id);
62-
return user
63-
? { userName: user.name.split(' ')[0], userEmail: user.email }
64-
: {};
57+
const targetUser = users.find((user) => user.id === id);
58+
return targetUser ? { userName: targetUser.name.split(' ')[0], userEmail: targetUser.email } : {};
6559
};
6660

6761
const findSlackUserId = (slackUsers, email) => {
68-
const user = slackUsers.find((slackUser) => slackUser.email === email);
69-
return user ? user.id : null;
62+
const slackTargetUser = slackUsers.find((slackUser) => slackUser.email === email);
63+
return slackTargetUser ? slackTargetUser.id : null;
7064
};
7165

7266
module.exports = { doClockOut };

nodejs-functions/src/handlers/automatic-clock-outs/msal_client.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ const getToken = async () => {
2121
},
2222
};
2323

24-
return await axios
25-
.post(endpoint, params, headers)
24+
return axios.post(endpoint, params, headers)
2625
.then((result) => {
2726
return result.data.access_token;
2827
})
@@ -41,7 +40,7 @@ const findUsersInMS = async () => {
4140
},
4241
};
4342

44-
return await axios.get(`${endpoint}/users`, headers);
43+
return axios.get(`${endpoint}/users`, headers);
4544
};
4645

4746
module.exports = { findUsersInMS };

0 commit comments

Comments
 (0)