Skip to content

Home

What is Rulebook?


  • Library extension
    A set of additional rules for static code analysis tools

  • Multiple languages
    Originally written for Kotlin, it now supports Java, Groovy and Python

How does it work?

flowchart LR
  subgraph "Project"
    src(Source code)
    config[Config files]
  end
  subgraph "Static analysis"
    linters[Linter libraries]
    extensions[Rule extensions]
  end
  subgraph "Report"
    cli[Build failure<br>on lint errors]
    ide[Live warnings]
  end
  subgraph "Refactor"
    manual(Manual edits<br>using suggestions)
  end
  src -- run --> linters
  linters -- CLI --> cli
  linters -- IDE --> ide
  cli -- fix --> manual
  ide -- fix --> manual

Compatibility table

Rule Java Groovy Kotlin C/C++ Python JavaScript TypeScript
Block tag punctuation71
TODO comment47
Trailing comma in call65
Trailing comma in collection76
Trailing comma in declaration65
Unused import46
Wildcard import26
format_text_clip Clipping group Java Groovy Kotlin C/C++ Python JavaScript TypeScript
Block comment clip52
Braces clip19
Brackets clip3
Parentheses clip3
Tags clip3
data_object Declaring group Java Groovy Kotlin C/C++ Python JavaScript TypeScript
Deprecated type57
Double quotes in block comment75
Internal error73
Lowercase d33
Lowercase f33
Lowercase Hexadecimal20
Lowercase i33
Missing inline in contract55
Missing private constructor5
Redundant qualifier39
Single quotes in literal22
Unnecessary abstract1
Unnecessary parentheses in lambda72
Uppercase L33
regular_expression Expressing group Java Groovy Kotlin C/C++ Python JavaScript TypeScript
Complicated boolean equality41
Complicated size equality42
Confusing predicate8
Deprecated identity64
Redundant equality36
Redundant equals36
draft Formatting group Java Groovy Kotlin C/C++ Python JavaScript TypeScript
Empty file4
File size63
Indent style17
Line feed17
Line length21
Trailing newline17
Unnecessary trailing space17
label Naming group Java Groovy Kotlin C/C++ Python JavaScript TypeScript
Abbreviation as word48
Boolean property interoperability60
Class name68
Constant name68
File name62
Generic name74
Identifier name68
Illegal variable name2
Meaningless word48
Package name68
swap_vert Ordering group Java Groovy Kotlin C/C++ Python JavaScript TypeScript
Block tag order13
Common function position67
Import order25
Inner class position50
Member order50
Modifier order58
Named import order9
Overload function position59
Static import position67
terminal Scripting group Java Groovy Kotlin C/C++ Python JavaScript TypeScript
Decentralized dependency29
Eager API30
Lonely configuration12
Root project name31
Script file name32
format_letter_spacing_2 Spacing group Java Groovy Kotlin C/C++ Python JavaScript TypeScript
Block comment spaces70
Block tag indentation23
Case separator51
Comment spaces15
Member separator28
Missing blank line before block tags54
code_blocks Stating group Java Groovy Kotlin C/C++ Python JavaScript TypeScript
Complicated assignment34
Illegal catch73
Illegal throw73
Lonely case43
Lonely if11
Missing braces14
Nested if-else35
Redundant default38
Redundant else38
Redundant if37
Semicolon61
Unnecessary continue44
Unnecessary return45
bug_report Testing group Java Groovy Kotlin C/C++ Python JavaScript TypeScript
Complicated assertion40
Confusing assertion8
Deprecated annotation56
format_letter_spacing_standard Trimming group Java Groovy Kotlin C/C++ Python JavaScript TypeScript
Block comment trim7
Braces trim18
Brackets trim10
Comment trim7
Duplicate blank line28
Duplicate blank line in block comment7
Duplicate blank line in comment7
Duplicate space53
Parentheses trim10
Tags trim10
Unnecessary blank line after colon18
Unnecessary leading blank line27
format_text_wrap Wrapping group Java Groovy Kotlin C/C++ Python JavaScript TypeScript
Assignment wrap24
Chain call wrap66
Elvis wrap6
Infix call wrap16
Lambda wrap24
Operator wrap16
Parameter wrap49
Statement wrap69

Legend

  • : The rule is fully implemented.
  • : Functionality already exists in other rules.
  • : The rule is already supported by the linter.
  • : Not supported due to technical limitations.
  • : Feature currently unexplored.
  • Empty: not applicable to this language.

Download

Get the artifacts from official package managers.

Download the library

Maven CentralPyPI

Integration

The main linter libraries can be downloaded using package managers. Preferrably, use IDE plugins to instantly see the issues while coding.

Integrate the linter tools


  1. Abstract class require abstract method 

  2. Avoid primitive names 

  3. Concise brackets, parentheses and tags 

  4. Delete empty file 

  5. Hide utility class instance 

  6. Move trailing elvis to the next line 

  7. No blank lines at initial, final and consecutive comments 

  8. Remove negation 

  9. Sort named imports 

  10. Trim multiline brackets, parentheses and tags 

  11. Use else-if 

  12. Use named object directly 

  13. Android: Block tags  

  14. Android: Braces  

  15. Android: Horizontal whitespace  

  16. Android: Where to break  

  17. EditorConfig: File format details  

  18. Google: Nonempty blocks: K & R style  

  19. Google: Empty blocks  

  20. Google: Capitalization  

  21. Google: Column limit: 100  

  22. Google: Use single quotes  

  23. Google: Block tags  

  24. Google: Where to break  

  25. Google: Ordering and spacing  

  26. Google: Imports  

  27. Google: Source file structure  

  28. Google: Vertical whitespace  

  29. Gradle: Use version catalogs to centralize dependency versions  

  30. Gradle: Eager APIs to avoid  

  31. Gradle: Name your root project  

  32. Gradle: Naming recommendations  

  33. Groovy: Number type suffixes  

  34. JetBrains: Assignment can be replaced with operator assignment  

  35. JetBrains: Invert 'if' statement to reduce nesting  

  36. JetBrains: 'equals()' call can be replaced with '=='  

  37. JetBrains: Redundant 'if' statement  

  38. JetBrains: Redundant 'else' keyword  

  39. JetBrains: Redundant name qualifier  

  40. JetBrains: Simplifiable assertion  

  41. JetBrains: Boolean expression can be simplified  

  42. JetBrains: 'size() == 0' can be replaced with 'isEmpty()'  

  43. JetBrains: Minimum 'switch' branches  

  44. JetBrains: Unnecessary 'continue' statement  

  45. JetBrains: Unnecessary 'return' statement  

  46. JetBrains: Unused import directive  

  47. JetBrains: TODO comments  

  48. Kotlin: Choose good names  

  49. Kotlin: Class headers  

  50. Kotlin: Class layout  

  51. Kotlin: Control flow statements  

  52. Kotlin: Documentation comments  

  53. Kotlin: Horizontal whitespace  

  54. Kotlin: KDoc syntax  

  55. Kotlin: Kotlin contracts  

  56. Kotlin: kotlin-test  

  57. Kotlin: Mapped types  

  58. Kotlin: Modifiers order  

  59. Kotlin: Overload layout  

  60. Kotlin: Calling Kotlin from Java  

  61. Kotlin: Semicolons  

  62. Kotlin: Source file names  

  63. Kotlin: Source file organization  

  64. Kotlin: Structural equality  

  65. Kotlin: Trailing commas  

  66. Kotlin: Wrap chained calls  

  67. OpenJDK: Summary of feedback  

  68. Oracle: Naming conventions  

  69. Oracle: Simple statements  

  70. Oracle: Javadoc reference  

  71. Oracle: Javadoc tool  

  72. Oracle: Lambda expressions  

  73. Oracle: How to throw exceptions  

  74. Oracle: Generic types  

  75. Python: What is a Docstring?  

  76. Python: When to use trailing commas