Visitar URL original
Warn against toString() on an array · Issue #65 · google/error-prone · GitHub
Skip to content

Warn against toString() on an array #65

Closed

Description

@cushon

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.

Activity

  1. cushon commented on Oct 31, 2014

    @cushon
    CollaboratorAuthor

    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.

  2. cushon commented on Oct 31, 2014

    @cushon
    CollaboratorAuthor

    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

  3. cushon commented on Oct 31, 2014

    @cushon
    CollaboratorAuthor

    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.

  4. cushon commented on Oct 31, 2014

    @cushon
    CollaboratorAuthor

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


    This has been checked into trunk.


    Status: Fixed

  5. cushon commented on Oct 31, 2014

    @cushon
    CollaboratorAuthor

    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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions