Opened 11 years ago

Closed 6 years ago

#554 closed enhancement (fixed)

C-style checking tool

Reported by: Jiri Svoboda Owned by: Jiri Svoboda
Priority: major Milestone: 0.7.2
Component: helenos-infrastructure Version:
Keywords: Cc:
Blocker for: Depends on:
See also:

Description

C-style enforcement by human review is putting an increased burden on HelenOS developers. We need an automatic tool for checking the source code C-style, to cover at least the more common C-style errors.

Change History (7)

comment:1 by Jiří Zárevúcky, 11 years ago

We can try using http://clang.llvm.org/docs/ClangFormat.html to automatically reformat all files.

comment:2 by Martin Decky, 11 years ago

On a regular basis, I would prefer checking only to automatically reformatting. We have a few basic coding style rules, but all the finer details should be perhaps left to the humans, since it is more art than science and formalizing everything up to the last bit might just not be very helpful.

One-off automatic cleanup of non-compliant sources merged from an external branch is perfectly fine, but I would be against, for example, adding any automatic reformatting as a commit hook.

comment:3 by Jiří Zárevúcky, 11 years ago

I haven't examined the tool too closely yet, but I think it can easily be used for checking style by diffing original and reformatted sources. It the tool is sane enough, then it would keep the unspecified things unchanged.

comment:4 by Vojtech Horky, 11 years ago

I briefly tried the ClangFormat tool, but I think it does not yet provide all the functionality we need (I was trying it with current SVN revision).

What I miss the most is way to specify how to handle wrapping of long lines. I have not found a way how to specify the indentation of the next line among possible options.

If someone want to give it a try, here is the closest configuration I was able to create.

ColumnLimit: 80
UseTab: true
IndentWidth: 8
SpacesBeforeTrailingComments: 1
SpacesInCStyleCastParentheses: false
ConstructorInitializerIndentWidth: 2
AlignEscapedNewlinesLeft: false
BinPackParameters: true
AllowAllParametersOfDeclarationOnNextLine: false
SpaceAfterControlStatementKeyword: true
SpacesInParentheses: false
PointerBindsToType: false
SpaceInEmptyParentheses: false
IndentCaseLabels: false
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
BreakBeforeBraces: Stroustrup

comment:5 by Jakub Jermář, 11 years ago

Note that there is also the Unix command line tool called indent which can do similar things and it can also specify the indentation of the continuation lines.

comment:6 by Jiri Svoboda, 6 years ago

Owner: set to Jiri Svoboda
Status: newaccepted

comment:7 by Jakub Jermář, 6 years ago

Milestone: 0.7.2
Resolution: fixed
Status: acceptedclosed

This is fixed by Sycek.

Note: See TracTickets for help on using tickets.