Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore: Fix Sonar Audit #72

Merged
merged 2 commits into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions processor/src/commercetools/action.commercetools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ export const setCustomFields = (fieldName: string, fieldValue: string) => {
*/
export const addInterfaceInteraction = (params: CreateInterfaceInteractionParams) => {
const { sctm_action_type, sctm_request, sctm_response, sctm_id, sctm_created_at } = params;
const interfaceInteractionId = sctm_id ? sctm_id : uuid();
const interfaceInteractionTimestamp = sctm_created_at ? sctm_created_at : createDateNowString();
const interfaceInteractionId = sctm_id || uuid();
const interfaceInteractionTimestamp = sctm_created_at || createDateNowString();

return {
action: 'addInterfaceInteraction',
Expand Down
6 changes: 3 additions & 3 deletions processor/src/utils/app.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export function parseStringToJsonObject(
try {
return JSON.parse(targetedString);
} catch {
const errorMessage = `${errorPrefix ? errorPrefix : 'SCTM - PAYMENT PROCESSING'} - Failed to parse the JSON string from the custom field ${fieldName}.`;
const errorMessage = `${errorPrefix || 'SCTM - PAYMENT PROCESSING'} - Failed to parse the JSON string from the custom field ${fieldName}.`;
logger.error(errorMessage, {
commerceToolsId: commerceToolsId,
});
Expand All @@ -48,10 +48,10 @@ export function parseStringToJsonObject(
* @return {object} - The object with empty properties removed.
*/
export function removeEmptyProperties(obj: object) {
const clonedObject: { [key: string]: any } = Object.assign({}, obj);
const clonedObject: { [key: string]: any } = { ...obj };

for (const key in clonedObject) {
if (Object.prototype.hasOwnProperty.call(clonedObject, key)) {
if (Object.hasOwn(clonedObject, key)) {
const value = clonedObject[key];

if (
Expand Down
2 changes: 1 addition & 1 deletion processor/src/utils/mollie.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export const calculateDueDate = (input?: string): string => {
input = DEFAULT_DUE_DATE + 'd';
}

const match = input.match(DUE_DATE_PATTERN);
const match = DUE_DATE_PATTERN.exec(input);

if (match) {
const days = parseInt(match[1]);
Expand Down