style code check tool

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: RoccoMarco, lbednarz, tfAteba

Post Reply
User avatar
tfAteba
Posts: 551
Joined: Fri Oct 16, 2015 11:03 pm
Has thanked: 91 times
Been thanked: 50 times

style code check tool

Post by tfAteba »

Hi,

I try to use style code check from trunk/tools/ but it seems to don't work properly.

I use it for exemple with hal test file but I have the following errors:

style: identation violation at line 43 in "main.c"
style: identation violation at line 43 in "main.c"
...
style: identation violation at line 98 in "main.c"

Is there any option to set when using this tools?

Here is how i use it : perl tools/styleccheck.pl testhal/STM32/STM32F4xx/EXT/main.c
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: style code check tool

Post by Giovanni »

Hi,

The tool is not complete, I suspended working on it because I have more urgent things in queue. it will be able to perform a mass style check when it will be complete.

Giovanni
Marco
Posts: 128
Joined: Tue Apr 16, 2013 8:22 pm
Has thanked: 4 times
Been thanked: 11 times

Re: style code check tool

Post by Marco »

Hi,

Did you see this tool? I think it can already do what you want so it would save some time writing your own.

Marco
awygle
Posts: 32
Joined: Sun Apr 03, 2016 8:39 pm
Has thanked: 6 times
Been thanked: 4 times

Re: style code check tool

Post by awygle »

As another alternative, I was able to put together something to do this in about an hour using clang-format.
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: style code check tool

Post by Giovanni »

Hi,

Probably I should better explain what I wanted to do.

It is not a reformatter, Eclipse is already able to do that and I codified the ChibiOS formatting rules in ChibiStudio.

I wist a rules driven checker able to generate a report of violations, rules would have to be something like:

- 2 spaces indent
- No tabs
- No trailing spaces
- EOL must be CRLF
- No multiple blank lines
- Single blank line after section separation comments.
- Doxygen comments before functions containing @brief, @details, @param etc
- No camel case identifiers for local variables
- No camel case identifiers for static objects
- Camel case identifiers for global symbols unless prefixed by _
- Source files must contains the sections separators part of the template.
- No defines within the struct section.
- Functions code is divided in codelets composed by a comment, statement+, single blank line.
- etc etc

Basically everything makes the ChibiOS code base look consistent. It would be used both as an acceptance tool and, for regular contributors, as a final check before submissions.

So not just a reformatter but more a quality enhancement tool.

Maybe I am just sick for this kind of things :)

Giovanni
Marco
Posts: 128
Joined: Tue Apr 16, 2013 8:22 pm
Has thanked: 4 times
Been thanked: 11 times

Re: style code check tool

Post by Marco »

Ok now it makes sense to write a custom tool. Artistic style has a dry-run option where it only checks but doesn't re-format the code. Unfortunately it is only able to check a few of your rules, not all.
User avatar
tfAteba
Posts: 551
Joined: Fri Oct 16, 2015 11:03 pm
Has thanked: 91 times
Been thanked: 50 times

Re: style code check tool

Post by tfAteba »

Hi all,

Marco, awygle, thank you for your suggestions of tools, I will take a look to when I will have some spare time.

Giovanni, no problem, the tool is not ready yet so I will do my best to respect the code style by using this guide :D : http://www.chibios.org/dokuwiki/doku.ph ... tyle_guide

But I'm so curious to see the power and features of this tool when it will be finish.
Post Reply