Skip to content

New Check to validate method parameter order in javadoc to match parameter order in method #8990

@romani

Description

@romani

taken from #2810

TestClass.java

package test;

public class TestClass {
    /**
     * Description.
     * 
     * @param p2
     *            Parameter 2 desc.
     * @param p1
     *            Parameter 1 desc.
     * @param <T>
     *            Parameter T desc.
     * @param p3
     *            Parameter 3 desc.
     */
    public <T> void test(String p1, String p2, T p3) {
    }
}

config.xml

<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
          "-//Puppy Crawl//DTD Check Configuration 1.3//EN"
          "http://www.puppycrawl.com/dtds/configuration_1_3.dtd">

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

To add less confusion between the javadoc order and the method when reading, I would like the at parameters to be validated in the javadoc so they both agree in terms of order. This will give new readers less headaches as they try to read and understand the method and what it's parameters mean.

With this new Check, I am expecting the javadocs for parameters 1 and T to produce errors that they are out of order in my example. If 2 and/or 3 produce errors that is fine, but I expect the main ones that go backwards in the list to definitely be there.
The preferred order, imo, should be T, 1, 2, 3 like they are defined in the method definition.

========

We need to come to agreement in names and behavior/design to make issue approved.

Metadata

Metadata

Assignees

No one assigned

    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