|
5 | 5 | has_app_changes = !git.modified_files.grep(/lib/).empty? |
6 | 6 | has_spec_changes = !git.modified_files.grep(/spec/).empty? |
7 | 7 |
|
8 | | -if has_app_changes && !has_spec_changes |
9 | | - warn("There're library changes, but not tests. That's OK as long as you're refactoring existing code.", sticky: false) |
10 | | -end |
| 8 | +warn("There're library changes, but not tests. That's OK as long as you're refactoring existing code.", sticky: false) if has_app_changes && !has_spec_changes |
11 | 9 |
|
12 | | -if !has_app_changes && has_spec_changes |
13 | | - message('We really appreciate pull requests that demonstrate issues, even without a fix. That said, the next step is to try and fix the failing tests!', sticky: false) |
14 | | -end |
| 10 | +message('We really appreciate pull requests that demonstrate issues, even without a fix. That said, the next step is to try and fix the failing tests!', sticky: false) if !has_app_changes && has_spec_changes |
15 | 11 |
|
16 | 12 | # Simplified changelog check (replaces danger-changelog plugin which requires github.* methods) |
17 | 13 | # Note: toc.check! from danger-toc plugin removed (not essential for CI) |
18 | 14 | has_changelog_changes = git.modified_files.include?('CHANGELOG.md') || git.added_files.include?('CHANGELOG.md') |
19 | | -if has_app_changes && !has_changelog_changes |
20 | | - warn('Please update CHANGELOG.md with a description of your changes.', sticky: false) |
21 | | -end |
| 15 | +warn('Please update CHANGELOG.md with a description of your changes.', sticky: false) if has_app_changes && !has_changelog_changes |
22 | 16 |
|
23 | 17 | (git.modified_files + git.added_files - %w[Dangerfile]).each do |file| |
24 | 18 | next unless File.file?(file) |
25 | 19 |
|
26 | 20 | contents = File.read(file) |
| 21 | + # rubocop:disable Style/SignalException -- `fail` is Danger's DSL method, not Kernel#fail |
27 | 22 | if file.start_with?('spec') |
28 | | - fail("`xit` or `fit` left in tests (#{file})") if contents =~ /^\w*[xf]it/ |
29 | | - fail("`fdescribe` left in tests (#{file})") if contents =~ /^\w*fdescribe/ |
| 23 | + fail("`xit` or `fit` left in tests (#{file})") if /^\w*[xf]it/.match?(contents) |
| 24 | + fail("`fdescribe` left in tests (#{file})") if /^\w*fdescribe/.match?(contents) |
30 | 25 | end |
| 26 | + # rubocop:enable Style/SignalException |
31 | 27 | end |
32 | 28 |
|
33 | 29 | # Output JSON report for GitHub Actions workflow_run to post as PR comment |
|
0 commit comments