mirror of
https://github.com/jlengrand/detekt.git
synced 2026-03-10 08:11:23 +00:00
Apply more formatting rules to our code (#3615)
* Update formatting configuration * Apply autocorrect to the project * Format using ktlint 0.41 --experimental * Minor manual improvements
This commit is contained in:
@@ -45,10 +45,12 @@ import org.jetbrains.kotlin.psi.psiUtil.getReceiverExpression
|
||||
*/
|
||||
class ForEachOnRange(config: Config = Config.empty) : Rule(config) {
|
||||
|
||||
override val issue = Issue("ForEachOnRange",
|
||||
Severity.Performance,
|
||||
"Using the forEach method on ranges has a heavy performance cost. Prefer using simple for loops.",
|
||||
Debt.FIVE_MINS)
|
||||
override val issue = Issue(
|
||||
"ForEachOnRange",
|
||||
Severity.Performance,
|
||||
"Using the forEach method on ranges has a heavy performance cost. Prefer using simple for loops.",
|
||||
Debt.FIVE_MINS
|
||||
)
|
||||
|
||||
private val minimumRangeSize = 3
|
||||
private val rangeOperators = setOf("..", "downTo", "until", "step")
|
||||
|
||||
@@ -28,15 +28,19 @@ import org.jetbrains.kotlin.psi.KtExpression
|
||||
*/
|
||||
class UnnecessaryTemporaryInstantiation(config: Config = Config.empty) : Rule(config) {
|
||||
|
||||
override val issue: Issue = Issue("UnnecessaryTemporaryInstantiation", Severity.Performance,
|
||||
"Avoid temporary objects when converting primitive types to String.",
|
||||
Debt.FIVE_MINS)
|
||||
override val issue: Issue = Issue(
|
||||
"UnnecessaryTemporaryInstantiation",
|
||||
Severity.Performance,
|
||||
"Avoid temporary objects when converting primitive types to String.",
|
||||
Debt.FIVE_MINS
|
||||
)
|
||||
|
||||
private val types: Set<String> = hashSetOf("Boolean", "Byte", "Short", "Integer", "Long", "Float", "Double")
|
||||
|
||||
override fun visitCallExpression(expression: KtCallExpression) {
|
||||
if (isPrimitiveWrapperType(expression.calleeExpression) &&
|
||||
isToStringMethod(expression.nextSibling?.nextSibling)) {
|
||||
isToStringMethod(expression.nextSibling?.nextSibling)
|
||||
) {
|
||||
report(CodeSmell(issue, Entity.from(expression), issue.description))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user