Skip to content

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

Merged
merged 6 commits into from
Dec 5, 2016
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 26 additions & 12 deletions CODING_STANDARD
Original file line number Diff line number Diff line change
@@ -1,17 +1,31 @@
Here a few minimalistic coding rules for the cprover source tree:

a) 2 spaces indent, no tabs
b) no "using namespace std;"
c) Avoid new/delete, use containers instead.
d) Avoid unnecessary #includes, especially in header files
e) No lines wider than 80 chars
f) Put matching { } into the same column
g) If a method is bigger than a page, break it into parts
h) Avoid destructive updates if possible. The irept has
constant time copy.
- Use 2 spaces indent, no tabs.
- No lines wider than 80 chars.
Copy link
Collaborator

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.

- If a method is bigger than a page, break it into parts.
- Put matching { } into the same column.
- Do not use namespaces.
- Prefer use of 'typedef' insted of 'using'.
- Prefer use of 'class' instead of 'struct'.
- User defined type identifiers have to be terminated by 't'. Moreover,
before 't' may not be '_'.
- Avoid new/delete, use containers instead. In other words, do not perform
heap operations directly.
- Write type modifiers before the type specifier.
- Do not use 'm_' prefix nor '_' suffix for names of attributes of structured
types.
- 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
Copy link
Collaborator

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")?

is required. Allowed libraries are: C++ standard library.
- No "using namespace std;".
Copy link
Collaborator

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"

- 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.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/SLT/STL/

- Prohibited stuff from the standard library: ??? TODO!
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would be prohibited?


Architecture-specific code:

a) Avoid if possible.
b) Use __LINUX__, __MACH__, and _WIN32 to distinguish the architectures.
c) Don't include architecture-specific header files without #ifdef ...
- Avoid if possible.
- Use __LINUX__, __MACH__, and _WIN32 to distinguish the architectures.
- Don't include architecture-specific header files without #ifdef ...