Skip to content

FAQ

Why is it necessary?

When working on a project with multiple programming languages, we often forget to apply the same coding style and leave the validation to a linter tool. However, the default behavior of these linters are not always consistent. Consider the example below:

Java Groovy Kotlin Python
Java does not allow trailing commas except in array initializers. Groovy allows trailing commas in call sites, but CodeNarc does not natively support it. Trailing commas can be placed in call and declaration sites in Kotlin, the rule is provided by Ktlint. Python allows trailing commas but Pylint considers it optional in PEP. Note that the comment spacing rule is different in Python.
void foo(
    int a,
    int b
) {
    bar(
        a,
        b
    )
}
def foo(
    int a,
    int b
) {
    bar(
        a,
        b // no!
    )
}
fun foo(
    a: Int,
    b: Int // no!
) =
    bar(
        a,
        b // no!
    )
def foo(
    a: int,
    b: int  # no!
):
    bar(
        a,
        b  # no!
    )

How stable is it?

The rules are mostly work in progress and have not been tested against a large codebase. Disable the rules individually if they behave unexpectedly.

<!--module name="CommentSpaces"/-->
<!--rule class="com.hanggrian.rulebook.codenarc.CommentSpacesRule"/-->
ktlint_rulebook_comment-spaces = disabled
# rulebook_pylint.comment_spaces,

What's next for Rulebook?

Although there is no timeline for the roadmap, the following features are planned:

  • More languages:
    • Java
    • Groovy
    • Kotlin
    • Python
    • JavaScript
    • TypeScript
  • Rigorous testing:
    • Consistent unit test names and cases across all languages.
    • Collect interesting code snippets from open-source projects.