Skip to content
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

Warn against toString() on an array #65

Closed
cushon opened this issue Oct 31, 2014 · 5 comments
Closed

Warn against toString() on an array #65

cushon opened this issue Oct 31, 2014 · 5 comments

Comments

@cushon
Copy link
Collaborator

cushon commented Oct 31, 2014

Original issue created by adgar@google.com on 2012-12-10 at 09:15 PM


Much like an Array's equals() method is warned against, so too should Array's toString() method. The resolution is also similar: use java.util.Arrays.toString(array).

I've attached a patch adding the check based on the ArrayEquals check.

@cushon
Copy link
Collaborator Author

cushon commented Oct 31, 2014

Original comment posted by adgar@google.com on 2012-12-10 at 09:59 PM


Apologies, was checked into the wrong git commit when I made that patch. Please consider the following.

@cushon
Copy link
Collaborator Author

cushon commented Oct 31, 2014

Original comment posted by eaftan@google.com on 2012-12-11 at 06:40 PM


Hi Mike,

Thanks for the contribution! This check has been on our todo list for a while.

Could you please create a clone of our repository and push your change there? Then request a code review with a link to the revision with your change. We'll do a code review and then merge it into our trunk.

How to create a clone:
https://code.google.com/p/error-prone/source/clones
http://code.google.com/p/support/wiki/MercurialFAQ#Why_should_I_create_a_server-side_clone?


Status: Accepted
Owner: eaftan@google.com

@cushon
Copy link
Collaborator Author

cushon commented Oct 31, 2014

Original comment posted by cpovirk@google.com on 2013-01-23 at 08:07 PM


Similar in spirit is a check for arrays used in string concatenation ("foo" + array) and, I suppose, in String.format(). I ran across an instance of the former not long ago.

@cushon
Copy link
Collaborator Author

cushon commented Oct 31, 2014

Original comment posted by eaftan@google.com on 2013-02-11 at 08:01 PM


This has been checked into trunk.


Status: Fixed

@cushon
Copy link
Collaborator Author

cushon commented Oct 31, 2014

Original comment posted by lowasser@google.com on 2013-04-13 at 07:29 PM


Issue #118 has been merged into this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant