Add validation for duplicate species within phases#124
Conversation
Co-authored-by: K20shores <13836216+K20shores@users.noreply.github.com>
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #124 +/- ##
=======================================
Coverage 86.95% 86.95%
=======================================
Files 3 3
Lines 23 23
=======================================
Hits 20 20
Misses 3 3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| // Check for duplicate species within this phase | ||
| for (size_t i = 0; i < species.size(); ++i) | ||
| { | ||
| for (size_t j = i + 1; j < species.size(); ++j) | ||
| { | ||
| if (species[i] == species[j]) | ||
| { | ||
| errors.push_back({ ConfigParseStatus::DuplicateSpeciesInPhaseDetected, | ||
| "Duplicate species '" + species[i] + "' found in phase '" + name + "'." }); | ||
| break; | ||
| } | ||
| } | ||
| } | ||
|
|
There was a problem hiding this comment.
We don't want to break. Can you try again?
There was a problem hiding this comment.
@copilot, we don't want to break here, we want to collect as many errors as we can. Please remove this break
There was a problem hiding this comment.
Removed the break statement as requested. The parser now collects all duplicate species errors within a phase rather than stopping at the first one. Verified with testing - configurations with multiple duplicates now report all instances (commit c4cfabc).
Co-authored-by: K20shores <13836216+K20shores@users.noreply.github.com>
This PR adds validation to detect and report duplicate species within individual phases in the v1 parser. Previously, the parser only validated duplicate phase names and duplicate species globally, but allowed duplicate species within the same phase.
Changes Made
Core Implementation:
DuplicateSpeciesInPhaseDetectedtoConfigParseStatusenumParsePhasesfunction inmechanism_parsers.cppto check for duplicate species within each phaseparse_status.cppTesting:
DetectsDuplicateSpeciesInPhasetest case totest_parse_phases.cppExample
The parser now correctly detects and reports errors like:
Error message:
Validation
Fixes #114.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.