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
Don't reset similarities config to defaults in parallel mode #4178
Conversation
When parallel mode is used (`--jobs 0`, `--jobs 2`, ...), the `similarities` checker seems to ignore the `min-similarity-lines` config values provided by the user. Instead it seems to use the builtin default value of 4. In "serial mode" (i.e. not specifying `--jobs`), this is not an issue. The `reduce_map_data` method is a class method, so a new instance of the similarity checker is created. I narrowed down the issue to the fact that this instance is not configured. I'm not sure if this is the right way to fix this, but using the originally configured instance of this checker, instead of creating a new one, works.
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 don't think this is the whole fix, although the similarities config will be set, the final code-quality report won't take the similarities score into account properly.
Overall, I feel this patch should be rejected, unfortunately.
recombined = SimilarChecker(linter) | ||
try: | ||
recombined = linter._checkers["similarities"][0] | ||
except: |
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.
Bare except.
Try running the following inside your checkout.
tox -e formatting
@@ -427,7 +427,10 @@ def reduce_map_data(cls, linter, data): | |||
"""Reduces and recombines data into a format that we can report on | |||
|
|||
The partner function of get_map_data()""" | |||
recombined = SimilarChecker(linter) | |||
try: | |||
recombined = linter._checkers["similarities"][0] |
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.
As suggested in #4175 a better way of doing this might be to change this method from a @classmethod
to an instance method. The call-site supports this.
Going to close this as the PR that would supersede this has been merged already. The associated issue (#4118) has also been closed. |
When parallel mode is used (
--jobs 0
,--jobs 2
, ...), thesimilarities
checker seems to ignore themin-similarity-lines
config values provided by the user. Instead it seems to use the builtin default value of 4. In "serial mode" (i.e. not specifying--jobs
), this is not an issue.The
reduce_map_data
method is a class method, so a new instance of the similarity checker is created. I narrowed down the issue to the fact that this instance is not configured. I'm not sure if this is the right way to fix this, but using the originally configured instance of this checker, instead of creating a new one, works.Steps
doc/whatsnew/<current release.rst>
.Description
Type of Changes
Related Issue