diff --git a/src/Cake.Issues.Terraform.Tests/Cake.Issues.Terraform.Tests.csproj b/src/Cake.Issues.Terraform.Tests/Cake.Issues.Terraform.Tests.csproj
index 5e57b42a6..ede13a53b 100644
--- a/src/Cake.Issues.Terraform.Tests/Cake.Issues.Terraform.Tests.csproj
+++ b/src/Cake.Issues.Terraform.Tests/Cake.Issues.Terraform.Tests.csproj
@@ -10,9 +10,11 @@
+
+
diff --git a/src/Cake.Issues.Terraform.Tests/TerraformProviderTests.cs b/src/Cake.Issues.Terraform.Tests/TerraformProviderTests.cs
index 88b395075..ad40ca0f0 100644
--- a/src/Cake.Issues.Terraform.Tests/TerraformProviderTests.cs
+++ b/src/Cake.Issues.Terraform.Tests/TerraformProviderTests.cs
@@ -95,6 +95,31 @@ public void Should_Read_Error_Correct()
.OfRule("Could not load plugin")
.WithPriority(IssuePriority.Error));
}
+
+ [SkippableFact]
+ public void Should_Read_Warning_Across_Multiple_Lines_Correct()
+ {
+ // Uses Windows specific paths.
+ Skip.IfNot(RuntimeInformation.IsOSPlatform(OSPlatform.Windows));
+
+ // Given
+ var fixture = new TerraformProviderFixture("warning-across-multiple-lines.json", @"./");
+
+ // When
+ var issues = fixture.ReadIssues().ToList();
+
+ // Then
+ issues.Count.ShouldBe(1);
+ IssueChecker.Check(
+ issues[0],
+ IssueBuilder.NewIssue(
+ "This feature is deprecated and will be removed in a major release. Please use the `lifecycle.ignore_changes` argument to specify the fields in `body` to ignore.",
+ "Cake.Issues.Terraform.TerraformIssuesProvider",
+ "Terraform")
+ .InFile("modules\\deployment-ring\\storage-account.tf", 84, 86, 25, 4)
+ .OfRule("Attribute Deprecated")
+ .WithPriority(IssuePriority.Warning));
+ }
}
}
}
diff --git a/src/Cake.Issues.Terraform.Tests/Testfiles/warning-across-multiple-lines.json b/src/Cake.Issues.Terraform.Tests/Testfiles/warning-across-multiple-lines.json
new file mode 100644
index 000000000..d8fce0f53
--- /dev/null
+++ b/src/Cake.Issues.Terraform.Tests/Testfiles/warning-across-multiple-lines.json
@@ -0,0 +1,35 @@
+{
+ "format_version": "1.0",
+ "valid": true,
+ "error_count": 0,
+ "warning_count": 1,
+ "diagnostics": [
+ {
+ "severity": "warning",
+ "summary": "Attribute Deprecated",
+ "detail": "This feature is deprecated and will be removed in a major release. Please use the `lifecycle.ignore_changes` argument to specify the fields in `body` to ignore.",
+ "address": "module.deployment-ring.azapi_update_resource.storage_account_data_blob_settings",
+ "range": {
+ "filename": "modules\\deployment-ring\\storage-account.tf",
+ "start": {
+ "line": 84,
+ "column": 25,
+ "byte": 2092
+ },
+ "end": {
+ "line": 86,
+ "column": 4,
+ "byte": 2121
+ }
+ },
+ "snippet": {
+ "context": "resource \"azapi_update_resource\" \"storage_account_data_blob_settings\"",
+ "code": " ignore_body_changes = [\n \"properties.cors\"\n ]",
+ "start_line": 84,
+ "highlight_start_offset": 24,
+ "highlight_end_offset": 51,
+ "values": []
+ }
+ }
+ ]
+}
\ No newline at end of file
diff --git a/src/Cake.Issues.Tests/IssueTests.cs b/src/Cake.Issues.Tests/IssueTests.cs
index 2ac46f43d..93fb7760f 100644
--- a/src/Cake.Issues.Tests/IssueTests.cs
+++ b/src/Cake.Issues.Tests/IssueTests.cs
@@ -2374,7 +2374,7 @@ public void Should_Throw_If_EndColumn_Is_Smaller_Column()
const string projectName = "foo";
const string filePath = @"src\foo.cs";
const int line = 10;
- const int endLine = 12;
+ const int endLine = 10;
const int column = 50;
const int endColumn = 5;
var fileLink = new Uri("https://github.com/myorg/myrepo/blob/develop/src/foo.cs#L10-L12");
@@ -2530,6 +2530,61 @@ public void Should_Handle_EndColumn_Which_Is_Equals_Column()
issue.EndColumn.ShouldBe(endColumn);
}
+ [Fact]
+ public void Should_Handle_EndColumn_Which_Is_Smaller_Than_Column_If_EndLine_Is_Higher()
+ {
+ // Given
+ const string identifier = "identifier";
+ const string projectPath = @"src\foo.csproj";
+ const string projectName = "foo";
+ const string filePath = @"src\foo.cs";
+ const int line = 10;
+ const int endLine = 12;
+ const int column = 50;
+ const int endColumn = 10;
+ var fileLink = new Uri("https://github.com/myorg/myrepo/blob/develop/src/foo.cs#L10-L12");
+ const string messageText = "MessageText";
+ const string messageHtml = "MessageHtml";
+ const string messageMarkdown = "MessageMarkdown";
+ const int priority = 1;
+ const string priorityName = "Warning";
+ const string rule = "Rule";
+ const string ruleName = "Rule Name";
+ var ruleUri = new Uri("https://google.com");
+ const string providerType = "ProviderType";
+ const string providerName = "ProviderName";
+ const string run = "Run";
+ var additionalInformation = new Dictionary();
+
+ // When
+ var issue =
+ new Issue(
+ identifier,
+ projectPath,
+ projectName,
+ filePath,
+ line,
+ endLine,
+ column,
+ endColumn,
+ fileLink,
+ messageText,
+ messageHtml,
+ messageMarkdown,
+ priority,
+ priorityName,
+ rule,
+ ruleName,
+ ruleUri,
+ run,
+ providerType,
+ providerName,
+ additionalInformation);
+
+ // Then
+ issue.EndColumn.ShouldBe(endColumn);
+ }
+
[Theory]
[InlineData(null)]
[InlineData(1)]
diff --git a/src/Cake.Issues/Issue.cs b/src/Cake.Issues/Issue.cs
index 4ebf57a24..dea1695ad 100644
--- a/src/Cake.Issues/Issue.cs
+++ b/src/Cake.Issues/Issue.cs
@@ -142,7 +142,8 @@ public Issue(
throw new ArgumentOutOfRangeException(nameof(endColumn), "Cannot specify the end of column range while not specifying start of column range.");
}
- if (column.HasValue && endColumn.HasValue && column.Value > endColumn.Value)
+ // End column is not allowed to be before start column, except if issue is across multiple lines.
+ if (column.HasValue && endColumn.HasValue && (!endLine.HasValue || endLine.Value == line.Value) && column.Value > endColumn.Value)
{
throw new ArgumentOutOfRangeException(nameof(endColumn), "Column range needs to end after start of range.");
}