Skip to content

Commit

Permalink
Downgrade ComposeCompositionLocalUsage to warning (#52)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisbanes authored Feb 10, 2023
1 parent 73cce5a commit 3975762
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class CompositionLocalUsageDetector : Detector(), SourceCodeScanner {
""",
category = Category.PRODUCTIVITY,
priority = Priorities.NORMAL,
severity = Severity.ERROR,
severity = Severity.WARNING,
implementation = sourceImplementation<CompositionLocalUsageDetector>()
)
.setOptions(listOf(ALLOW_LIST))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class CompositionLocalUsageDetectorTest : BaseSlackLintTest() {
override val skipTestModes: Array<TestMode> = arrayOf(TestMode.PARENTHESIZED)

@Test
fun `error when a CompositionLocal is defined`() {
fun `warning when a CompositionLocal is defined`() {
lint()
.files(
kotlin(
Expand All @@ -37,27 +37,27 @@ class CompositionLocalUsageDetectorTest : BaseSlackLintTest() {
)
.allowCompilationErrors()
.run()
.expectErrorCount(4)
.expectWarningCount(4)
.expect(
"""
src/test.kt:2: Error: `CompositionLocal`s are implicit dependencies and creating new ones should be avoided.
src/test.kt:2: Warning: `CompositionLocal`s are implicit dependencies and creating new ones should be avoided.
See https://slackhq.github.io/compose-lints/rules/#compositionlocals for more information. [ComposeCompositionLocalUsage]
private val LocalApple = staticCompositionLocalOf<String> { "Apple" }
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/test.kt:3: Error: `CompositionLocal`s are implicit dependencies and creating new ones should be avoided.
src/test.kt:3: Warning: `CompositionLocal`s are implicit dependencies and creating new ones should be avoided.
See https://slackhq.github.io/compose-lints/rules/#compositionlocals for more information. [ComposeCompositionLocalUsage]
internal val LocalPlum: String = staticCompositionLocalOf { "Plum" }
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/test.kt:4: Error: `CompositionLocal`s are implicit dependencies and creating new ones should be avoided.
src/test.kt:4: Warning: `CompositionLocal`s are implicit dependencies and creating new ones should be avoided.
See https://slackhq.github.io/compose-lints/rules/#compositionlocals for more information. [ComposeCompositionLocalUsage]
val LocalPrune = compositionLocalOf { "Prune" }
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/test.kt:5: Error: `CompositionLocal`s are implicit dependencies and creating new ones should be avoided.
src/test.kt:5: Warning: `CompositionLocal`s are implicit dependencies and creating new ones should be avoided.
See https://slackhq.github.io/compose-lints/rules/#compositionlocals for more information. [ComposeCompositionLocalUsage]
private val LocalKiwi: String = compositionLocalOf { "Kiwi" }
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4 errors, 0 warnings
"""
0 errors, 4 warnings
"""
.trimIndent()
)
}
Expand All @@ -68,9 +68,9 @@ class CompositionLocalUsageDetectorTest : BaseSlackLintTest() {
.files(
kotlin(
"""
val LocalBanana = staticCompositionLocalOf<String> { "Banana" }
val LocalPotato = compositionLocalOf { "Potato" }
"""
val LocalBanana = staticCompositionLocalOf<String> { "Banana" }
val LocalPotato = compositionLocalOf { "Potato" }
"""
)
)
.allowCompilationErrors()
Expand Down

0 comments on commit 3975762

Please sign in to comment.