Automatically enforce Phobos's styleguide

Seb via Digitalmars-d digitalmars-d at puremagic.com
Tue Apr 26 12:04:44 PDT 2016


Hey all,

tl;dr: I want to pull improve Phobos code style for the greater 
good of having a bot that automatically checks the coding style. 
This should be quite useful for submitters. I hope we all agree 
that the time spent "nitpicking" is wasted, we overlook much (see 
below) and we can do better!

Agenda
------

The idea is quite simple:
1) Fix one violation for the entire codebase
2) Enable it in the bot.
3) Pick next violation and goto 1)

First violation: space between operators
----------------------------------------

Can be easily fixed by running this:

```
sed -i "s/switch(/switch (/" **/*.d
sed -i "s/foreach(/foreach (/" **/*.d
sed -i "s/foreach_reverse(/foreach_reverse (/" **/*.d
sed -i "s/while(/while (/" **/*.d
sed -i "s/if(/if (/" **/*.d
```

I started with some PRs (one is way to large to review):

https://github.com/dlang/phobos/pull/4239
https://github.com/dlang/phobos/pull/4240
https://github.com/dlang/phobos/pull/4241
https://github.com/dlang/phobos/pull/4242

How big is this change?
-----------------------

> grep -E "(for|foreach|foreach_reverse|if|while)\(" $(find . 
> -name '*.d') | wc -l

3505

As expected a styleguide without a automatically enforcing it, 
leaks ...

Disadvantages
-------------

This potentially might create some troubles with forks or pending 
PRs.

-> If anyone objects the introduction of automatic linting to 
Phobos, please raise your voice!


More information about the Digitalmars-d mailing list