-
Notifications
You must be signed in to change notification settings - Fork 273
Coding rules and cpplint #293
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
Conversation
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.
I'm not quite sure why this one is tagged "help", or actually whether there are specific questions that need answers?
- Avoid destructive updates if possible. The irept has | ||
constant time copy. | ||
- Avoid unnecessary #includes, especially in header files | ||
- We allow to use 3rd libraries directly. No wrapper matching the coding rules |
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.
Should that be 3rd-party libraries (instead of "3rd libraries")?
- Avoid unnecessary #includes, especially in header files | ||
- We allow to use 3rd libraries directly. No wrapper matching the coding rules | ||
is required. Allowed libraries are: C++ standard library. | ||
- No "using namespace std;". |
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.
Redundant with "Do not use namespaces"
is required. Allowed libraries are: C++ standard library. | ||
- No "using namespace std;". | ||
- Use instances of std::size_t for comparison with return values of .size() of | ||
SLT containers and algorithms, and use them as indices to arrays or vectors. |
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.
s/SLT/STL/
- No "using namespace std;". | ||
- Use instances of std::size_t for comparison with return values of .size() of | ||
SLT containers and algorithms, and use them as indices to arrays or vectors. | ||
- Prohibited stuff from the standard library: ??? TODO! |
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.
What would be prohibited?
Suggestions for further rules:
|
These are the questions I've had so far on which style is prefered. I don't know if these are too detailed/heavy handed. A ruling on spacing, e.g. prefer
Preferred header guard style, e.g.:
Specify whether the Should
|
Very useful questions, and I'm answering them from having read a lot of code (no right or wrong here, just ruling from majority of cases):
|
h) Avoid destructive updates if possible. The irept has | ||
constant time copy. | ||
- Use 2 spaces indent, no tabs. | ||
- No lines wider than 80 chars. |
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.
The code base, by and large, actually uses 70 chars. Though be sensible about it: don't trade extra-short (and then meaningless) variable names for achieving short lines.
A couple of other things that have come up from @peterschrammel reviewing my code (apologies Peter if I've misunderstood anything): When splitting function parameters on to multiple lines (both in headers and in source files), subsequent lines should not be indented to continue from previous line i.e. No Continuation
instead of Continuation:
Does anyone know of a way to get QtCreator to do this? As far as I can tell it can either have no indentation or align with the previous line Full variable names (e.g. Prefer Use American spellings Use |
We'll make this machine checkable so that we don't have to comment on most style issues during reviewing anymore. |
1ce0116
to
912df12
Compare
The integration with travis is working now. The CPP-LINT log is at the end of the log. |
912df12
to
f266914
Compare
Is this really what the coding rules suggest? Old code:
New code:
This code is already accepted by the linter, would this be preferable?
|
On Tue, Nov 29, 2016 at 3:21:44 -0800, thk123 wrote:
Is this really what the coding rules suggest?
Old code:
mock_generator.reset(new c_fff_mock_generatort(*message_handler, *e2c,
symbol_table));
I suppose the linter says the above is undesirable? I would agree, because
working out matching parentheses is a bit hard (i.e., is symbol_table an
argument to reset or to c_fff_mock_generatort?).
New code:
mock_generator.reset(
new c_fff_mock_generatort(
*message_handler,
*e2c,
symbol_table));
This code is already accepted by the linter, would this be preferable?
mock_generator.reset(
new c_fff_mock_generatort(
*message_handler,
*e2c,
symbol_table));
Ideally the linter would always require that last suggestion, but I guess that's
hard to do.
Overall there are many aspects here that are a matter of personal taste and
perception. The codebase, at present, vastly conforms with the last example
given above.
Best,
Michael
|
@peterschrammel If you could squash my additional commits into your Travis configuration modifications I'd be grateful! |
cb9c95a
to
6aa54be
Compare
@tautschnig, squashed. |
@thk123, as @tautschnig pointed out, the latter version is preferable:
|
6aa54be
to
2826561
Compare
The following changes were made: - admissible source files - header guards - do not check order of header files - no whitespace around = - operator spacing - braces on separate lines - keep access keywords on base column - allow virtual override - argument and parameter indent - types end with t - fix spaces around && and || - no namespace and using - exclude auto-generated files
2826561
to
e24acd4
Compare
@kroening, can we merge this? |
Initial version of trace transformer utility
No description provided.