refactor function joinPaths and isAscii in utils.go
I would suggest some improvements to further improve robustness and readability
##Proposal
Improve robustness of joinPaths function
Currently, the joinPaths function uses a homebrew lastChar function to determine if a path ends with a trailing slash. lastChar is a potential risk because it panics when passed an empty string. Replacing this logic with strings.HasSuffix, which is safer and clearer in intent, improves robustness and readability. This change also eliminates the need for the lastChar function, making the code base simpler.
Simplify isASCII functions
The current isASCII function is implemented using a for loop; it can be rewritten to be more modern and concise using strings.ContainsFunc, available in Go 1.19 and later. is safe.
Delete unnecessary tests
In conjunction with the removal of the lastChar function, we have also removed the associated test in utils_test.go.
Codecov Report
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 98.92%. Comparing base (
3dc1cd6) to head (e8622bf). Report is 142 commits behind head on master.
Additional details and impacted files
@@ Coverage Diff @@
## master #4288 +/- ##
==========================================
- Coverage 99.21% 98.92% -0.30%
==========================================
Files 42 44 +2
Lines 3182 3431 +249
==========================================
+ Hits 3157 3394 +237
- Misses 17 26 +9
- Partials 8 11 +3
| Flag | Coverage Δ | |
|---|---|---|
? |
||
| --ldflags="-checklinkname=0" -tags sonic | 98.85% <100.00%> (?) |
|
| -tags go_json | 98.85% <100.00%> (?) |
|
| -tags nomsgpack | 98.90% <100.00%> (?) |
|
| go-1.18 | ? |
|
| go-1.19 | ? |
|
| go-1.20 | ? |
|
| go-1.21 | ? |
|
| go-1.23 | 98.92% <100.00%> (?) |
|
| go-1.24 | 98.92% <100.00%> (?) |
|
| macos-latest | 98.92% <100.00%> (-0.30%) |
:arrow_down: |
| ubuntu-latest | 98.92% <100.00%> (-0.30%) |
:arrow_down: |
Flags with carried forward coverage won't be shown. Click here to find out more.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
Codecov's overall project coverage is showing as -0.30% and failed, but for my changes (diffs), everything is covered by the tests (100%). Please contact me to discuss additional tests if needed.
Hi! Just following up to see if there's anything I can improve in this PR 🙇
Hi maintainers 👋 Just following up on this PR — happy to make any changes if needed. Please let me know if there's anything blocking review. Thanks!