Ask Your Question
4

Code style checking, specifically naming convention

asked 2014-01-02 08:43:02 -0600

updated 2014-01-07 05:32:33 -0600

Is there a ROS tool that enforces the ROS coding style and in particular the naming conventions?

I am currently using roslint, but it doesn't seem to be checking the variable/class/method naming conventions.

<edit> I would like a tool that catches/fixes naming issues (those that don't adhere to a style). Currently, I catch these issues at code review time, but it would be better if developers had a tool to catch/fix these mistakes themselves.

edit retag flag offensive close merge delete

3 Answers

Sort by » oldest newest most voted
3

answered 2014-01-06 08:54:03 -0600

gvdhoorn gravatar image

updated 2014-01-08 04:44:35 -0600

Also likely not an answer you're hoping for, but for C++ there is ClangFormat, which supports customisable style rulesets. Should be available on all platforms that Clang is available on.

By default it reformats any input files using the specified style, but it has options to output replacements as xml, which should allow for inclusion in a Jenkins style CI setup.

With some work, it looks like the ROS_format.xml from the wiki could be ported to ClangFormat format.


Edit:

But will it catch/fix naming issues?

I don't think so (but I'm not sure). One of the few free tools that can do this seems to be vera++, which apparently is now on bitbucket. From what I understand this would need some serious work getting the ROS C++ style configured though (available ruleset here).


Edit2: Codehaus SonarCube seems to have a vera++ plugin, which outputs checkstyle style XML reports, see here for a 'sample'.

edit flag offensive delete link more

Comments

I'm not a stickler for spacing, just naming. Since the ROS format is based on the google style and ClangFormat for google already exists, this might be OK. But will it catch/fix naming issues?

sedwards gravatar imagesedwards ( 2014-01-07 05:30:53 -0600 )edit
2

answered 2014-01-06 00:33:42 -0600

I'm not aware of any ROS tools that do that, but if you're using Python, try pylint. It's available as a Ubuntu/Debian package and can be configured to match the ROS naming conventions.

If you're using Eclipse to develop C++ code, check out the ROS_format.xml code style.

edit flag offensive delete link more

Comments

I'm using ROS_format.xml, but it doesn't catch/fix naming mistakes. Am I wrong?

sedwards gravatar imagesedwards ( 2014-01-07 05:29:16 -0600 )edit

No, you're probably right. I haven't used it in a while, but now come to think of it of course it can only correct formatting, not variable names.

Martin Günther gravatar imageMartin Günther ( 2014-01-07 22:24:42 -0600 )edit
0

answered 2017-08-25 11:50:54 -0600

KwanFace gravatar image

Resharper has a utility to accomplish this. Look under "Naming style".

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2014-01-02 08:43:02 -0600

Seen: 1,613 times

Last updated: Jan 08 '14