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

Incomplete postfix detected for enum_variant_names #4639

Closed
mrcnski opened this issue Oct 7, 2019 · 6 comments · Fixed by #6770
Closed

Incomplete postfix detected for enum_variant_names #4639

mrcnski opened this issue Oct 7, 2019 · 6 comments · Fixed by #6770
Labels
C-bug Category: Clippy is not doing the correct thing C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages good-first-issue These issues are a good way to get started with Clippy I-false-positive Issue: The lint was triggered on code it shouldn't have

Comments

@mrcnski
Copy link
Contributor

mrcnski commented Oct 7, 2019

Given this enum (reproduced in its entirety):

pub(crate) enum IDataRequest {
    PutIData(IData),
    GetIData(IDataAddress),
    DeleteUnpubIData(IDataAddress),
}

The error I get is:

error: All variants have the same postfix: `Data`

It seems to me like the complete, shared postfix should be IData instead of Data. Maybe the I part is too short and doesn't get detected.

@flip1995 flip1995 added good-first-issue These issues are a good way to get started with Clippy C-bug Category: Clippy is not doing the correct thing C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages labels Oct 8, 2019
@phansch
Copy link
Member

phansch commented Oct 9, 2019

As a starting point, the problem seems to lie in our camel case detection. We only look for the last camel case component and don't consider that, in this case, I and Data belong to the same component.

That file has a bunch of unit tests which should help with fixing the problem, too.

@chansuke
Copy link
Contributor

I would like to challenge this issue

@chansuke
Copy link
Contributor

@phansch Hi. I have checked the codes in camel_case.rs and enum_variants.rs and simply change the from() function to detect first camel-case component and am updating the unit tests right now and do I need to update stderr too?

@flip1995
Copy link
Member

flip1995 commented Oct 21, 2019

This explains our testing environment best: https://github.com/rust-lang/rust-clippy/blob/master/doc/adding_lints.md#testing

TL;DR: You have to run cargo +master uitest once and then tests/ui/update-all-references.sh, which updates the stderr files automatically.

@chansuke
Copy link
Contributor

@flip1995 Thanks!!

@chansuke
Copy link
Contributor

Sorry, I'm stucking...I am trying to detect consecutive camel case by updating if else condition in fn from() but can not handle well. Please give me some suggestions to solve the issue...

@phansch phansch added the I-false-positive Issue: The lint was triggered on code it shouldn't have label Dec 18, 2020
@bors bors closed this as completed in 208e957 Feb 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages good-first-issue These issues are a good way to get started with Clippy I-false-positive Issue: The lint was triggered on code it shouldn't have
Projects
None yet
5 participants