Repository: smithy-lang/smithy
Pull request #2136 (2024-02-12 19:59:45)

Fix CSV headers after moving line and column
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.



Patch:
diff --git a/smithy-cli/src/main/java/software/amazon/smithy/cli/commands/ValidationEventFormatOptions.java b/smithy-cli/src/main/java/software/amazon/smithy/cli/commands/ValidationEventFormatOptions.java
index 7e1b265be..9eb3c6d94 100644
--- a/smithy-cli/src/main/java/software/amazon/smithy/cli/commands/ValidationEventFormatOptions.java
+++ b/smithy-cli/src/main/java/software/amazon/smithy/cli/commands/ValidationEventFormatOptions.java
@@ -29,7 +29,7 @@ final class ValidationEventFormatOptions implements ArgumentReceiver {
         CSV {
             @Override
             void beginPrinting(CliPrinter printer) {
-                printer.println("severity,id,shape,file,message,hint,suppressionReason");
+                printer.println("severity,id,shape,file,line,column,message,hint,suppressionReason");
             }
 
             @Override


Test patch:
diff --git a/smithy-cli/src/test/java/software/amazon/smithy/cli/commands/DiffCommandTest.java b/smithy-cli/src/test/java/software/amazon/smithy/cli/commands/DiffCommandTest.java
index f71620cb3..19a2150ca 100644
--- a/smithy-cli/src/test/java/software/amazon/smithy/cli/commands/DiffCommandTest.java
+++ b/smithy-cli/src/test/java/software/amazon/smithy/cli/commands/DiffCommandTest.java
@@ -33,7 +33,7 @@ public class DiffCommandTest {
 
         String[] lines = result.stdout().split("(\\r\\n|\\r|\\n)");
         assertThat(lines.length, is(2));
-        assertThat(lines[0], containsString("severity,id,shape,file,message,hint,suppressionReason"));
+        assertThat(lines[0], containsString("severity,id,shape,file,line,column,message,hint,suppressionReason"));
         assertThat(lines[1], containsString("\"ERROR\",\"ChangedShapeType\",\"smithy.example#Hello\""));
     }
 }
diff --git a/smithy-cli/src/test/java/software/amazon/smithy/cli/commands/ValidateCommandTest.java b/smithy-cli/src/test/java/software/amazon/smithy/cli/commands/ValidateCommandTest.java
index 91654f57c..7461b109b 100644
--- a/smithy-cli/src/test/java/software/amazon/smithy/cli/commands/ValidateCommandTest.java
+++ b/smithy-cli/src/test/java/software/amazon/smithy/cli/commands/ValidateCommandTest.java
@@ -18,6 +18,7 @@ package software.amazon.smithy.cli.commands;
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.containsString;
 import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.is;
 import static org.hamcrest.Matchers.not;
 
 import java.net.URISyntaxException;
@@ -228,6 +229,9 @@ public class ValidateCommandTest {
         assertThat(result.stdout(), containsString("EmitDangers"));
         assertThat(result.stdout(), containsString("HttpLabelTrait"));
         assertThat(result.stdout(), not(containsString("FAILURE"))); // stderr
+
+        String[] lines = result.stdout().split("(\\r\\n|\\r|\\n)");
+        assertThat(lines[0], containsString("severity,id,shape,file,line,column,message,hint,suppressionReason"));
     }
 
     @Test