Subject: Re: [PATCH 01/23] contrib/coccinnelle: add equals-null.cocci

From: Junio C Hamano <[email-masked]>
Date: Sat, 30 Apr 2022 16:13:56 -0700

Philip Oakley <[email-masked]> writes:

> I think it goes both ways when the 'bad' style can be cargo-cult copied
> too easily, negating the value of the guidance.

Yes, and the cocci rules by themselves do not help protecting our
codebase against it all that much.

In order to help developers follow the guideline to avoid adding
_new_ instances (by copying-and-pasting), it should be easy to use
such a checker in such a way that we can notice only _new_ breakges
while ignoring existing offenders.  I do not think the current cocci
check target in our Makefile is prepared for that.

And there are two ways to deal with that shortcoming.

One, which often appears easier to implement but in the medium term
is very costly, is to freeze the codebase and apply tree-wide code
churn to make warning disappear.

Then _any_ breakages noticed by an inadequate tool, which does not
allow us to notice only the new breakages, after applying a patch to
such a cleansed codebase by definition are coming from the patch.

But it is costly.  The codebase is rarely frozen, so there isn't a
good time to apply such a patch, whether it is 22-patch series or a
single patch that concatenates everything into one.  There may be
more urgent issues than style fixes that would force us to revert a
change made before such a tree-wide clean-up, and when that happens,
such a "clean-up for clean-up's sake because we cannot check
incrementally" will inevitably conflict with such a change.

The other approach is to make it possible (and easy) to check
incrementally, so that we can detect new instances made by copying
and pasting.

Thanks.