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

fix: standardize custom fields for policy check #3324

Merged
merged 3 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
7 changes: 3 additions & 4 deletions src/app/fyle/add-edit-expense/add-edit-expense.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3518,14 +3518,13 @@ export class AddEditExpensePage implements OnInit {
const isAdvanceWalletEnabled = res.orgSettings?.advances?.advance_wallets_enabled;
let customProperties = res.customProperties;
customProperties = customProperties.map((customProperty) => {
if (!customProperty.value) {
customProperty = this.customFieldsService.setDefaultValue(customProperty, customProperty.type);
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Aye aye aye! Reassigning function parameter is not the style.

Macha, reassigning function parameter is like changing the climax of the movie at the last minute. Audience will feel cheated, no?

Use a local variable instead and give a satisfying ending.

Apply this diff to fix the issue:

-          if (!customProperty.value) {
-            customProperty = this.customFieldsService.setDefaultValue(customProperty, customProperty.type);
-          }
+          let updatedCustomProperty = customProperty;
+          if (!customProperty.value) {
+            updatedCustomProperty = this.customFieldsService.setDefaultValue(customProperty, customProperty.type);
+          }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (!customProperty.value) {
customProperty = this.customFieldsService.setDefaultValue(customProperty, customProperty.type);
}
let updatedCustomProperty = customProperty;
if (!customProperty.value) {
updatedCustomProperty = this.customFieldsService.setDefaultValue(customProperty, customProperty.type);
}
🧰 Tools
🪛 Biome (1.9.4)

[error] 3522-3522: Reassigning a function parameter is confusing.

The parameter is declared here:

Use a local variable instead.

(lint/style/noParameterAssign)

if (customProperty.type === 'DATE') {
customProperty.value = customProperty.value
? this.dateService.getUTCDate(new Date(customProperty.value as string))
: null;
} else if (customProperty.type === 'LOCATION' && !customProperty.value) {
customProperty.value = {};
} else if (customProperty.type === 'BOOLEAN' && !customProperty.value) {
customProperty.value = false;
}
return customProperty;
});
Expand Down
3 changes: 3 additions & 0 deletions src/app/fyle/add-edit-mileage/add-edit-mileage.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2415,6 +2415,9 @@ export class AddEditMileagePage implements OnInit {
const formValue = this.getFormValues();
let customProperties = res.customProperties;
customProperties = customProperties?.map((customProperty) => {
if (!customProperty.value) {
customProperty = this.customFieldsService.setDefaultValue(customProperty, customProperty.type);
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Tch tch tch! Reassigning function parameter is not the way to go.

Macha, reassigning function parameter is like changing the hero of the movie halfway through. Audience will get confused, no?

Use a local variable instead and keep the story straight.

Apply this diff to fix the issue:

-          if (!customProperty.value) {
-            customProperty = this.customFieldsService.setDefaultValue(customProperty, customProperty.type);
-          }
+          let updatedCustomProperty = customProperty;
+          if (!customProperty.value) {
+            updatedCustomProperty = this.customFieldsService.setDefaultValue(customProperty, customProperty.type);
+          }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (!customProperty.value) {
customProperty = this.customFieldsService.setDefaultValue(customProperty, customProperty.type);
}
let updatedCustomProperty = customProperty;
if (!customProperty.value) {
updatedCustomProperty = this.customFieldsService.setDefaultValue(customProperty, customProperty.type);
}
🧰 Tools
🪛 Biome (1.9.4)

[error] 2419-2419: Reassigning a function parameter is confusing.

The parameter is declared here:

Use a local variable instead.

(lint/style/noParameterAssign)

if (customProperty.type === 'DATE') {
customProperty.value =
customProperty.value && this.dateService.getUTCDate(new Date(customProperty.value as string));
Expand Down
3 changes: 3 additions & 0 deletions src/app/fyle/add-edit-per-diem/add-edit-per-diem.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1697,6 +1697,9 @@ export class AddEditPerDiemPage implements OnInit {
const isAdvanceWalletEnabled = res.orgSettings?.advances?.advance_wallets_enabled;
let customProperties = res.customProperties;
customProperties = customProperties.map((customProperty) => {
if (!customProperty.value) {
customProperty = this.customFieldsService.setDefaultValue(customProperty, customProperty.type);
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Mind it! Reassigning function parameter is not cool.

Macha, reassigning function parameter is like changing the rules of the game midway. Not fair, no?

Use a local variable instead and keep the game clean.

Apply this diff to fix the issue:

-          if (!customProperty.value) {
-            customProperty = this.customFieldsService.setDefaultValue(customProperty, customProperty.type);
-          }
+          let updatedCustomProperty = customProperty;
+          if (!customProperty.value) {
+            updatedCustomProperty = this.customFieldsService.setDefaultValue(customProperty, customProperty.type);
+          }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (!customProperty.value) {
customProperty = this.customFieldsService.setDefaultValue(customProperty, customProperty.type);
}
let updatedCustomProperty = customProperty;
if (!customProperty.value) {
updatedCustomProperty = this.customFieldsService.setDefaultValue(customProperty, customProperty.type);
}
🧰 Tools
🪛 Biome (1.9.4)

[error] 1701-1701: Reassigning a function parameter is confusing.

The parameter is declared here:

Use a local variable instead.

(lint/style/noParameterAssign)

if (customProperty.type === 'DATE') {
customProperty.value =
customProperty.value && this.dateService.getUTCDate(new Date(customProperty.value as string));
Expand Down
Loading