Skip to content

Add remaining checks to New OpenJDK Java Style Guide coverage page and config #19798

@Aman-Baliyan

Description

@Aman-Baliyan

continuation of : #19604

Style Guide: OpenJDK Java Style Guidelines v6 (cached page)
Coverage Page: src/site/xdoc/openjdk_style.xml
Config File: src/main/resources/openjdk_checks.xml

Context

The infrastructure for the New OpenJDK Java Style Guide coverage page openjdk_style.xml and embedded config openjdk_checks.xml has been created. We need to add checks for each rule in the style guide and complete all ??? entries in the coverage page - similar to how it is done for Google's Java Style Checkstyle Coverage.

All sections and rules are already listed in the coverage page. Rows marked with ??? need to be completed.

How to contribute

  1. Pick a subsection from the tracking list below, comment "I am working on §X.Y - Subsection Name" on this issue, and create a child issue referencing this parent issue.

    • Title format: Add checks for OpenJDK Style [§X.Y - Subsection Name]
    • In the child issue, list all the rules and corresponding checks that will enforce that rule (see example child issue).
    • Add a checklist in the child issue to track progress per rule.
  2. Wait for the issue to get approved before starting work to avoid unnecessary iterations on PRs.

  3. Make one PR per check/rule. If a subsection has multiple rules, do NOT put them all in one PR. Submit a separate PR for each check so it is easy to review and merge.

  4. In each PR clearly mention:

    • Which rule it covers (e.g., "Source files must be encoded in 7-bit ASCII")
    • Which check is being added
    • Reference the child issue
  5. Each PR should include:

    • The check added to src/main/resources/openjdk_checks.xml with proper configuration
    • The corresponding ??? row updated in src/site/xdoc/openjdk_style.xml, following the format used in google_style.xml
    • Integration tests following the folder structure below
  6. Update your child issue checklist as PRs are raised.

Integration test structure

Tests must follow the same section-based folder structure used by Google style tests. The existing structure is:

src/it/resources/com/openjdk/checkstyle/test/chapter{N}{description}/rule{NNN}{description}/Input*.java
src/it/java/com/openjdk/checkstyle/test/chapter{N}{description}/rule{NNN}{description}/*Test.java

Use src/it/resources/com/google/checkstyle/test/ as the reference for how test input files and test classes are organized by chapter and rule.

Note: For the integration tests, we will not follow modulewise testing. We will follow chapterwise testing like Google style, one test class per section, not per check. The existing OneStatementPerLineTest will also be refactored into the chapterwise format. Please follow the Google style test structure as reference.

Example Child Issue : #19619

Reference

Use google_style.xml and google_checks.xml as the formatting and structure reference.

Subsection tracking

2 - Java Source Files

Subsection Child Issue Status
§2 - Java Source Files #19617 ☑️
§2.1 - Special Characters #19617 ☑️

3 - Formatting

Subsection Child Issue Status
§3.1 - Copyright notice
§3.2 - Package declaration #19622 ☑️
§3.3 - Import statements #19623
§3.3.1 - Wildcard imports #19734 ☑️
§3.4 - Class Structure #19624
§3.4.1 - Order of Constructors and Overloaded Methods #19805
§3.5 - Modifiers #19629
§3.6 - Braces #19670
§3.6.1 - Short Forms #19670
§3.7 - Indentation #19619 ☑️
§3.8 - Wrapping Lines
§3.8.1 - Wrapping Class Declarations #19743
§3.8.2 - Wrapping Method Declarations
§3.8.3 - Wrapping Expressions
§3.9 - Whitespace
§3.9.1 - Vertical Whitespace
§3.9.2 - Horizontal Whitespace
§3.10 - Variable Declarations #19641 ☑️
§3.11 - Annotations
§3.12 - Lambda Expressions #19662
§3.13 - Redundant Parentheses #20093
§3.14 - Literals #19620 ☑️
§3.15 - Javadoc

4 - Naming

Subsection Child Issue Status
§4.1 - Package Names #19640 ☑️
§4.2 - Class, Interface and Enum Names
§4.3 - Method Names #19755 ☑️
§4.4 - Variables
§4.5 - Type Variables
§4.6 - Constants

5 - Programming Practices

Subsection Child Issue Status
§5 - Programming Practices
§5.1 - Commenting Code

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions