PicnicSupermarket / error-prone-support

Error Prone extensions: extra bug checkers and a large battery of Refaster rules.

Home Page:https://error-prone.picnic.tech

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Rewrite `String#copyValueOf(char[])` to `new String(char[])`

rickie opened this issue · comments

Problem

Rewrite String#copyValueOf(char[]) to new String(char[]).

Description of the proposed new feature

  • Support a stylistic preference.
  • Avoid a common gotcha, or potential problem.
  • Improve performance.

The Refaster rule should live in the StringRules file.
Make sure to add a test entry in the StringRulesTestInput and StringRulesTestOutput 😄.

I would like to rewrite the following code:

char[] foo = new char[0]; 
String s = String.copyValueOf(foo);

to:

char[] foo = new char[0]; 
String s = new String(foo);

Hi,

Will start working on this.

Thanks,
Benura

HI @rickie ,

Is there a slack channel or any other way to communicate installation issues? I'm facing some issues when running mvn clean install regarding some jars not found.

Thanks,
Benura

Hi @rickie ,

When running mvn clean install, it gives the below error.
Caused by: org.eclipse.aether.resolution.ArtifactResolutionException: The following artifacts could not be resolved: tech.picnic.error-prone-support:error-prone-contrib:jar:2.24.1 (absent), tech.picnic.error-prone-support:refaster-runner:jar:2.24.1 (absent): tech.picnic.error-prone-support:error-prone-contrib:jar:2.24.1 was not found in https://repo.maven.apache.org/maven2 during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of central has elapsed or updates are forced

I'm using maven 3.9.5 and java 11.0.16.

Thanks,
Benura

Hey @BLasan! Unfortunately we don't have a Slack channel. But we can use this issue thread to sync :)

W.r.t. your question: it looks like you mixed up some version numbers: version 2.24.1 is the version of Error Prone, while the tech.picnic.error-prone-support:* artifacts for which you get are error are for Error Prone Support (this project), of which the most recent version is 0.14.0.

That said: if you tried to build an unmodified version of this project, then it shouldn't be necessary to modify pom.xml at all. If you're still stuck, feel free to share the code you have so far :)

Hi @Stephan202 ,

Thanks for the prompt response. It worked for me without the pom.xml modifications. If it's not needed, shall we remove it from the README?

Thanks,
Benura

Hey @BLasan! The README instructions are for people that want to use this library (i.e., include it in their own project), while you're currently trying to contribute to this library. For the latter the usual contribution workflow should be followed; for the former those README instructions are very much needed :)

Hope that clears things up! Cheers :)

Hey @BLasan! The README instructions are for people that want to use this library (i.e., include it in their own project), while you're currently trying to contribute to this library. For the latter the usual contribution workflow should be followed; for the former those README instructions are very much needed :)

Hope that clears things up! Cheers :)

Thanks for the detailed explanation :)