-
Notifications
You must be signed in to change notification settings - Fork 157
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Code style conformance #145
Conversation
These scripts provide a convenient way to update code to match a uniform style. These scripts were adapted from the tools used on the ITK codebase.
Uniformly formatted code will make future maintenance and support easier.
I would love to hear your comments about how we can make the code more uniform. I have seen that other bug/warning fixes are often confounded when bug/warning fixes are unnecessarily confounded with code style consistencey changes. By having a consistent style, it makes reading all the code easier, and it makes future patch sets easier to review. |
@@ -80,20 +80,20 @@ extern "C" { | |||
#define XML_TOK_PREFIXED_NAME 41 | |||
|
|||
#ifdef XML_DTD | |||
#define XML_TOK_IGNORE_SECT 42 | |||
# define XML_TOK_IGNORE_SECT 42 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a style choice. It can be turned off. Many places would indent the contents of if/else pragma statements.
Some code had it each way. I went with indenting to make it easier to identify code blocks of pramas.
@hjmjohnson Brilliant!! This is far overdue and will make working with this code dramatically less painful. Ignore my inline comments: I didn't notice that the indented |
bsta_algo_test_fit_gaussian <-- failed on clang Both of these tests pass on my computer. I think these are transient failures not related to this patch set. |
I'm fine with the change, but I have a couple procedural comments:
|
Actually, if we are going to go through the trouble of a sweeping code style update, perhaps we should first discuss whether to update the indentation style. The current style with content aligned with curly braces is called Whitesmiths style. While it was popular when vxl, ITK, and VTK started it is much less so now and few editors support it. This was discussed on the VTK dev list and after many alternative styles were debated the conclusion was that the least disruptive change is to just move all the curly braces two spaces to the left. That modernizes the content (non-)alignment without making any other style changes. |
@bradking Great Comments. I had mostly expected this patch set to be rejected as is, and a second (and perhaps third) iteration before we get some (not unanimous) agreement. There are many tools that have defaults for the "Google C++ style" or the "LLVM" style. In my mind being consistent is the most important. Having support for maintaining that consistency is second most important. By choosing an established style protocol gives the advantage of offloading the maintenance of the style documentation and formatting tool (both editors and code beautifiers) support to a larger community that spans many projects. Here's my current plan (please suggest a different approach):
Note: I don't have a strong preference on most style issues, and the "Google C++ Style" is just the most prominant (perhaps not best) one that I could find. |
@bradking I'm not religiously attached to any style method either, but I do value consistency between vxl and ITK (and VTK, though I'm less familiar). I don't know if the discussions you've referred to have resulted in any official changes to the guidelines, but the style guides I've been using (ITK [1], VTK [2]) both suggest that the curly braces be done the way @hjmjohnson suggested originally. If there's will to change practice towards something like the Google guide, I would have no problem, but for the time being I wonder if maintaining multiple practices would be confusing. Do we have a good sense of who the main users of vxl are? From the github activity it feels like the majority of vxl users are also using ITK/VTK, in which case consistency is in my mind a bigger issue, but I could be wrong. [1] http://www.vtk.org/Wiki/ITK/Coding_Style_Guide#Use_of_Braces |
To be really clear here: I am ONLY advocating for consistentcy. I will take community comments and do by best to reconcile differences of opinions. |
A few more comments:
|
If we are to change styles and achieve consistency between ITK and VXL then this should probably be brought up on the ITK list first since that has more interested parties. Since this PR is also based on a topic branch in the main repository I propose we close this PR, delete the branch, and move to a new one in @hjmjohnson's fork. |
@bradking Sorry about using the main branch for the pull request. Future requests will be made from a forked version. This is a big decision, and will probably take more than a few days to get rigtht. I'll pull all the comments from this and other threads together this weekend, and make proposals to the ITK community. I also like the clang-format model. It seems like it will integrate more naturally with editors automated cleanings. With respect to ITK, it also means some KWSTYLE changes. |
+1 to all the comments. I think the most effective proposed style change is one that provides a On Fri, Jan 29, 2016 at 9:28 AM, Hans Johnson [email protected]
|
This pull request provides consistent code style conformance for all the code in vxl. It uses tools similar to those used by ITK to accomplish the same task.