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

Trim multiline text in warnings #322

Merged
merged 3 commits into from
Sep 24, 2020
Merged
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 @@ -92,6 +92,8 @@ enum class Warnings(private val canBeAutoCorrected: Boolean, private val warn: S
WRONG_DECLARATIONS_ORDER(true, "declarations of constants and enum members should be sorted alphabetically"),
WRONG_MULTIPLE_MODIFIERS_ORDER(true, "sequence of modifiers is incorrect"),
LOCAL_VARIABLE_EARLY_DECLARATION(false, "local variables should be declared close to the line where they are first used"),

// ======== chapter 4 ========
TYPE_ALIAS(false, "variable's type is too complex and should be replaced with typealias"),
STRING_TEMPLATE_CURLY_BRACES(true, "string template has redundant curly braces"),
STRING_TEMPLATE_QUOTES(true, "string template has redundant quotes"),
Expand Down Expand Up @@ -126,8 +128,11 @@ enum class Warnings(private val canBeAutoCorrected: Boolean, private val warn: S
node: ASTNode) {

if (configs.isRuleEnabled(this) && !node.hasSuppress(name)) {
val trimmedFreeText = freeText
.lines()
.run { if (size > 1) "${first()}..." else first() }
emit(offset,
"${this.warnText()} $freeText",
"${this.warnText()} $trimmedFreeText",
autoCorrected
)
}
Expand Down