I'm looking for a script/tool that can be customized to check and enforce coding/naming conventions on a C/C++ code.
It should check for example:
_
Many of the projects I'm working on are outsourced by customers which tend to have various internal coding and naming conventions.
The first character of the name should be a letter and all characters (except the period) should be lower-case letters and numbers. The base name should be eight or fewer characters and the suffix should be three or fewer characters (four, if you include the period).
A C coding standard is a set of rules for source code that is adopted by a team of programmers working together on a project, such as the design of an embedded system. Programming teams and companies write down their C coding standards for a variety of reasons but often bicker internally about which rules to follow.
The first character of the identifier must be a letter of the alphabet (upper or lowercase) or an underscore ('_'). The rest of the identifier name can consist of letters (upper or lowercase), underscores ('_') or digits (0-9). Identifier names are case-sensitive. For example, myname and myName are not the same.
A naming convention is a convention (generally agreed scheme) for naming things. Conventions differ in their intents, which may include to: Allow useful information to be deduced from the names based on regularities.
Don't know if it's really worth the time, but if you really want, you could try building something similar to google's cpplint, which does checking of their style guide.
I personally think that thorough reviews and people's commitment to follow certain conventions is a much better way to make sure your code is "indented properly" and variables named consistently. Maybe invest in making a document like google has done, describing the details of acceptable style, and have people in your company accept it and stick to it.
Why humans are better than a script? The answer is quite simple: people will have to deal with the code later, they should care about the stuff they are writing. A variable name like i
will be fine for a script, but not going to slip from my eyes, if it is a clientCount
, it should just be named appropriately, script which would be able to do that might take over the world rather soon. :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With