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

lib/Rex/Config.pm: slurp file content using IO::File. #1511

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

Conversation

monsieurp
Copy link

@monsieurp monsieurp commented Oct 13, 2021

Fixes #1466.

This PR is an attempt to fix #1466. The ticket is self-explanatory as well as those changes.

Checklist

  • based on top of latest source code
  • changelog entry included: not needed.
  • tests pass in CI: not sure there are tests for such a change.
  • git history is clean
  • git commit messages are well-written

@monsieurp monsieurp marked this pull request as draft October 13, 2021 16:51
@monsieurp monsieurp force-pushed the 1466_local-argv branch 2 times, most recently from 73badfc to a93c45b Compare October 14, 2021 20:56
@ferki
Copy link
Member

ferki commented Oct 31, 2021

Thanks @monsieurp for your contribution!

Tis PR is still marked as draft only, but reading through the linked issue and the proposed changes, I can provide some early feedback below and/or as code comments.


  • changelog entry included: not needed.

Hmm, yeah, I agree it's probably fine to skip changelog entries for changes such as automated code formatting, refactoring, or CI workflow changes.


  • tests pass in CI: not sure there are tests for such a change.

As a minimum quality requirement the current test suite should still pass. Ideally, if a changed code path is not covered yet, tests could be added first (to demonstrate a code is solid either by fixing a failing test to proving that it still passes the tests).

Currently t/config-ssh.t fails in CI and on my system too.


There are currently 35 instances of local @ARGV ... <>-style slurps. What do you think about fixing them all? Would we need a good module for that, or perhaps some helper function in Rex core?


I've fixed some CI-related issues recently, so you might need to rebase this PR on top if current default branch, and (force) push your branch again.

Copy link
Member

@ferki ferki left a comment

Choose a reason for hiding this comment

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

Let's make sure all tests pass. Please rebase these changes on top of the default branch in order to test them against the current state.

lib/Rex/Config.pm Show resolved Hide resolved
my @lines = do {
use IO::File;
my $fh = IO::File->new( $config_file, 'r' );
join '', $fh->getlines();
Copy link
Member

Choose a reason for hiding this comment

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

Can it be that t/config-ssh.t fails because now all lines of the file is concatenated with join while it was treated as an array of lines before?

@ferki
Copy link
Member

ferki commented Oct 31, 2021

ps.: a git commit is explicit about which files are being changed, so there's no need to duplicate that info in the commit message. and to stop it with the period. Also do not end the subject line with a period.

E.g. instead of:

lib/Rex/Config.pm: slurp file content using IO::File.

it's fine to simply write:

Slurp file content using IO::File

It might also work better to explain what and why vs. how. E.g.

Avoid slurping with <> during compile time

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.

Don't use local @ARGV=...; <> for slurping file contents
2 participants