Skip to content
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

Merged
merged 1 commit into from
Mar 24, 2023

Conversation

bruntib
Copy link
Contributor

@bruntib bruntib commented Jan 16, 2023

"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.

@bruntib bruntib added CLI 💻 Related to the command-line interface, such as the cmd, store, etc. commands bugfix 🔨 analyzer 📈 Related to the analyze commands (analysis driver) labels Jan 16, 2023
@bruntib bruntib added this to the release 6.22.0 milestone Jan 16, 2023
@bruntib bruntib requested a review from vodorok as a code owner January 16, 2023 10:29
@bruntib bruntib added the WIP 💣 Work In Progress label Jan 16, 2023
@bruntib
Copy link
Contributor Author

bruntib commented Jan 16, 2023

Please don't review it yet. I'd rather like to give a whole different implementation for this issue.

@bruntib bruntib requested a review from dkrupp as a code owner January 20, 2023 15:39
@bruntib bruntib removed the WIP 💣 Work In Progress label Jan 20, 2023
@bruntib
Copy link
Contributor Author

bruntib commented Jan 20, 2023

The alternative implementation is done, it can be reviewed.

Copy link
Collaborator

@Szelethus Szelethus left a 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 @@
# -------------------------------------------------------------------------
"""
"""
Copy link
Collaborator

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?

Copy link
Contributor Author

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.

Copy link
Collaborator

@Szelethus Szelethus left a 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.


if not m:
raise argparse.ArgumentTypeError(
f"Checker option in wrong format: {arg}")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...should be

Suggested change
f"Checker option in wrong format: {arg}")
f"Checker option in wrong format: {arg}, should be <analyzer>:<checker>:<option>=<value>")

Copy link
Collaborator

@vodorok vodorok left a 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:
Copy link
Collaborator

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.
Copy link
Collaborator

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.

@@ -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):
Copy link
Collaborator

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?

m.group("analyzer"), m.group("option"), m.group("value"))


def checker_config(arg: str):
Copy link
Collaborator

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>")
Copy link
Collaborator

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.)

Copy link
Contributor Author

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)
Copy link
Collaborator

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?

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
Copy link
Collaborator

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
Copy link
Collaborator

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.
Copy link
Collaborator

@vodorok vodorok left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Collaborator

@Szelethus Szelethus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@bruntib bruntib merged commit 6f92895 into Ericsson:master Mar 24, 2023
@bruntib bruntib deleted the tidy_config_format branch March 24, 2023 14:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzer 📈 Related to the analyze commands (analysis driver) bugfix 🔨 CLI 💻 Related to the command-line interface, such as the cmd, store, etc. commands
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants