Skip to content

Support multiple severity levels for diags from a single checker #4643

@tauchris

Description

@tauchris

I have a checker that flags differences in parameter type declaration spelling between the prototype and definition for C functions. Some differences (for example, inconsistent use of 'const' qualifier) are purely questions of STYLE. But it can be argued that some (for example, inconsistent use of 'restrict' qualifier) have real risk, even though the difference in declaration spelling is meaningless to the compiler. So, I'd like to set the severity for some of the diagnostics differently than for the purely-STYLE findings.

As things stand, with CodeChecker settings, I don't see a way for distinct diagnostics from a single checker to have different severity levels. I think it might be possible to do something like this with regular expressions in the codechecker config, though. Perhaps, instead of

"mychecker": [ "doc_url:https://blah-blah-blah/blah-blah", "severity:STYLE" ],

we might have:

"mychecker": [ "doc_url:https://blah-blah-blah/blah-blah", "conditional-severity": [ "match-regex:.*restrict.*", "severity:LOW" ], "severity:STYLE" ],

Not sure what would make the most sense for the config parser, as this format looks like JSON at the top, but values in the JSON look like they are further broken into key/value pairs with some additional custom syntax expectations...

The only other alternative is for me to break the checker into multiple checkers with different severity levels, which costs extra runtime, and also can generate redundant diagnostics (consider a single declaration where both 'const' and 'restrict' are used inconsistently between prototype and definition, for example -- a single checker can emit one diagnostic and one fixit covering both conditions, but multiple checkers cannot). Breaking up the checker also increases code complexity and/or maintenance risk for the checker implementation.

I've had similar cases before that forced me to break checkers up into multiple checkers. Since this came up for me a second time, I thought I might ask...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions