Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Promote PlatformTypeMockDetector to error #157

Merged
merged 2 commits into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ object PlatformTypeMockDetector : MockDetector.TypeChecker {
""",
Category.CORRECTNESS,
6,
Severity.WARNING,
Severity.ERROR,
sourceImplementation<MockDetector>()
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,10 @@ class DataClassMockDetectorTest : BaseSlackLintTest() {
test/test/slack/test/TestClass.kt:35: Error: 'slack.test.TestClass' is a data class, so mocking it should not be necessary [DoNotMockDataClass]
list = listOf(mock())
~~~~~~
test/test/slack/test/TestClass.kt:27: Warning: platform type 'java.util.List' should not be mocked [DoNotMockPlatformTypes]
test/test/slack/test/TestClass.kt:27: Error: platform type 'java.util.List' should not be mocked [DoNotMockPlatformTypes]
mock()
~~~~~~
10 errors, 1 warnings
11 errors, 0 warnings
"""
.trimIndent()
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,16 +155,16 @@ class MockDetectorOptionsTest : BaseSlackLintTest() {
test/slack/test/MyTests.kt:53: Error: 'slack.test.ObjectClass' is an object, so mocking it should not be necessary [DoNotMockObjectClass]
val localClassMock = mockkClass<ObjectClass>(ObjectClass::class)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
test/slack/test/MyTests.kt:62: Warning: platform type 'java.lang.Comparable' should not be mocked [DoNotMockPlatformTypes]
test/slack/test/MyTests.kt:62: Error: platform type 'java.lang.Comparable' should not be mocked [DoNotMockPlatformTypes]
mockk<Comparable<String>>()
~~~~~~~~~~~~~~~~~~~~~~~~~~~
test/slack/test/MyTests.kt:63: Warning: platform type 'java.lang.Runnable' should not be mocked [DoNotMockPlatformTypes]
test/slack/test/MyTests.kt:63: Error: platform type 'java.lang.Runnable' should not be mocked [DoNotMockPlatformTypes]
mockk<Runnable>()
~~~~~~~~~~~~~~~~~
test/slack/test/MyTests.kt:65: Warning: platform type 'kotlin.io.FileTreeWalk' should not be mocked [DoNotMockPlatformTypes]
test/slack/test/MyTests.kt:65: Error: platform type 'kotlin.io.FileTreeWalk' should not be mocked [DoNotMockPlatformTypes]
mockk<FileTreeWalk>()
~~~~~~~~~~~~~~~~~~~~~
test/slack/test/MyTests.kt:66: Warning: platform type 'kotlin.Lazy' should not be mocked [DoNotMockPlatformTypes]
test/slack/test/MyTests.kt:66: Error: platform type 'kotlin.Lazy' should not be mocked [DoNotMockPlatformTypes]
mockk<Lazy<String>>()
~~~~~~~~~~~~~~~~~~~~~
test/slack/test/MyTests.kt:26: Error: 'slack.test.SealedClass' is a sealed type and has a restricted type hierarchy, use a subtype instead. [DoNotMockSealedClass]
Expand All @@ -191,7 +191,7 @@ class MockDetectorOptionsTest : BaseSlackLintTest() {
test/slack/test/MyTests.kt:38: Error: 'slack.test.SealedClass' is a sealed type and has a restricted type hierarchy, use a subtype instead. [DoNotMockSealedClass]
val localClassMock = mockkClass<SealedClass>(SealedClass::class)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
24 errors, 4 warnings
28 errors, 0 warnings
"""
.trimIndent()
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,25 +60,25 @@ class PlatformTypeMockDetectorTest : BaseSlackLintTest() {
.run()
.expect(
"""
test/test/slack/test/TestClass.kt:12: Warning: platform type 'java.lang.Comparable' should not be mocked [DoNotMockPlatformTypes]
test/test/slack/test/TestClass.kt:12: Error: platform type 'java.lang.Comparable' should not be mocked [DoNotMockPlatformTypes]
mock<Comparable<String>>()
~~~~~~~~~~~~~~~~~~~~~~~~~~
test/test/slack/test/TestClass.kt:13: Warning: platform type 'java.lang.Runnable' should not be mocked [DoNotMockPlatformTypes]
test/test/slack/test/TestClass.kt:13: Error: platform type 'java.lang.Runnable' should not be mocked [DoNotMockPlatformTypes]
mock<Runnable>()
~~~~~~~~~~~~~~~~
test/test/slack/test/TestClass.kt:15: Warning: platform type 'kotlin.io.FileTreeWalk' should not be mocked [DoNotMockPlatformTypes]
test/test/slack/test/TestClass.kt:15: Error: platform type 'kotlin.io.FileTreeWalk' should not be mocked [DoNotMockPlatformTypes]
mock<FileTreeWalk>()
~~~~~~~~~~~~~~~~~~~~
test/test/slack/test/TestClass.kt:16: Warning: platform type 'kotlin.Lazy' should not be mocked [DoNotMockPlatformTypes]
test/test/slack/test/TestClass.kt:16: Error: platform type 'kotlin.Lazy' should not be mocked [DoNotMockPlatformTypes]
mock<Lazy<String>>()
~~~~~~~~~~~~~~~~~~~~
test/test/slack/test/TestClass.kt:18: Warning: platform type 'android.graphics.Typeface' should not be mocked [DoNotMockPlatformTypes]
test/test/slack/test/TestClass.kt:18: Error: platform type 'android.graphics.Typeface' should not be mocked [DoNotMockPlatformTypes]
mock<Typeface>()
~~~~~~~~~~~~~~~~
test/test/slack/test/TestClass.kt:20: Warning: platform type 'androidx.collection.ArrayMap' should not be mocked [DoNotMockPlatformTypes]
test/test/slack/test/TestClass.kt:20: Error: platform type 'androidx.collection.ArrayMap' should not be mocked [DoNotMockPlatformTypes]
mock<ArrayMap<String, String>>()
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
0 errors, 6 warnings
6 errors, 0 warnings
"""
.trimIndent()
)
Expand Down Expand Up @@ -122,25 +122,25 @@ class PlatformTypeMockDetectorTest : BaseSlackLintTest() {
.run()
.expect(
"""
test/test/slack/test/TestClass.java:13: Warning: platform type 'java.lang.Comparable' should not be mocked [DoNotMockPlatformTypes]
test/test/slack/test/TestClass.java:13: Error: platform type 'java.lang.Comparable' should not be mocked [DoNotMockPlatformTypes]
mock(Comparable.class);
~~~~~~~~~~~~~~~~~~~~~~
test/test/slack/test/TestClass.java:14: Warning: platform type 'java.lang.Runnable' should not be mocked [DoNotMockPlatformTypes]
test/test/slack/test/TestClass.java:14: Error: platform type 'java.lang.Runnable' should not be mocked [DoNotMockPlatformTypes]
mock(Runnable.class);
~~~~~~~~~~~~~~~~~~~~
test/test/slack/test/TestClass.java:16: Warning: platform type 'kotlin.io.FileTreeWalk' should not be mocked [DoNotMockPlatformTypes]
test/test/slack/test/TestClass.java:16: Error: platform type 'kotlin.io.FileTreeWalk' should not be mocked [DoNotMockPlatformTypes]
mock(FileTreeWalk.class);
~~~~~~~~~~~~~~~~~~~~~~~~
test/test/slack/test/TestClass.java:17: Warning: platform type 'kotlin.Lazy' should not be mocked [DoNotMockPlatformTypes]
test/test/slack/test/TestClass.java:17: Error: platform type 'kotlin.Lazy' should not be mocked [DoNotMockPlatformTypes]
mock(Lazy.class);
~~~~~~~~~~~~~~~~
test/test/slack/test/TestClass.java:19: Warning: platform type 'android.graphics.Typeface' should not be mocked [DoNotMockPlatformTypes]
test/test/slack/test/TestClass.java:19: Error: platform type 'android.graphics.Typeface' should not be mocked [DoNotMockPlatformTypes]
mock(Typeface.class);
~~~~~~~~~~~~~~~~~~~~
test/test/slack/test/TestClass.java:21: Warning: platform type 'androidx.collection.ArrayMap' should not be mocked [DoNotMockPlatformTypes]
test/test/slack/test/TestClass.java:21: Error: platform type 'androidx.collection.ArrayMap' should not be mocked [DoNotMockPlatformTypes]
mock(ArrayMap.class);
~~~~~~~~~~~~~~~~~~~~
0 errors, 6 warnings
6 errors, 0 warnings
"""
.trimIndent()
)
Expand Down