Skip to content
This repository was archived by the owner on Jun 28, 2025. It is now read-only.

Commit e44e43b

Browse files
committed
Update CONTRIBUTING.md
1 parent f34cad3 commit e44e43b

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

CONTRIBUTING.md

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,36 @@
11
# Spock Contribution Guide
22

3-
Don't fear. I won't abandon your proposal to the backlog unless I have a really good reason;
4-
contributions are welcome and accepted.
3+
Contributions are welcome and accepted. Please create issues or pull requests!
54

65
> [!NOTE]
76
> This project is mainly developed [on Codeberg](https://codeberg.org/Laxystem/Spock);
87
> Please don't create pull requests on GitHub.
98
> I'll try to review them properly if you do, but it's a lot easier for me if everything is in one place.
109
10+
## Kotlin Style Guide
11+
12+
### APIs
13+
14+
APIs should be thread-safe and immutable. Expensive operations should be `suspend fun`s.
15+
16+
To create a new API, *always* declare an interface or (for immutable data) a data class. If possible, declare it as a `fun interface` (see [Interfaces, Functional Interfaces, or Typealiases](#interfaces-functional-interfaces-or-typealiases) below).
17+
18+
Implementations should be creatable via extension functions (e.g. `ByteArray.appender()`) or functions named the same or as if they were a subtype of as the interface (e.g. `ByteAppender()`, `NonThrowingByteAppender()`).
19+
20+
If the implementation accepts a function as a parameter (e.g. `EverlastingMutex(producer: (Descriptor) -> Product)`), it should be implemented as an object expression using `crossinline` on the lamabdas. Otherwise, declare a private class (usually called `FooImpl`).
21+
22+
#### Interfaces, functional interfaces, or typealiases.
23+
24+
If you need to choose between having more than one function on your interface and `fun`ness, rhe non-functional interface is likely the better choice.
25+
26+
If you intend on declaring extensions on the interface, do not use a typealias.
27+
28+
If an interface can be made functional, make it so.
29+
30+
Prefer a `@RequiresSubclassOptIn` annotation over `fun`ness.
31+
32+
See the [Kotlin documentation](https://kotlinlang.org/docs/fun-interfaces.html#functional-interfaces-vs-type-aliases) on the topic.
33+
1134
## Useful Commands
1235

1336
> [!TIP]

0 commit comments

Comments
 (0)