Skip to content
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

Indentation of public, protected, private keywords #4448

Open
thomasgeissl opened this issue Oct 18, 2015 · 7 comments
Open

Indentation of public, protected, private keywords #4448

thomasgeissl opened this issue Oct 18, 2015 · 7 comments

Comments

@thomasgeissl
Copy link
Contributor

I am suggesting a little change to the coding style used for oF.
I would like to remove the indentation of public, protected and private keywords.

Here is the snippet from the style guidelines I am referring to:
The public, protected, and private keywords should be indented inside the class with the function declarations indented as well.

Every time a new line is added in a header file, it gets indented according to the IDE's (in my case Xcode) default style. And one has to manually indent the line.

screen shot 2015-10-18 at 12 41 15

I guess most people using Xcode as their IDE (I haven't checked the latest survey) and the default Xcode style is the default for other IDEs too, as Arturo says in (openframeworks/projectGenerator#59). I can confirm Qt Creator uses the same styling.

In my opinion this often leads to bad formatted code.

Another point I would like to change is the order of the following two lines in the ofApp template. They should be swapped to be in the same order as in the implementation file.

void dragEvent(ofDragInfo dragInfo);
void gotMessage(ofMessage msg);

What were the reasons for the indentation? And what are the disadvantages of changing the style guidelines?

@danoli3
Copy link
Member

danoli3 commented Oct 18, 2015

Also Xcode makes it easy to make this change if this is the path we go down.
Select All - > Cut ->Paste

Easy to Xcode Default indentation :)

@julapy
Copy link
Member

julapy commented Oct 18, 2015

yeah +1
that always niggles at me too.
i also do what @danoli3 does, cut and paste to get it back into xcode format.
be nice if it was already formatted correctly tho...

@drlight-code
Copy link
Contributor

dudes.... get to know your tools.
https://www.gnu.org/software/indent/
brew install gnu-indent

here's PR: #4453

Created with

find . -name '*.cpp' -o -name '*.h' -exec indent -ci4 -i4 -nut {} \;

You might want to take this opportunity to have your tiresome discussion about where braces need to be placed, etc. however I think there are more pressing issues at hand ;)

@bilderbuchi
Copy link
Member

dude, get to know your tools: https://github.com/openframeworks/openFrameworks/wiki/openFrameworks-Coding-style-guidelines and the /scripts/dev/style directory.
also, time to get off your high horse I think. ;-)

@drlight-code
Copy link
Contributor

Ah nice so there is stuff available regarding this. Well don't have an overview about all the details of the project yet, scusi :/ Was just irritated that copy/paste is used for reformatting of sourcecode. And yeah maybe I should step back here a little bit, thanks for pointing that out. Anyways I have seen that there is no consistently applied style right now by looking at the different headers, so I think having this automated solution which will indent the complete source tree for once would be nice.

(wtf happened with that const keyword? looking into it...)

@bilderbuchi
Copy link
Member

If you look at /scripts/dev/style, you will find that an automated solution (using uncrustify) already exists, although it probably needs a bit of updating.
The reason we haven't formatted OF with this yet is that it was felt by @openframeworks/core that the whitespace changes would pollute the git history; and because there was not mechanism in place to ensure compliance with the style after we applied it - if that's not there, the code would slowly go "out of style" again. In the meantime, we got a CI setup using Travis, so maybe it's time to revisit the question of an automated checker (based on styleWholeOF, and using @ofbot to make the changes).
There seems to be an uncrustify setting doing what you want, so you can probably play around with that in the style config file to see if that matches your expectations.

see also issue #3392 and probably some threads on the mailing list (if you want earlier history).

@danoli3
Copy link
Member

danoli3 commented Oct 20, 2015

Yeah it really would break a lot of old PR's that are yet to be looked at.
If this is a thing to do, have to really take that into consideration.

@arturoc arturoc added this to the 0.10.0 milestone Nov 9, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants