Repository: checkstyle/checkstyle (Java)

Issue:
Indentation check doesn't give violation when google formatter does
Checkstyle 8.37, google-java-format 1.9
config (taken from google_checks.xml - https://github.com/checkstyle/checkstyle/blob/checkstyle-8.37/src/main/resources/google_checks.xml#L243):
```xml
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
        "-//Puppy Crawl//DTD Check Configuration 1.3//EN"
        "http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
<module name="Checker">
  <module name="TreeWalker">
    <module name="Indentation">
      <property name="basicOffset" value="2"/>
      <property name="braceAdjustment" value="2"/>
      <property name="caseIndent" value="2"/>
      <property name="throwsIndent" value="4"/>
      <property name="lineWrappingIndentation" value="4"/>
      <property name="arrayInitIndent" value="2"/>
    </module>
  </module>
</module>
```
code:
```java
class Test {
  public Object foo() {
    return Optional.empty()
        .orElseThrow(
          () ->
new IllegalArgumentException(
"Something wrong 1, something wrong 2, something wrong 3"));
  }
}
```
none violations given by Checkstyle:
```bash
$ java -jar checkstyle-8.37-all.jar -c config.xml Test.java 
Starting audit...
Audit done.
```
but there is a non-empty diff when applying google-java-format (which leads to errors when using https://github.com/coveooss/fmt-maven-plugin):
```bash
$ java -jar google-java-format-1.9-all-deps.jar Test.java > /tmp/FormattedTest.java && diff -Naru Test.java /tmp/FormattedTest.java
--- Test.java	2020-11-05 06:46:28.027335639 +0000
+++ /tmp/FormattedTest.java	2020-11-05 07:13:01.536163532 +0000
@@ -2,8 +2,8 @@
   public Object foo() {
     return Optional.empty()
         .orElseThrow(
-          () ->
-new IllegalArgumentException(
-"Something wrong 1, something wrong 2, something wrong 3"));
+            () ->
+                new IllegalArgumentException(
+                    "Something wrong 1, something wrong 2, something wrong 3"));
   }
 }
```


Discussion: if i may ask what is 
> $ java -jar google-java-format-1.9-all-deps.jar Test.java > /tmp/FormattedTest.java && diff -Naru Test.java /tmp/FormattedTest.java

this command and what is this  `/tmp/FormattedTest.java`?
and 
> $ java -jar checkstyle-8.41-all.jar -c config.xml Testclass.java

```
Starting audit...
[ERROR] /home/aryaniiit002/Desktop/checkstyle/IgnoreFor_Checkstyle/Testclass.java:6:1: 'new' has incorrect indentation level 0, expected level should be one of the following: 10, 12. [Indentation]
Audit done.
Checkstyle ends with 1 errors.

```
@aryaniiit002 
> if i may ask what is this command and what is this /tmp/FormattedTest.java?

* `java -jar google-java-format-1.9-all-deps.jar Test.java > /tmp/FormattedTest.java` - format `Test.java` using google-java-format and output the formatted code into `/tmp/FormattedTest.java`
* `diff -Naru Test.java /tmp/FormattedTest.java` - find a difference between the original and formatted code

However, I don't understand the second part of your comment. Could you clarify please what was the question?
thank you for that, now i get it what the command is doing exactly but it seems like it's not working in my ide.
```

Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.UnsupportedClassVersionError: com/google/googlejavaformat/java/Main has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
```

> Could you clarify...


the checkstyle output i am getting is not same as you are getting.
The indentation problems related to new keyword is fixed in https://github.com/checkstyle/checkstyle/pull/8983
And you are getting error logs with 8.41
<details><summary>checkstyle output with 8.41</summary>
<p>

```java
class Test {
  public Object foo() {
    return Optional.empty()
        .orElseThrow(
          () ->
new IllegalArgumentException(
"Something wrong 1, something wrong 2, something wrong 3"));
  }
}
```
config:
```xml
 <module name="Indentation">
      <property name="basicOffset" value="2"/>
      <property name="braceAdjustment" value="2"/>
      <property name="caseIndent" value="2"/>
      <property name="throwsIndent" value="4"/>
      <property name="lineWrappingIndentation" value="4"/>
      <property name="arrayInitIndent" value="2"/>
    </module>
```

$ java -jar checkstyle-8.41-all.jar -c config.xml t2.java 
```
Starting audit...
[ERROR] /home/abhishhek/playground/t2.java:6:1: 'new' has incorrect indentation level 0, expected level should be one of the following: 10, 12. [Indentation]
Audit done.
Checkstyle ends with 1 errors.
```

</p>
</details>

But still there is some problem: 
$ t2.java
```java
class Test {
  public Object foo() {
    return Optional.empty()
        .orElseThrow(
          () ->
            new IllegalArgumentException(
"Something wrong 1, something wrong 2, something wrong 3")); // expected a violation here
  }
}
```

**Actual**
java -jar checkstyle-8.41-all.jar -c config.xml t2.java 
```
Starting audit...
Audit done.
```

**expected**
violation on line 7

```
src % cat config.xml Test.java                                 
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
        "-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
        "https://checkstyle.org/dtds/configuration_1_3.dtd">
<module name = "Checker">
    <property name="charset" value="UTF-8"/>

    <property name="severity" value="warning"/>

    <property name="fileExtensions" value="java, properties, xml"/>

    <module name="TreeWalker">
        <module name="IndentationCheck">
        </module>
    </module>
    <module name="SuppressionSingleFilter">
        <property name="lines" value="5"/>
    </module>
</module>

import java.util.function.Function;

enum Test {
        t1(
           v ->
v, // violation expected
        new Object()
),
        t2(
v -> v, // violation expected and reported
        new Object()
        );

    Test(Function<Object, Object> function, Object o1) {
    }
}

src % java -jar checkstyle-10.0-all.jar -c config.xml Test.java
Starting audit...
[WARN] /Users/shabana/Documents/OpenSource/CheckStyleTest/src/src/Test.java:10:1: 'lambda arguments' has incorrect indentation level 0, expected level should be 4. [Indentation]
Audit done.

```

Suppression is used to prevent existing issue #11103,
Check fails to recognize when line wrapping is used



Fix (patch):
diff --git a/.ci/google-java-format.sh b/.ci/google-java-format.sh
index f0aba68b478..d4f6673b1ae 100755
--- a/.ci/google-java-format.sh
+++ b/.ci/google-java-format.sh
@@ -70,6 +70,7 @@ INPUT_PATHS=($(find src/it/resources/com/google/checkstyle/test/ -name "Input*.j
     | grep -v "rule4841indentation/InputClassWithChainedMethods.java" \
     | grep -v "rule4841indentation/InputAnnotationArrayInitMultiline.java" \
     | grep -v "rule4841indentation/InputAnnotationArrayInitMultiline2.java" \
+    | grep -v "rule4841indentation/InputNewKeywordChildren.java" \
     | grep -v "rule4852classannotations/InputClassAnnotations.java" \
     | grep -v "rule4853methodsandconstructorsannotations/InputMethodsAndConstructorsAnnotations.java" \
     | grep -v "rule4854fieldannotations/InputFieldAnnotations.java" \
diff --git a/src/main/java/com/puppycrawl/tools/checkstyle/checks/indentation/NewHandler.java b/src/main/java/com/puppycrawl/tools/checkstyle/checks/indentation/NewHandler.java
index 30ec799e37a..ab976e58196 100644
--- a/src/main/java/com/puppycrawl/tools/checkstyle/checks/indentation/NewHandler.java
+++ b/src/main/java/com/puppycrawl/tools/checkstyle/checks/indentation/NewHandler.java
@@ -65,10 +65,36 @@ public void checkIndentation() {
             checkExpressionSubtree(firstChild, getIndent(), false, false);
         }
 
+        final DetailAST expression = mainAst.findFirstToken(TokenTypes.ELIST);
+        if (checkNestedNew(expression) && isOnStartOfLine(expression)) {
+            final IndentLevel indentLevel = new IndentLevel(getIndent(),
+                    getLineWrappingIndent());
+            checkExpressionSubtree(expression, indentLevel, false, false);
+        }
+
         final DetailAST lparen = mainAst.findFirstToken(TokenTypes.LPAREN);
         checkLeftParen(lparen);
     }
 
+    /**
+     * Check if nested {@code new} present.
+     *
+     * @param expression expression
+     *
+     * @return true if nested new is present.
+     */
+    public boolean checkNestedNew(DetailAST expression) {
+        boolean result = false;
+        if (expression != null && expression.getFirstChild() != null) {
+            final boolean isNestedNewPresent = expression.getFirstChild()
+                .findFirstToken(TokenTypes.LITERAL_NEW) != null;
+            if (!isNestedNewPresent) {
+                result = true;
+            }
+        }
+        return result;
+    }
+
     @Override
     public IndentLevel getSuggestedChildIndent(AbstractExpressionHandler child) {
         final int offset;