-
Notifications
You must be signed in to change notification settings - Fork 358
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[bugfix] Required format for --checker-config #3817
Conversation
Please don't review it yet. I'd rather like to give a whole different implementation for this issue. |
af52f5e
to
fe3c6c3
Compare
The alternative implementation is done, it can be reviewed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, I guess! I like that the code in most places got a lot simpler.
@@ -7,6 +7,7 @@ | |||
# ------------------------------------------------------------------------- | |||
""" | |||
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might as well remove these?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I rather added some minimal documentation in order to keep consistency.
fe3c6c3
to
95e4f46
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My usual gripe -- please, cope the commit message to the description.
analyzer/codechecker_analyzer/arg.py
Outdated
|
||
if not m: | ||
raise argparse.ArgumentTypeError( | ||
f"Checker option in wrong format: {arg}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...should be
f"Checker option in wrong format: {arg}") | |
f"Checker option in wrong format: {arg}, should be <analyzer>:<checker>:<option>=<value>") |
95e4f46
to
9675a43
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please see my remarks
if cfg.analyzer == cls.ANALYZER_NAME: | ||
analyzer_config[cfg.option] = cfg.value | ||
|
||
if not analyzer_config: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain in a comment why we adding this minimal configuration?
@@ -6,6 +6,7 @@ | |||
# | |||
# ------------------------------------------------------------------------- | |||
""" | |||
ClangTidy related functions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a very shy module comment.
analyzer/codechecker_analyzer/arg.py
Outdated
@@ -87,3 +89,47 @@ def existing_abspath(path: str) -> str: | |||
raise argparse.ArgumentTypeError(f"File doesn't exist: {path}") | |||
|
|||
return path | |||
|
|||
|
|||
def analyzer_config(arg: str): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you specifiy the return type, if you define the NamedTuple at the module level?
analyzer/codechecker_analyzer/arg.py
Outdated
m.group("analyzer"), m.group("option"), m.group("value")) | ||
|
||
|
||
def checker_config(arg: str): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you specifiy the return type, if you define the NamedTuple at the module level?
if not m: | ||
raise argparse.ArgumentTypeError( | ||
f"Checker option in wrong format: {arg}, should be" | ||
"<analyzer>:<checker>:<option>=<value>") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These error messages, and the examples provided in the help messages should be in the same format. I prefer these ... variant, so please modify the help messages of argparser. (You can chose the other, if you want.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please give an example?
return_code, _, err = run_cmd(cmd) | ||
|
||
self.assertEqual(return_code, 1) | ||
self.assertIn("Checker option in wrong format", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you make a negative testcase for testing a mistyped analyzer option too?
docs/analyzer/user_guide.md
Outdated
of the clang-tidy binary. (default: ['clang- | ||
tidy:HeaderFilterRegex=.*']) | ||
a -config flag then those options extend these. To use | ||
analyzer configuration file in case of Clang Tidy |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick, but for my ears this rings better: ...To use an analyzer configuration...
option. It will skip setting the '-checks' parameter | ||
of the clang-tidy binary. (default: ['clang- | ||
tidy:HeaderFilterRegex=.*']) | ||
a -config flag then those options extend these. To use |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick, but for my ears this rings better: ...To use an analyzer configuration...
"CodeChecker analyze" command has a --checker-config flag. The parameter of this flag should be in the following format: <analyzer>:<checker>:<option>=<value> clang-tidy tool requires a "." character between the checker and the option, so CodeChecker should convert it from : to . The format of --checker-config (and --analyzer-config) is now checked at the command line parsing phase, so it is done with a common algorithm for all analyzer tools. Earlier the default value of --analyzer-config was "clang-tidy:HeaderFilterRegex='.*'", so clang-tidy analysis of header files is also done. This is not a default value for the flag anymore, but it is handled under clang-tidy module.
9675a43
to
1a7a53e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
"CodeChecker analyze" command has a --checker-config flag. The parameter
of this flag should be in the following format:
<analyzer>:<checker>:<option>=<value>
clang-tidy tool requires a "." character between the checker and the
option, so CodeChecker should convert it from : to .
The format of --checker-config (and --analyzer-config) is now checked
at the command line parsing phase, so it is done with a common algorithm
for all analyzer tools.
Earlier the default value of --analyzer-config was
"clang-tidy:HeaderFilterRegex='.*'", so clang-tidy analysis of header
files is also done. This is not a default value for the flag anymore,
but it is handled under clang-tidy module.