ashfurrow / danger-ruby-swiftlint

A Danger plugin for SwiftLint.
https://rubygems.org/gems/danger-swiftlint
MIT License
203 stars 80 forks source link

How to pass 'fail_on_error' when using custom filter logic #198

Closed romit07 closed 3 weeks ago

romit07 commented 6 months ago

if we are not using any violation filter, passing fail_on_errors : true is simple swiftlint.lint_files fail_on_error: true

But I am using custom filtering of violations like this:

swiftlint.lint_files(inline_mode: true) { |violation|
  diff_filename = violation['file'].gsub(dir, '')
  file_patch = diff.find_patch_by_file(diff_filename)
  file_patch != nil && file_patch.changed_lines.any? { |line| line.number == violation['line']}
}

Seems like there is now way to pass fail_on_errors : true in this way

dirtyhabits97 commented 6 months ago

You should be able to simply pass fail_on_errors : true as an argument:

swiftlint.lint_files(inline_mode: true, fail_on_error: true) { |violation| ... }

I have created #199 to reflect and test the expected behavior of this combination of arguments

aiKrice commented 3 months ago

@romit07 . Can you confirm this has been fixed regarding #199 ?