-
-
Notifications
You must be signed in to change notification settings - Fork 530
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
Use bundle-audit rake task from the gem #831
Conversation
Instead of defining the audit task from scratch, we can import the task from the gem itself.
end | ||
end | ||
end | ||
require "bundler/audit/task" |
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.
Prefer single-quoted strings when you don't need string interpolation or special symbols.
@@ -29,6 +29,14 @@ | |||
end | |||
end | |||
|
|||
it "includes the bundle:audit task" do |
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.
Prefer single-quoted strings when you don't need string interpolation or special symbols.
@@ -401,7 +401,7 @@ def setup_segment | |||
|
|||
def setup_bundler_audit | |||
copy_file "bundler_audit.rake", "lib/tasks/bundler_audit.rake" | |||
append_file "Rakefile", %{\ntask default: "bundler:audit"\n} | |||
append_file "Rakefile", %{\ntask default: "bundle:audit"\n} |
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.
Prefer single-quoted strings when you don't need string interpolation or special symbols.
%-literals should be delimited by ( and ).
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.
Should this be task default: ["spec", "bundle:audit"]
?
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.
Although it may be clearer what's going on defined as one line, is it lumping together responsibilities? I think we should augment the default task with bundle:audit
independently of expecting the specs to run.
Having said that, I did find Rake's behaviour of find the append (rather-than-redefine) mechanism confusing at first... it's not clear.
# Rakefile
task :foo do
puts "FOO"
end
task :bar do
puts "BAR"
end
task(:default).clear
task default: :foo
task default: :bar
$ bundle exec rake
FOO
BAR
One way we could make this clearer is writing it as:
Rake::Task[:default].enhance ["bundle:audit"]
Then there's less confusion whether the task is being overwritten or modified.
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.
@croaky also this comment on the original PR for context: #831 (comment)
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.
Although it may be clearer what's going on defined as one line, is it lumping together responsibilities? I think we should augment the default task with bundle:audit independently of expecting the specs to run.
I think I'd expect rake
in a Suspender-ized app to run spec
then bundle:audit
at this point. If that's what is happening via multiple task default:
invocations, that's great.
Related: I learned about https://github.com/presidentbeef/brakeman last week. Seems like it covers security cases additional to Bundle Audit. Might be worth experimenting with on some apps.
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.
@croaky we are using brakeman in our suspenders fork. I can cherry-pick and create a PR if you are interested!
end | ||
end | ||
end | ||
require "bundler/audit/task" |
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.
Prefer single-quoted strings when you don't need string interpolation or special symbols.
@@ -29,6 +29,14 @@ | |||
end | |||
end | |||
|
|||
it "includes the bundle:audit task" do |
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.
Prefer single-quoted strings when you don't need string interpolation or special symbols.
@@ -401,7 +401,7 @@ def setup_segment | |||
|
|||
def setup_bundler_audit | |||
copy_file "bundler_audit.rake", "lib/tasks/bundler_audit.rake" | |||
append_file "Rakefile", %{\ntask default: "bundler:audit"\n} | |||
append_file "Rakefile", %{\ntask default: "bundle:audit"\n} |
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.
Prefer single-quoted strings when you don't need string interpolation or special symbols.
%-literals should be delimited by ( and ).
Disregarding the Hound single-quoted strings warnings because the changes match the current formatting of the files changed, and the thoughtbot Ruby styleguide states:
We could disable this check by adding a |
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.
Nice! Do we need to update any generated RSpec task to reference bundle:audit now instead of bundler:audit? I think we configure it to run after the suite passes.
I like the idea of switching the Hound config to prefer double quotes strings and moving toward that over time as files are touched. |
@croaky yes, the default Rake task (which has So ultimately the Rakefile in a new Suspenders project looks like this:
So task default ends up being |
Instead of defining the audit task from scratch, we can now import the task from the gem itself.
One caveat: The task name changes from
bundler:audit
tobundle:audit
as defined by the gem. We could make an alias between the old & new command but I suspect most use is just via the default Rake task.