Skip to content

Discover rake tasks - #2130

Merged
bbatsov merged 1 commit into
masterfrom
feature/rake-task-discovery
Jul 27, 2026
Merged

Discover rake tasks#2130
bbatsov merged 1 commit into
masterfrom
feature/rake-task-discovery

Conversation

@bbatsov

@bbatsov bbatsov commented Jul 27, 2026

Copy link
Copy Markdown
Owner

Rake was the obvious gap in the task providers - most Ruby projects keep their
tasks there, and Rails apps spread them across lib/tasks/*.rake too.

The tasks are read out of the Rakefile and the .rake files rather than by
running rake -T, which would load the whole application just to fill a
completion prompt. The tradeoff is that only literally-named tasks can be
offered: task type, [:id] inside an each loop isn't knowable without
running rake. In exchange the provider stays as cheap as the others, and it
costs nothing at all in a project with no Rakefile.

Names are qualified with the namespace blocks they sit in, so you get
rake:db:migrate rather than rake:migrate, and the command runs through
bundle exec when there's a Gemfile.

Checked against real projects rather than just the fixtures - rubocop (17
tasks), rubocop-ast (14) and metaredux (2) all come out right, including
prof:run, changelog:merge and references:verify. Two things that had to
be handled to get there: task.files = [...] inside a RakeTask.new block is
a method call on the block argument and not a definition, and rubocop's
%w[new fix change].each { |type| task type, [:id] } is the dynamic case
above. Both have specs.

Rake is the obvious omission from the task providers - most Ruby
projects keep their tasks there, and Rails apps put them in
lib/tasks/*.rake as well.

The tasks are read out of the task files rather than by running rake -T,
which would load the whole application just to fill a completion prompt.
That means only literally-named tasks can be offered - one whose name
comes from a variable isn't knowable without running rake - but it keeps
the provider as cheap as the others. Names are qualified with the
namespace blocks they sit in, so what you get is what you'd type.
@bbatsov
bbatsov merged commit 1d56a87 into master Jul 27, 2026
10 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.

1 participant