Skip to content

Commit

Permalink
Fix an error for rake slow_cops
Browse files Browse the repository at this point in the history
RuboCop will be inspected by a remote process when using `rubocop --server`.
As a result `RuboCop::Cop::Commissioner#trigger_responding_cops` is nothing:

```console
% rake prof:slow_cops
stackprof tmp/stackprof.dump --text --method
'RuboCop::Cop::Commissioner#trigger_responding_cops' rake aborted!
NoMethodError: undefined method `first' for nil:NilClass
tasks/prof.rake:28:in `block (2 levels) in <top (required)>'
Tasks: TOP => prof:slow_cops
```

This commit is inspected by a local process to prevent the above error.
  • Loading branch information
koic committed Jun 19, 2022
1 parent 3b49d85 commit fbac3a5
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tasks/prof.rake
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ namespace :prof do

desc 'Run RuboCop on itself with profiling on'
task :run, [:path] do |_task, args|
# Must be run `rubocop` with the local process.
require 'rubocop/server'
if RuboCop::Server.running?
RuboCop::Server::ClientCommand::Stop.new.run
puts 'Stop the server for profiling.'
end

path = args.fetch(:path, '.')
cmd = "bin/rubocop-profile #{path}"
system cmd
Expand Down

0 comments on commit fbac3a5

Please sign in to comment.