From 539f8afef3f7cf1e9a0b7b3e976d9515c900e696 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Fri, 17 Nov 2017 14:21:13 +0300 Subject: [PATCH] Style: do not highlight single `return when` as "Use expresison body" --- .../kotlin/idea/inspections/UseExpressionBodyInspection.kt | 2 +- idea/testData/inspectionsLocal/useExpressionBody/when.kt | 2 ++ idea/testData/inspectionsLocal/useExpressionBody/when.kt.after | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/idea/src/org/jetbrains/kotlin/idea/inspections/UseExpressionBodyInspection.kt b/idea/src/org/jetbrains/kotlin/idea/inspections/UseExpressionBodyInspection.kt index b9f921a7893..3de65eda89b 100644 --- a/idea/src/org/jetbrains/kotlin/idea/inspections/UseExpressionBodyInspection.kt +++ b/idea/src/org/jetbrains/kotlin/idea/inspections/UseExpressionBodyInspection.kt @@ -60,7 +60,7 @@ class UseExpressionBodyInspection(private val convertEmptyToUnit: Boolean) : Abs val toHighlight = valueStatement.toHighlight() return when { valueStatement !is KtReturnExpression -> Status(toHighlight, "block body", INFORMATION) - valueStatement.returnedExpression is KtWhenExpression -> Status(toHighlight, "'return when'", GENERIC_ERROR_OR_WARNING) + valueStatement.returnedExpression is KtWhenExpression -> Status(toHighlight, "'return when'", INFORMATION) valueStatement.isOneLiner() -> Status(toHighlight, "one-line return", GENERIC_ERROR_OR_WARNING) else -> Status(toHighlight, "return", INFORMATION) } diff --git a/idea/testData/inspectionsLocal/useExpressionBody/when.kt b/idea/testData/inspectionsLocal/useExpressionBody/when.kt index 27f513a8ee5..cac4ddb8fc0 100644 --- a/idea/testData/inspectionsLocal/useExpressionBody/when.kt +++ b/idea/testData/inspectionsLocal/useExpressionBody/when.kt @@ -1,3 +1,5 @@ +// HIGHLIGHT: INFORMATION + fun sign(x: Int): Int { return when { x < 0 -> -1 diff --git a/idea/testData/inspectionsLocal/useExpressionBody/when.kt.after b/idea/testData/inspectionsLocal/useExpressionBody/when.kt.after index 16630fc8f0c..bc3aa12c09d 100644 --- a/idea/testData/inspectionsLocal/useExpressionBody/when.kt.after +++ b/idea/testData/inspectionsLocal/useExpressionBody/when.kt.after @@ -1,3 +1,5 @@ +// HIGHLIGHT: INFORMATION + fun sign(x: Int): Int = when { x < 0 -> -1 x > 0 -> 1