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

chore: Fix for Incorrect Object Passing and Loop Control #5822

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mdqst
Copy link

@mdqst mdqst commented Jan 21, 2025

Description

I noticed a couple of issues in the script:

  1. The function fix_unreachable_pub_warning was receiving m (part of the warning) instead of the full warning object, which caused unexpected behavior. I fixed this by passing the correct object.
  2. The script was using return to exit the loop when the code wasn't in the current workspace. I replaced it with continue to ensure the loop processes all warnings as intended.

Change checklist

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • A changelog entry has been made in the appropriate crates

Copy link
Member

@jxs jxs left a comment

Choose a reason for hiding this comment

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

Hi, and thanks for your interest.
Left some comments, also I am curious can you describe the context in which you run the script?
We haven't have had the need to run it in the repo as clippy hasn't reported unreachable_pub's afaik

@@ -61,7 +61,7 @@ def main():
if code is None:
continue

fix_unreachable_pub_warning(m)
fix_unreachable_pub_warning(warning) # Pass the entire warning object, not just m
Copy link
Member

Choose a reason for hiding this comment

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

can you elaborate give an example of the unexpected behavior you were presented?

@@ -49,7 +49,7 @@ def main():

# Don't modify code that is not in the current workspace
if str(Path.cwd()) not in str(warning['target']['src_path']):
return
continue # Use continue instead of return to process other warnings
Copy link
Member

@jxs jxs Jan 24, 2025

Choose a reason for hiding this comment

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

You referred that:

The script was using return to exit the loop when the code wasn't in the current workspace. I replaced it with continue to ensure the loop processes all warnings as intended.

but as the comment above states, we do not want to modify code that is not in the current workspace, the function is called for every path that is outputted by clippy, so I think we should just return if the path is not part of the current workspace, no?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants