"Good PR" mechanical check

Brian Schott via Digitalmars-d digitalmars-d at puremagic.com
Tue Jan 12 23:53:45 PST 2016


On Wednesday, 13 January 2016 at 05:19:36 UTC, H. S. Teoh wrote:
> 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.

It will. There's a solution in the form of special comments:

// dfmt off
auto treeStructure = [
     node(0, 0),
         node(1, 0),
         node(2, 0),
             node(10, 2),
         node(3, 0)
];
// dfmt on

// dfmt off
stuff.map!(a => complicatedFunction(a, 100) * 20)
      .filter!(a => a < 2_000 && a %3 == 0)
      .sum();
// dfmt on

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

Correct.

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

This might work.



More information about the Digitalmars-d mailing list