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

Ensure excluded config exists #37

Merged
merged 1 commit into from
Apr 19, 2017
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
4 changes: 3 additions & 1 deletion lib/danger_plugin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,10 @@ def excluded_files_from_config(filepath)
{"excluded" => []}
end

excluded_paths = config['excluded'] || []

# Extract excluded paths
return config['excluded'].
return excluded_paths.
map { |path| File.join(File.dirname(config_file), path) }.
map { |path| File.expand_path(path) }.
select { |path| File.exists?(path) || Dir.exists?(path) }
Expand Down
15 changes: 15 additions & 0 deletions spec/danger_plugin_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,21 @@ module Danger
@swiftlint.lint_files
end

it 'does not crash when excluded is nil' do
allow(@swiftlint.git).to receive(:added_files).and_return([])
allow(@swiftlint.git).to receive(:modified_files).and_return([
'spec/fixtures/SwiftFile.swift',
])

expect(Swiftlint).to receive(:lint)
.with(hash_including(:path => File.expand_path('spec/fixtures/SwiftFile.swift')))
.and_return(@swiftlint_response)
.once

@swiftlint.config_file = 'spec/fixtures/empty_excluded.yml'
@swiftlint.lint_files
end

it 'does not lint deleted files paths' do
# Danger (4.3.0 at the time of writing) returns deleted files in the
# modified fiels array, which kinda makes sense.
Expand Down
7 changes: 7 additions & 0 deletions spec/fixtures/empty_excluded.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
disabled_rules:
- todo

included:
- an/included/folder

excluded: