From #13423 (comment)
Method constructMessageKeyUrl in ViolationMessagesMacro does not encode the URL
private static String constructMessageKeyUrl(Class<?> clss, String messageKey) {
return "https://github.com/search?q="
+ "path%3Asrc%2Fmain%2Fresources%2F"
+ clss.getPackage().getName().replace(".", "%2F")
+ "%20path%3A**%2Fmessages*.properties+repo%3Acheckstyle%2F"
+ "checkstyle+%22" + messageKey + "%22";
}
UrlEncoder.encode can be used in this case (https://www.baeldung.com/java-url-encoding-decoding). However, this is not possible without creating a ton of suppressions.
A space can be transformed to + or %20. From https://www.w3schools.com/tags/ref_urlencode.ASP:
URLs cannot contain spaces. URL encoding normally replaces a space with a plus (+) sign or with %20.
UrlEncoder.encode replaces spaces to + but the following test expects both %20 and +
|
else { |
|
expectedUrl = "https://github.com/search?q=" |
|
+ "path%3Asrc%2Fmain%2Fresources%2F" |
|
+ clss.getPackage().getName().replace(".", "%2F") |
|
+ "%20path%3A**%2Fmessages*.properties+repo%3Acheckstyle%2F" |
|
+ "checkstyle+%22" + linkText + "%22"; |
|
} |
After all check templates use the violation messages macro, we can switch to UrlEncoder and edit the test to expect +
From #13423 (comment)
Method
constructMessageKeyUrlinViolationMessagesMacrodoes not encode the URLUrlEncoder.encodecan be used in this case (https://www.baeldung.com/java-url-encoding-decoding). However, this is not possible without creating a ton of suppressions.A
spacecan be transformed to+or%20. From https://www.w3schools.com/tags/ref_urlencode.ASP:UrlEncoder.encodereplaces spaces to+but the following test expects both%20and+checkstyle/src/test/java/com/puppycrawl/tools/checkstyle/internal/XdocsPagesTest.java
Lines 1427 to 1433 in 0c2ab53
After all check templates use the violation messages macro, we can switch to
UrlEncoderand edit the test to expect+