-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Cognitive Complexity (step 1 out of 3+): name changes #3803
Conversation
Whoops, Travis failed because I didn't run the automatic naming update script |
I think we have a way of registering renames so that the old name still works but warns about the lint being renamed. Also, we should probably have something similar for the conf option, allowing people to migrate. |
☔ The latest upstream changes (presumably #3790) made this pull request unmergeable. Please resolve the merge conflicts. |
That seems to be the case. The stability guarantees postulated for Clippy mention that a PR may never quite "remove" a Lint, only deprecate it and warn about its subsequent usage. Might that be the cause of the error? Should we be deprecating Cyclomatic Complexity and offering to use Cognitive Complexity (as an entirely different lint) instead? (CC @oli-obk) |
Take a look at #3554 if you want an example of renaming a lint. |
Thanks @mikerite! (I'll continue tomorrow tho, now it's pretty late) I think it's great that there's a mechanism in place for renaming lints 😊 |
Nvm, I think I solved the conflicts! |
Yay! All the checks have passed. Finally 😅 |
To summarize, the PR now contains these changes:
What's blocking this PR:
|
Reading further into the |
☔ The latest upstream changes (presumably #3814) made this pull request unmergeable. Please resolve the merge conflicts. |
Alright, I think I've made it tell the user about the usage of the deprecated field |
CI gives an odd error. Maybe I just missed an upstream change once again 🤔 Anyone got a clue? |
Yes, you'll probably want to rebase so you get the latest fixes |
The changes seemingly worked. Now I'm adding a test to check that the |
Okay, all checks have passed and now |
I have one more case that should be tested:
It is currently possible to set the cyclomatic_complexity with an attribute. What is the output of the compiler if you sill use this attribute? Could you add a test for this? |
It is apparently invisible. I made a test like this: #[clippy::cyclomatic_complexity = "0"]
fn main() {
} And the compiler and test said nothing (not even in #![warn(clippy::cyclomatic_complexity)]
#[clippy::cyclomatic_complexity = "0"]
fn main() {
} Throws something like this:
Is that okay? Is the value-setter alone enough to trigger the lint? It should crash, shouldn't it? Then I think it didn't trigger at all, because I didn't see it crash. Maybe the setting is invisible to Clippy if you're not using the |
Oh yeah, that's kind of the behavior I expected. From the RFC:
We already implemented a lint for unknown Clippy lints (#3161). This should also be done for Clippy attributes. I try to get to this today. I will notify you if I'm done. |
#3830 will give you the ability to add the new attribute |
Your PR got merged, that's awesome! Btw @flip1995, what kinds of attributes are there? "Builtin" is one, what are the other ones? |
I don't think there are other types of attributes in Clippy. I just copied the naming from rustc https://github.com/rust-lang/rust/blob/1999a2288123173b2e487865c9a04386173025f7/src/libsyntax/feature_gate.rs#L828 In rustc there are for example "tool attributes", which are provided by tools like Clippy and rustfmt. Also there are "custom attributes". |
( | ||
"cyclomatic_complexity", | ||
DeprecationStatus::Replaced("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.
So if I understand this list correctly, you'll need to add an entry for cognitive_complexity
with DeprecationStatus::None
, otherwise you'll get complaints about an unknown attribute when you start using #[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.
Ahh! I see. Thank you :D
(Unrelated to the attributes talk,) I'm getting another compilation error, but this time I'm almost certain I'm running the And these are the commands I ran before I got that result:
EDIT: CI shows the same error. Maybe Clippy got broken with the latest changes from the |
The fix for this error is on it's way: #3823 |
So to recap, the PR has now:
I think all the user-facing errors have been implemented. Anything else I might be missing? @oli-obk ^^ |
Ok, this looks good to me now. Can you just squash your commits then I'll send it off to bors |
Sure! |
Okay after the squashing I had solved an old merge conflict leaving behind the wrong line, twice 😅 . I've been really sleepy today >.< But I double checked it this time. The rebase should work! (still me -> 🤞) |
☔ The latest upstream changes (presumably #3845) made this pull request unmergeable. Please resolve the merge conflicts. |
* Ran automatic naming update * Formalized rename of `cyclomatic_complexity` to `cognitive_complexity` ** Added the rename to `lib.rs` ** Added rename test * Added warning for deprecated key `cyclomatic_complexity_threshold` and tests for it * Added deprecation status for Clippy's builtin attribute * Updated tests for new builtin attribute renaming
Resolved upstream conflict and rebased again. |
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.
Just a small thing, otherwise it LGTM
@bors r=oli-obk |
📌 Commit ddc7180 has been approved by |
Cognitive Complexity (step 1 out of 3+): name changes Following up on #3793 **Overall checklist:** 1. **Name changes** 2. MVP of functionality 3. Tests After this PR, we will start working on the implementation itself.
☀️ Test successful - checks-travis, status-appveyor |
⛵️ |
Following up on #3793
Overall checklist:
After this PR, we will start working on the implementation itself.