correction of parsing of attributes in AtclauseOrderCheck, #1152
This commit is contained in:
parent
8397781224
commit
b930ba24be
|
|
@ -21,7 +21,6 @@ package com.puppycrawl.tools.checkstyle.checks.javadoc;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import com.puppycrawl.tools.checkstyle.Utils;
|
||||
|
|
@ -105,8 +104,9 @@ public class AtclauseOrderCheck extends AbstractJavadocCheck {
|
|||
*/
|
||||
public void setTarget(String target) {
|
||||
final List<Integer> customTarget = new ArrayList<>();
|
||||
for (String type : target.split(", ")) {
|
||||
customTarget.add(Utils.getTokenId(type));
|
||||
final String[] sTarget = target.split(",");
|
||||
for (int i = 0; i < sTarget.length; i++) {
|
||||
customTarget.add(Utils.getTokenId(sTarget[i].trim()));
|
||||
}
|
||||
this.target = customTarget;
|
||||
}
|
||||
|
|
@ -117,8 +117,11 @@ public class AtclauseOrderCheck extends AbstractJavadocCheck {
|
|||
*/
|
||||
public void setTagOrder(String order) {
|
||||
final List<String> customOrder = new ArrayList<>();
|
||||
Collections.addAll(customOrder, order.split(", "));
|
||||
tagOrder = customOrder;
|
||||
final String[] sOrder = order.split(",");
|
||||
for (int i = 0; i < sOrder.length; i++) {
|
||||
customOrder.add(sOrder[i].trim());
|
||||
}
|
||||
this.tagOrder = customOrder;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -83,16 +83,17 @@ public class AtclauseOrderCheckTest extends BaseCheckTestSupport {
|
|||
|
||||
@Test
|
||||
public void testIncorrectCustom() throws Exception {
|
||||
final String tagOrder = "[@author, @version, @param, @return, @throws, @exception, @see,"
|
||||
+ " @since, @serial, @serialField, @serialData, @deprecated]";
|
||||
final String tagOrder = "[@since, @version, @param, @return, @throws, @exception,"
|
||||
+ " @deprecated, @see, @serial, @serialField, @serialData, @author]";
|
||||
final String customOrder = " @since, @version, @param,@return,@throws, @exception,"
|
||||
+ "@deprecated, @see,@serial, @serialField, @serialData,@author";
|
||||
|
||||
DefaultConfiguration checkConfig = createCheckConfig(AtclauseOrderCheck.class);
|
||||
checkConfig.addAttribute("target", "CLASS_DEF");
|
||||
checkConfig.addAttribute("tagOrder", customOrder);
|
||||
|
||||
final String[] expected = {
|
||||
"9: " + getCheckMessage(MSG_KEY, tagOrder),
|
||||
"11: " + getCheckMessage(MSG_KEY, tagOrder),
|
||||
"12: " + getCheckMessage(MSG_KEY, tagOrder),
|
||||
"115: " + getCheckMessage(MSG_KEY, tagOrder),
|
||||
"113: " + getCheckMessage(MSG_KEY, tagOrder),
|
||||
};
|
||||
verify(checkConfig, getPath("javadoc/InputIncorrectAtClauseOrderCheck.java"), expected);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue