-
Notifications
You must be signed in to change notification settings - Fork 746
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
StringSplitter provides no actionable fix #899
Comments
If you don't want to use Guava Splitter, you can disable the StringSplitter check with -Xep:StringSplitter:OFF and ensure StringSplit, which does provide a direct replacement within the Java standard library, is turned on. |
Fixes #899 RELNOTES: N/A ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=182158360
Fixes #899 RELNOTES: N/A ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=182158360
I'm grateful for the opportunity to use errorprone, and appreciate your suggestipn to use Xep:StringSpitter:OFF, but I have to say that this warning feels entirely self-serving. Reading the explanation (http://errorprone.info/bugpattern/StringSplitter), the bit about "more predictable behaviour" is just wrong. The behavior of String.split is well documented in the Javadoc: "If the expression does not match any part of the input then the resulting array has just one element, namely this string". The errorprone documentation goes on to say, "[Guava's Splitter] provides explicit control over the handling of empty strings and the trimming of whitespace", which reads like an advertisement. Finally, the recommended solution, e.g. use Guava, is far more problematic. I have used Guava for many years both commercially and for government work, and Guava very well known for a rapid update cycle of binary incompatible updates. (Google: "Guava Stopwatch Hbase" just for starter). Thank you for an excellent tool in errorprone. Keep up the good work. |
I personally agree with @arakelian's observations, specifically about how (1) checker http://errorprone.info/bugpattern/StringSplitter feels self-serving (even though I'm sure that wasn't the author's intention!), and (2) how it recommends a solution in the form of I wonder if the best course of action would be to merge this checker with http://errorprone.info/bugpattern/StringSplit, doing so in such a way that the resulting checker would recommend WDYT @cushon @epmjohnston? |
To understand the behavior of That said, I don't suppose that Error Prone can suggest the Guava |
Respectfully, I'll suggest one last time that To this reader, unpredictable (http://www.thesaurus.com/browse/unpredictable), is synonymous with uncertain, unreliable, fluctuating, unforeseeable and chancy. That doesn't feel appropriate to me when the method's inputs and outputs are documented. With respect to the idea that Error Prone would only suggest Guava |
It's predictable but error prone. |
Ah, I see -- not "unpredictable" in the sense of "undefined behavior" or "depends on thread scheduling." Just "different than some users would predict." Perhaps that word was chosen to sound less judgmental than "unnatural." But "error-prone" or "surprising" sounds about right :) |
(Oh, and |
In StringSplitter, warn about all uses of split(String) (not just ones that can be trivially migrated to Splitter), and only emit a suffested fix if Splitter is already on the classpath. Fixes #899 RELNOTES: N/A ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=186067129
It's been closed since the first day. |
D'oh! Thanks @oprypin. :P |
To be clear, we took the feedback from this issue and removed the Guava-only suggested fix for the StringSplitter fix. The check now only suggests Guava's |
In StringSplitter, warn about all uses of split(String) (not just ones that can be trivially migrated to Splitter), and only emit a suffested fix if Splitter is already on the classpath. Fixes #899 RELNOTES: N/A ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=186067129
What version of Error Prone are you using?
https://chromium.googlesource.com/chromium/third_party/errorprone/+/ecc57c2b00627667874744b9ad8efe10734d97a8
Does this issue reproduce with the latest release?
Don't know
What did you do?
https://cs.chromium.org/chromium/src/third_party/webrtc/sdk/android/api/org/webrtc/FileVideoCapturer.java?rcl=3e189a6dc342dcf115c910783444ba7ef9a354af&l=59
What did you expect to see?
Information on how to fix the "StringSplitter" warning using Java standard library.
What did you see instead?
This replacement uses code that is not part of standard library and I have no interest in adding a dependency.
If there is no direct replacement, maybe this isn't a good warning.
The text was updated successfully, but these errors were encountered: