You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix false positive for multi dep single use statements (#120)
Resolves#91
This also resolves some false detections of `not_my_dep::my_dep_name::stuff_in_my_dep` 😊 I couldn't find a way to avoid detection of `futures` in with the single line regexp
```rust
pub use {
async_trait::{mod1, dep2},
not_futures::{
futures::{futures_mod1, futures_mod2::{futures_mod21, futures_mod22}}
},
reqwest,
};
```
This update does come at a small performance downside (that might be resolved by not instantiating a regexp per dependency?). On our repo of ~500k lines of machete goes from ~45s user time to ~48s of user time.
---------
Co-authored-by: Elrendio <oscar.walter@ens.fr>
Co-authored-by: Benjamin Bouvier <benjamin@bouvier.cc>
// 1. Matches modules before the usage of the crate's name: `\s*(?:(::)?\w+{sub_modules_match}\s*,\s*)*`
102
+
// 2. Matches the crate's name with optional sub-modules: `(::)?{name}{sub_modules_match}\s*`
103
+
// 3. Matches modules after the usage of the crate's name: `(?:\s*,\s*(::)?\w+{sub_modules_match})*\s*,?\s*`
104
+
//
105
+
// In order to avoid false usage detection of `not_my_dep::my_dep` the regexp ensures that the
106
+
// crate's name is at the top level of the use statement. However, it's not possible with
107
+
// regexp to allow any number of matching `{` and `}` before the crate's usage (rust regexp
108
+
// engine doesn't support recursion). Therefore, sub modules are authorized up to 4 levels
109
+
// deep.
110
+
111
+
let sub_modules_match = r#"(?:::\w+)*(?:::\*|\s+as\s+\w+|::\{(?:[^{}]*(?:\{(?:[^{}]*(?:\{(?:[^{}]*(?:\{[^{}]*\})?[^{}]*)*\})?[^{}]*)*\})?[^{}]*)*\})?"#;
0 commit comments