libs-opal
libs-opal copied to clipboard
Apply standard coding style
As described in the commit message, apply a standard code style for Opal with the following configurations:
- Use broken braces without GNU-indented blocks
- Use GNU-style indentation (two spaces as tabs)
- Use GNU-style Objective-C:
- Insert GNU padding after Objective-C method colon
- Align Objective-C colons in declarations and calls
- Indent
case
s inside switch blocks - Pad parentheses after statements (e.g.
if ()
as opposed toif()
) - Insert one indent for continuing a function call.
- Do not limit line width.
Unlike other GNUstep projects (Base, GUI, CoreBase), which may not conform fully to a coding style but mostly converge to one, Opal is currently a very big mess when it comes to styles to the point that reading code becomes really hard sometimes. This one I came up with tries to resemble most of the codebase.
If you agree with applying this, I intend on adding a CI build stage which fails the build if AStyle detects a file is outside these constraints.
On a sidenote, I am sure either formatter bugs or a bad config may have generated awkward or worse code in parts of the codebase. But the overall
For purposes of not corrupting the git history with this huge commit, Git provides git blame -w
, which ignores whitespaces from a blame
for debugging purposes.
@ivucica, I can't request a review in the GitHub UI so I think this mention is a way of doing it.
(I do not expect this to be merged immediately or as-is, or ever; it's just a discussion-prompter).
Hi! Sorry for leaving things in a messy formatting state!
I am OK with merging a reformat, but I would suggest aiming for the style used by CoreBase / libs-back / libs-gui, rather than trying to preserve elements of the original Opal style.
One question is whether to use tab characters at all; it seems older code in GNUstep does but some newer code doesn't (corebase, e.g. the cairo backend in libs-back). I don't see it mentioned explicitly in https://www.gnu.org/prep/standards/standards.html#Formatting , but the manpage for GNU indent says the default is to use tabs (-ut
option). Using tabs with GNU brace indentation always seemed odd to me, since they have to be rendered as 8 spaces or the formatting gets completely ruined.
Also - I noticed CGGradient.h
is showing ^M
characters added when I do git diff master theiostream/cleanup
, so it looks like it was converted to DOS line endings by accident. Probably all files should be using unix line endings?
I just updated the pull request to contain a reformat which follows the GNU format (or should, at least). There is also a second commit that has the files converted from DOS line endings to Unix.
Maybe now we have a better reformat to start discussing.
(This time we use astyle --style=gnu -s2 -xM -S -xP2 -H -xC79
)
Whenever I try using GNU indent Objective-C stuff gets screwed up. That's why I tend to prefer astyle.
@theiostream Any updates in this PR?