Search code examples
javajavadoccheckstyle

JavadocMethod: Expected @param tag error when actually it exist


I am getting following check style error

[ERROR] src\main\java\com\disney\wdpr\dclm\personalization\base\service\mapper\PaymentSvcMapper.java:[45,46] (javadoc) JavadocMethod: Expected @param tag for 'retrievePersonByPersonIdPayerResponse'.
[ERROR] src\main\java\com\disney\wdpr\dclm\personalization\base\service\mapper\PaymentSvcMapper.java:[46,33] (javadoc) JavadocMethod: Expected @param tag for 'fidelioPostResponse'.
[ERROR] src\main\java\com\disney\wdpr\dclm\personalization\base\service\mapper\PaymentSvcMapper.java:[46,62] (javadoc) JavadocMethod: Expected @param tag for 'personId'.
[ERROR] src\main\java\com\disney\wdpr\dclm\personalization\base\service\mapper\PaymentSvcMapper.java:[46,89] (javadoc) JavadocMethod: Expected @param tag for 'blist'.
[ERROR] src\main\java\com\disney\wdpr\dclm\personalization\base\service\mapper\PaymentSvcMapper.java:[46,103] (javadoc) JavadocMethod: Expected @param tag for 'paymentType'.
[ERROR] src\main\java\com\disney\wdpr\dclm\personalization\base\service\mapper\PaymentSvcMapper.java:[47,21] (javadoc) JavadocMethod: Expected @param tag for 'routedPId'.

But my code contains @param tags in the specified function and line numbers.

/**
 * @param retrievePersonByPersonIdPayerResponse
 * @param fidelioPostResponse
 * @param personId
 * @param blist
 * @param paymentType
 * @param routedPId
 * @return
 */
public static PaymentResponse mapPaymentRequest(
        RetrievePersonByPersonIdResponse retrievePersonByPersonIdPayerResponse,
        FidelioPostResponse fidelioPostResponse, Integer personId, HashSet<Integer> blist, String paymentType,
        Integer routedPId) {

Please advice.


Solution

  • This is because you just list the arguments, but don't explain them. Your javadoc is a waste of space, it doesn't add anything that is not already there in code.

    Here is a minimal example:

    public class Test {
        /**
         * @param theFoo what to foo
         */
        public String foo(String theFoo) {
            return theFoo;
        }
    }
    

    When I run javadoc on it, I get a similar complaint:

    robert:~$ javadoc Test.java
    Loading source file Test.java...
    Constructing Javadoc information...
    Standard Doclet version 14.0.1
    Building tree for all the packages and classes...
    Generating ./Test.html...
    Test.java:3: warning: no description for @param
         * @param theFoo
           ^
    Test.java:5: warning: no @return
        public String foo(String theFoo) {
                      ^
    ...
    

    Just add a bit of explanation to fix it:

    public class Test {
        /**
         * @param theFoo what to foo
         * @return the same foo
         */
        public String foo(String theFoo) {
            return theFoo;
        }
    }
    

    You don't get a warning about it, but honestly, your Javadoc should explain what the method does, above the first @param.