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

Suggest use of clang-format #9

Open
WolfgangVogl opened this issue Dec 5, 2018 · 4 comments
Open

Suggest use of clang-format #9

WolfgangVogl opened this issue Dec 5, 2018 · 4 comments

Comments

@WolfgangVogl
Copy link

It's hard to comply to the coding style, a clang-format file would help at some points:

The "nearest" style actually seems something like

Language: Cpp
BasedOnStyle: Mozilla
AlignAfterOpenBracket: DontAlign
AlignOperands: false
AlignTrailingComments: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
BinPackArguments: true
BinPackParameters: true
BraceWrapping:
  AfterClass: true
  AfterControlStatement: true
  AfterFunction: true
  AfterNamespace: true
  AfterStruct: true
  BeforeCatch: true
  BeforeElse: true
BreakBeforeBraces: Custom
BreakConstructorInitializers: AfterColon
ColumnLimit: 0
Cpp11BracedListStyle: true
MaxEmptyLinesToKeep: 1
SortIncludes: false

(Used whatstyle to analyze).

What do you think about adding some reasonable style format?

@octobanana
Copy link
Owner

The current formatting style is quite consistent with itself. When in doubt, looking at the surrounding code and similar sections should help to clarify things. Although, having a format spec would ease code reviews, so I'll have a look.

What do you specifically find unreasonable regarding the current formatting style?

@WolfgangVogl
Copy link
Author

Yes, you're right. The formatting is consistent with itself - sorry for the bad explanation/misleading topic.
My problem was that I HAVE TO look at the surrounding code to adapt a foreign code style instead of just write code and let a (formatting) tool do it's job.

Just as an example: When do you write spaces with curly braces initializions?
=> std::string index_file {"index.html"};
You've to find another place with this kind of initializion... some people write
std::string index_file { "index.html" }; or
std::string index_file{"index.html"}; or
std::string index_file{ "index.html" };
Thats annoying extra work with big chance of doing styling wrong.

I couldn't tell you which form of the above example I would write intuitively as I don't really care - I think thats the job of a formatting tool.

@octobanana
Copy link
Owner

I can see how a formatter would make things easier. I haven't had a chance to try out clang-format yet, but I still plan on checking it out.

Interestingly, the example you provided for how spaces are formatted with uniform initialization syntax, has the following surrounding lines:

// the public directory for serving static files
std::string public_dir {};

// default index filename for the public directory
std::string index_file {"index.html"};

// socket timeout
std::chrono::seconds timeout {10};

// serve static files from public directory
bool http_static {true};

// serve dynamic content
bool http_dynamic {true};

// upgrade http to websocket connection
bool websocket {true};

@WolfgangVogl
Copy link
Author

It was just an proposal and the example was the first that passed through my mind.

"I couldn't tell you which form of the above example I would write intuitively".

@octobanana octobanana changed the title Hard to comply with the coding style - suggest clang_format Suggest use of clang-format Dec 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants