Skip to content

Commit 0c89207

Browse files
authored
Improve code review rules for visibility modifiers (#17800)
1 parent 87092a6 commit 0c89207

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

.github/agents/knowledge/general-rules.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,18 @@ Do not flag the following patterns (common false positives):
7777

7878
- FQCN is acceptable when class-name collision makes import impossible.
7979

80+
## [Style] Visibility modifiers
81+
82+
Follow the principle of minimal necessary visibility. Use the most restrictive access modifier that
83+
still allows the code to function correctly.
84+
85+
**Exception — Single public class**: If a module has only one public class then don't change it to
86+
package-private. Javadoc task fails when module has no public classes.**
87+
88+
**Exception — Used from advice**: All classes and methods used from methods annotated with
89+
`@Advice.OnMethodEnter` or `@Advice.OnMethodExit` must be public. These methods are inlined into
90+
transformed classes and must be accessible from those classes, which may be in different packages.
91+
8092
## [Style] `@SuppressWarnings` Usage
8193

8294
- Method-level `@SuppressWarnings` is preferred over class-level for tighter scope, but

0 commit comments

Comments
 (0)