Skip to content

Commit

Permalink
Issue checkstyle#13839: make aliasList simple String[] but extend des…
Browse files Browse the repository at this point in the history
…cription how we interpretate value
  • Loading branch information
romani committed Nov 20, 2023
1 parent c93a60b commit 76a65e1
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@
* <ul>
* <li>
* Property {@code aliasList} - Specify aliases for check names that can be used in code
* within {@code SuppressWarnings}.
* within {@code SuppressWarnings} in a format of comma separated attribute=value entries.
* The attribute is the fully qualified name of the Check and value is its alias.
* Type is {@code java.lang.String[]}.
* Default value is {@code ""}.
* </li>
Expand Down Expand Up @@ -149,7 +150,8 @@ private static void registerAlias(String sourceName, String checkAlias) {

/**
* Setter to specify aliases for check names that can be used in code
* within {@code SuppressWarnings}.
* within {@code SuppressWarnings} in a format of comma separated attribute=value entries.
* The attribute is the fully qualified name of the Check and value is its alias.
*
* @param aliasList comma-separated alias assignments
* @throws IllegalArgumentException when alias item does not have '='
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
<properties>
<property default-value="" name="aliasList" type="java.lang.String[]">
<description>Specify aliases for check names that can be used in code
within {@code SuppressWarnings}.</description>
within {@code SuppressWarnings} in a format of comma separated attribute=value entries.
The attribute is the fully qualified name of the Check and value is its alias.</description>
</property>
</properties>
</check>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1014,17 +1014,10 @@ private static void validatePropertySectionPropertyEx(String fileName, String se
final Class<?> fieldClass = getFieldClass(fileName, sectionName, instance, field,
propertyName);

final String expectedTypeName;
// SuppressWarningsHolder#aliasList is backed by a static (upper case) property.
if ("SuppressWarningsHolder".equals(sectionName) && "aliasList".equals(propertyName)) {
expectedTypeName = "String[]";
}
else {
expectedTypeName = Optional.ofNullable(field)
final String expectedTypeName = Optional.ofNullable(field)
.map(nonNullField -> nonNullField.getAnnotation(XdocsPropertyType.class))
.map(propertyType -> propertyType.value().getDescription())
.orElse(fieldClass.getSimpleName());
}
final String expectedValue = getModulePropertyExpectedValue(sectionName, propertyName,
field, fieldClass, instance);

Expand Down
2 changes: 1 addition & 1 deletion src/xdocs/checks/annotation/suppresswarningsholder.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
</tr>
<tr>
<td>aliasList</td>
<td>Specify aliases for check names that can be used in code within <code>SuppressWarnings</code>.</td>
<td>Specify aliases for check names that can be used in code within <code>SuppressWarnings</code> in a format of comma separated attribute=value entries. The attribute is the fully qualified name of the Check and value is its alias.</td>
<td><a href="../../property_types.html#String.5B.5D">String[]</a></td>
<td><code>{}</code></td>
<td>5.7</td>
Expand Down

0 comments on commit 76a65e1

Please sign in to comment.