Coding style and white space

Lubomir I. Ivanov neolit123 at gmail.com
Thu Jan 16 12:26:58 UTC 2014


On 16 January 2014 21:14, Danilo Cesar Lemes de Paula
<danilo.eu at gmail.com> wrote:
> On 01/16/2014 06:32 AM, Benjamin wrote:
>> Are the flaming and discarding being done for the children? Or is using
>> the correct coding style being done for them?
>>
>
> Working on so many projects with so many different conventions is quite
> difficult to adapt vim/emacs/whatever to each project.
> I like the idea that if a project has its own coding style guidelines
> and wants to enforce them, it should also ship a tool to help doing
> that.
>
> gstreamer has a git-hook that uses indent (gnu indent) to force or
> complain about coding style before the commit is accepted by git.
> webkit also has its own coding complainer (webkit-check-style) that is
> always called before webkit-upload-patch.
> I've heard that clang also has a built-in tool to fix coding style.
>
> Might be a good idea to take a look on those tools.
>

subsurface's coding style is based on the linux kernel coding style,
which also translates to the c++ part as much as possible.
therefore we already have a tool for that - checkpatch.pl

but you may have to disable the kernel root checking:
if (!defined $root) {
# print "Must be run from the top-level dir. of a kernel tree\n";
# exit(2);
}

./checkpatch.pl -f --max-line-length=200 --ignore=C99_COMMENTS tagwidget.h

for the above c++ header file it will report false positives like:
ERROR: spaces required around that '>' (ctx:VxW)
#14: FILE: tagwidget.h:14:
+ QPair<int, int> getCursorTagPosition();

but also things like:
ERROR: code indent should use tabs where possible
#25: FILE: tagwidget.h:25:
+        QCompleter *m_completer;$

lubomir
--


More information about the subsurface mailing list