danger-dangermattic 1.2.0 → 1.2.2
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +13 -0
- data/Gemfile.lock +1 -1
- data/lib/dangermattic/gem_version.rb +1 -1
- data/lib/dangermattic/plugins/android_unit_test_checker.rb +15 -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/TestsINeedThem2.kt +20 -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: dee5f031f75e2069d6d197e11a2c20be5e8bdd24792e04c36733632886bcbe56
|
4
|
+
data.tar.gz: 6375edfd326a90f60eb89b073d43896582fe23626624ccf08c148ada39bdacb2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2c6fdb6234e0f0957b20ab49aa4fc855a546edd73ac26b6d0ecafd8808a2dc5168530e784dc0341044684e0477e77b8d528bf5922753f6286dca47ff8f8d5407
|
7
|
+
data.tar.gz: 64ec129dac49b60046827c2ca42f91728fc395202cfbe2e4cf8d34773113fd6da4064c02f4f971fab9736f7a2842fd86f9f25d23c6208257c862d55fe7b9c39c
|
data/CHANGELOG.md
CHANGED
@@ -20,6 +20,19 @@ _None_
|
|
20
20
|
|
21
21
|
_None_
|
22
22
|
|
23
|
+
## 1.2.2
|
24
|
+
|
25
|
+
### Bug Fixes
|
26
|
+
|
27
|
+
- `android_unit_test_checker`: add `sealed` and `value` classes as an exception when reporting missing Android unit tests [#94]
|
28
|
+
|
29
|
+
## 1.2.1
|
30
|
+
|
31
|
+
### Bug Fixes
|
32
|
+
|
33
|
+
- Fix `android_unit_test_checker` plugin so it doesn't detect private, enum, and data classes. [#92]
|
34
|
+
- `view_changes_checker`: update view checker regex to cover GHE user storage URLs [#91]
|
35
|
+
|
23
36
|
## 1.2.0
|
24
37
|
|
25
38
|
### New Features
|
data/Gemfile.lock
CHANGED
@@ -24,7 +24,16 @@ 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|sealed|value)*)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
|
+
/\s*sealed\s*/,
|
34
|
+
/\s*value\s*/
|
35
|
+
].freeze
|
36
|
+
|
28
37
|
DEFAULT_CLASSES_EXCEPTIONS = [
|
29
38
|
/ViewHolder$/,
|
30
39
|
/Module$/,
|
@@ -142,7 +151,7 @@ module Danger
|
|
142
151
|
# @return [Array<ClassViolation>] An array of ClassViolation objects representing the violations found.
|
143
152
|
def find_violations(path:, diff_patch:, classes_exceptions:, subclasses_exceptions:)
|
144
153
|
added_lines = git_utils.added_lines(diff_patch: diff_patch)
|
145
|
-
matches = added_lines.scan(
|
154
|
+
matches = added_lines.scan(CLASS_MODIFIER_DETECTOR)
|
146
155
|
matches.reject! do |m|
|
147
156
|
class_match_is_exception?(
|
148
157
|
m,
|
@@ -152,7 +161,7 @@ module Danger
|
|
152
161
|
)
|
153
162
|
end
|
154
163
|
|
155
|
-
matches.map { |m| ClassViolation.new(m[
|
164
|
+
matches.map { |m| ClassViolation.new(m[1], path) }
|
156
165
|
end
|
157
166
|
|
158
167
|
# Finds the names of removed classes based on the removals the diff patch.
|
@@ -173,10 +182,11 @@ module Danger
|
|
173
182
|
#
|
174
183
|
# @return [void]
|
175
184
|
def class_match_is_exception?(match, file, classes_exceptions, subclasses_exceptions)
|
176
|
-
return true if classes_exceptions.any? { |re| match[
|
185
|
+
return true if classes_exceptions.any? { |re| match[1] =~ re }
|
186
|
+
return true if CLASS_MODIFIER_EXCEPTIONS.any? { |re| match[0] =~ re }
|
177
187
|
|
178
188
|
subclass_regexp = File.extname(file) == '.java' ? /extends\s+([A-Z]\w+)/m : /\s*:\s*([A-Z]\w+)/m
|
179
|
-
subclass = match[
|
189
|
+
subclass = match[2].scan(subclass_regexp)&.last&.last
|
180
190
|
subclasses_exceptions.any? { |re| subclass =~ re }
|
181
191
|
end
|
182
192
|
|
@@ -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)
|
@@ -10,3 +10,23 @@ class TestsINeedThem2AnotherClass
|
|
10
10
|
println("thisNeedsATest")
|
11
11
|
}
|
12
12
|
}
|
13
|
+
|
14
|
+
enum class ProtocolState {
|
15
|
+
WAITING {
|
16
|
+
override fun signal() = TALKING
|
17
|
+
},
|
18
|
+
|
19
|
+
TALKING {
|
20
|
+
override fun signal() = WAITING
|
21
|
+
};
|
22
|
+
|
23
|
+
abstract fun signal(): ProtocolState
|
24
|
+
}
|
25
|
+
|
26
|
+
value class Password(private val s: String)
|
27
|
+
|
28
|
+
sealed class Error(val message: String) {
|
29
|
+
class NetworkError : Error("Network failure")
|
30
|
+
class DatabaseError : Error("Database cannot be reached")
|
31
|
+
class UnknownError : Error("An unknown error has occurred")
|
32
|
+
}
|
@@ -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.2
|
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-25 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
|