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

Issue #7573: update doc for MissingOverride #7789

Merged
merged 1 commit into from Mar 11, 2020

Conversation

HuGanghui
Copy link
Contributor

@HuGanghui HuGanghui commented Mar 6, 2020

Issue #7573: update doc for MissingOverride

image

image

Ouput of default example:
$ cat 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="MissingOverride"/>
    </module>
</module>

$ cat Test.java

class Test extends SuperClass {

    /** {@inheritDoc} */
    @Override
    public void test1() { // OK

    }

    /** {@inheritDoc} */
    public void test2() { // violation, should be annotated with &#64;Override

    }

    /** {@inheritDoc} */
    private void test3() { // violation, using the @inheritDoc tag on private method that is not valid

    }

    /** {@inheritDoc} */
    public static void test4() { // violation, using the @inheritDoc tag on static method that is not valid

    }

}

$ RUN_LOCALE="-Duser.language=en -Duser.country=US"
$ java $RUN_LOCALE -jar /var/tmp/checkstyle-8.31-SNAPSHOT-all.jar -c config.xml Test2.java
Starting audit...
[ERROR] /var/tmp/Test.java:10: Must include @java.lang.Override annotation when {@inheritdoc} Javadoc tag exists. [MissingOverride]
[ERROR] /var/tmp/Test.java:15: The Javadoc {@inheritdoc} tag is not valid at this location. [MissingOverride]
[ERROR] /var/tmp/Test.java:20: The Javadoc {@inheritdoc} tag is not valid at this location. [MissingOverride]
Audit done.
Checkstyle ends with 3 errors.

Ouput of configure the check for the javaFiveCompatibility mode:
$ cat 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="MissingOverride">
            <property name="javaFiveCompatibility"
                      value="true"/>
        </module>
    </module>
</module>

$ cat Test.java

class Test1 {

    /** {@inheritDoc} */
    public void equals() { // violation, should be annotated with &#64;Override

    }
}

interface Test2 {

    /** {@inheritDoc} */
    public abstract void test(); // violation, should be annotated with &#64;Override

}

class Test3 extends SuperClass {

    /** {@inheritDoc} */
    public void test() { // OK, is ignored because class extends other class

    }
}

class Test4 implements SuperInterface {

    /** {@inheritDoc} */
    public void test() { // OK, is ignored because class implements interface

    }
}

class Test5 {
    Runnable r = new Runnable() {

        /** {@inheritDoc} */
        public void run() { // OK, is ignored because class is anonymous class

        }
    };
}

$ RUN_LOCALE="-Duser.language=en -Duser.country=US"
$ java $RUN_LOCALE -jar /var/tmp/checkstyle-8.31-SNAPSHOT-all.jar -c config.xml Test.java
Starting audit...
[ERROR] /var/tmp/Test.java:4: Must include @java.lang.Override annotation when {@inheritdoc} Javadoc tag exists. [MissingOverride]
[ERROR] /var/tmp/Test.java:12: Must include @java.lang.Override annotation when {@inheritdoc} Javadoc tag exists. [MissingOverride]
Audit done.
Checkstyle ends with 2 errors.

@HuGanghui
Copy link
Contributor Author

HuGanghui commented Mar 8, 2020

image

I need some help, I don't why the travis-ci test fail

@HuGanghui HuGanghui requested a review from strkkk March 8, 2020 13:05
@rnveach
Copy link
Member

rnveach commented Mar 9, 2020

Please rebase on latest master to resolve CI spellchecker issue.

@HuGanghui HuGanghui force-pushed the missing-over-ride branch 2 times, most recently from ff4c4c9 to b5d9644 Compare March 9, 2020 13:57
@HuGanghui
Copy link
Contributor Author

image

In my local computer, all tests pass, but wercker/build failed and I can't see details, so please give me some help. @strkkk

@rnveach
Copy link
Member

rnveach commented Mar 10, 2020

Please fix failing travis. Wercker has to be ignored now as we are trying to fix an issue with it.

@HuGanghui HuGanghui requested a review from strkkk March 10, 2020 05:00
Copy link
Member

@strkkk strkkk left a comment

Choose a reason for hiding this comment

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

@HuGanghui please also update first post

Copy link
Member

@strkkk strkkk left a comment

Choose a reason for hiding this comment

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

last minor

src/xdocs/config_annotation.xml Outdated Show resolved Hide resolved
src/xdocs/config_annotation.xml Outdated Show resolved Hide resolved
src/xdocs/config_annotation.xml Outdated Show resolved Hide resolved
src/xdocs/config_annotation.xml Outdated Show resolved Hide resolved
@HuGanghui HuGanghui requested a review from strkkk March 11, 2020 06:29
@strkkk strkkk removed their request for review March 11, 2020 06:49
@strkkk
Copy link
Member

strkkk commented Mar 11, 2020

@HuGanghui I have added review comments above, please take a look

@strkkk
Copy link
Member

strkkk commented Mar 11, 2020

Can be merged after CI pass

@strkkk strkkk merged commit 9f5f68f into checkstyle:master Mar 11, 2020
@HuGanghui HuGanghui deleted the missing-over-ride branch March 11, 2020 11:43
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.

None yet

3 participants