danger-dangermattic 1.2.2 → 1.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (25) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +1 -1
  3. data/CHANGELOG.md +12 -0
  4. data/Gemfile.lock +95 -57
  5. data/lib/dangermattic/gem_version.rb +1 -1
  6. data/lib/dangermattic/plugins/android_unit_test_checker.rb +7 -4
  7. data/lib/dangermattic/plugins/manifest_pr_checker.rb +25 -8
  8. data/lib/dangermattic/plugins/podfile_checker.rb +2 -0
  9. data/lib/dangermattic/plugins/pr_size_checker.rb +10 -12
  10. data/rakelib/console.rake +1 -1
  11. data/rakelib/git_helpers.rake +1 -1
  12. data/spec/android_unit_test_checker_spec.rb +93 -3
  13. data/spec/fixtures/android_unit_test_checker/MixDataPlusNormalClass.kt +14 -0
  14. data/spec/fixtures/android_unit_test_checker/src/main/java/com/dayoneapp/dayone/api/ApiResult.kt +69 -0
  15. data/spec/fixtures/android_unit_test_checker/src/main/java/com/dayoneapp/dayone/api/WebRecordApi.kt +49 -0
  16. data/spec/fixtures/android_unit_test_checker/src/main/java/com/dayoneapp/dayone/domain/drive/UiStates.kt +13 -0
  17. data/spec/fixtures/android_unit_test_checker/src/main/java/com/dayoneapp/dayone/main/settings/integrations/connect/AppIntegrationModule.kt +29 -0
  18. data/spec/fixtures/android_unit_test_checker/src/main/java/com/dayoneapp/dayone/main/streaks/StreaksViewModel.kt +377 -0
  19. data/spec/fixtures/android_unit_test_checker/src/main/java/com/dayoneapp/dayone/mediastorage/MediaStorageConfiguration.kt +31 -0
  20. data/spec/fixtures/android_unit_test_checker/src/main/java/com/dayoneapp/dayone/utils/AccountType.kt +15 -0
  21. data/spec/fixtures/android_unit_test_checker/src/main/java/com/dayoneapp/dayone/utils/usecase/SelectPhotoUseCase.kt +76 -0
  22. data/spec/pr_size_checker_spec.rb +27 -26
  23. data/spec/spec_helper.rb +8 -2
  24. data/spec/view_changes_checker_spec.rb +15 -15
  25. metadata +11 -2
@@ -72,19 +72,19 @@ module Danger
72
72
  end
73
73
 
74
74
  context 'when fail on error is false and a custom message is given' do
75
- include_examples 'reporting diff size custom warnings or errors', false, 'this is my custom warning message'
75
+ it_behaves_like 'reporting diff size custom warnings or errors', false, 'this is my custom warning message'
76
76
  end
77
77
 
78
78
  context 'when fail on error is false' do
79
- include_examples 'reporting diff size custom warnings or errors', false
79
+ it_behaves_like 'reporting diff size custom warnings or errors', false
80
80
  end
81
81
 
82
82
  context 'when fail on error is true' do
83
- include_examples 'reporting diff size custom warnings or errors', true
83
+ it_behaves_like 'reporting diff size custom warnings or errors', true
84
84
  end
85
85
 
86
86
  context 'when a custom error message is given and fail on error is true' do
87
- include_examples 'reporting diff size custom warnings or errors', true, 'this is my custom error message'
87
+ it_behaves_like 'reporting diff size custom warnings or errors', true, 'this is my custom error message'
88
88
  end
89
89
  end
90
90
  end
@@ -146,35 +146,36 @@ module Danger
146
146
  allow(@plugin.git).to receive_messages(added_files: [added_config, added_file], modified_files: [modified_file1, modified_file2, added_test_file, modified_strings], deleted_files: [deleted_file1, deleted_test_file, deleted_strings, deleted_file2])
147
147
 
148
148
  allow(@plugin.git).to receive(:diff).and_return(instance_double(Git::Diff))
