"Good PR" mechanical check

H. S. Teoh via Digitalmars-d digitalmars-d at puremagic.com
Tue Jan 12 21:19:36 PST 2016


On Tue, Jan 12, 2016 at 02:03:57PM -0500, Andrei Alexandrescu via Digitalmars-d wrote:
> On 01/12/2016 08:42 AM, Martin DraĊĦar via Digitalmars-d wrote:
> >Wouldn't it be sufficient to mandate usage of dfmt with proper
> >settings before submitting a PR?
> 
> That would suffice at least in the beginning. We also need to put dfmt
> in tools, again a project that's been in limbo for a long time. --
> Andrei

In principle, I agree with mechanical checking of formatting (instead of
the endless tedious nitpicking over the fine points of Phobos style),
but, as Jonathan has brought up before, there are cases where human
judgment is required and a tool would probably make a big mess of
things.

For example, certain unittests in std.datetime where customized
formatting of array literals are used to make it easier to read the test
cases, such as `testGregDaysBC` in std/datetime.d, as well as the
several array literals inside the same unittest block. This is just one
of many examples one can find in std.datetime.

There are also some (smaller) examples in std.range, such as in
transposed(), where nested arrays are formatted like matrices in order
to make it clear what the function is trying to do. I'm almost certain
dfmt (or any mechanical formatting tool) will completely ruin this.

These formatting exceptions are primarily semantically-motivated; as
such I don't expect a mechanical tool to be able to figure it out
automatically. (E.g., nested arrays in transposed() may need 2D
formatting, but in byChunk() it makes more sense to format them linearly
with line-wrapping.)

I propose that a better approach is to automate dfmt (or whatever tool)
to check PRs and highlight places where the formatting deviates from the
mechanical interpretation of the rules, so that submitters can have
their attention brought to potentially problematic points, and reviewers
don't have to scrutinize every line, but only look at the places that
may require some human judgment to decide on.


T

-- 
"640K ought to be enough" -- Bill G. (allegedly), 1984. "The Internet is not a primary goal for PC usage" -- Bill G., 1995. "Linux has no impact on Microsoft's strategy" -- Bill G., 1999.


More information about the Digitalmars-d mailing list