Rust-clippy: Incomplete postfix detected for `enum_variant_names`

Created on 7 Oct 2019  路  6Comments  路  Source: rust-lang/rust-clippy

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.

L-bug L-enhancement L-false-positive good-first-issue hacktoberfest

All 6 comments

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.

I would like to challenge this issue

@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?

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.

@flip1995 Thanks!!

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...

Was this page helpful?
0 / 5 - 0 ratings