diff --git a/.appveyor.yml b/.appveyor.yml index f7f80b0..a8b1255 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -11,8 +11,9 @@ install: - ps: mkdir $env:DOTNET_INSTALL_DIR -Force | Out-Null - ps: Invoke-WebRequest -Uri "https://dotnet.microsoft.com/download/dotnet/scripts/v1/dotnet-install.ps1" -OutFile "$($env:DOTNET_INSTALL_DIR)/dotnet-install.ps1" - ps: '& "$($env:DOTNET_INSTALL_DIR)/dotnet-install.ps1" -Version 5.0.408 -InstallDir $env:DOTNET_INSTALL_DIR' - - ps: '& "$($env:DOTNET_INSTALL_DIR)/dotnet-install.ps1" -Version 6.0.405 -InstallDir $env:DOTNET_INSTALL_DIR' - - ps: '& "$($env:DOTNET_INSTALL_DIR)/dotnet-install.ps1" -Version 7.0.102 -InstallDir $env:DOTNET_INSTALL_DIR' + - ps: '& "$($env:DOTNET_INSTALL_DIR)/dotnet-install.ps1" -Version 6.0.417 -InstallDir $env:DOTNET_INSTALL_DIR' + - ps: '& "$($env:DOTNET_INSTALL_DIR)/dotnet-install.ps1" -Version 7.0.404 -InstallDir $env:DOTNET_INSTALL_DIR' + - ps: '& "$($env:DOTNET_INSTALL_DIR)/dotnet-install.ps1" -Version 8.0.100 -InstallDir $env:DOTNET_INSTALL_DIR' - ps: $env:Path = "$env:DOTNET_INSTALL_DIR;$env:Path" - ps: dotnet --info diff --git a/.github/dependabot.yml b/.github/dependabot.yml deleted file mode 100644 index 409c718..0000000 --- a/.github/dependabot.yml +++ /dev/null @@ -1,21 +0,0 @@ -version: 2 -updates: -- package-ecosystem: nuget - directory: "/src" - schedule: - interval: daily - time: "04:00" - open-pull-requests-limit: 10 - ignore: - - dependency-name: Cake.Core - versions: - - "(,3.0)" - - dependency-name: Cake.Testing - versions: - - "(,3.0)" - - dependency-name: Cake.Issues - versions: - - "> 1.0.0, < 2" - - dependency-name: Cake.Issues.Testing - versions: - - "> 1.0.0, < 2" diff --git a/.github/renovate.json b/.github/renovate.json new file mode 100644 index 0000000..8588d1c --- /dev/null +++ b/.github/renovate.json @@ -0,0 +1,6 @@ +{ + "$schema": "https://docs.renovatebot.com/renovate-schema.json", + "extends": [ + "github>cake-contrib/renovate-presets:cake-issues" + ] +} diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 02465a6..99ff29d 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -28,6 +28,10 @@ jobs: inputs: version: '7.x' displayName: 'Install .NET 7' + - task: UseDotNet@2 + inputs: + version: '8.x' + displayName: 'Install .NET 8' - powershell: ./build.ps1 displayName: 'Cake Build' - publish: $(Build.SourcesDirectory)/BuildArtifacts/Packages/NuGet @@ -40,6 +44,10 @@ jobs: pool: vmImage: 'windows-2019' steps: + - task: UseDotNet@2 + inputs: + version: '6.x' + displayName: 'Install .NET 6' - task: NodeTool@0 inputs: versionSpec: '18.x' @@ -67,6 +75,10 @@ jobs: pool: vmImage: 'windows-2019' steps: + - task: UseDotNet@2 + inputs: + version: '6.x' + displayName: 'Install .NET 6' - task: NodeTool@0 inputs: versionSpec: '18.x' @@ -94,6 +106,10 @@ jobs: pool: vmImage: 'macOS-11' steps: + - task: UseDotNet@2 + inputs: + version: '6.x' + displayName: 'Install .NET 6' - task: NodeTool@0 inputs: versionSpec: '18.x' @@ -122,6 +138,10 @@ jobs: pool: vmImage: 'macOS-13' steps: + - task: UseDotNet@2 + inputs: + version: '6.x' + displayName: 'Install .NET 6' - task: NodeTool@0 inputs: versionSpec: '18.x' @@ -150,6 +170,10 @@ jobs: pool: vmImage: 'ubuntu-20.04' steps: + - task: UseDotNet@2 + inputs: + version: '6.x' + displayName: 'Install .NET 6' - task: NodeTool@0 inputs: versionSpec: '18.x' @@ -178,6 +202,10 @@ jobs: pool: vmImage: 'ubuntu-22.04' steps: + - task: UseDotNet@2 + inputs: + version: '6.x' + displayName: 'Install .NET 6' - task: NodeTool@0 inputs: versionSpec: '16.x' diff --git a/global.json b/global.json new file mode 100644 index 0000000..3660ff8 --- /dev/null +++ b/global.json @@ -0,0 +1,7 @@ +{ + "sdk": { + "allowPrerelease": true, + "version": "8.0.100", + "rollForward": "latestFeature" + } +} \ No newline at end of file diff --git a/nuspec/nuget/Cake.Issues.Markdownlint.nuspec b/nuspec/nuget/Cake.Issues.Markdownlint.nuspec index 75daa99..edbdb55 100644 --- a/nuspec/nuget/Cake.Issues.Markdownlint.nuspec +++ b/nuspec/nuget/Cake.Issues.Markdownlint.nuspec @@ -24,7 +24,7 @@ See the Project Site for an overview of the whole ecosystem of addins for workin Copyright © BBT Software AG and contributors cake cake-addin cake-issues cake-issueprovider linting markdown markdownlint - https://github.com/cake-contrib/Cake.Issues.Markdownlint/releases/tag/3.0.0 + https://github.com/cake-contrib/Cake.Issues.Markdownlint/releases/tag/4.0.0 @@ -34,5 +34,8 @@ See the Project Site for an overview of the whole ecosystem of addins for workin + + + \ No newline at end of file diff --git a/recipe.cake b/recipe.cake index 7af0f12..4432955 100644 --- a/recipe.cake +++ b/recipe.cake @@ -1,4 +1,4 @@ -#load nuget:?package=Cake.Recipe&version=3.0.1 +#load nuget:?package=Cake.Recipe&version=3.1.1 //************************************************************************************************* // Settings diff --git a/src/Cake.Issues.Markdownlint.Tests/Cake.Issues.Markdownlint.Tests.csproj b/src/Cake.Issues.Markdownlint.Tests/Cake.Issues.Markdownlint.Tests.csproj index ef9f6e6..6f32eb7 100644 --- a/src/Cake.Issues.Markdownlint.Tests/Cake.Issues.Markdownlint.Tests.csproj +++ b/src/Cake.Issues.Markdownlint.Tests/Cake.Issues.Markdownlint.Tests.csproj @@ -29,6 +29,7 @@ + @@ -41,6 +42,7 @@ + @@ -52,28 +54,28 @@ - 3.0.0 + 4.0.0 - 3.0.0 + 4.0.0 - 3.0.0 + 4.0.0 - 4.1.0 + 4.2.1 1.1.118 runtime; build; native; contentfiles; analyzers all - + - 2.4.2 + 2.6.3 - 2.4.5 + 2.5.5 runtime; build; native; contentfiles; analyzers all diff --git a/src/Cake.Issues.Markdownlint.Tests/LogFileFormat/MarkdownlintCliLogFileFormatTests.cs b/src/Cake.Issues.Markdownlint.Tests/LogFileFormat/MarkdownlintCliLogFileFormatTests.cs index 1dde2b8..c139f2f 100644 --- a/src/Cake.Issues.Markdownlint.Tests/LogFileFormat/MarkdownlintCliLogFileFormatTests.cs +++ b/src/Cake.Issues.Markdownlint.Tests/LogFileFormat/MarkdownlintCliLogFileFormatTests.cs @@ -411,6 +411,104 @@ public void Should_Read_Issue_Correct_0_22_0() .OfRule("MD047", new Uri("https://github.com/DavidAnson/markdownlint/blob/master/doc/Rules.md#md047")) .WithPriority(IssuePriority.Warning)); } + + [Fact] + public void Should_Read_Issue_Correct_0_35_0() + { + // Given + var fixture = + new MarkdownlintIssuesProviderFixture("markdownlint-cli-0.35.0.log") + { + ReadIssuesSettings = new ReadIssuesSettings("C:/git/github/cake-contrib/Cake.Issues.Markdownlint/tests"), + }; + + // When + var issues = fixture.ReadIssues().ToList(); + + // Then + issues.Count.ShouldBe(9); + IssueChecker.Check( + issues[0], + IssueBuilder.NewIssue( + "Headings should be surrounded by blank lines [Expected: 1; Actual: 0; Below] [Context: \"# foo\"]", + "Cake.Issues.Markdownlint.MarkdownlintIssuesProvider", + "markdownlint") + .InFile("docs/index.md", 1) + .OfRule("MD022", new Uri("https://github.com/DavidAnson/markdownlint/blob/master/doc/Rules.md#md022")) + .WithPriority(IssuePriority.Warning)); + IssueChecker.Check( + issues[1], + IssueBuilder.NewIssue( + "Trailing spaces [Expected: 0 or 2; Actual: 1]", + "Cake.Issues.Markdownlint.MarkdownlintIssuesProvider", + "markdownlint") + .InFile("docs/index.md", 2, 811) + .OfRule("MD009", new Uri("https://github.com/DavidAnson/markdownlint/blob/master/doc/Rules.md#md009")) + .WithPriority(IssuePriority.Warning)); + IssueChecker.Check( + issues[2], + IssueBuilder.NewIssue( + "Line length [Expected: 80; Actual: 811]", + "Cake.Issues.Markdownlint.MarkdownlintIssuesProvider", + "markdownlint") + .InFile("docs/index.md", 2, 81) + .OfRule("MD013", new Uri("https://github.com/DavidAnson/markdownlint/blob/master/doc/Rules.md#md013")) + .WithPriority(IssuePriority.Warning)); + IssueChecker.Check( + issues[3], + IssueBuilder.NewIssue( + "Headings should be surrounded by blank lines [Expected: 1; Actual: 0; Below] [Context: \"# bar\"]", + "Cake.Issues.Markdownlint.MarkdownlintIssuesProvider", + "markdownlint") + .InFile("docs/index.md", 4) + .OfRule("MD022", new Uri("https://github.com/DavidAnson/markdownlint/blob/master/doc/Rules.md#md022")) + .WithPriority(IssuePriority.Warning)); + IssueChecker.Check( + issues[4], + IssueBuilder.NewIssue( + "Multiple top-level headings in the same document [Context: \"# bar\"]", + "Cake.Issues.Markdownlint.MarkdownlintIssuesProvider", + "markdownlint") + .InFile("docs/index.md", 4) + .OfRule("MD025", new Uri("https://github.com/DavidAnson/markdownlint/blob/master/doc/Rules.md#md025")) + .WithPriority(IssuePriority.Warning)); + IssueChecker.Check( + issues[5], + IssueBuilder.NewIssue( + "Fenced code blocks should be surrounded by blank lines [Context: \"```\"]", + "Cake.Issues.Markdownlint.MarkdownlintIssuesProvider", + "markdownlint") + .InFile("docs/index.md", 5) + .OfRule("MD031", new Uri("https://github.com/DavidAnson/markdownlint/blob/master/doc/Rules.md#md031")) + .WithPriority(IssuePriority.Warning)); + IssueChecker.Check( + issues[6], + IssueBuilder.NewIssue( + "Fenced code blocks should have a language specified [Context: \"```\"]", + "Cake.Issues.Markdownlint.MarkdownlintIssuesProvider", + "markdownlint") + .InFile("docs/index.md", 5) + .OfRule("MD040", new Uri("https://github.com/DavidAnson/markdownlint/blob/master/doc/Rules.md#md040")) + .WithPriority(IssuePriority.Warning)); + IssueChecker.Check( + issues[7], + IssueBuilder.NewIssue( + "Line length [Expected: 80; Actual: 840]", + "Cake.Issues.Markdownlint.MarkdownlintIssuesProvider", + "markdownlint") + .InFile("docs/index.md", 6, 81) + .OfRule("MD013", new Uri("https://github.com/DavidAnson/markdownlint/blob/master/doc/Rules.md#md013")) + .WithPriority(IssuePriority.Warning)); + IssueChecker.Check( + issues[8], + IssueBuilder.NewIssue( + "Files should end with a single newline character", + "Cake.Issues.Markdownlint.MarkdownlintIssuesProvider", + "markdownlint") + .InFile("docs/index.md", 7, 3) + .OfRule("MD047", new Uri("https://github.com/DavidAnson/markdownlint/blob/master/doc/Rules.md#md047")) + .WithPriority(IssuePriority.Warning)); + } } } } diff --git a/src/Cake.Issues.Markdownlint.Tests/MarkdownlintIssuesSettingsTests.cs b/src/Cake.Issues.Markdownlint.Tests/MarkdownlintIssuesSettingsTests.cs index 7eac241..d6b64ee 100644 --- a/src/Cake.Issues.Markdownlint.Tests/MarkdownlintIssuesSettingsTests.cs +++ b/src/Cake.Issues.Markdownlint.Tests/MarkdownlintIssuesSettingsTests.cs @@ -93,7 +93,7 @@ public void Should_Set_LogFileContent() public void Should_Set_LogFileContent_If_Empty() { // Given - byte[] logFileContent = Array.Empty(); + byte[] logFileContent = []; var format = new MarkdownlintV1LogFileFormat(new FakeLog()); // When diff --git a/src/Cake.Issues.Markdownlint.Tests/Testfiles/MarkdownlintCliLogFileFormat/markdownlint-cli-0.35.0.log b/src/Cake.Issues.Markdownlint.Tests/Testfiles/MarkdownlintCliLogFileFormat/markdownlint-cli-0.35.0.log new file mode 100644 index 0000000..591f166 --- /dev/null +++ b/src/Cake.Issues.Markdownlint.Tests/Testfiles/MarkdownlintCliLogFileFormat/markdownlint-cli-0.35.0.log @@ -0,0 +1,9 @@ +C:\git\github\cake-contrib\Cake.Issues.Markdownlint\tests\docs\index.md:1 MD022/blanks-around-headings/blanks-around-headers Headings should be surrounded by blank lines [Expected: 1; Actual: 0; Below] [Context: "# foo"] +C:\git\github\cake-contrib\Cake.Issues.Markdownlint\tests\docs\index.md:2:811 MD009/no-trailing-spaces Trailing spaces [Expected: 0 or 2; Actual: 1] +C:\git\github\cake-contrib\Cake.Issues.Markdownlint\tests\docs\index.md:2:81 MD013/line-length Line length [Expected: 80; Actual: 811] +C:\git\github\cake-contrib\Cake.Issues.Markdownlint\tests\docs\index.md:4 MD022/blanks-around-headings/blanks-around-headers Headings should be surrounded by blank lines [Expected: 1; Actual: 0; Below] [Context: "# bar"] +C:\git\github\cake-contrib\Cake.Issues.Markdownlint\tests\docs\index.md:4 MD025/single-title/single-h1 Multiple top-level headings in the same document [Context: "# bar"] +C:\git\github\cake-contrib\Cake.Issues.Markdownlint\tests\docs\index.md:5 MD031/blanks-around-fences Fenced code blocks should be surrounded by blank lines [Context: "```"] +C:\git\github\cake-contrib\Cake.Issues.Markdownlint\tests\docs\index.md:5 MD040/fenced-code-language Fenced code blocks should have a language specified [Context: "```"] +C:\git\github\cake-contrib\Cake.Issues.Markdownlint\tests\docs\index.md:6:81 MD013/line-length Line length [Expected: 80; Actual: 840] +C:\git\github\cake-contrib\Cake.Issues.Markdownlint\tests\docs\index.md:7:3 MD047/single-trailing-newline Files should end with a single newline character diff --git a/src/Cake.Issues.Markdownlint/Cake.Issues.Markdownlint.csproj b/src/Cake.Issues.Markdownlint/Cake.Issues.Markdownlint.csproj index c5905ba..174246e 100644 --- a/src/Cake.Issues.Markdownlint/Cake.Issues.Markdownlint.csproj +++ b/src/Cake.Issues.Markdownlint/Cake.Issues.Markdownlint.csproj @@ -1,8 +1,8 @@ - + Library - net6.0;net7.0 + net6.0;net7.0;net8.0 Markdownlint support for the Cake.Issues Addin for Cake Build Automation System BBT Software AG BBT Software AG @@ -26,12 +26,12 @@ - 3.0.0 + 4.0.0 - 3.0.0 + 4.0.0 - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/Cake.Issues.Markdownlint/IssueDataContract.cs b/src/Cake.Issues.Markdownlint/IssueDataContract.cs index f878c17..889a815 100644 --- a/src/Cake.Issues.Markdownlint/IssueDataContract.cs +++ b/src/Cake.Issues.Markdownlint/IssueDataContract.cs @@ -4,7 +4,6 @@ #pragma warning disable SA1401 // Fields must be private #pragma warning disable SA1307 // Accessible fields must begin with upper-case letter -#pragma warning disable SA1402 // File may only contain a single class #pragma warning disable SA1600 // Elements must be documented #pragma warning disable SA1649 // File name must match first type name @@ -34,7 +33,6 @@ internal class Issue } #pragma warning restore SA1401 // Fields must be private #pragma warning restore SA1307 // Accessible fields must begin with upper-case letter -#pragma warning restore SA1402 // File may only contain a single class #pragma warning restore SA1600 // Elements must be documented #pragma warning restore SA1649 // File name must match first type name } diff --git a/src/Cake.Issues.Markdownlint/LogFileFormat/MarkdownlintCliJsonLogFileFormat.cs b/src/Cake.Issues.Markdownlint/LogFileFormat/MarkdownlintCliJsonLogFileFormat.cs index e888d50..d52d3bd 100644 --- a/src/Cake.Issues.Markdownlint/LogFileFormat/MarkdownlintCliJsonLogFileFormat.cs +++ b/src/Cake.Issues.Markdownlint/LogFileFormat/MarkdownlintCliJsonLogFileFormat.cs @@ -12,17 +12,10 @@ /// /// Logfile format as written by markdownlint-cli with --json parameter. /// - internal class MarkdownlintCliJsonLogFileFormat : BaseMarkdownlintLogFileFormat + /// The Cake log instance. + internal class MarkdownlintCliJsonLogFileFormat(ICakeLog log) + : BaseMarkdownlintLogFileFormat(log) { - /// - /// Initializes a new instance of the class. - /// - /// The Cake log instance. - public MarkdownlintCliJsonLogFileFormat(ICakeLog log) - : base(log) - { - } - /// public override IEnumerable ReadIssues( MarkdownlintIssuesProvider issueProvider, @@ -33,7 +26,7 @@ public override IEnumerable ReadIssues( repositorySettings.NotNull(nameof(repositorySettings)); markdownlintIssuesSettings.NotNull(nameof(markdownlintIssuesSettings)); - if (!markdownlintIssuesSettings.LogFileContent.Any()) + if (markdownlintIssuesSettings.LogFileContent.Length == 0) { return new List(); } diff --git a/src/Cake.Issues.Markdownlint/LogFileFormat/MarkdownlintCliLogFileFormat.cs b/src/Cake.Issues.Markdownlint/LogFileFormat/MarkdownlintCliLogFileFormat.cs index af15ccd..5698851 100644 --- a/src/Cake.Issues.Markdownlint/LogFileFormat/MarkdownlintCliLogFileFormat.cs +++ b/src/Cake.Issues.Markdownlint/LogFileFormat/MarkdownlintCliLogFileFormat.cs @@ -9,16 +9,11 @@ /// /// Logfile format as written by markdownlint-cli. /// - internal class MarkdownlintCliLogFileFormat : BaseMarkdownlintLogFileFormat + /// The Cake log instance. + internal class MarkdownlintCliLogFileFormat(ICakeLog log) + : BaseMarkdownlintLogFileFormat(log) { - /// - /// Initializes a new instance of the class. - /// - /// The Cake log instance. - public MarkdownlintCliLogFileFormat(ICakeLog log) - : base(log) - { - } + private static readonly string[] Separator = ["\r\n", "\r", "\n"]; /// public override IEnumerable ReadIssues( @@ -32,7 +27,7 @@ public override IEnumerable ReadIssues( var regex = new Regex(@"(?.*[^:\d+]): ?(?\d+):?(?\d+)? (?MD\d+)/(?(?:\w*-*/*)*) (?.*)"); - foreach (var line in markdownlintIssuesSettings.LogFileContent.ToStringUsingEncoding().Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.None).ToList().Where(s => !string.IsNullOrEmpty(s))) + foreach (var line in markdownlintIssuesSettings.LogFileContent.ToStringUsingEncoding().Split(Separator, StringSplitOptions.None).ToList().Where(s => !string.IsNullOrEmpty(s))) { var groups = regex.Match(line).Groups; diff --git a/src/Cake.Issues.Markdownlint/LogFileFormat/MarkdownlintV1LogFileFormat.cs b/src/Cake.Issues.Markdownlint/LogFileFormat/MarkdownlintV1LogFileFormat.cs index 3ca07df..0fc1d54 100644 --- a/src/Cake.Issues.Markdownlint/LogFileFormat/MarkdownlintV1LogFileFormat.cs +++ b/src/Cake.Issues.Markdownlint/LogFileFormat/MarkdownlintV1LogFileFormat.cs @@ -9,17 +9,10 @@ /// /// Logfile format as written by Markdownlint with options.resultVersion set to 1. /// - internal class MarkdownlintV1LogFileFormat : BaseMarkdownlintLogFileFormat + /// The Cake log instance. + internal class MarkdownlintV1LogFileFormat(ICakeLog log) + : BaseMarkdownlintLogFileFormat(log) { - /// - /// Initializes a new instance of the class. - /// - /// The Cake log instance. - public MarkdownlintV1LogFileFormat(ICakeLog log) - : base(log) - { - } - /// public override IEnumerable ReadIssues( MarkdownlintIssuesProvider issueProvider, diff --git a/src/Cake.Issues.Markdownlint/MarkdownlintIssuesProvider.cs b/src/Cake.Issues.Markdownlint/MarkdownlintIssuesProvider.cs index 15a41d2..0ffa725 100644 --- a/src/Cake.Issues.Markdownlint/MarkdownlintIssuesProvider.cs +++ b/src/Cake.Issues.Markdownlint/MarkdownlintIssuesProvider.cs @@ -5,18 +5,11 @@ /// /// Provider for issues reported by Markdownlint. /// - public class MarkdownlintIssuesProvider : BaseMultiFormatIssueProvider + /// The Cake log context. + /// Settings for reading the log file. + public class MarkdownlintIssuesProvider(ICakeLog log, MarkdownlintIssuesSettings settings) + : BaseMultiFormatIssueProvider(log, settings) { - /// - /// Initializes a new instance of the class. - /// - /// The Cake log context. - /// Settings for reading the log file. - public MarkdownlintIssuesProvider(ICakeLog log, MarkdownlintIssuesSettings settings) - : base(log, settings) - { - } - /// /// Gets the name of the Markdownlint issue provider. /// This name can be used to identify issues based on the property. diff --git a/src/Directory.Build.props b/src/Directory.Build.props new file mode 100644 index 0000000..a95ac95 --- /dev/null +++ b/src/Directory.Build.props @@ -0,0 +1,5 @@ + + + latest + + \ No newline at end of file diff --git a/tests/.config/dotnet-tools.json b/tests/.config/dotnet-tools.json index 831d039..da200cd 100644 --- a/tests/.config/dotnet-tools.json +++ b/tests/.config/dotnet-tools.json @@ -3,7 +3,7 @@ "isRoot": true, "tools": { "cake.tool": { - "version": "3.0.0", + "version": "4.0.0", "commands": [ "dotnet-cake" ] diff --git a/tests/global.json b/tests/global.json new file mode 100644 index 0000000..d00a6bc --- /dev/null +++ b/tests/global.json @@ -0,0 +1,7 @@ +{ + "sdk": { + "allowPrerelease": true, + "version": "6.0.417", + "rollForward": "latestFeature" + } +} \ No newline at end of file