Skip to content
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

Default to parallel true #541

Merged
merged 2 commits into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion lib/haml_lint/options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Options
# @param args [Array<String>] arguments passed via the command line
# @return [Hash] parsed options
def parse(args)
@options = {}
@options = default_options

OptionParser.new do |parser|
parser.banner = "Usage: #{APP_NAME} [options] [file1, file2, ...]"
Expand All @@ -32,6 +32,10 @@ def parse(args)

private

def default_options
{ parallel: true }
end

def add_linter_options(parser) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
parser.on('--auto-gen-config', 'Generate a configuration file acting as a TODO list') do
@options[:auto_gen_config] = true
Expand All @@ -56,6 +60,10 @@ def add_linter_options(parser) # rubocop:disable Metrics/AbcSize, Metrics/Method
@options[:parallel] = true
end

parser.on('--no-parallel', 'Disable parallel linter runs') do
@options[:parallel] = false
end

parser.on('-a', '--auto-correct', 'Auto-correct offenses (only when it’s safe)') do
@options[:autocorrect] = :safe
end
Expand Down
14 changes: 14 additions & 0 deletions spec/haml_lint/options_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@
subject { super().parse(args) }
let(:args) { [] }

context 'without options' do
it 'sets the default values' do
subject[:parallel].should == true
end
end

context 'with a configuration file specified' do
let(:args) { %w[--config some-config.yml] }

Expand Down Expand Up @@ -89,6 +95,14 @@
end
end

context 'with a no-parallel option' do
let(:args) { %w[--no-parallel] }

it 'sets the parallel option' do
subject[:parallel].should == false
end
end

context 'with an auto-correct option' do
let(:args) { %w[--auto-correct] }

Expand Down
Loading