Add strength/stretching workouts - #16
Open
rbro112 wants to merge 1 commit into
Open
Conversation
| } | ||
|
|
||
| if (item.discipline === 'strength') { | ||
| return (item.sets ?? 1) * (item.reps ?? 1); |
There was a problem hiding this comment.
Bug: The getWeight function incorrectly defaults to a weight of 1 for strength workouts when sets and reps are missing, instead of 0.
Severity: MEDIUM
Suggested Fix
Modify the nullish coalescing operator's default value from 1 to 0 for both sets and reps within the getWeight function. The calculation should be return (item.sets ?? 0) * (item.reps ?? 0); to ensure a missing value results in a weight of 0.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.
Location: src/workouts/workout-utils.ts#L47
Potential issue: For 'strength' discipline workouts, the `getWeight` function calculates
weight using `(item.sets ?? 1) * (item.reps ?? 1)`. If both `sets` and `reps` are
undefined, which is permitted by the schema, the weight incorrectly defaults to 1. This
behavior is inconsistent with other workout disciplines, which default to a weight of 0
when their primary metrics are missing. This will cause functions like
`getTotalWeight()` to report inflated values for strength workouts that do not have
specified sets and reps.
Did we get this right? 👍 / 👎 to inform future reviews.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
No description provided.