Skip to content

New rule OneTopLevelClass - #831

Merged
chrismair merged 1 commit into
CodeNarc:masterfrom
rinsley:one-top-level-class-rule
Aug 9, 2026
Merged

New rule OneTopLevelClass#831
chrismair merged 1 commit into
CodeNarc:masterfrom
rinsley:one-top-level-class-rule

Conversation

@rinsley

@rinsley rinsley commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

This adds a new rule OneTopLevelClass to require exactly one top-level class/enum/interface per file. The rule is patterned off of and similar to ClassNameSameAsFilename but added to the convention ruleset instead, as this is more of a Java/Groovy convention than a naming issue. Classes inside scripts or other classes are not considered violations. Similar to some other convention rules, it has to be excluded from the RunCodeNarcAgainstProjectSourceCode.ruleset.

@chrismair chrismair left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice idea. Thanks for the contribution.

@chrismair
chrismair merged commit af843c3 into CodeNarc:master Aug 9, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants