You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@accumulo.apache.org by GitBox <gi...@apache.org> on 2022/02/19 15:40:18 UTC

[GitHub] [accumulo] ctubbsii opened a new issue #2511: Update checkstyle to ban "string1" + "string2"

ctubbsii opened a new issue #2511:
URL: https://github.com/apache/accumulo/issues/2511


   **Is your feature request related to a problem? Please describe.**
   Sometimes when we edit code, some strings wrap differently than they did before we changed it. So, we sometimes get something like: `String myMessage = "some part of message " + "the rest of the message";` when we could just have `String myMessage = "some part of message the rest of the message";`
   This can occur if previously the second half of the message had wrapped onto the next line, so we needed the concatenation to make it look okay, but now the strings are being concatenated on the same line.
   
   **Describe the solution you'd like**
   Find and fix all occurrences where two string literals are concatenated, replacing all `"a" + "b"` with `"ab"` (only considering concatenations that are on the same line; concatenations that exist to wrap a string onto the next line are okay).
   Add a regular expression to the checkstyle config to ban the sequence `" + "` in our code to detect and prevent new occurrences, with a reasonable error message when the pattern is seen.
   
   **Describe alternatives you've considered**
   Could just ignore since it's not particularly harmful, it's just ugly.
   
   **Additional context**
   N/A


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [accumulo] KikiManjaro edited a comment on issue #2511: Update checkstyle to ban "string1" + "string2"

Posted by GitBox <gi...@apache.org>.
KikiManjaro edited a comment on issue #2511:
URL: https://github.com/apache/accumulo/issues/2511#issuecomment-1046337633


   While running maven task `checkstyle:check` an error is thrown:
   `
   Element type "property" must be followed by either attribute specifications, ">" or "/>".
   `
   I think it come from the Regex itself but not sure.
   
   When i change the regex i have an other error saying that class `RegexpStringToStringConcatenation` can't be instantiated. I'm not very good at maven task, i'm usually using Gradle :)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [accumulo] KikiManjaro commented on issue #2511: Update checkstyle to ban "string1" + "string2"

Posted by GitBox <gi...@apache.org>.
KikiManjaro commented on issue #2511:
URL: https://github.com/apache/accumulo/issues/2511#issuecomment-1046356395


   That was it thanks :D !


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [accumulo] KikiManjaro commented on issue #2511: Update checkstyle to ban "string1" + "string2"

Posted by GitBox <gi...@apache.org>.
KikiManjaro commented on issue #2511:
URL: https://github.com/apache/accumulo/issues/2511#issuecomment-1046270878


   Hi :)
   
   I'm trying to add :
   
   `
   <module name="RegexpStringToStringConcatenation">
                                       <property name="format" value="&quot; + &quot;" />
                                       <property name="message" value="Concatenation from string to string is not needed"/>
                                   </module>
   `
   
   to the pom.xml inside
   
   `
   <checkstyleRules>
                           <module name="Checker">
   `
   
   but it's not working, did i missed something ?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [accumulo] ctubbsii commented on issue #2511: Update checkstyle to ban "string1" + "string2"

Posted by GitBox <gi...@apache.org>.
ctubbsii commented on issue #2511:
URL: https://github.com/apache/accumulo/issues/2511#issuecomment-1046347603


   Try this one:
   
   ```xml
                   <module name="RegexpSinglelineJava">
                     <!-- double escape quotes because checkstyle passes these through another xml parser -->
                     <property name="format" value="&amp;quot; [+] &amp;quot;" />
                     <property name="message" value="Unnecessary concatenation of string literals" />
                   </module>
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [accumulo] KikiManjaro commented on issue #2511: Update checkstyle to ban "string1" + "string2"

Posted by GitBox <gi...@apache.org>.
KikiManjaro commented on issue #2511:
URL: https://github.com/apache/accumulo/issues/2511#issuecomment-1046337633


   While running maven task `checkstyle:check` an error is thrown:
   `
   Element type "property" must be followed by either attribute specifications, ">" or "/>".
   `
   I think it come from the Regex itself but not sure.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [accumulo] ctubbsii closed issue #2511: Update checkstyle to ban "string1" + "string2"

Posted by GitBox <gi...@apache.org>.
ctubbsii closed issue #2511:
URL: https://github.com/apache/accumulo/issues/2511


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [accumulo] ctubbsii commented on issue #2511: Update checkstyle to ban "string1" + "string2"

Posted by GitBox <gi...@apache.org>.
ctubbsii commented on issue #2511:
URL: https://github.com/apache/accumulo/issues/2511#issuecomment-1046335252


   > but it's not working
   
   Can you explain what's not working? What problem did you encounter?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org