-
-
Notifications
You must be signed in to change notification settings - Fork 295
refactor: nested ternary operators into independent statements #2532
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
Merged
kasya
merged 9 commits into
OWASP:main
from
ishanBahuguna:feature/refactor-nested-ternary-operators
Nov 19, 2025
Merged
Changes from 7 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
b1cbe3c
refactor: nested ternary operators into independent statements
ishanBahuguna 68bec80
fix: inconsistent equality operator
ishanBahuguna b70ed34
removed unwanted comment
ishanBahuguna 186932c
fix : added test
ishanBahuguna 9d500f6
fix: added comments
ishanBahuguna 6974dc3
fix : fixed ci issue and imporved code readability by refactoring neg…
ishanBahuguna 3f693ab
fix: remove invalid sortBy[0] check and clean comments
ishanBahuguna dae4921
Merge branch 'main' into feature/refactor-nested-ternary-operators
kasya 3ee8893
refactor : replaced alignment conditionals with map based lookups
ishanBahuguna File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| import { faCircleCheck, faClock, faUserGear } from '@fortawesome/free-solid-svg-icons' | ||
|
|
||
| import { getMilestoneProgressIcon, getMilestoneProgressText } from 'utils/milestoneProgress' | ||
|
|
||
| describe('milestone progress helpers', () => { | ||
| describe('getMilestoneProgressText', () => { | ||
| test('returns "Completed" when progress is 100', () => { | ||
| expect(getMilestoneProgressText(100)).toBe('Completed') | ||
| }) | ||
|
|
||
| test('returns "In Progress" when progress is between 1 and 99', () => { | ||
| expect(getMilestoneProgressText(50)).toBe('In Progress') | ||
| }) | ||
|
|
||
| test('returns "Not Started" when progress is 0', () => { | ||
| expect(getMilestoneProgressText(0)).toBe('Not Started') | ||
| }) | ||
| }) | ||
|
|
||
| describe('getMilestoneProgressIcon', () => { | ||
| test('returns faCircleCheck when progress is 100', () => { | ||
| expect(getMilestoneProgressIcon(100)).toBe(faCircleCheck) | ||
| }) | ||
|
|
||
| test('returns faUserGear when progress is between 1 and 99', () => { | ||
| expect(getMilestoneProgressIcon(50)).toBe(faUserGear) | ||
| }) | ||
|
|
||
| test('returns faClock when progress is 0', () => { | ||
| expect(getMilestoneProgressIcon(0)).toBe(faClock) | ||
| }) | ||
| }) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| import { faCircleCheck, faClock, faUserGear } from '@fortawesome/free-solid-svg-icons' | ||
|
|
||
| // helper functions used in about/page.tsx | ||
| export const getMilestoneProgressText = (progress: number): string => { | ||
| if (progress === 100) { | ||
| return 'Completed' | ||
| } else if (progress > 0) { | ||
| return 'In Progress' | ||
| } else { | ||
| return 'Not Started' | ||
| } | ||
| } | ||
|
|
||
| export const getMilestoneProgressIcon = (progress: number) => { | ||
| if (progress === 100) { | ||
| return faCircleCheck | ||
| } else if (progress > 0) { | ||
| return faUserGear | ||
| } else { | ||
| return faClock | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ishanBahuguna I think this would be more clean and readable if we switch to using maps here. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Map would be great , more readable code , avoid repeated if/else logic and easier to extend
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kasya should I go ahead and make the changes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ishanBahuguna yes, let's do it!