Implementing Case Sensitive Rules with CodeChecker
April 30, 2022
In a recent post I mentioned that CodeChecker can now be run in a CI environment. There's another addition that I'm happy to have and that is the ability to write case-sensitive code rules.
The syntax of writing case-sensitive rules is straight-forward. Here's an example:
...
{
"customRules": [
{
"name": "Use correct BIF case for arrayLen",
"pattern": "arraylen",
"caseSensitive": true
}
]
}
...
This is a pretty trivial example, but you get the idea. This would flag up an instance
of arraylen
which you may want to have written as arrayLen
. This feature won't come
in handy a lot, but there are times when it is useful (e.g. "Coldfusion" instead of the proper "ColdFusion").
Under the hood, the matcher uses reFind
or reFindNoCase
to search depending on
your preferred case sensitivity.