149
- expected_files = { added_test_file => {}, added_config => {}, added_file => {}, modified_file1 => {}, modified_file2 => {}, modified_strings => {}, deleted_file1 => {}, deleted_file2 => {}, deleted_test_file => {}, deleted_strings => {} }
149
+ # Populate stats hash directly with insertions/deletions data for the optimized code path
150
+ expected_files = {
151
+ added_test_file => { insertions: 201 },
152
+ added_config => { insertions: 311 },
153
+ added_file => { insertions: 13 },
154
+ modified_file1 => { insertions: 127, deletions: 159 },
155
+ modified_file2 => { insertions: 43, deletions: 37 },
156
+ modified_strings => { insertions: 432, deletions: 297 },
157
+ deleted_file1 => { deletions: 246 },
158
+ deleted_file2 => { deletions: 493 },
159
+ deleted_test_file => { deletions: 222 },
160
+ deleted_strings => { deletions: 593 }
161
+ }
150
162
  allow(@plugin.git.diff).to receive(:stats).and_return({ files: expected_files })
151
-
152
- allow(@plugin.git).to receive(:info_for_file).with(added_test_file).and_return({ insertions: 201 })
153
- allow(@plugin.git).to receive(:info_for_file).with(added_config).and_return({ insertions: 311 })
154
- allow(@plugin.git).to receive(:info_for_file).with(added_file).and_return({ insertions: 13 })
155
- allow(@plugin.git).to receive(:info_for_file).with(modified_file1).and_return({ insertions: 127, deletions: 159 })
156
- allow(@plugin.git).to receive(:info_for_file).with(modified_file2).and_return({ insertions: 43, deletions: 37 })
157
- allow(@plugin.git).to receive(:info_for_file).with(modified_strings).and_return({ insertions: 432, deletions: 297 })
158
- allow(@plugin.git).to receive(:info_for_file).with(deleted_file1).and_return({ deletions: 246 })
159
- allow(@plugin.git).to receive(:info_for_file).with(deleted_file2).and_return({ deletions: 493 })
160
- allow(@plugin.git).to receive(:info_for_file).with(deleted_test_file).and_return({ deletions: 222 })
161
- allow(@plugin.git).to receive(:info_for_file).with(deleted_strings).and_return({ deletions: 593 })
162
163
  end
163
164
  end
164
165
 
165
166
  context 'with the entire diff' do
166
- include_examples 'using the default diff size counter, without a file selector', :all
167
- include_examples 'using a file selector to filter and count the changes in a diff', :all, [422, 520, 1541]
167
+ it_behaves_like 'using the default diff size counter, without a file selector', :all
168
+ it_behaves_like 'using a file selector to filter and count the changes in a diff', :all, [422, 520, 1541]
168
169
  end
169
170
 
170
171
  context 'with the insertions in the diff' do
171
- include_examples 'using the default diff size counter, without a file selector', :insertions
172
- include_examples 'using a file selector to filter and count the changes in a diff', :insertions, [200, 139, 384]
172
+ it_behaves_like 'using the default diff size counter, without a file selector', :insertions
173
+ it_behaves_like 'using a file selector to filter and count the changes in a diff', :insertions, [200, 139, 384]
173
174
  end
174
175
 
175
176
  context 'with the deletions in the diff' do
176
- include_examples 'using the default diff size counter, without a file selector', :deletions
177
- include_examples 'using a file selector to filter and count the changes in a diff', :deletions, [221, 380, 1157]
177
+ it_behaves_like 'using the default diff size counter, without a file selector', :deletions
178
+ it_behaves_like 'using a file selector to filter and count the changes in a diff', :deletions, [221, 380, 1157]
178
179
  end
179
180
  end
180
181
 
@@ -221,19 +222,19 @@ module Danger
221
222
  end
222
223
 
223
224
  context 'when fail on error is false and a custom message is given' do
224
- include_examples 'reporting PR length check custom warnings or errors', false, 'this is my custom warning message'
225
+ it_behaves_like 'reporting PR length check custom warnings or errors', false, 'this is my custom warning message'
225
226
  end
226
227
 
227
228
  context 'when fail on error is false' do
228
- include_examples 'reporting PR length check custom warnings or errors', false
229
+ it_behaves_like 'reporting PR length check custom warnings or errors', false
229
230
  end
230
231
 
231
232
  context 'when fail on error is true' do
232
- include_examples 'reporting PR length check custom warnings or errors', true
233
+ it_behaves_like 'reporting PR length check custom warnings or errors', true
233
234
  end
234
235
 
235
236
  context 'when a custom error message is given and fail on error is true' do
236
- include_examples 'reporting PR length check custom warnings or errors', true, 'this is my custom error message'
237
+ it_behaves_like 'reporting PR length check custom warnings or errors', true, 'this is my custom error message'
237
238
  end
238
239
  end
239
240
  end
data/spec/spec_helper.rb CHANGED
@@ -58,8 +58,14 @@ def testing_dangerfile
58
58
  Danger::Dangerfile.new(env, testing_ui)
59
59
  end
60
60
 
61
- def fixture(name)
62
- File.read("spec/fixtures/#{name}")
61
+ # Returns the full path of the fixture at the given subpath (relative to `spec/fixtures`)
62
+ def fixture_path(*path_components)
63
+ File.join('spec', 'fixtures', *path_components)
64
+ end
65
+
66
+ # Returns the content of the fixture at the given path (relative to `spec/fixtures`)
67
+ def fixture(*path_components)
68
+ File.read(fixture_path(*path_components))
63
69
  end
64
70
 
65
71
  # custom matchers
@@ -123,62 +123,62 @@ module Danger
123
123
 
124
124
  context 'when checking an iOS PR' do
125
125
  context 'with view code changes in Swift files' do
126
- include_examples 'PR with view code changes', ['TestView.swift', 'SimpleViewHelper.m']
126
+ it_behaves_like 'PR with view code changes', ['TestView.swift', 'SimpleViewHelper.m']
127
127
  end
128
128
 
129
129
  context 'with button changes in Swift files' do
130
- include_examples 'PR with view code changes', ['SimpleViewHelper.m', 'MyAwesomeButton.swift']
130
+ it_behaves_like 'PR with view code changes', ['SimpleViewHelper.m', 'MyAwesomeButton.swift']
131
131
  end
132
132
 
133
133
  context 'with view code changes in ObjC files' do
134
- include_examples 'PR with view code changes', ['TestView.m', 'SimpleViewHelper.m']
134
+ it_behaves_like 'PR with view code changes', ['TestView.m', 'SimpleViewHelper.m']
135
135
  end
136
136
 
137
137
  context 'with button changes in ObjC files' do
138
- include_examples 'PR with view code changes', ['SimpleViewHelper.m', 'MyAwesomeButton.m']
138
+ it_behaves_like 'PR with view code changes', ['SimpleViewHelper.m', 'MyAwesomeButton.m']
139
139
  end
140
140
 
141
141
  context 'with changes in a .xib file' do
142
- include_examples 'PR with view code changes', ['SimpleViewHelper.m', 'top_bar.xib']
142
+ it_behaves_like 'PR with view code changes', ['SimpleViewHelper.m', 'top_bar.xib']
143
143
  end
144
144
 
145
145
  context 'with changes in a Storyboard' do
146
- include_examples 'PR with view code changes', ['SimpleViewHelper.m', 'main_screen.storyboard']
146
+ it_behaves_like 'PR with view code changes', ['SimpleViewHelper.m', 'main_screen.storyboard']
147
147
  end
148
148
 
149
149
  context 'with no view changes' do
150
- include_examples 'PR without view code changes',
151
- ['SimpleViewHelper.m', 'MyButtonTester.swift', 'Version.xcconfig']
150
+ it_behaves_like 'PR without view code changes',
151
+ ['SimpleViewHelper.m', 'MyButtonTester.swift', 'Version.xcconfig']
152
152
  end
153
153
  end
154
154
 
155
155
  context 'when checking an Android PR' do
156
156
  context 'with view code changes in Kotlin files' do
157
- include_examples 'PR with view code changes', ['SimpleViewHelper.kt', 'MySimpleView.kt']
157
+ it_behaves_like 'PR with view code changes', ['SimpleViewHelper.kt', 'MySimpleView.kt']
158
158
  end
159
159
 
160
160
  context 'with button changes in Kotlin files' do
161
- include_examples 'PR with view code changes', ['MyAwesomeButton.kt', 'SimpleViewHelper.java']
161
+ it_behaves_like 'PR with view code changes', ['MyAwesomeButton.kt', 'SimpleViewHelper.java']
162
162
  end
163
163
 
164
164
  context 'with view code changes in Java files' do
165
- include_examples 'PR with view code changes', ['TestView.java', 'SimpleViewHelper.kt']
165
+ it_behaves_like 'PR with view code changes', ['TestView.java', 'SimpleViewHelper.kt']
166
166
  end
167
167
 
168
168
  context 'with button changes in Java files' do
169
- include_examples 'PR with view code changes', ['SimpleViewHelper.kt', 'MyAwesomeButton.java']
169
+ it_behaves_like 'PR with view code changes', ['SimpleViewHelper.kt', 'MyAwesomeButton.java']
170
170
  end
171
171
 
172
172
  context 'with view code changes in a XML file' do
173
- include_examples 'PR with view code changes', ['test_view.xml', 'SimpleViewHelper.kt', 'strings.xml']
173
+ it_behaves_like 'PR with view code changes', ['test_view.xml', 'SimpleViewHelper.kt', 'strings.xml']
174
174
  end
175
175
 
176
176
  context 'with button changes in a XML file' do
177
- include_examples 'PR with view code changes', ['SimpleViewHelper.kt', 'strings.xml', 'my_awesome_button.xml']
177
+ it_behaves_like 'PR with view code changes', ['SimpleViewHelper.kt', 'strings.xml', 'my_awesome_button.xml']
178
178
  end
179
179
 
180
180
  context 'with no view changes' do
181
- include_examples 'PR without view code changes', ['SimpleViewHelper.java', 'values.xml', 'MyButtonTester.kt']
181
+ it_behaves_like 'PR without view code changes', ['SimpleViewHelper.java', 'values.xml', 'MyButtonTester.kt']
182
182
  end
183
183
  end
184
184
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: danger-dangermattic
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.2
4
+ version: 1.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Automattic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-11-25 00:00:00.000000000 Z
11
+ date: 2025-10-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: danger
@@ -247,6 +247,7 @@ files:
247
247
  - spec/fixtures/android_unit_test_checker/Abcdef.kt
248
248
  - spec/fixtures/android_unit_test_checker/AbcdefgViewHelper.java
249
249
  - spec/fixtures/android_unit_test_checker/AnotherViewHelper.kt
250
+ - spec/fixtures/android_unit_test_checker/MixDataPlusNormalClass.kt
250
251
  - spec/fixtures/android_unit_test_checker/MyNewClass.java
251
252
  - spec/fixtures/android_unit_test_checker/Polygon.kt
252
253
  - spec/fixtures/android_unit_test_checker/PublicAndPrivateType.kt
@@ -267,6 +268,14 @@ files:
267
268
  - spec/fixtures/android_unit_test_checker/src/androidTest/java/org/test/PublicTypeTest.kt
268
269
  - spec/fixtures/android_unit_test_checker/src/androidTest/java/org/test/TestMyNewClass.java
269
270
  - spec/fixtures/android_unit_test_checker/src/androidTest/java/org/test/ToolTest.kt
271
+ - spec/fixtures/android_unit_test_checker/src/main/java/com/dayoneapp/dayone/api/ApiResult.kt
272
+ - spec/fixtures/android_unit_test_checker/src/main/java/com/dayoneapp/dayone/api/WebRecordApi.kt
273
+ - spec/fixtures/android_unit_test_checker/src/main/java/com/dayoneapp/dayone/domain/drive/UiStates.kt
274
+ - spec/fixtures/android_unit_test_checker/src/main/java/com/dayoneapp/dayone/main/settings/integrations/connect/AppIntegrationModule.kt
275
+ - spec/fixtures/android_unit_test_checker/src/main/java/com/dayoneapp/dayone/main/streaks/StreaksViewModel.kt
276
+ - spec/fixtures/android_unit_test_checker/src/main/java/com/dayoneapp/dayone/mediastorage/MediaStorageConfiguration.kt
277
+ - spec/fixtures/android_unit_test_checker/src/main/java/com/dayoneapp/dayone/utils/AccountType.kt
278
+ - spec/fixtures/android_unit_test_checker/src/main/java/com/dayoneapp/dayone/utils/usecase/SelectPhotoUseCase.kt
270
279
  - spec/fixtures/android_unit_test_checker/src/main/java/org/wordpress/android/widgets/NestedWebView.kt
271
280
  - spec/fixtures/android_unit_test_checker/src/main/java/org/wordpress/util/config/BloggingPromptsFeatureConfig.kt
272
281
  - spec/fixtures/android_unit_test_checker/src/test/java/org/test/TestsINeedThem.java