-
-
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
LocalizedMessage should accept message argument in string only #7488
Comments
It seems wrong that a class that deals with message localization will not localize the arguments too. |
I am not sure how it can localize something that he do not understand and can not differentiate, it is just list/array of some string values. Do you see example of how localization of arguments can be done and become useful ? |
This has now been moved to
This issue (if we are changing the constructor arguments as well) has a large impact on everything from LocalizedMessage and Violation all the way to modules. Modules cannot have integer/enum arguments anymore in their message, they need to be converted to Strings. Even if we do not change the constructor and only do a conversion in
|
@romani ping Please clarify the extent of the issue. Are we converting the field only, or are we converting the constructor arguments as well? |
Both. To make it clear that all consideration of how to serialize of arguments should be done outside of this API class. It will print just strings. |
Then this a pretty big break. Method signature is changing, so I am sure all checks will need to be recompiled from source. Sevntu is surely impacted. I wasn't seeing any usages in 3rd parties of |
Yes, I can imagine, we can start with extension of API with new ctor that takes array of string and store it as array of string. And we mark old ctor and field as deprecated to remove in few years. And we will see migration nuances of sevntu. |
@romani I assume this is all coming solely because this class is serializable and everything associated to it needs to be the same. Can you update issue with why this class needs to remain serializable? If we are to break things, maybe it makes more sense to just not make this serializable. While yes we don't want to be responsible for how arguments are displayed, the property file can also be configured to handle this as seen from the exception I provided for things like numbers. Truthfully all we are doing for this objects is a to string, which is pretty much common Java imo. This class was made serializable in d2af4ac , 15 years ago. |
If we continue, then the following will also have to be changed, impacting all our tests. checkstyle/src/test/java/com/puppycrawl/tools/checkstyle/AbstractModuleTestSupport.java Line 505 in dcadc13
If all checks are to format their own output now, then they require #12104 as there is no other way to access the current set Locale, as there is no getter. Things like
Migration nuances can be seen at https://github.com/rnveach/checkstyle/commits/issue_7488_large in our own repo. Sevntu will be duplicating the same. Currently since we have to format integers ourselves, if we don't do something we lose commas as seen in rnveach@12c4f91 . We now have to call a lot more
Yes, we can, but output will be damaged (we still must call |
uhh, I missed this. it looks like we can not make this update as this will damage whole world. We can extend doc to explain usage of Object, to avoid attempt to do same next time. |
I agree.
Lets keep issue open until this is done, as a reminder. |
@rnveach , is this extension of javadoc is good? |
I am think extension is good. |
Detected by IDEA inspection and Sonar Inspection
Make "args" transient or serializable.
https://sonarcloud.io/project/issues?id=org.checkstyle%3Acheckstyle&issues=AW9t2w2MYD2QG1pPXIUJ&open=AW9t2w2MYD2QG1pPXIUJ
Code:
checkstyle/src/main/java/com/puppycrawl/tools/checkstyle/api/LocalizedMessage.java
Lines 84 to 89 in 2f9f8c6
We did not change it as it is API class, so it should be done separately and clear consideration of breaking affects.
Expected: change
Object[]
toString[]
to simply do string concatenation without any thoughts on special format/serialization of particular type.If some localization is required, it should be done by module/Check that report such violation.
The text was updated successfully, but these errors were encountered: