Repository: elm-tooling/elm-language-server (ts)
Issue: False positive List.concat hint
<!--- Provide a general summary of the issue in the Title above -->
![image](https://user-images.githubusercontent.com/1430958/121411590-16b7f800-c964-11eb-9dd1-8c039e31f17f.png)
```elm
test =
    let
        aList =
            if True then
                [ 2, 3 ]

            else
                []
    in
    List.concat
        [ [ 1 ]
        , aList
        , [ 4 ]
        ]
```

## Expected Behavior
<!--- If you're describing a bug, tell us what should happen -->
<!--- If you're suggesting a change/improvement, tell us how it should work -->
No warnings.

## Current Behavior
<!--- If describing a bug, tell us what happens instead of the expected behavior -->
<!--- If suggesting a change/improvement, explain the difference from current behavior -->
ElmLS gives me a warning on the `List.concat` expression:

> You should just merge the arguments of `List.concat` to a single list. - ElmLS

## Possible Solution
<!--- Not obligatory, but suggest a fix/reason for the bug, -->
<!--- or ideas how to implement the addition or change -->
don't show warnings in these cases. (Optimize for having false negatives sometimes, instead of having false positives sometimes?)

## Steps to Reproduce (for bugs)
<!--- Provide a link to a live example, or an unambiguous set of steps to -->
<!--- reproduce this bug. Include code to reproduce, if relevant -->
1. Paste the code above into e.g. VSCode and wait for ElmLS to scan the file & report warnings


## Your Environment
<!--- Include as many relevant details about the environment you experienced the bug in -->
* Version used: 2.1.0
* Editor used: VSCode 1.56

Pull request description: Fix false positive for unnecessary list concat diagnostics
Fixes #605. I couldn't find a way to fix it with the query, so I just added a filter. 

Patch:
diff --git a/src/providers/diagnostics/elmLsDiagnostics.ts b/src/providers/diagnostics/elmLsDiagnostics.ts
index c19be93..2bfbf71 100644
--- a/src/providers/diagnostics/elmLsDiagnostics.ts
+++ b/src/providers/diagnostics/elmLsDiagnostics.ts
@@ -287,7 +287,7 @@ export class ElmLsDiagnostics {
               ("," . (list_expr))*
               .
               "]"
-            )
+            ) @listExpr
           ) @functionCall
           (#eq? @target "List.concat")
         )
@@ -861,6 +861,11 @@ export class ElmLsDiagnostics {
 
     const listConcats = this.unnecessaryListConcatQuery
       .matches(tree.rootNode)
+      .filter((match) =>
+        match.captures[2].node?.namedChildren.every(
+          (c) => c.type === "list_expr",
+        ),
+      )
       .map((match) => match.captures[0].node)
       .filter(Utils.notUndefinedOrNull);
 


Test patch:
diff --git a/test/diagnosticTests/elmLsDiagnostics.test.ts b/test/diagnosticTests/elmLsDiagnostics.test.ts
index f7a8710..ed44f27 100644
--- a/test/diagnosticTests/elmLsDiagnostics.test.ts
+++ b/test/diagnosticTests/elmLsDiagnostics.test.ts
@@ -1345,6 +1345,29 @@ foo =
 
       await testDiagnostics(source, "unnecessary_list_concat", []);
     });
+
+    it("could not merge 2", async () => {
+      const source = `
+module Bar exposing (foo)
+
+test =
+    let
+        aList =
+            if True then
+                [ 2, 3 ]
+
+            else
+                []
+    in
+    List.concat
+        [ [ 1 ]
+        , aList
+        , [ 4 ]
+        ]
+			`;
+
+      await testDiagnostics(source, "unnecessary_list_concat", []);
+    });
   });
 
   describe("unnecessary port module", () => {