Skip to content
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

Last round of suggestions by clippy #403

Merged
merged 10 commits into from Dec 29, 2020
Merged

Conversation

crawford
Copy link
Contributor

This is a follow-on to #402 and is the last in the series. Now that all of the warnings have been addressed, I've also set cargo clippy to fail when it encounters warnings going forward.

Should we pin to a specific toolchain or do folks think it's feasible to keep up-to-date with the latest stable? I don't have a sense for how often new lints are added.

These were flagged by `cargo clippy`:

    warning: redundant field names in struct initialization

There are plenty more redundant field names, but I only changed the ones
where the initialization was a single line of code. I still prefer the
redundant style for multi-line initializations (and I'm under the
impression that others agree), so I've also disabled the warning.
These were flagged by `cargo clippy`:

    warning: this `else { if .. }` block can be collapsed
These were flagged by `cargo clippy`:

    warning: returning the result of a `let` binding from a block
    warning: this import is redundant
These were flagged by `cargo clippy`:

    warning: the loop variable is used to index

I've verified that this doesn't increase the size of consuming binaries.
Pretty impressive. I tested this with a project that uses the following
features: ethernet, proto-dhcpv4, socket-tcp.
src/phy/loopback.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@whitequark whitequark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've reviewed individual commits and I agree with almost all of your judgement calls (except where noted). Good work!

These were flagged by `cargo clippy`:

    warning: the operation is ineffective. Consider reducing it to `number`
    warning: this function has too many arguments (8/7)
    warning: you should consider adding a `Default` implementation for
             `phy::loopback::Loopback`

I like the code better as it is.
This was flagged by `cargo clippy`:

    warning: called `map(f)` on an `Option` value where `f` is a closure
             that returns the unit type `()`

I decided to disable this because it was suggesting changes like the
following and I prefer the original:

    @@ -1 +1 @@
    -self.waker.take().map(|w| w.wake());
    +if let Some(w) = self.waker.take() { w.wake() }
@crawford
Copy link
Contributor Author

I want to double check that the clippy check actually fails this time. I've got one final commit to address the last lint.

These were flagged by `cargo clippy`:

    warning: using `clone` on a `Copy` type
This was flagged by `cargo clippy`:

    warning: redundant closure found
@crawford
Copy link
Contributor Author

Today I learned about pulL_request_target:

we’ve added a new pull_request_target event, which behaves in an almost identical way to the pull_request event with the same set of filters and payload. However, instead of running against the workflow and code from the merge commit, the event runs against the workflow and code from the base of the pull request.

That's why the job isn't failing. I'm reasonably confident this will work as-is.

@whitequark whitequark merged commit 5cfbfbb into smoltcp-rs:master Dec 29, 2020
@crawford crawford deleted the clippy branch December 29, 2020 07:35
@crawford crawford mentioned this pull request Jan 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants