danger-dangermattic 1.2.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/Gemfile.lock +1 -1
- data/lib/dangermattic/gem_version.rb +1 -1
- data/lib/dangermattic/plugins/android_unit_test_checker.rb +13 -5
- data/lib/dangermattic/plugins/view_changes_checker.rb +1 -0
- data/spec/android_unit_test_checker_spec.rb +14 -0
- data/spec/fixtures/android_unit_test_checker/PublicAndPrivateType.kt +7 -0
- data/spec/fixtures/android_unit_test_checker/src/androidTest/java/org/test/PublicTypeTest.kt +4 -0
- data/spec/view_changes_checker_spec.rb +9 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 475e995ad47a8b43461803346efd892f806b60b95714f31fa7ff5c44c7148a80
|
4
|
+
data.tar.gz: 9ce8906845c50e840c4e129f419f93d7907fb3cc001daeaa8cb66db1390d2de3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 87f999a8b4c043997a558305046a8263c0218ce2c14da8359ff1d998d55690345bacd1914c2ef75417503cd54dcb1b99f59c5deaa40f1ea0508c09a7804a8365
|
7
|
+
data.tar.gz: 13916d9ab80f9ab9e1e9252a431e0807198f11130d199b1d144b7d9baaad7416289f9b72ce11fc90384da2d63f49fb358b4414c9fade23d5658bf588f65b0530
|
data/CHANGELOG.md
CHANGED
@@ -20,6 +20,13 @@ _None_
|
|
20
20
|
|
21
21
|
_None_
|
22
22
|
|
23
|
+
## 1.2.1
|
24
|
+
|
25
|
+
### Bug Fixes
|
26
|
+
|
27
|
+
- Fix `android_unit_test_checker` plugin so it doesn't detect private, enum, and data classes. [#92]
|
28
|
+
- `view_changes_checker`: update view checker regex to cover GHE user storage URLs [#91]
|
29
|
+
|
23
30
|
## 1.2.0
|
24
31
|
|
25
32
|
### New Features
|
data/Gemfile.lock
CHANGED
@@ -24,7 +24,14 @@ module Danger
|
|
24
24
|
#
|
25
25
|
class AndroidUnitTestChecker < Plugin
|
26
26
|
ANY_CLASS_DETECTOR = /class\s+([A-Z]\w+)\s*(.*?)\s*{/m
|
27
|
-
|
27
|
+
CLASS_MODIFIER_DETECTOR = /((?:\s|public|internal|protected|private|final|abstract|static|data|enum)*)class\s+([A-Z]\w+)\s*(.*?)\s*{/m
|
28
|
+
|
29
|
+
CLASS_MODIFIER_EXCEPTIONS = [
|
30
|
+
/\s*data\s*/,
|
31
|
+
/\s*private\s*/,
|
32
|
+
/\s*enum\s*/
|
33
|
+
].freeze
|
34
|
+
|
28
35
|
DEFAULT_CLASSES_EXCEPTIONS = [
|
29
36
|
/ViewHolder$/,
|
30
37
|
/Module$/,
|
@@ -142,7 +149,7 @@ module Danger
|
|
142
149
|
# @return [Array<ClassViolation>] An array of ClassViolation objects representing the violations found.
|
143
150
|
def find_violations(path:, diff_patch:, classes_exceptions:, subclasses_exceptions:)
|
144
151
|
added_lines = git_utils.added_lines(diff_patch: diff_patch)
|
145
|
-
matches = added_lines.scan(
|
152
|
+
matches = added_lines.scan(CLASS_MODIFIER_DETECTOR)
|
146
153
|
matches.reject! do |m|
|
147
154
|
class_match_is_exception?(
|
148
155
|
m,
|
@@ -152,7 +159,7 @@ module Danger
|
|
152
159
|
)
|
153
160
|
end
|
154
161
|
|
155
|
-
matches.map { |m| ClassViolation.new(m[
|
162
|
+
matches.map { |m| ClassViolation.new(m[1], path) }
|
156
163
|
end
|
157
164
|
|
158
165
|
# Finds the names of removed classes based on the removals the diff patch.
|
@@ -173,10 +180,11 @@ module Danger
|
|
173
180
|
#
|
174
181
|
# @return [void]
|
175
182
|
def class_match_is_exception?(match, file, classes_exceptions, subclasses_exceptions)
|
176
|
-
return true if classes_exceptions.any? { |re| match[
|
183
|
+
return true if classes_exceptions.any? { |re| match[1] =~ re }
|
184
|
+
return true if CLASS_MODIFIER_EXCEPTIONS.any? { |re| match[0] =~ re }
|
177
185
|
|
178
186
|
subclass_regexp = File.extname(file) == '.java' ? /extends\s+([A-Z]\w+)/m : /\s*:\s*([A-Z]\w+)/m
|
179
|
-
subclass = match[
|
187
|
+
subclass = match[2].scan(subclass_regexp)&.last&.last
|
180
188
|
subclasses_exceptions.any? { |re| subclass =~ re }
|
181
189
|
end
|
182
190
|
|
@@ -19,6 +19,7 @@ module Danger
|
|
19
19
|
%r{https?://\S*\.(gif|jpg|jpeg|png|svg)},
|
20
20
|
%r{https?://\S*\.(mp4|avi|mov|mkv)},
|
21
21
|
%r{https?://\S*github\S+/\S+/assets/},
|
22
|
+
%r{https?://\S*github\S+/storage/user/},
|
22
23
|
/!\[(.*?)\]\((.*?)\)/,
|
23
24
|
/<img\s+[^>]*src\s*=\s*[^>]*>/,
|
24
25
|
/<video\s+[^>]*src\s*=\s*[^>]*>/
|
@@ -283,6 +283,20 @@ module Danger
|
|
283
283
|
|
284
284
|
expect(@dangerfile).to not_report
|
285
285
|
end
|
286
|
+
|
287
|
+
it 'does not report private class' do
|
288
|
+
added_files = %w[
|
289
|
+
PublicAndPrivateType.kt
|
290
|
+
src/androidTest/java/org/test/PublicTypeTest.kt
|
291
|
+
]
|
292
|
+
|
293
|
+
diff = generate_add_diff_from_fixtures(added_files)
|
294
|
+
allow(@dangerfile.git).to receive(:diff).and_return(diff)
|
295
|
+
|
296
|
+
@plugin.check_missing_tests
|
297
|
+
|
298
|
+
expect(@dangerfile).to not_report
|
299
|
+
end
|
286
300
|
end
|
287
301
|
|
288
302
|
def generate_add_diff_from_fixtures(paths)
|
@@ -92,6 +92,15 @@ module Danger
|
|
92
92
|
|
93
93
|
expect(@dangerfile).to not_report
|
94
94
|
end
|
95
|
+
|
96
|
+
it 'does nothing when a PR with view code changes has a video defined with a simple GHE storage user files URL' do
|
97
|
+
allow(@plugin.github).to receive(:pr_body)
|
98
|
+
.and_return("see image:\nhttps://github.tumblr.net/storage/user/1327/files/9b6fde2b-b20e-4d82-938a-6fab63897723 body body")
|
99
|
+
|
100
|
+
@plugin.check
|
101
|
+
|
102
|
+
expect(@dangerfile).to not_report
|
103
|
+
end
|
95
104
|
end
|
96
105
|
|
97
106
|
shared_examples 'PR without view code changes' do |modified_files|
|
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.
|
4
|
+
version: 1.2.1
|
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-
|
11
|
+
date: 2024-11-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: danger
|
@@ -249,6 +249,7 @@ files:
|
|
249
249
|
- spec/fixtures/android_unit_test_checker/AnotherViewHelper.kt
|
250
250
|
- spec/fixtures/android_unit_test_checker/MyNewClass.java
|
251
251
|
- spec/fixtures/android_unit_test_checker/Polygon.kt
|
252
|
+
- spec/fixtures/android_unit_test_checker/PublicAndPrivateType.kt
|
252
253
|
- spec/fixtures/android_unit_test_checker/Shape.kt
|
253
254
|
- spec/fixtures/android_unit_test_checker/TestsINeedThem.java
|
254
255
|
- spec/fixtures/android_unit_test_checker/TestsINeedThem.kt
|
@@ -263,6 +264,7 @@ files:
|
|
263
264
|
- spec/fixtures/android_unit_test_checker/src/androidTest/java/org/test/AbcTests.java
|
264
265
|
- spec/fixtures/android_unit_test_checker/src/androidTest/java/org/test/AnotherTestClass.java
|
265
266
|
- spec/fixtures/android_unit_test_checker/src/androidTest/java/org/test/PolygonTest.kt
|
267
|
+
- spec/fixtures/android_unit_test_checker/src/androidTest/java/org/test/PublicTypeTest.kt
|
266
268
|
- spec/fixtures/android_unit_test_checker/src/androidTest/java/org/test/TestMyNewClass.java
|
267
269
|
- spec/fixtures/android_unit_test_checker/src/androidTest/java/org/test/ToolTest.kt
|
268
270
|
- spec/fixtures/android_unit_test_checker/src/main/java/org/wordpress/android/widgets/NestedWebView.kt
|