This is an archive of the discontinued LLVM Phabricator instance.

[clang-tidy] readability-inconsistent-declaration-parameter-name: accept approximate name matches.
ClosedPublic

Authored by sammccall on Jul 13 2018, 2:58 AM.

Details

Summary

The goal is to reduce false positives when the difference is intentional, like:

foo(StringRef name);
foo(StringRef name_ref) {

string name = cleanup(name_ref);
...

}

Or semantically unimportant, like:
foo(StringRef full_name);
foo(StringRef name) { ... }

There are other matching names we won't recognise (e.g. syns vs synonyms) but
this catches many that we see in practice, and gives people a systematic
workaround.

Event Timeline

sammccall created this revision.Jul 13 2018, 2:58 AM
sammccall updated this revision to Diff 155340.Jul 13 2018, 3:19 AM

Make strictness (old behavior) available as an option.

sammccall added a subscriber: alexfh.

(First foray into clang-tidy, not sure what I'm doing...)

hokein added inline comments.Jul 13 2018, 3:24 AM
clang-tidy/readability/InconsistentDeclarationParameterNameCheck.cpp
96

I have a concern that this is too general -- it will cover the middle case like inBFix in you test, which seems not happen often in the real world.

Two important cases are prefix and suffix, maybe just restrict to these two cases?

sammccall updated this revision to Diff 155343.Jul 13 2018, 3:42 AM

Restrict matches to prefix/suffix, not substring.

sammccall marked an inline comment as done.Jul 13 2018, 3:42 AM
hokein accepted this revision.Jul 13 2018, 4:36 AM

LGTM.

This revision is now accepted and ready to land.Jul 13 2018, 4:36 AM
This revision was automatically updated to reflect the committed changes.