sonatype-lift[bot] commented on code in PR #1867:
URL: https://github.com/apache/groovy/pull/1867#discussion_r1123362375


##########
src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java:
##########
@@ -3906,13 +3906,17 @@ private void validateParameterList(final 
List<Parameter> parameterList) {
         for (int n = parameterList.size(), i = n - 1; i >= 0; i -= 1) {
             Parameter parameter = parameterList.get(i);
 
+            String name = parameter.getName();
+            if ("_".equals(name)) {

Review Comment:
   <picture><img alt="8% of developers fix this issue" 
src="https://lift.sonatype.com/api/commentimage/fixrate/8/display.svg";></picture>
   
   <b>*[YodaCondition](https://errorprone.info/bugpattern/YodaCondition):</b>*  
The non-constant portion of an equals check generally comes first.
   
   ---
   
   
   ```suggestion
               if (Objects.equals(name, "_")) {
   ```
   
   
   ---
   
   <details><summary>â„šī¸ Expand to see all <b>@sonatype-lift</b> 
commands</summary>
   
   You can reply with the following commands. For example, reply with 
***@sonatype-lift ignoreall*** to leave out all findings.
   | **Command** | **Usage** |
   | ------------- | ------------- |
   | `@sonatype-lift ignore` | Leave out the above finding from this PR |
   | `@sonatype-lift ignoreall` | Leave out all the existing findings from this 
PR |
   | `@sonatype-lift exclude <file\|issue\|path\|tool>` | Exclude specified 
`file\|issue\|path\|tool` from Lift findings by updating your config.toml file |
   
   **Note:** When talking to LiftBot, you need to **refresh** the page to see 
its response.
   <sub>[Click here](https://github.com/apps/sonatype-lift/installations/new) 
to add LiftBot to another repo.</sub></details>
   
   
   
   ---
   
   <b>Help us improve LIFT! (<i>Sonatype LiftBot external survey</i>)</b>
   
   Was this a good recommendation for you? <sub><small>Answering this survey 
will not impact your Lift settings.</small></sub>
   
   [ [🙁 Not 
relevant](https://www.sonatype.com/lift-comment-rating?comment=420485466&lift_comment_rating=1)
 ] - [ [😕 Won't 
fix](https://www.sonatype.com/lift-comment-rating?comment=420485466&lift_comment_rating=2)
 ] - [ [😑 Not critical, will 
fix](https://www.sonatype.com/lift-comment-rating?comment=420485466&lift_comment_rating=3)
 ] - [ [🙂 Critical, will 
fix](https://www.sonatype.com/lift-comment-rating?comment=420485466&lift_comment_rating=4)
 ] - [ [😊 Critical, fixing 
now](https://www.sonatype.com/lift-comment-rating?comment=420485466&lift_comment_rating=5)
 ]



##########
src/main/java/org/codehaus/groovy/control/PlaceholderVisitor.java:
##########
@@ -0,0 +1,69 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+package org.codehaus.groovy.control;
+
+import org.codehaus.groovy.ast.ASTNode;
+import org.codehaus.groovy.ast.ClassCodeVisitorSupport;
+import org.codehaus.groovy.ast.expr.ClosureExpression;
+import org.codehaus.groovy.ast.expr.DeclarationExpression;
+import org.codehaus.groovy.ast.expr.VariableExpression;
+
+import java.util.stream.StreamSupport;
+
+public class PlaceholderVisitor extends ClassCodeVisitorSupport {
+    public static final String PLACEHOLDER = "Underscore_Placeholder";
+    private SourceUnit source;
+
+    public PlaceholderVisitor(CompilationUnit compilationUnit, SourceUnit 
source) {
+        this.source = source;
+    }
+
+    @Override
+    public void visitDeclarationExpression(DeclarationExpression expression) {
+        if (expression.isMultipleAssignmentDeclaration() && 
expression.getTupleExpression().getExpressions().size() > 1) {
+            long underscoreCount = 
StreamSupport.stream(expression.getTupleExpression().spliterator(), false)
+                .map(e -> ((VariableExpression) e).getName())
+                .filter(s -> s.equals("_"))
+                .count();
+            if (underscoreCount > 1) {
+                expression.getTupleExpression().getExpressions().forEach(e -> {
+                    String name = ((VariableExpression) e).getName();
+                    if ("_".equals(name)) {

Review Comment:
   <picture><img alt="8% of developers fix this issue" 
src="https://lift.sonatype.com/api/commentimage/fixrate/8/display.svg";></picture>
   
   <b>*[YodaCondition](https://errorprone.info/bugpattern/YodaCondition):</b>*  
The non-constant portion of an equals check generally comes first.
   
   ---
   
   
   ```suggestion
                       if (Objects.equals(name, "_")) {
   ```
   
   
   ---
   
   <details><summary>â„šī¸ Expand to see all <b>@sonatype-lift</b> 
commands</summary>
   
   You can reply with the following commands. For example, reply with 
***@sonatype-lift ignoreall*** to leave out all findings.
   | **Command** | **Usage** |
   | ------------- | ------------- |
   | `@sonatype-lift ignore` | Leave out the above finding from this PR |
   | `@sonatype-lift ignoreall` | Leave out all the existing findings from this 
PR |
   | `@sonatype-lift exclude <file\|issue\|path\|tool>` | Exclude specified 
`file\|issue\|path\|tool` from Lift findings by updating your config.toml file |
   
   **Note:** When talking to LiftBot, you need to **refresh** the page to see 
its response.
   <sub>[Click here](https://github.com/apps/sonatype-lift/installations/new) 
to add LiftBot to another repo.</sub></details>
   
   
   
   ---
   
   <b>Help us improve LIFT! (<i>Sonatype LiftBot external survey</i>)</b>
   
   Was this a good recommendation for you? <sub><small>Answering this survey 
will not impact your Lift settings.</small></sub>
   
   [ [🙁 Not 
relevant](https://www.sonatype.com/lift-comment-rating?comment=420488766&lift_comment_rating=1)
 ] - [ [😕 Won't 
fix](https://www.sonatype.com/lift-comment-rating?comment=420488766&lift_comment_rating=2)
 ] - [ [😑 Not critical, will 
fix](https://www.sonatype.com/lift-comment-rating?comment=420488766&lift_comment_rating=3)
 ] - [ [🙂 Critical, will 
fix](https://www.sonatype.com/lift-comment-rating?comment=420488766&lift_comment_rating=4)
 ] - [ [😊 Critical, fixing 
now](https://www.sonatype.com/lift-comment-rating?comment=420488766&lift_comment_rating=5)
 ]



-- 
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-unsubscr...@groovy.apache.org

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

Reply via email to