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

Fix blank line before declarations rule code example #2657

Merged
merged 2 commits into from
May 19, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
19 changes: 7 additions & 12 deletions documentation/release-latest/docs/rules/standard.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,22 +59,22 @@ Requires a blank line before any class or function declaration. No blank line is
=== "[:material-heart:](#) Ktlint"

```kotlin
const val FOO_1 = "foo1"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FOO_1 is used intentionally. Constant value which are deeply immutable property should be written in screaming case according to property-naming rule. Of course it should have been consistent with the disallowed example.

const val foo1 = "foo1"

class FooBar {
val foo2 = "foo2"
val foo3 = "foo3"

fun bar1() {
val foo4 = "foo4"
val foo5 = "foo5"
}

fun bar2() = "bar"

val foo6 = "foo3"
val foo7 = "foo4"

enum class Foo
}
```
Expand All @@ -83,22 +83,17 @@ Requires a blank line before any class or function declaration. No blank line is

```kotlin
const val foo1 = "foo1"

class FooBar {
val foo2 = "foo2"
val foo3 = "foo3"

fun bar1() {
val foo4 = "foo4"
val foo5 = "foo5"
val foo4 = "foo4"
val foo5 = "foo5"
}

fun bar2() = "bar"

val foo6 = "foo3"
val foo7 = "foo4"

enum class Foo {}
enum class Foo
}
```

Expand Down
19 changes: 7 additions & 12 deletions documentation/snapshot/docs/rules/standard.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,22 +59,22 @@ Requires a blank line before any class or function declaration. No blank line is
=== "[:material-heart:](#) Ktlint"

```kotlin
const val FOO_1 = "foo1"
const val foo1 = "foo1"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FOO_1 is used intentionally. Constant value which are deeply immutable property should be written in screaming case according to property-naming rule. Of course it should have been consistent with the disallowed example.


class FooBar {
val foo2 = "foo2"
val foo3 = "foo3"

fun bar1() {
val foo4 = "foo4"
val foo5 = "foo5"
}

fun bar2() = "bar"

val foo6 = "foo3"
val foo7 = "foo4"

enum class Foo
}
```
Expand All @@ -83,22 +83,17 @@ Requires a blank line before any class or function declaration. No blank line is

```kotlin
const val foo1 = "foo1"

class FooBar {
val foo2 = "foo2"
val foo3 = "foo3"

fun bar1() {
val foo4 = "foo4"
val foo5 = "foo5"
val foo4 = "foo4"
val foo5 = "foo5"
}

fun bar2() = "bar"

val foo6 = "foo3"
val foo7 = "foo4"

enum class Foo {}
enum class Foo
}
```

Expand Down