Skip to content

[I.24] Adjacent parameters of the same type - issues in implementing proper automated analysis #1732

@whisperity

Description

@whisperity

Follow-up for #1579, both @vingeldal and I started to implement a check in Clang-Tidy that is aimed to target the I.24 rule. I'm still trying to perfect the implementation and continue drumming...
However, with the maintainer of Clang-Tidy, @AaronBallman, we are at an impasse, not about the implementation, but about the rule itself. I've run extensive testing and hand-evaluation of findings on multiple open-source projects, and one or two internal ones. Together with my colleagues, we devised some rules (now still dubbed relatedness-heuristics, although they'll be renamed soon due to #1579 being fixed) and filterings (follow-up #1288, I've offered in the check a list of banned parameter names and types, including bool). Now the problem is, all these measurements were done on project that do not follow CPPCG (at least not this rule in particular, but most likely not the vast majority of the rules!), so naturally there are a lot of warnings.

I believe that this rule is worth some automated checking for. Aaron suggested me coming to you about improving the rule itself, he believes it's too vague. But the guideline itself

(Simple) Warn if two consecutive parameters have the same type

is waay too noisy. Did you intend this rule to be automatically checked? After #1579, "changes meaning" is impossible to prove in static analysis, but the given exceptions are easy to approximate.

Do you believe coming up with more exception cases in an analysis tool (without explicitly specifying them in the guideline) is worth it?
I'm coming close to a 25% false positive ratio with a few simple heuristics that looks at the code, and also things like "ignore binary operators", or "ignore unnamed parameters", etc.

Some of the results of hand-evaluation are compiled here, in the discussion for the implementation of the checker in particular: https://reviews.llvm.org/D69560#2457961.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions