Skip to content

Commit

Permalink
Formulate rule/bugs descriptions consistently (#4418)
Browse files Browse the repository at this point in the history
* Formulate rule/bugs descriptions consistently

reference #4384

* Apply code review suggestion for msg

Co-authored-by: Chao Zhang <zhangchao6865@gmail.com>

Co-authored-by: Chao Zhang <zhangchao6865@gmail.com>
  • Loading branch information
schalkms and chao2zhang committed Dec 28, 2021
1 parent d98e43a commit 634d29a
Show file tree
Hide file tree
Showing 15 changed files with 30 additions and 31 deletions.
Expand Up @@ -39,7 +39,7 @@ class AvoidReferentialEquality(config: Config) : Rule(config) {
override val issue = Issue(
"AvoidReferentialEquality",
Severity.Warning,
"Avoid using referential equality checks",
"Avoid using referential equality and prefer to use referential equality checks instead.",
Debt.FIVE_MINS
)

Expand Down
Expand Up @@ -12,8 +12,9 @@ import org.jetbrains.kotlin.psi.KtBinaryExpressionWithTypeRHS
import org.jetbrains.kotlin.psi.KtNullableType

/**
* Disallow to cast to nullable types. There are cases where `as String?` is misused as the safe cast (`as? String`),
* so if you want to prevent those cases, turn on this rule.
* Disallow to cast to nullable types.
* There are cases where `as String?` is misused as safe cast (`as? String`).
* So if you want to prevent those cases, turn on this rule.
*
* <noncompliant>
* fun foo(a: Any?) {
Expand All @@ -31,7 +32,7 @@ class CastToNullableType(config: Config = Config.empty) : Rule(config) {
override val issue: Issue = Issue(
javaClass.simpleName,
Severity.Defect,
"Disallow to cast to nullable types",
"Disallow to cast to nullable types.",
Debt.FIVE_MINS
)

Expand Down
Expand Up @@ -44,7 +44,7 @@ class DontDowncastCollectionTypes(config: Config) : Rule(config) {
override val issue = Issue(
"DontDowncastCollectionTypes",
Severity.Warning,
"Down-casting immutable collection types is breaking the collection contract",
"Down-casting immutable collection types is breaking the collection contract.",
Debt.TEN_MINS
)

Expand Down
Expand Up @@ -11,9 +11,9 @@ import io.gitlab.arturbosch.detekt.api.internal.ActiveByDefault
import org.jetbrains.kotlin.psi.KtWhenExpression

/**
* Flags duplicate case statements in when expressions.
* Flags duplicate `case` statements in `when` expressions.
*
* If a when expression contains the same case statement multiple times they should be merged. Otherwise, it might be
* If a `when` expression contains the same `case` statement multiple times they should be merged. Otherwise, it might be
* easy to miss one of the cases when reading the code, leading to unwanted side effects.
*
* <noncompliant>
Expand All @@ -37,7 +37,7 @@ class DuplicateCaseInWhenExpression(config: Config) : Rule(config) {
override val issue = Issue(
"DuplicateCaseInWhenExpression",
Severity.Warning,
"Duplicated case statements in when expression. Both cases should be merged.",
"Duplicated `case` statements in a `when` expression detected. Both cases should be merged.",
Debt.TEN_MINS
)

Expand Down
Expand Up @@ -19,7 +19,7 @@ import org.jetbrains.kotlin.psi.KtReturnExpression
import org.jetbrains.kotlin.psi.psiUtil.collectDescendantsOfType

/**
* Reports equals() methods which will always return true or false.
* Reports `equals()` methods which will always return true or false.
*
* Equals methods should always report if some other object is equal to the current object.
* See the Kotlin documentation for Any.equals(other: Any?):
Expand All @@ -43,10 +43,9 @@ class EqualsAlwaysReturnsTrueOrFalse(config: Config = Config.empty) : Rule(confi
override val issue = Issue(
"EqualsAlwaysReturnsTrueOrFalse",
Severity.Defect,
"Having an equals method which always returns true or false is not a good idea. " +
"Having an `equals()` method that always returns true or false is not a good idea. " +
"It does not follow the contract of this method. " +
"Consider a good default implementation. " +
"For example this == other",
"Consider a good default implementation (e.g. `this == other`).",
Debt.TWENTY_MINS
)

Expand Down
Expand Up @@ -30,7 +30,7 @@ class ExplicitGarbageCollectionCall(config: Config) : Rule(config) {
override val issue = Issue(
"ExplicitGarbageCollectionCall",
Severity.Defect,
"Don't try to be smarter than the JVM. Your code should work independently if the garbage " +
"Don't try to be smarter than the JVM. Your code should work independently whether the garbage " +
"collector is disabled or not. If you face memory issues, " +
"try tuning the JVM options instead of relying on code itself.",
Debt.TWENTY_MINS
Expand Down
Expand Up @@ -45,12 +45,10 @@ class ImplicitUnitReturnType(config: Config) : Rule(config) {
override val issue = Issue(
javaClass.simpleName,
Severity.Defect,
"""
Functions using expression statements have an implicit return type.
Changing the type of the expression accidentally, changes the function return type.
This may lead to backward incompatibility.
Use a block statement to make clear this function will never return a value.
""".trimIndent(),
"Functions using expression statements have an implicit return type. " +
"Changing the type of the expression accidentally, changes the function return type. " +
"This may lead to backward incompatibility. " +
"Use a block statement to make clear this function will never return a value.",
Debt.FIVE_MINS
)

Expand Down
Expand Up @@ -35,9 +35,9 @@ class IteratorHasNextCallsNextMethod(config: Config = Config.empty) : Rule(confi
override val issue = Issue(
"IteratorHasNextCallsNextMethod",
Severity.Defect,
"The hasNext() method of an Iterator implementation should not call the next() method. " +
"The state of the iterator should not be changed inside the hasNext() method. " +
"The hasNext() method is not supposed to have any side effects.",
"The `hasNext()` method of an Iterator implementation should not call the `next()` method. " +
"The state of the iterator should not be changed inside the `hasNext()` method. " +
"The `hasNext()` method is not supposed to have any side effects.",
Debt.TEN_MINS
)

Expand Down
Expand Up @@ -50,8 +50,8 @@ class IteratorNotThrowingNoSuchElementException(config: Config = Config.empty) :
override val issue = Issue(
"IteratorNotThrowingNoSuchElementException",
Severity.Defect,
"The next() method of an Iterator implementation should throw a NoSuchElementException " +
"when there are no more elements to return",
"The `next()` method of an `Iterator` implementation should throw a `NoSuchElementException` " +
"when there are no more elements to return.",
Debt.TEN_MINS
)

Expand Down
Expand Up @@ -33,7 +33,7 @@ class LateinitUsage(config: Config = Config.empty) : Rule(config) {
override val issue = Issue(
javaClass.simpleName,
Severity.Defect,
"Usage of lateinit detected. Using lateinit for property initialization " +
"Usage of `lateinit` detected. Using `lateinit` for property initialization " +
"is error prone, try using constructor injection or delegation.",
Debt.TWENTY_MINS
)
Expand Down
Expand Up @@ -18,7 +18,7 @@ class MissingPackageDeclaration(config: Config = Config.empty) : Rule(config) {
override val issue = Issue(
javaClass.simpleName,
Severity.Maintainability,
"Kotlin source files should define a package",
"Kotlin source files should define a package.",
debt = Debt.FIVE_MINS
)

Expand Down
Expand Up @@ -40,7 +40,7 @@ class UnreachableCode(config: Config = Config.empty) : Rule(config) {
override val issue = Issue(
"UnreachableCode",
Severity.Warning,
"Unreachable code detected. This code should be removed",
"Unreachable code detected. This code should be removed.",
Debt.TEN_MINS
)

Expand Down
Expand Up @@ -39,7 +39,8 @@ class UnsafeCallOnNullableType(config: Config = Config.empty) : Rule(config) {
override val issue: Issue = Issue(
"UnsafeCallOnNullableType",
Severity.Defect,
"It will throw a NullPointerException at runtime if your nullable value is null.",
"Unsafe calls on nullable types detected. These calls will throw a NullPointerException in case " +
"the nullable value is null.",
Debt.TWENTY_MINS
)

Expand Down
Expand Up @@ -42,7 +42,7 @@ class UnusedUnaryOperator(config: Config = Config.empty) : Rule(config) {
override val issue = Issue(
javaClass.simpleName,
Severity.Defect,
"This unary operator is not used",
"This unary operator is unused.",
Debt.FIVE_MINS
)

Expand Down
Expand Up @@ -41,8 +41,8 @@ class WrongEqualsTypeParameter(config: Config = Config.empty) : Rule(config) {
override val issue = Issue(
"WrongEqualsTypeParameter",
Severity.Defect,
"Wrong parameter type for equals() method found. " +
"To correctly override the equals() method use Any?",
"Wrong parameter type for `equals()` method found. " +
"To correctly override the `equals()` method use `Any?`.",
Debt.TEN_MINS
)

Expand Down

0 comments on commit 634d29a

Please sign in to comment.