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

MaxLineLength: raw typo and test cleanup #5315

Merged
merged 2 commits into from Sep 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -45,7 +45,7 @@ class MaxLineLength(config: Config = Config.empty) : Rule(config) {
@Configuration("if comment statements should be ignored")
private val excludeCommentStatements: Boolean by config(false)

@Configuration("if comment statements should be ignored")
@Configuration("if raw strings should be ignored")
private val excludeRawStrings: Boolean by config(true)

override fun visitKtFile(file: KtFile) {
Expand Down
Expand Up @@ -14,6 +14,7 @@ private const val MAX_LINE_LENGTH = "maxLineLength"
private const val EXCLUDE_PACKAGE_STATEMENTS = "excludePackageStatements"
private const val EXCLUDE_IMPORT_STATEMENTS = "excludeImportStatements"
private const val EXCLUDE_COMMENT_STATEMENTS = "excludeCommentStatements"
private const val EXCLUDE_RAW_STRINGS = "excludeRawStrings"

class MaxLineLengthSpec {

Expand All @@ -23,7 +24,11 @@ class MaxLineLengthSpec {

@Test
fun `should report no errors when maxLineLength is set to 200`() {
val rule = MaxLineLength(TestConfig(mapOf(MAX_LINE_LENGTH to "200")))
val rule = MaxLineLength(
TestConfig(
MAX_LINE_LENGTH to "200",
)
)

rule.visitKtFile(file)
assertThat(rule.findings).isEmpty()
Expand All @@ -39,7 +44,11 @@ class MaxLineLengthSpec {

@Test
fun `should report all errors with default maxLineLength including raw strings`() {
val rule = MaxLineLength(TestConfig("excludeRawStrings" to false))
val rule = MaxLineLength(
TestConfig(
EXCLUDE_RAW_STRINGS to false,
)
)

rule.visitKtFile(file)
assertThat(rule.findings).hasSize(7)
Expand Down Expand Up @@ -85,9 +94,7 @@ class MaxLineLengthSpec {
fun `should not report the package statement and import statements by default`() {
val rule = MaxLineLength(
TestConfig(
mapOf(
MAX_LINE_LENGTH to "60"
)
MAX_LINE_LENGTH to "60",
)
)

Expand All @@ -99,11 +106,9 @@ class MaxLineLengthSpec {
fun `should report the package statement and import statements if they're enabled`() {
val rule = MaxLineLength(
TestConfig(
mapOf(
MAX_LINE_LENGTH to "60",
EXCLUDE_PACKAGE_STATEMENTS to "false",
EXCLUDE_IMPORT_STATEMENTS to "false"
)
MAX_LINE_LENGTH to "60",
EXCLUDE_PACKAGE_STATEMENTS to "false",
EXCLUDE_IMPORT_STATEMENTS to "false",
)
)

Expand Down Expand Up @@ -133,7 +138,9 @@ class MaxLineLengthSpec {
@Test
fun `should report the package statement, import statements, line and comments by default`() {
val rule = MaxLineLength(
TestConfig(MAX_LINE_LENGTH to "60")
TestConfig(
MAX_LINE_LENGTH to "60",
)
)

rule.visitKtFile(file)
Expand All @@ -159,10 +166,8 @@ class MaxLineLengthSpec {
fun `should not report comments if they're disabled`() {
val rule = MaxLineLength(
TestConfig(
mapOf(
MAX_LINE_LENGTH to "60",
EXCLUDE_COMMENT_STATEMENTS to "true"
)
MAX_LINE_LENGTH to "60",
EXCLUDE_COMMENT_STATEMENTS to "true",
)
)

Expand All @@ -188,7 +193,9 @@ class MaxLineLengthSpec {
@Test
fun `should only the function line by default`() {
val rule = MaxLineLength(
TestConfig(MAX_LINE_LENGTH to "60")
TestConfig(
MAX_LINE_LENGTH to "60",
)
)

rule.visitKtFile(file)
Expand Down