fix: normalisePath and normalisePathWin incorrectly return changed=true when path is unmodified#1672
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1672 +/- ##
=======================================
Coverage 87.78% 87.78%
=======================================
Files 178 178
Lines 9151 9153 +2
=======================================
+ Hits 8033 8035 +2
Misses 854 854
Partials 264 264
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
@coderabbitai full_review |
|
✅ Action performedFull review finished. |
|
Important Review skippedBot user detected. To trigger a single review, invoke the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughThe path normalization functions now compute the changed flag by comparing the normalized output with the original input. Test data adds unchanged ChangesPath normalization
Estimated code review effort: 1 (Trivial) | ~5 minutes Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@internal/transformations/testdata/normalisePath.json`:
- Around line 218-224: Update transformations_test.go to capture the
normalisePath changed boolean and assert it against data.Ret != 0. In
internal/transformations/testdata/normalisePath.json lines 218-224, retain the
unchanged // vector with ret: 0; in
internal/transformations/testdata/normalisePathWin.json lines 218-224, add
unchanged // and backslash-separator conversion vectors, with the latter using
ret: 1 to verify changed=true.
🪄 Autofix (Beta)
✅ Autofix completed
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 94086f40-ce46-48ec-8dbd-c54cc493dea5
📒 Files selected for processing (4)
internal/transformations/normalise_path.gointernal/transformations/normalise_path_win.gointernal/transformations/testdata/normalisePath.jsoninternal/transformations/testdata/normalisePathWin.json
|
Note Autofix is a beta feature. Expect some limitations and changes as we gather feedback and continue to improve it. Fixes Applied SuccessfullyFixed 2 file(s) based on 1 unresolved review comment. Files modified:
Commit: The changes have been pushed to the Time taken: |
…h is unchanged - normalisePath: when path ends with '/', compare result to original instead of always returning true - normalisePathWin: compare result against original input (before backslash replacement) so backslash-only changes are correctly reported - Add // test cases to both JSON test data files Fixes #1670
Fixed 2 file(s) based on 1 unresolved review comment. Co-authored-by: CodeRabbit <noreply@coderabbit.ai>
80eda40 to
da99412
Compare
normalisePathhardcodedchanged = truefor any path ending with/, even whenfilepath.Clean(data) + "/"equals the original input.normalisePathWinhad a related bug: it discarded thechangedflag fromnormalisePathand never accounted for whether the backslash→slash replacement itself constituted a change.Changes
normalise_path.go: Replace hardcodedtruein the trailing-slash branch with a proper comparison:normalise_path_win.go: Compare the final normalized result against the original input (pre-replacement) so both path normalization and backslash conversion are reflected inchanged:Test data: Added
"//"cases (ret: 0) tonormalisePath.jsonandnormalisePathWin.json.Examples of corrected behavior
////true❌false✅../../true❌false✅../../../../true❌false✅dir/../foo/foo/true✅true✅\\foo\\bar(win)/foo/barfalse❌true✅Summary by CodeRabbit
Bug Fixes
Tests