Skip to content

Enable clippy in Cargo.toml, fix associated issues#8

Open
DeflateAwning wants to merge 3 commits intorp-rs:mainfrom
DeflateAwning:feat-enable-lints
Open

Enable clippy in Cargo.toml, fix associated issues#8
DeflateAwning wants to merge 3 commits intorp-rs:mainfrom
DeflateAwning:feat-enable-lints

Conversation

@DeflateAwning
Copy link
Contributor

No description provided.

Cargo.toml Outdated
Comment on lines +8 to +9
keywords = ["embedded", "rp235x", "hal", "rust", "template"]
categories = ["embedded", "hardware-support"]
Copy link
Member

Choose a reason for hiding this comment

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

I don't think all of these keywords/categories make sense for a template?
As a user of this template, I would be surprised if my binary crate was tagged with "template" or "hardware support"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, fair enough, I agree! Will remove those.

{
"rust-analyzer.cargo.target": "thumbv8m.main-none-eabihf",
"rust-analyzer.check.allTargets": false,
"rust-analyzer.check.command": "clippy",
Copy link
Member

Choose a reason for hiding this comment

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

I think this change is controversial. We should discuss whether this is a sensible default for all users in the rp-rs matrix channel.

Copy link
Member

Choose a reason for hiding this comment

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

This is difficult to answer. I'm not even sure what my personal preference would be, I often switch between clippy and check.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The current CI config fails if there's linting issues (checked with clippy), so it's important that the default IDE configuration points out these issues before pushing. This change simply reconciles the IDE config with the CI config.

Comment on lines +72 to +79
[lints.clippy]
all = { level = "warn", priority = -1 }
pedantic = { level = "warn", priority = -1 }
multiple_crate_versions = "allow"

nursery = { level = "warn", priority = -1 }
cargo = { level = "warn", priority = -1 }
# restriction = { level = "warn", priority = -1 }
Copy link
Member

Choose a reason for hiding this comment

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

Why these particular settings?
This should be discussed in the rp-rs matrix channel too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These are basically all the stardard lints in an "all lints enabled" repo. It should be easy for people to start with a template that passes all lints, and they can disable linting if they choose. It's way more of a pain to offer a template that fails linting and that has to be fixed in every generated repo.

Additionally, I suspect that this template is used by a decent number of people who are still new in Rust. Clippy is a fantastic way to offer "here's the best Rust way to do it" training to people as they write code. Again, easier to disable than enable in a generated repo.

priority = -1 is used so that overrides (e.g., multiple_crate_versions) can be used. That override exists here because it fails currently, and doesn't seem like a huge deal (basically complains that two versions of a single crate are built in the dependency graph). Could be fixed in a future PR if we cared; didn't dig too far into it.

Copy link
Member

Choose a reason for hiding this comment

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

I think those are somewhat orthogonal issues.

Having the template lint free with the most strict/pedantic selection makes sense.
Forcing everyone setting up their project from the template to this level does not.

The template is there as a quick starter.
If one has to spend time fiddling with the linter setting to get going, that's counter productive IMHO.

Copy link
Member

Choose a reason for hiding this comment

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

I think those are somewhat orthogonal issues.

Having the template lint free with the most strict/pedantic selection makes sense.
Forcing everyone setting up their project from the template to this level does not.

The template is there as a quick starter.
If one has to spend time fiddling with the linter setting to get going, that's counter productive IMHO.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'd suggest that writing code that satisfies the linter is the correct way to get going. Writing shitty code is a step of a lot of people's learning paths, but it certainly doesn't have to be.

I wish someone gave me a linter when I was learning to code (in Python and C) - would have progressed me along a fair bit faster.

Why do you think the default action of users of the template would be to "fiddle with the linter" (which I assume you're implying means to turn off the linter)?

name: CI Checks

on: [push, pull_request]
on: [push, pull_request, workflow_dispatch]
Copy link
Member

Choose a reason for hiding this comment

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

You never mention this change in the PR notes either

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Being able to re-run CI arbitrarily is helpful in cases of failures, checking against the latest version of Rust (esp. when new linting rules are added), etc. Pretty minor note. I'd consider it a misconfiguration to not have this in basically all repos.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants