Skip to content

docs: Google style coverage page missing sample example for 3.4.2.1 Overloads: never split #21447

Closed

Description

@Atharv3221

Child Issue of #21428

I have read check https://checkstyle.org/checks/coding/overloadmethodsdeclarationorder.html,
https://checkstyle.org/checks/coding/constructorsdeclarationgrouping.html
I have downloaded the latest checkstyle from: https://checkstyle.org/cmdline.html#Download_and_Run
I have executed the cli and showed it below, as cli describes the problem better than 1,000 words

3.4.2.1 Overloads: never split

Methods of a class that share the same name appear in a single contiguous group with no other members in between. The same applies to multiple constructors. This rule applies even when modifiers such as static or private differ between the methods or constructors.

samples: https://github.com/checkstyle/checkstyle/tree/master/src/it/resources/com/google/checkstyle/test/chapter3filestructure/rule3421overloadsplit

Missing examples for different modifiers

atharv@atharv-IdeaPad-3-15IIL05:~/test$ cat Test.java
/** Some javadoc. */
public class Test {

  /** Some javadoc. */
  public Test() {}

  private void foo() {}

  private Test(int x) {}

  static void foo(int x) {}

  /** Some javadoc. */
  public Test(String s) {}

  /** Some javadoc. */
  public void foo(double d) {}
}
atharv@atharv-IdeaPad-3-15IIL05:~/test$ java -jar checkstyle-14.1.0-all.jar -c /google_checks.xml Test.java
Starting audit...
[WARN] /home/atharv/test/Test.java:9:3: Constructors should be grouped together. The last grouped constructor is declared at line '5'. [ConstructorsDeclarationGrouping]
[WARN] /home/atharv/test/Test.java:11:3: All overloaded methods should be placed next to each other. Previous overloaded method located at line '7'. [OverloadMethodsDeclarationOrder]
[WARN] /home/atharv/test/Test.java:14:3: Constructors should be grouped together. The last grouped constructor is declared at line '5'. [ConstructorsDeclarationGrouping]
[WARN] /home/atharv/test/Test.java:17:3: All overloaded methods should be placed next to each other. Previous overloaded method located at line '11'. [OverloadMethodsDeclarationOrder]
Audit done.

Activity

  1. Atharv3221 commented on Sep 4, 2026

    @Atharv3221
    MemberAuthor

    @NianJiuZst please work on another issue this is project related

  2. Atharv3221 commented on Sep 4, 2026

    @Atharv3221
    MemberAuthor

    I am working on it

  3. added a commit that references this issue on Sep 9, 2026
  4. added a commit that references this issue on Sep 10, 2026
  5. added this to the 14.1.1 milestone on Sep 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions