You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In certain scenarios, using *%W may improve readability. So there should be exceptions to: Lint/UnneededSplatExpansion
Most of those scenarios are when building shell commands.
E.g.:
# filename may be an arbitrary string, containing spaces and other weird stuff.
filename = "file \" ' name.txt"
# Unsafe!
# May lead to wrong behavior. E.g. delete `file` and `name.txt`, but not `file name.txt`.
system('sudo -u ' + target_user + '/usr/bin/rm -r -- ' + filename)
system("sudo -u '#{target_user}' -- /usr/bin/rm -r -- '#{filename}'")
# Safe, but hard to read.
# And this rm example is still a simple shell command.
# Longer shell commands get much harder to read in this style.
system('sudo', '-u', target_user, '/usr/bin/rm', '-r', '--', filename)
# Safe and good to read. But triggers Lint/UnneededSplatExpansion
# *%W[ isn't very pretty to read. But the important shell command is clearly recognizable
system(*%W[sudo -u #{target_user} -- /usr/bin/rm -r -- #{filename}])
Be aware, that system is not the only method covered by this. Open3.... is also affected and I'm actually using a custom method with adds additional checks when running external command. So excluding Lint/UnneededSplatExpansion for certain methods may not be a satisfying solution.
This is similar to #3512
But here the problem is, that using *%W explicitly improves readability.
The text was updated successfully, but these errors were encountered:
In certain scenarios, using
*%W
may improve readability. So there should be exceptions to:Lint/UnneededSplatExpansion
Most of those scenarios are when building shell commands.
E.g.:
Be aware, that
system
is not the only method covered by this.Open3....
is also affected and I'm actually using a custom method with adds additional checks when running external command. So excludingLint/UnneededSplatExpansion
for certain methods may not be a satisfying solution.This is similar to #3512
But here the problem is, that using
*%W
explicitly improves readability.The text was updated successfully, but these errors were encountered: