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

[plugins,distros] Resolve code alerts for file not always closed #3360

Merged
merged 1 commit into from
Sep 23, 2023

Conversation

TurboTurtle
Copy link
Member

Fix a number of outstanding "File is not always closed" errors highlighted by GitHub's code scanning.

This involves (almost exclusively) changing such as:

   for line in open('/some/file', 'r').read().splitlines():

To using a context manager to ensure the file is always closed:

   with open('/some/file', 'r') as sfile:
       for line in sfile.read().splitlines():

...or something similar. Overall the logic of what a specific block of code was doing (mostly in plugins) is not changed however.


Please place an 'X' inside each '[]' to confirm you adhere to our Contributor Guidelines

  • Is the commit message split over multiple lines and hard-wrapped at 72 characters?
  • Is the subject and message clear and concise?
  • Does the subject start with [plugin_name] if submitting a plugin patch or a [section_name] if part of the core sosreport code?
  • Does the commit contain a Signed-off-by: First Lastname [email protected]?
  • Are any related Issues or existing PRs properly referenced via a Closes (Issue) or Resolved (PR) line?

Fix a number of outstanding "File is not always closed" errors highlighted by
GitHub's code scanning.

This involves (almost exclusively) changing such as:

   for line in open('/some/file', 'r').read().splitlines():

To using a context manager to ensure the file is always closed:

   with open('/some/file', 'r') as sfile:
       for line in sfile.read().splitlines():

...or something similar. Overall the logic of what a specific block of code was
doing (mostly in plugins) is not changed however.

Signed-off-by: Jake Hunsaker <[email protected]>
@packit-as-a-service
Copy link

Congratulations! One of the builds has completed. 🍾

You can install the built RPMs by following these steps:

  • sudo yum install -y dnf-plugins-core on RHEL 8
  • sudo dnf install -y dnf-plugins-core on Fedora
  • dnf copr enable packit/sosreport-sos-3360
  • And now you can install the packages.

Please note that the RPMs should be used only in a testing environment.

@TurboTurtle TurboTurtle merged commit 62b4cec into sosreport:main Sep 23, 2023
34 checks passed
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