-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path.cursorrules
More file actions
34 lines (27 loc) 路 1.25 KB
/
Copy path.cursorrules
File metadata and controls
34 lines (27 loc) 路 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
You are working in a Kotlin codebase.
General rules:
- Follow idiomatic Kotlin and official Kotlin style conventions.
- Prefer clarity over brevity.
Strict rules:
- NEVER generate single-line `if` statements.
- Always use block `if` statements with braces, even for single statements.
- For ?: long operators, move ?: and the following expression to a new line, and indent it by 4 spaces.
- Before any block or multiline statement, insert a blank line, unless it's the first statement in a method.
- When writing values in tests, introduce them in variable within the test-method instead of using the hard-code multiple times.
- Also for values put in fields of objects and in the lists, use variable in the method.
- Within class, put the `companion object` first, before any fields or methods.
- Don't move already existing imports into non-imported signatures.
- Within a class, call the calling methods before the called methods, especially for the methods with the same name.
- Instead of `throw IllegalStateException` use Kotlin's `error`.
Example (FORBIDDEN):
if (x > 0) println(x)
Correct:
if (x > 0) {
println(x)
}
Example (incorrect)
val person = Person(name = "Bob", age = 25)
Correct:
val name = "Bob"
val age = 25
val person = Person(name = name, age = age)