Skip to content

Rakefile:33 reads --live/--verbose via ARGV.include?, but Rake consumes those flags before the task runs #228

Description

@edmoffo

Rakefile:33-35 reads CLI flags out of ARGV to switch the judges task behavior:

task :judges do
  live = ARGV.include?('--live') ? '' : '--disable live'
  sh "judges #{ARGV.include?('--verbose') ? '--verbose' : ''} test --no-log #{live} --lib lib judges"
end

Rake parses ARGV before any task body runs and treats every non-option positional token as a task name. Running bundle exec rake judges --live makes Rake parse --live against its own option set and abort with invalid option: --live, so the live branch is unreachable from the documented CLI. Running bundle exec rake judges -- --live does not help either, because the trailing --live ends up in ARGV but Rake first interprets the -- as the end of its own options. The --verbose branch has the same defect; the only reason it does not abort is that Rake itself accepts --verbose, and that flag never reaches the judges test invocation in the form the code expects.

The current Rakefile.default task chain (clean test judges rubocop) silences the issue because nobody ever passes --live or --verbose to rake, so both branches always take the no-op path. The flag-routing code is dead.

Fix: switch to task arguments, e.g. task :judges, [:live] do |_, args| invoked as rake "judges[live]", or read the flags from environment variables (ENV['LIVE'], ENV['VERBOSE']). Both patterns are robust against Rake's argument parser.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions