Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,9 @@ class ChallengeReviewerField extends Component {
const { challenge, metadata = {}, readOnly = false } = this.props
const { scorecards = [], workflows = [] } = metadata
const validationErrors = challenge.submitTriggered ? this.validateReviewer(reviewer) : {}
const selectedPhase = challenge.phases.find(p => p.phaseId === reviewer.phaseId)

Choose a reason for hiding this comment

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

[❗❗ correctness]
The selectedPhase variable is assigned using find, which will return undefined if no matching phase is found. This could lead to potential runtime errors when accessing properties of selectedPhase later in the code. Consider adding a check to handle the case where selectedPhase is undefined.

const isDesignChallenge = challenge && challenge.trackId === DES_TRACK_ID
const filteredScorecards = scorecards.filter(item => item.type?.toLowerCase() === selectedPhase?.name.toLowerCase());

Choose a reason for hiding this comment

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

[❗❗ correctness]
The filteredScorecards array is filtered based on selectedPhase?.name.toLowerCase(). If selectedPhase is undefined, this will result in an error. Ensure selectedPhase is not undefined before attempting to access its properties.


return (
<div key={`reviewer-${index}`} className={styles.reviewerForm}>
Expand Down Expand Up @@ -666,7 +668,7 @@ class ChallengeReviewerField extends Component {
onChange={(e) => this.updateReviewer(index, 'scorecardId', e.target.value)}
>
<option value=''>Select Scorecard</option>
{scorecards.map(scorecard => (
{filteredScorecards.map(scorecard => (
<option key={scorecard.id} value={scorecard.id}>
{scorecard.name || 'Unknown'} - {scorecard.type || 'Unknown'} ({scorecard.challengeTrack || 'Unknown'}) v{scorecard.version || 'Unknown'}
</option>
Expand Down