Conversation
|
Let's merge this after #208 and I'll combine rebase it. |
30b4e33 to
f1518f5
Compare
lychee-lib/src/filter/excludes.rs
Outdated
| use crate::Uri; | ||
|
|
||
| // TODO: renaming | ||
| // TODO: should just be added to the Excludes set. |
There was a problem hiding this comment.
That's a great idea! We could call it default_excludes or something
There was a problem hiding this comment.
In a second thought, this is doable but will makes the filtering messy.
Because when only includes are provided without excludes, we require URLs to be explicitly included.
If we add false positives as default excludes, this mechanism need to be changed.
So the updated code removed these TODOs.
| /// | ||
| /// 1. If any of the following conditions is met, the URI is excluded: | ||
| /// - If it's a mail address and it's configured to ignore mail addresses. | ||
| /// - If the IP address belongs to a type that is configured to exclude. |
There was a problem hiding this comment.
is configured to exclude -> is configured to be excluded
There was a problem hiding this comment.
No, the grammar is correct.
Consider there's work to be done and there's work to do.
Active infinitive focuses on the agent of action.
This is the documentation of the behaviour of a Filter. So the focus in on Filter.
If you use passive infinitive, the focus transferred to the receiver, which is the Url.
|
|
||
| if is_false_positive(input) | ||
| // Exclude well-known false-positives | ||
| // Performed after checking includes to allow user-overwriddes |
There was a problem hiding this comment.
This is a common misusage.
See the section title: https://doc.rust-lang.org/cargo/reference/overriding-dependencies.html
| || self.is_excludes_match(input) | ||
| // If excludes rules matches input, then | ||
| // *explicitly excluded* | ||
| { |
There was a problem hiding this comment.
In the above if conditions, I'd personally also move the comment before the condition. At least I find it easier to read this way, but it's subjective of course. Just wonder if rustfmt would also change the indentation in that case.
There was a problem hiding this comment.
if
// Exclude well-known false-positives
// Performed after checking includes to allow user-overwriddes
is_false_positive(input)
// Previous checks imply input is not explicitly included,
// if excludes rules is empty, then *presumably excluded*
|| self.is_excludes_empty()
// If excludes rules matches input, then
// *explicitly excluded*
|| self.is_excludes_match(input)
{
return true;
}This is also hard to read
|
I love it. Added some comments. Other than that all good. |
61bc8d5 to
7c4b26b
Compare
- Major changes in `lychee-lib::filter` module:
- Fields in `Excludes` except the `RegexSet` is now moved to `Filter`.
- `Filter` contains `Option<Excludes>` and `Option<Includes>`, which are
wrapper struct of `RegexSet` instead of `Option<RegexSet>`. As a result
the code now looks cleaner.
- Factored out some filtering logics to dedicated functions.
- It's possible to write tests for those functions in addition to tests
for the `Filter` struct.
- Added docs to `Filter::is_excluded` and reorgnized the code.
- placed `derive_builder` by `typed_builder`:
- The internal interface very ugly, as admitted by the author, but we no
longer have nested `Option`s like before.
- As a result, the `Client` building is much easier to read.
- Main benefit of `typed_builder` is, the arguments feeded to builder is
checked at compile time instead of run-time.
- Fixed a bug in `lychee::tests::usage` and `lychee-lib::stats::test`.
- Now it will clear environment variable which would otherwise cause an
issue if `GITHUB_TOKEN` is set.
- Updated dependencies.
db439b7 to
631de96
Compare
|
The publish error is due to Also, this is a breaking change so it would be |
|
Failed. |
lychee-lib::filtermodule:Excludesexcept theRegexSetis now moved toFilter.FiltercontainsOption<Excludes>andOption<Includes>, which arewrapper struct of
RegexSetinstead ofOption<RegexSet>. As a resultthe code now looks cleaner.
for the
Filterstruct.Filter::is_excludedand reorgnized the code.derive_builderbytyped_builder:longer have nested
Options like before.Clientbuilding is much easier to read.typed_builderis, the arguments feeded to builder ischecked at compile time instead of run-time.
lychee::tests::usageandlychee-lib::stats::test.issue if
GITHUB_TOKENis set.