-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: apply nursery lints #202
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your PR! Some neat changes are new knowledge to me ;-) .
Please see inline comments. Overall looks good, and I think it's cool to run nursery lints once a while locally and adopt some suggestions, even though I don't think we're ready to codify it in CI yet.
.github/workflows/build.yml
Outdated
@@ -27,6 +27,6 @@ jobs: | |||
- name: Build | |||
run: cargo build | |||
- name: Run clippy and fail if any warnings | |||
run: cargo clippy -- -D warnings | |||
run: cargo clippy -- -W clippy::all -W clippy::nursery -D warnings |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's ok to specify -W clippy::all
, but I don't think we need to have clippy::nursery
in CI yet.
src/lib.rs
Outdated
@@ -147,6 +147,7 @@ mod log { | |||
|
|||
mod dns_parser; | |||
mod error; | |||
#[allow(clippy::cognitive_complexity)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since I suggest we don't add clippy::nursery
in CI, we don't need this line either.
It's cool to learn about this (for me). Although I opted not to mandate cognitive_complexity lint, I'm curious what the two functions are. (A quick local run didn't turn up such warnings unless I missed them). |
Yeah, very interesting to see that clippy nursery suggests splitting big chunks of code/complexity.
|
cool! we can look into them. I opened a separate issue #204 to track this . |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
This PR upgrades clippy to warn about nursery lints
on CIand applies said lints.Applied changes:
pub(crate)
withpub
in already private modules.From
for an enum, inside said functions you dont have to useEnum::Variant
as it's already implying its usage, therefore usingSelf
instead ofEnum
).Eq
forDnsEntry
, it already implementsPartialEq
butEq
is also applicable.Addallow(clippy::cognitive_complexity)
for theservice_daemon
module, the lint rates the complexity of a function and warns if it is exceeded, in this case 2 functions pass the default threshold, the solution to this is to make it smaller by refactoring, splitting it into multiple functions etc (or maybe not possible in some cases), I've added this as solving it would be outside of the PR's scope, so lets make CI pass.This is a 'low-hanging fruit' PR that attempts on making the code a bit more concise (and possible more performant because of the constants and/or dedicated methods for if/match).
Note: the
nursery
lint group are "new lints that are still under development", if you might not want it, I'll remove it from the CI file.