-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
ImportOrder: replace Pattern[] with String[] type for properties staticGroups and groups #13758
Comments
checkstyle/src/main/java/com/puppycrawl/tools/checkstyle/AbstractAutomaticBean.java Lines 110 to 111 in 5a0f923
If I make a 3rd party check, I expect every type listed on that page ( https://checkstyle.org/property_types.html ) to work as described if I were to use them in a property in said 3rd party check. Otherwise, it would confusing on what we do and do not support. |
I will give a try on this issue. |
@rnveach @romani It looks like the Below is the code segment of if (WILDCARD_GROUP_NAME.equals(pkg)) {
// matches any package
grp = Pattern.compile("");
}
else if (pkg.startsWith(FORWARD_SLASH)) {
if (!pkg.endsWith(FORWARD_SLASH)) {
throw new IllegalArgumentException("Invalid group: " + pkg);
}
pkg = pkg.substring(1, pkg.length() - 1);
grp = Pattern.compile(pkg);
}
else {
final StringBuilder pkgBuilder = new StringBuilder(pkg);
if (!pkg.endsWith(".")) {
pkgBuilder.append('.');
}
grp = Pattern.compile("^" + Pattern.quote(pkgBuilder.toString()));
} This could be very confusing. Instead enforcing users to use Update: alternatively, maybe it's better to split this |
If we can enforce this, we can get rid of the delim |
If this proposal works, I will:
|
I see that type at ImportOrderCheck is correct. @Lmh-java, please create new PR with only what I referencing in this post, I am voting to do only this update, not a new global type as it has problems in design, as I mentioned in your PR. |
@romani Thanks for your response! Sure, I will create a new PR with only documentation changes. For discussion: |
It might be too late. Users will be frustrated. We need to respect user backward compatibility, and use it only when absolutely required. |
I have read through all the linked PRs, comments, etc. and I am struggling to understand why we need Is there some conceptual difference between this and a |
@nrmancuso, Basically, this property works by converting My reasoning for this is that we have some checks that use this This property might also remind checkstyle users about the nature of some properties. If the type of a property is Please feel free to correct me :). |
No need for correction in any case, it is a matter of opinion.
Yes, this is good, I agree. |
@romani please update the issue description to reflect what is left to do here. |
I do not remember what is left, look like we fixed all. #14857 is postponed for future. |
from #13754 (comment)
We think our documentation at https://checkstyle.org/property_types.html#Pattern.5B.5D is either wrong or misleading.
Found looking at https://checkstyle.org/checks/metrics/classfanoutcomplexity.html#Properties
When glancing at this, i thought it meant each pattern is separated by a
/
.But looking at the code at
checkstyle/src/main/java/com/puppycrawl/tools/checkstyle/checks/metrics/AbstractClassCouplingCheck.java
Line 160 in 5a0f923
/
.Even
createPattern
method that it calls does nothing with/
, so I don't understand where the/
is coming from.https://github.com/search?q=repo%3Acheckstyle%2Fcheckstyle+%22Pattern.5B.5D%22+path%3A%2F%5Esrc%5C%2Fxdocs%5C%2Fchecks%5C%2F%2F&type=code
We have 6 checks with this type.
It looks like documentation is coming from
checkstyle/src/main/java/com/puppycrawl/tools/checkstyle/checks/imports/ImportOrderCheck.java
Line 759 in 5a0f923
We need review all Patern[] usage and probably move ImportOrderCheck to have special type.
how we can support list of Pattern, when "," can be used in regexp.
agreement on how to fix we archived at #14764 (comment)
Migration Notes:
ImportOrder
is update to replacePattern[]
withString[]
type for propertiesstaticGroups
andgroups
.user who use xml config are not affected, but plugins who might have type validation during Check configuration (before Check execution) might be affected. Validation type in metadata is different from 10.17.0 for this Check.
The text was updated successfully, but these errors were encountered: