Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OverloadMethodDeclarationOrder check ignores anything besides methods #14765

Closed
Zopsss opened this issue Apr 7, 2024 · 2 comments
Closed

OverloadMethodDeclarationOrder check ignores anything besides methods #14765

Zopsss opened this issue Apr 7, 2024 · 2 comments

Comments

@Zopsss
Copy link
Contributor

Zopsss commented Apr 7, 2024

I have read check documentation: https://checkstyle.org/checks/coding/overloadmethodsdeclarationorder.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

The OverloadMethodDeclarationOrderCheck gives us error if there is another method between the overloaded methods. But it does not gives error when there is anything else besides method between overloaded methods like a variable, array, inner interface, inner class, etc.

This is how the check works currently:

Test.java

public class Test {
    void test() {}

    void test(int x) {}

    private interface Testing {}

    String str;

    void test(String str) {}
}

config.xml

<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
        "-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
        "https://checkstyle.org/dtds/configuration_1_3.dtd">

<module name="Checker">
    <module name="TreeWalker">
        <module name="OverloadMethodsDeclarationOrder"/>
    </module>
</module>

Output

➜ java -jar ../checkstyle-10.15.0-all.jar -c config.xml Test.java
Starting audit...
Audit done.

The check should be giving error for the last method

void test(String str) {}

Describe what you expect in detail.

The check should be give an error something like this for the above example:

➜ java -jar ../checkstyle-10.15.0-all.jar -c config.xml Test.java
Starting audit...
[ERROR] C:\checkstyle testing\OverloadMethods\Test.java:10:5: 
All overloaded methods should be placed next to each other. Placing non-overloaded methods
 in between overloaded methods with the same type is a violation. 
Previous overloaded method located at line '4'. [OverloadMethodsDeclarationOrder]
Audit done.
Checkstyle ends with 1 errors.

@romani romani added the approved label Apr 7, 2024
@Zopsss
Copy link
Contributor Author

Zopsss commented Apr 8, 2024

I'm working on it!

Zopsss added a commit to Zopsss/checkstyle that referenced this issue Apr 8, 2024
Zopsss added a commit to Zopsss/checkstyle that referenced this issue Apr 9, 2024
Zopsss added a commit to Zopsss/checkstyle that referenced this issue Apr 9, 2024
Zopsss added a commit to Zopsss/checkstyle that referenced this issue Apr 11, 2024
Zopsss added a commit to Zopsss/checkstyle that referenced this issue Apr 14, 2024
Zopsss added a commit to Zopsss/checkstyle that referenced this issue Apr 16, 2024
Zopsss added a commit to Zopsss/checkstyle that referenced this issue Apr 20, 2024
Zopsss added a commit to Zopsss/checkstyle that referenced this issue Apr 20, 2024
Zopsss added a commit to Zopsss/checkstyle that referenced this issue Apr 20, 2024
Zopsss added a commit to Zopsss/checkstyle that referenced this issue Apr 20, 2024
Zopsss added a commit to Zopsss/checkstyle that referenced this issue Apr 20, 2024
Zopsss added a commit to Zopsss/checkstyle that referenced this issue Apr 20, 2024
@nrmancuso nrmancuso added the bug label Apr 28, 2024
@nrmancuso
Copy link
Member

Closed via #14766

@nrmancuso nrmancuso added this to the 10.16.0 milestone Apr 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants