Skip to content

CI: Detect common antipaterns in coding style that are not caught by clang-format

Recently, we tried to initialize all the pointers. It would be good if we could automate this check, but also some others that we see frequently in code reviews.

@npocs came up with the following grep during that time:

grep -rinP '^(?!.*=)\s*(?:\w+\s+)*\w+\s*\*\s*\w+\s*;'

So the idea is to tweak the grep and include in the review phase to simplify catching these cases in the future.

Similarly, our coding style suggest that we should not omit braces around the if blocks:

https://gitlab.com/libssh/libssh-mirror/-/blob/master/CONTRIBUTING.md?ref_type=heads#if-switch--code-blocks

I think the clang does not have a check for that either, but we might be able to figure out some grep to handle that.

Similarly I quite often come over an array missing trailing comma, which is then formatted in ugly way such as

int a[] = {
    1,
    2,
    ...
    99};

and clang being happy about that, while its enough to add trailing comma and close the brace on new line:

int a[] = {
    1,
    2,
    ...
    99,
};
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information