uutils / findutils

Rust implementation of findutils
MIT License
280 stars 35 forks source link

find: Fix `convert_arg_to_comparable_value()` function parsing unexpected characters. #361

Closed hanbings closed 1 month ago

hanbings commented 2 months ago

convert_arg_to_comparable_value() as mentioned in https://github.com/uutils/findutils/pull/355#issuecomment-2067613423 parses some strange characters.

The original regular expression was ([+-]?)(\d+)$ , which did a partial match and only included 1%2 of 2 as part of the match. After adding the ^ limiter (^([+-]?)(\d+)$), the expression can be restricted to only match + - or 0-9.

codecov[bot] commented 2 months ago

Codecov Report

Attention: Patch coverage is 94.11765% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 58.88%. Comparing base (baa09ba) to head (c0b8cd0).

Files Patch % Lines
src/find/matchers/mod.rs 0.00% 0 Missing and 1 partial :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #361 +/- ## ========================================== + Coverage 58.34% 58.88% +0.53% ========================================== Files 30 30 Lines 3815 3831 +16 Branches 860 860 ========================================== + Hits 2226 2256 +30 + Misses 1257 1254 -3 + Partials 332 321 -11 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

sylvestre commented 2 months ago

please add integration tests too to trigger the error and make sure we are handling it correctly

hanbings commented 2 months ago

Thanks. I added an command test for the -a/c/mtime directive in find_cmd_tests.rs.

But it may be that Codecov does not detect the diff because the PR only fixes regular expressions, so the coverage changes cannot be seen in the Codecov report.