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

Allow --file and skipfile option to be given together and analyze header file #3616

Merged
merged 2 commits into from
Mar 8, 2022

Conversation

csordasmarton
Copy link
Contributor

@csordasmarton csordasmarton added enhancement 🌟 test ☑️ Adding or refactoring tests analyzer 📈 Related to the analyze commands (analysis driver) labels Mar 2, 2022
@csordasmarton csordasmarton added this to the release 6.19.0 milestone Mar 2, 2022
@@ -107,3 +107,18 @@ def __call__(self, source_file_path: str) -> bool:
Check if the given source should be skipped.
"""
return self.should_skip(source_file_path)


class SkipListHandlers(list):
Copy link
Contributor

Choose a reason for hiding this comment

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

This class has two methods doing the same thing. Couldn't we eliminate one of them?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The above class also implemented these methods. For now I added a FIXME to remove one of the method from both classes.

Comment on lines 734 to 735
header_file_extensions=(
'.h', '.hh', '.H', '.hp', '.hxx', '.hpp', '.HPP', '.h++', '.tcc')
Copy link
Contributor

Choose a reason for hiding this comment

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

This shouldn't be a parameter of this function.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, I moved it to a separate variable outside of this function.

skip_file_content = ""
file_paths = []
for file_filter in file_filters:
file_paths.append(file_filter)
Copy link
Contributor

Choose a reason for hiding this comment

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

The goal of the function would be clearer if its result wouldn't include these header files. The function's name is get_source_file_paths() where "source" indicates that non-headers are returned. At least we are using "source file" for non-headers conventionally throughout in our naming conventions. The list of headers could be concatenated to the source files at the caller.

I'm not sure, but I'm thinking if this function is necessary at all. Couldn't tu_collector.get_dependent_sources() be used directly? As far as I can see, the added behavior of this function is to check only existing headers in the given list. What is the reason of this restriction? The result of this function goes to a skipfile where it is not a big problem if the file doesn't exist.

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 renamed this function to get_affected_file_paths.

"""
skip_file_content = ""
file_paths = []
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
file_paths = []
file_paths = set()

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 used list to keep the order of the items. I added a comment to highlight it.

LOG.debug("Dependent source files: %s",
', '.join(dependent_sources))

file_paths.extend(dependent_sources)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
file_paths.extend(dependent_sources)
file_paths.update(dependent_sources)

Initialize and return a list of skiplist handlers if
there is a skip list file in the arguments or files options is provided.
"""
skip_handlers = SkipListHandlers()
Copy link
Contributor

Choose a reason for hiding this comment

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

Wouldn't concatenation of two skipfile contents be equivalent with the usage of SkipListHandlers()? Because I think it wouldn't be necessary introducing SkipListHandlers() if they are.

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 described the problem why we can't use a single skip file in the following issue: #3595 (comment)

The CodeChecker VSCodePlugin uses the `--file` parameter to analyze single files.
Large projects load in their configuration using the `--config` parameter and
if there is a `-i skipfile` given in the config, `CodeChecker analyze` call
drops an error.

This patch will allow `-i skipfile` and `--file` to be given together.
@csordasmarton csordasmarton force-pushed the file_opt_with_skipfile branch 2 times, most recently from f832a75 to ec491fb Compare March 7, 2022 10:57
@csordasmarton csordasmarton merged commit f850ad0 into Ericsson:master Mar 8, 2022
@csordasmarton csordasmarton deleted the file_opt_with_skipfile branch April 7, 2022 12:30
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) enhancement 🌟 test ☑️ Adding or refactoring tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CodeChecker analyze --file does not work together with -i skipfile Re-analyze header file
2 participants