diff --git a/cake.config b/cake.config
new file mode 100644
index 0000000..8615723
--- /dev/null
+++ b/cake.config
@@ -0,0 +1,3 @@
+[Nuget]
+; Use the new InProcess client, because some packages have long file paths.
+UseInProcessClient=true
\ No newline at end of file
diff --git a/nuspec/nuget/Cake.Issues.Markdownlint.nuspec b/nuspec/nuget/Cake.Issues.Markdownlint.nuspec
index dd1332b..e36dd1b 100644
--- a/nuspec/nuget/Cake.Issues.Markdownlint.nuspec
+++ b/nuspec/nuget/Cake.Issues.Markdownlint.nuspec
@@ -21,13 +21,13 @@ See the Project Site for an overview of the whole ecosystem of addins for workin
https://github.com/cake-contrib/Cake.Issues.Markdownlint
https://cdn.rawgit.com/cake-contrib/graphics/a5cf0f881c390650144b2243ae551d5b9f836196/png/cake-contrib-medium.png
false
- Copyright © 2017 BBT Software AG and contributors
+ Copyright © BBT Software AG and contributors
Cake Script Cake-Issues Cake-IssueProvider Linting Markdownlint
- https://github.com/cake-contrib/Cake.Issues.Markdownlint/releases/tag/0.1.0
+ https://github.com/cake-contrib/Cake.Issues.Markdownlint/releases/tag/0.2.0
-
-
-
+
+
+
\ No newline at end of file
diff --git a/setup.cake b/setup.cake
index 55fdd3a..f2c14f0 100644
--- a/setup.cake
+++ b/setup.cake
@@ -9,13 +9,21 @@ BuildParameters.SetParameters(
title: "Cake.Issues.Markdownlint",
repositoryOwner: "cake-contrib",
repositoryName: "Cake.Issues.Markdownlint",
- appVeyorAccountName: "cakecontrib");
+ appVeyorAccountName: "cakecontrib",
+ shouldRunCodecov: false);
BuildParameters.PrintParameters(Context);
ToolSettings.SetToolSettings(
context: Context,
- dupFinderExcludePattern: new string[] { BuildParameters.RootDirectoryPath + "/src/Cake.Issues.Markdownlint.Tests/*.cs" },
+ dupFinderExcludePattern: new string[]
+ {
+ BuildParameters.RootDirectoryPath + "/src/Cake.Issues.Markdownlint/Markdownlint/MarkdownlintIssuesSettings.cs",
+ BuildParameters.RootDirectoryPath + "/src/Cake.Issues.Markdownlint/MarkdownlintCli/MarkdownlintCliIssuesSettings.cs",
+ BuildParameters.RootDirectoryPath + "/src/Cake.Issues.Markdownlint.Tests/*.cs",
+ BuildParameters.RootDirectoryPath + "/src/Cake.Issues.Markdownlint.Tests/Markdownlint/*.cs",
+ BuildParameters.RootDirectoryPath + "/src/Cake.Issues.Markdownlint.Tests/MarkdownlintCli/*.cs"
+ },
testCoverageFilter: "+[*]* -[xunit.*]* -[Cake.Core]* -[Cake.Testing]* -[*.Tests]* -[Cake.Issues]* -[Cake.Issues.Testing]*",
testCoverageExcludeByAttribute: "*.ExcludeFromCodeCoverage*",
testCoverageExcludeByFile: "*/*Designer.cs;*/*.g.cs;*/*.g.i.cs");
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 4edc4f5..831e6f4 100644
--- a/src/Cake.Issues.Markdownlint.Tests/Cake.Issues.Markdownlint.Tests.csproj
+++ b/src/Cake.Issues.Markdownlint.Tests/Cake.Issues.Markdownlint.Tests.csproj
@@ -1,6 +1,7 @@
-
+
+
Debug
@@ -10,7 +11,7 @@
Properties
Cake.Issues.Markdownlint.Tests
Cake.Issues.Markdownlint.Tests
- v4.6
+ v4.6.1
512
@@ -36,20 +37,20 @@
..\Cake.Issues.Markdownlint.Tests.ruleset
-
- ..\packages\Cake.Core.0.22.0\lib\net46\Cake.Core.dll
+
+ ..\packages\Cake.Core.0.26.0\lib\net46\Cake.Core.dll
-
- ..\packages\Cake.Issues.0.1.0\lib\net45\Cake.Issues.dll
+
+ ..\packages\Cake.Issues.0.2.0\lib\netstandard2.0\Cake.Issues.dll
-
- ..\packages\Cake.Issues.Testing.0.1.0\lib\net45\Cake.Issues.Testing.dll
+
+ ..\packages\Cake.Issues.Testing.0.2.0\lib\netstandard2.0\Cake.Issues.Testing.dll
-
- ..\packages\Cake.Testing.0.22.0\lib\net46\Cake.Testing.dll
+
+ ..\packages\Cake.Testing.0.26.0\lib\net46\Cake.Testing.dll
-
- ..\packages\Shouldly.2.8.3\lib\net451\Shouldly.dll
+
+ ..\packages\Shouldly.3.0.0\lib\net451\Shouldly.dll
@@ -62,20 +63,23 @@
..\packages\xunit.abstractions.2.0.1\lib\net35\xunit.abstractions.dll
-
- ..\packages\xunit.assert.2.2.0\lib\netstandard1.1\xunit.assert.dll
+
+ ..\packages\xunit.assert.2.3.1\lib\netstandard1.1\xunit.assert.dll
-
- ..\packages\xunit.extensibility.core.2.2.0\lib\netstandard1.1\xunit.core.dll
+
+ ..\packages\xunit.extensibility.core.2.3.1\lib\netstandard1.1\xunit.core.dll
-
- ..\packages\xunit.extensibility.execution.2.2.0\lib\net452\xunit.execution.desktop.dll
+
+ ..\packages\xunit.extensibility.execution.2.3.1\lib\net452\xunit.execution.desktop.dll
-
-
-
+
+
+
+
+
+
@@ -93,16 +97,22 @@
+
+
+
This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
-
+
+
+
+
\ No newline at end of file
diff --git a/src/Cake.Issues.Markdownlint.Tests/MarkdownlintIssuesProviderFixture.cs b/src/Cake.Issues.Markdownlint.Tests/Markdownlint/MarkdownlintIssuesProviderFixture.cs
similarity index 93%
rename from src/Cake.Issues.Markdownlint.Tests/MarkdownlintIssuesProviderFixture.cs
rename to src/Cake.Issues.Markdownlint.Tests/Markdownlint/MarkdownlintIssuesProviderFixture.cs
index 4c031c1..e9248c1 100644
--- a/src/Cake.Issues.Markdownlint.Tests/MarkdownlintIssuesProviderFixture.cs
+++ b/src/Cake.Issues.Markdownlint.Tests/Markdownlint/MarkdownlintIssuesProviderFixture.cs
@@ -1,7 +1,8 @@
-namespace Cake.Issues.Markdownlint.Tests
+namespace Cake.Issues.Markdownlint.Tests.Markdownlint
{
using System.Collections.Generic;
using System.IO;
+ using Cake.Issues.Markdownlint.Markdownlint;
using Cake.Testing;
using Core.Diagnostics;
diff --git a/src/Cake.Issues.Markdownlint.Tests/MarkdownlintIssuesProviderTests.cs b/src/Cake.Issues.Markdownlint.Tests/Markdownlint/MarkdownlintIssuesProviderTests.cs
similarity index 97%
rename from src/Cake.Issues.Markdownlint.Tests/MarkdownlintIssuesProviderTests.cs
rename to src/Cake.Issues.Markdownlint.Tests/Markdownlint/MarkdownlintIssuesProviderTests.cs
index 4b45334..080a365 100644
--- a/src/Cake.Issues.Markdownlint.Tests/MarkdownlintIssuesProviderTests.cs
+++ b/src/Cake.Issues.Markdownlint.Tests/Markdownlint/MarkdownlintIssuesProviderTests.cs
@@ -1,6 +1,7 @@
-namespace Cake.Issues.Markdownlint.Tests
+namespace Cake.Issues.Markdownlint.Tests.Markdownlint
{
using System.Linq;
+ using Cake.Issues.Markdownlint.Markdownlint;
using Cake.Testing;
using Core.IO;
using Shouldly;
diff --git a/src/Cake.Issues.Markdownlint.Tests/MarkdownlintIssuesSettingsTests.cs b/src/Cake.Issues.Markdownlint.Tests/Markdownlint/MarkdownlintIssuesSettingsTests.cs
similarity index 97%
rename from src/Cake.Issues.Markdownlint.Tests/MarkdownlintIssuesSettingsTests.cs
rename to src/Cake.Issues.Markdownlint.Tests/Markdownlint/MarkdownlintIssuesSettingsTests.cs
index fcbd45e..d77979e 100644
--- a/src/Cake.Issues.Markdownlint.Tests/MarkdownlintIssuesSettingsTests.cs
+++ b/src/Cake.Issues.Markdownlint.Tests/Markdownlint/MarkdownlintIssuesSettingsTests.cs
@@ -1,9 +1,10 @@
-namespace Cake.Issues.Markdownlint.Tests
+namespace Cake.Issues.Markdownlint.Tests.Markdownlint
{
using System;
using System.IO;
using System.Linq;
using System.Text;
+ using Cake.Issues.Markdownlint.Markdownlint;
using Shouldly;
using Testing;
using Xunit;
diff --git a/src/Cake.Issues.Markdownlint.Tests/MarkdownlintCli/MarkdownlintCliIssuesProviderFixture.cs b/src/Cake.Issues.Markdownlint.Tests/MarkdownlintCli/MarkdownlintCliIssuesProviderFixture.cs
new file mode 100644
index 0000000..4c84ad6
--- /dev/null
+++ b/src/Cake.Issues.Markdownlint.Tests/MarkdownlintCli/MarkdownlintCliIssuesProviderFixture.cs
@@ -0,0 +1,48 @@
+namespace Cake.Issues.Markdownlint.Tests.MarkdownlintCli
+{
+ using System.Collections.Generic;
+ using System.IO;
+ using Cake.Issues.Markdownlint.MarkdownlintCli;
+ using Cake.Testing;
+ using Core.Diagnostics;
+
+ internal class MarkdownlintCliIssuesProviderFixture
+ {
+ public MarkdownlintCliIssuesProviderFixture(string fileResourceName)
+ {
+ this.Log = new FakeLog { Verbosity = Verbosity.Normal };
+
+ using (var stream = this.GetType().Assembly.GetManifestResourceStream("Cake.Issues.Markdownlint.Tests.Testfiles." + fileResourceName))
+ {
+ using (var sr = new StreamReader(stream))
+ {
+ this.Settings =
+ MarkdownlintCliIssuesSettings.FromContent(
+ sr.ReadToEnd());
+ }
+ }
+
+ this.RepositorySettings =
+ new RepositorySettings(@"c:\Source\Cake.Issues");
+ }
+
+ public FakeLog Log { get; set; }
+
+ public MarkdownlintCliIssuesSettings Settings { get; set; }
+
+ public RepositorySettings RepositorySettings { get; set; }
+
+ public MarkdownlintCliIssuesProvider Create()
+ {
+ var provider = new MarkdownlintCliIssuesProvider(this.Log, this.Settings);
+ provider.Initialize(this.RepositorySettings);
+ return provider;
+ }
+
+ public IEnumerable ReadIssues()
+ {
+ var issueProvider = this.Create();
+ return issueProvider.ReadIssues(IssueCommentFormat.PlainText);
+ }
+ }
+}
diff --git a/src/Cake.Issues.Markdownlint.Tests/MarkdownlintCli/MarkdownlintCliIssuesProviderTests.cs b/src/Cake.Issues.Markdownlint.Tests/MarkdownlintCli/MarkdownlintCliIssuesProviderTests.cs
new file mode 100644
index 0000000..f2f37e6
--- /dev/null
+++ b/src/Cake.Issues.Markdownlint.Tests/MarkdownlintCli/MarkdownlintCliIssuesProviderTests.cs
@@ -0,0 +1,156 @@
+namespace Cake.Issues.Markdownlint.Tests.MarkdownlintCli
+{
+ using System.Linq;
+ using Cake.Issues.Markdownlint.MarkdownlintCli;
+ using Cake.Testing;
+ using Core.IO;
+ using Shouldly;
+ using Testing;
+ using Xunit;
+
+ public sealed class MarkdownlintCliIssuesProviderTests
+ {
+ public sealed class TheCtor
+ {
+ [Fact]
+ public void Should_Throw_If_Log_Is_Null()
+ {
+ // Given / When
+ var result = Record.Exception(() =>
+ new MarkdownlintCliIssuesProvider(
+ null,
+ MarkdownlintCliIssuesSettings.FromContent("Foo")));
+
+ // Then
+ result.IsArgumentNullException("log");
+ }
+
+ [Fact]
+ public void Should_Throw_If_Settings_Are_Null()
+ {
+ var result = Record.Exception(() =>
+ new MarkdownlintCliIssuesProvider(
+ new FakeLog(),
+ null));
+
+ // Then
+ result.IsArgumentNullException("settings");
+ }
+ }
+
+ public sealed class TheReadIssuesMethod
+ {
+ [Fact]
+ public void Should_Read_Issue_Correct()
+ {
+ // Given
+ var fixture = new MarkdownlintCliIssuesProviderFixture("markdownlint-cli.log");
+
+ // When
+ var issues = fixture.ReadIssues().ToList();
+
+ // Then
+ issues.Count.ShouldBe(8);
+ CheckIssue(
+ issues[0],
+ @"docs/index.md",
+ 1,
+ "MD022",
+ "https://github.com/DavidAnson/markdownlint/blob/master/doc/Rules.md#md022",
+ 0,
+ "Headers should be surrounded by blank lines [Context: \"# foo\"]");
+ CheckIssue(
+ issues[1],
+ @"docs/index.md",
+ 2,
+ "MD009",
+ "https://github.com/DavidAnson/markdownlint/blob/master/doc/Rules.md#md009",
+ 0,
+ "Trailing spaces [Expected: 2; Actual: 1]");
+ CheckIssue(
+ issues[2],
+ @"docs/index.md",
+ 2,
+ "MD013",
+ "https://github.com/DavidAnson/markdownlint/blob/master/doc/Rules.md#md013",
+ 0,
+ "Line length [Expected: 100; Actual: 811]");
+ CheckIssue(
+ issues[3],
+ @"docs/index.md",
+ 4,
+ "MD022",
+ "https://github.com/DavidAnson/markdownlint/blob/master/doc/Rules.md#md022",
+ 0,
+ "Headers should be surrounded by blank lines [Context: \"# bar\"]");
+ CheckIssue(
+ issues[4],
+ @"docs/index.md",
+ 4,
+ "MD025",
+ "https://github.com/DavidAnson/markdownlint/blob/master/doc/Rules.md#md025",
+ 0,
+ "Multiple top level headers in the same document [Context: \"# bar\"]");
+ CheckIssue(
+ issues[5],
+ @"docs/index.md",
+ 5,
+ "MD031",
+ "https://github.com/DavidAnson/markdownlint/blob/master/doc/Rules.md#md031",
+ 0,
+ "Fenced code blocks should be surrounded by blank lines [Context: \"```\"]");
+ CheckIssue(
+ issues[6],
+ @"docs/index.md",
+ 5,
+ "MD040",
+ "https://github.com/DavidAnson/markdownlint/blob/master/doc/Rules.md#md040",
+ 0,
+ "Fenced code blocks should have a language specified [Context: \"```\"]");
+ CheckIssue(
+ issues[7],
+ @"docs/index.md",
+ 6,
+ "MD009",
+ "https://github.com/DavidAnson/markdownlint/blob/master/doc/Rules.md#md009",
+ 0,
+ "Trailing spaces [Expected: 2; Actual: 1]");
+ }
+
+ private static void CheckIssue(
+ IIssue issue,
+ string affectedFileRelativePath,
+ int? line,
+ string rule,
+ string ruleUrl,
+ int priority,
+ string message)
+ {
+ if (issue.AffectedFileRelativePath == null)
+ {
+ affectedFileRelativePath.ShouldBeNull();
+ }
+ else
+ {
+ issue.AffectedFileRelativePath.ToString().ShouldBe(new FilePath(affectedFileRelativePath).ToString());
+ issue.AffectedFileRelativePath.IsRelative.ShouldBe(true, "Issue path is not relative");
+ }
+
+ issue.Line.ShouldBe(line);
+ issue.Rule.ShouldBe(rule);
+
+ if (issue.RuleUrl == null)
+ {
+ ruleUrl.ShouldBeNull();
+ }
+ else
+ {
+ issue.RuleUrl.ToString().ShouldBe(ruleUrl);
+ }
+
+ issue.Priority.ShouldBe(priority);
+ issue.Message.ShouldBe(message);
+ }
+ }
+ }
+}
diff --git a/src/Cake.Issues.Markdownlint.Tests/MarkdownlintCli/MarkdownlintCliIssuesSettingsTests.cs b/src/Cake.Issues.Markdownlint.Tests/MarkdownlintCli/MarkdownlintCliIssuesSettingsTests.cs
new file mode 100644
index 0000000..0eea153
--- /dev/null
+++ b/src/Cake.Issues.Markdownlint.Tests/MarkdownlintCli/MarkdownlintCliIssuesSettingsTests.cs
@@ -0,0 +1,112 @@
+namespace Cake.Issues.Markdownlint.Tests.MarkdownlintCli
+{
+ using System;
+ using System.IO;
+ using System.Linq;
+ using System.Text;
+ using Cake.Issues.Markdownlint.MarkdownlintCli;
+ using Shouldly;
+ using Testing;
+ using Xunit;
+
+ public sealed class MarkdownlintCliIssuesSettingsTests
+ {
+ public sealed class TheCtor
+ {
+ [Fact]
+ public void Should_Throw_If_LogFilePath_Is_Null()
+ {
+ // Given / When
+ var result = Record.Exception(() =>
+ MarkdownlintCliIssuesSettings.FromFilePath(null));
+
+ // Then
+ result.IsArgumentNullException("logFilePath");
+ }
+
+ [Fact]
+ public void Should_Throw_If_LogFileContent_Is_Null()
+ {
+ // Given / When
+ var result = Record.Exception(() =>
+ MarkdownlintCliIssuesSettings.FromContent(null));
+
+ // Then
+ result.IsArgumentNullException("logFileContent");
+ }
+
+ [Fact]
+ public void Should_Throw_If_LogFileContent_Is_Empty()
+ {
+ // Given / When
+ var result = Record.Exception(() =>
+ MarkdownlintCliIssuesSettings.FromContent(string.Empty));
+
+ // Then
+ result.IsArgumentOutOfRangeException("logFileContent");
+ }
+
+ [Fact]
+ public void Should_Throw_If_LogFileContent_Is_WhiteSpace()
+ {
+ // Given / When
+ var result = Record.Exception(() =>
+ MarkdownlintCliIssuesSettings.FromContent(" "));
+
+ // Then
+ result.IsArgumentOutOfRangeException("logFileContent");
+ }
+
+ [Fact]
+ public void Should_Set_Property_Values_Passed_To_Constructor()
+ {
+ // Given
+ const string logFileContent = "foo";
+
+ // When
+ var settings = MarkdownlintCliIssuesSettings.FromContent(logFileContent);
+
+ // Then
+ settings.LogFileContent.ShouldBe(logFileContent);
+ }
+
+ [Fact]
+ public void Should_Read_File_From_Disk()
+ {
+ var fileName = Path.GetTempFileName();
+ try
+ {
+ // Given
+ string expected;
+ using (var ms = new MemoryStream())
+ using (var stream = this.GetType().Assembly.GetManifestResourceStream("Cake.Issues.Markdownlint.Tests.Testfiles.markdownlint-cli.log"))
+ {
+ stream.CopyTo(ms);
+ var data = ms.ToArray();
+
+ using (var file = new FileStream(fileName, FileMode.Create, FileAccess.Write))
+ {
+ file.Write(data, 0, data.Length);
+ }
+
+ expected = Encoding.UTF8.GetString(data);
+ }
+
+ // When
+ var settings =
+ MarkdownlintCliIssuesSettings.FromFilePath(fileName);
+
+ // Then
+ settings.LogFileContent.ShouldBe(expected);
+ }
+ finally
+ {
+ if (File.Exists(fileName))
+ {
+ File.Delete(fileName);
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/src/Cake.Issues.Markdownlint.Tests/Properties/AssemblyInfo.cs b/src/Cake.Issues.Markdownlint.Tests/Properties/AssemblyInfo.cs
index b6f0042..7752953 100644
--- a/src/Cake.Issues.Markdownlint.Tests/Properties/AssemblyInfo.cs
+++ b/src/Cake.Issues.Markdownlint.Tests/Properties/AssemblyInfo.cs
@@ -9,7 +9,7 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("BBT Software AG")]
[assembly: AssemblyProduct("Cake.Issues")]
-[assembly: AssemblyCopyright("Copyright © 2017 BBT Software AG and contributors")]
+[assembly: AssemblyCopyright("Copyright © BBT Software AG and contributors")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
diff --git a/src/Cake.Issues.Markdownlint.Tests/Testfiles/markdownlint-cli.log b/src/Cake.Issues.Markdownlint.Tests/Testfiles/markdownlint-cli.log
new file mode 100644
index 0000000..8a11f8a
--- /dev/null
+++ b/src/Cake.Issues.Markdownlint.Tests/Testfiles/markdownlint-cli.log
@@ -0,0 +1,8 @@
+C:/Git/Test/Cake.Prca/docs/index.md: 1: MD022/blanks-around-headers Headers should be surrounded by blank lines [Context: "# foo"]
+C:/Git/Test/Cake.Prca/docs/index.md: 2: MD009/no-trailing-spaces Trailing spaces [Expected: 2; Actual: 1]
+C:/Git/Test/Cake.Prca/docs/index.md: 2: MD013/line-length Line length [Expected: 100; Actual: 811]
+C:/Git/Test/Cake.Prca/docs/index.md: 4: MD022/blanks-around-headers Headers should be surrounded by blank lines [Context: "# bar"]
+C:/Git/Test/Cake.Prca/docs/index.md: 4: MD025/single-h1 Multiple top level headers in the same document [Context: "# bar"]
+C:/Git/Test/Cake.Prca/docs/index.md: 5: MD031/blanks-around-fences Fenced code blocks should be surrounded by blank lines [Context: "```"]
+C:/Git/Test/Cake.Prca/docs/index.md: 5: MD040/fenced-code-language Fenced code blocks should have a language specified [Context: "```"]
+C:/Git/Test/Cake.Prca/docs/index.md: 6: MD009/no-trailing-spaces Trailing spaces [Expected: 2; Actual: 1]
\ No newline at end of file
diff --git a/src/Cake.Issues.Markdownlint.Tests/packages.config b/src/Cake.Issues.Markdownlint.Tests/packages.config
index 14de413..4bcb8fe 100644
--- a/src/Cake.Issues.Markdownlint.Tests/packages.config
+++ b/src/Cake.Issues.Markdownlint.Tests/packages.config
@@ -1,16 +1,17 @@
-
-
-
-
-
+
+
+
+
+
-
+
-
-
-
-
-
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Cake.Issues.Markdownlint.sln b/src/Cake.Issues.Markdownlint.sln
index f3aa237..230814d 100644
--- a/src/Cake.Issues.Markdownlint.sln
+++ b/src/Cake.Issues.Markdownlint.sln
@@ -14,7 +14,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build", "Build", "{CE25C309
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "nuspec", "nuspec", "{0E6A55DD-0E2C-42C5-9444-F5F894A0A11E}"
ProjectSection(SolutionItems) = preProject
- ..\nuspec\Cake.Issues.Markdownlint.nuspec = ..\nuspec\Cake.Issues.Markdownlint.nuspec
+ ..\nuspec\nuget\Cake.Issues.Markdownlint.nuspec = ..\nuspec\nuget\Cake.Issues.Markdownlint.nuspec
EndProjectSection
EndProject
Global
diff --git a/src/Cake.Issues.Markdownlint/Cake.Issues.Markdownlint.csproj b/src/Cake.Issues.Markdownlint/Cake.Issues.Markdownlint.csproj
index 2c60e07..36615f8 100644
--- a/src/Cake.Issues.Markdownlint/Cake.Issues.Markdownlint.csproj
+++ b/src/Cake.Issues.Markdownlint/Cake.Issues.Markdownlint.csproj
@@ -1,5 +1,9 @@
+
+
+
+
Debug
@@ -9,7 +13,7 @@
Properties
Cake.Issues.Markdownlint
Cake.Issues.Markdownlint
- v4.6
+ v4.6.1
512
@@ -37,11 +41,11 @@
..\Cake.Issues.Markdownlint.ruleset
-
- ..\packages\Cake.Core.0.22.0\lib\net46\Cake.Core.dll
+
+ ..\packages\Cake.Core.0.26.0\lib\net46\Cake.Core.dll
-
- ..\packages\Cake.Issues.0.1.0\lib\net45\Cake.Issues.dll
+
+ ..\packages\Cake.Issues.0.2.0\lib\netstandard2.0\Cake.Issues.dll
..\packages\Costura.Fody.1.6.2\lib\dotnet\Costura.dll
@@ -61,8 +65,12 @@
-
-
+
+
+
+
+
+
@@ -71,13 +79,18 @@
-
-
+
+
+
+
+
+
-
-
+
+
+
@@ -85,6 +98,10 @@
+
+
+
+
diff --git a/src/Cake.Issues.Markdownlint/MarkdownlintIssuesProvider.cs b/src/Cake.Issues.Markdownlint/Markdownlint/MarkdownlintIssuesProvider.cs
similarity index 97%
rename from src/Cake.Issues.Markdownlint/MarkdownlintIssuesProvider.cs
rename to src/Cake.Issues.Markdownlint/Markdownlint/MarkdownlintIssuesProvider.cs
index 6edbb2f..1ea3d2b 100644
--- a/src/Cake.Issues.Markdownlint/MarkdownlintIssuesProvider.cs
+++ b/src/Cake.Issues.Markdownlint/Markdownlint/MarkdownlintIssuesProvider.cs
@@ -1,4 +1,4 @@
-namespace Cake.Issues.Markdownlint
+namespace Cake.Issues.Markdownlint.Markdownlint
{
using System.Collections.Generic;
using System.Linq;
diff --git a/src/Cake.Issues.Markdownlint/MarkdownlintIssuesSettings.cs b/src/Cake.Issues.Markdownlint/Markdownlint/MarkdownlintIssuesSettings.cs
similarity index 97%
rename from src/Cake.Issues.Markdownlint/MarkdownlintIssuesSettings.cs
rename to src/Cake.Issues.Markdownlint/Markdownlint/MarkdownlintIssuesSettings.cs
index a7eae34..d45d4ab 100644
--- a/src/Cake.Issues.Markdownlint/MarkdownlintIssuesSettings.cs
+++ b/src/Cake.Issues.Markdownlint/Markdownlint/MarkdownlintIssuesSettings.cs
@@ -1,4 +1,4 @@
-namespace Cake.Issues.Markdownlint
+namespace Cake.Issues.Markdownlint.Markdownlint
{
using System.IO;
using Core.IO;
diff --git a/src/Cake.Issues.Markdownlint/MarkdownlintCli/MarkdownlintCliIssuesProvider.cs b/src/Cake.Issues.Markdownlint/MarkdownlintCli/MarkdownlintCliIssuesProvider.cs
new file mode 100644
index 0000000..5d482f4
--- /dev/null
+++ b/src/Cake.Issues.Markdownlint/MarkdownlintCli/MarkdownlintCliIssuesProvider.cs
@@ -0,0 +1,86 @@
+namespace Cake.Issues.Markdownlint.MarkdownlintCli
+{
+ using System;
+ using System.Collections.Generic;
+ using System.IO;
+ using System.Linq;
+ using System.Text.RegularExpressions;
+ using Core.Diagnostics;
+
+ ///
+ /// Provider for issues reported by markdownlint-cli.
+ ///
+ internal class MarkdownlintCliIssuesProvider : IssueProvider
+ {
+ private readonly MarkdownlintCliIssuesSettings settings;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The Cake log context.
+ /// Settings for reading the log file.
+ public MarkdownlintCliIssuesProvider(ICakeLog log, MarkdownlintCliIssuesSettings settings)
+ : base(log)
+ {
+ settings.NotNull(nameof(settings));
+
+ this.settings = settings;
+ }
+
+ ///
+ protected override IEnumerable InternalReadIssues(IssueCommentFormat format)
+ {
+ var regex = new Regex(@"(.*): (\d*): (MD\d*)/((?:\w*-*)*) (.*)");
+
+ foreach (var line in this.settings.LogFileContent.Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.None).ToList().Where(s => !string.IsNullOrEmpty(s)))
+ {
+ var groups = regex.Match(line).Groups;
+
+ // Read affected file from the line.
+ if (!this.TryGetFile(groups, this.Settings, out string fileName))
+ {
+ continue;
+ }
+
+ var lineNumber = int.Parse(groups[2].Value);
+ var rule = groups[3].Value;
+ var ruleDescription = groups[5].Value;
+
+ yield return
+ new Issue(
+ fileName,
+ lineNumber,
+ ruleDescription,
+ 0,
+ rule,
+ MarkdownlintRuleUrlResolver.Instance.ResolveRuleUrl(rule));
+ }
+ }
+
+ ///
+ /// Reads the affected file path from a parsed entry.
+ ///
+ /// Parsed values of a line in the log file.
+ /// Repository settings to use.
+ /// Returns the full path to the affected file.
+ /// True if the file path could be parsed.
+ private bool TryGetFile(
+ GroupCollection values,
+ RepositorySettings repositorySettings,
+ out string fileName)
+ {
+ fileName = values[1].Value;
+
+ // Make path relative to repository root.
+ fileName = fileName.Substring(repositorySettings.RepositoryRoot.FullPath.Length);
+
+ // Remove leading directory separator.
+ if (fileName.StartsWith("/"))
+ {
+ fileName = fileName.Substring(1);
+ }
+
+ return true;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Cake.Issues.Markdownlint/MarkdownlintCli/MarkdownlintCliIssuesSettings.cs b/src/Cake.Issues.Markdownlint/MarkdownlintCli/MarkdownlintCliIssuesSettings.cs
new file mode 100644
index 0000000..02072b1
--- /dev/null
+++ b/src/Cake.Issues.Markdownlint/MarkdownlintCli/MarkdownlintCliIssuesSettings.cs
@@ -0,0 +1,65 @@
+namespace Cake.Issues.Markdownlint.MarkdownlintCli
+{
+ using System.IO;
+ using Core.IO;
+
+ ///
+ /// Settings for .
+ ///
+ public class MarkdownlintCliIssuesSettings
+ {
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Path to the the Markdownlint log file.
+ protected MarkdownlintCliIssuesSettings(FilePath logFilePath)
+ {
+ logFilePath.NotNull(nameof(logFilePath));
+
+ using (var stream = new FileStream(logFilePath.FullPath, FileMode.Open, FileAccess.Read))
+ {
+ using (var sr = new StreamReader(stream))
+ {
+ this.LogFileContent = sr.ReadToEnd();
+ }
+ }
+ }
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Content of the the Markdownlint log file.
+ protected MarkdownlintCliIssuesSettings(string logFileContent)
+ {
+ logFileContent.NotNullOrWhiteSpace(nameof(logFileContent));
+
+ this.LogFileContent = logFileContent;
+ }
+
+ ///
+ /// Gets the content of the log file.
+ ///
+ public string LogFileContent { get; private set; }
+
+ ///
+ /// Returns a new instance of the class from a log file on disk.
+ ///
+ /// Path to the Markdownlint log file.
+ /// Instance of the class.
+ public static MarkdownlintCliIssuesSettings FromFilePath(FilePath logFilePath)
+ {
+ return new MarkdownlintCliIssuesSettings(logFilePath);
+ }
+
+ ///
+ /// Returns a new instance of the class from the content
+ /// of a Markdownlint log file.
+ ///
+ /// Content of the Markdownlint log file.
+ /// Instance of the class.
+ public static MarkdownlintCliIssuesSettings FromContent(string logFileContent)
+ {
+ return new MarkdownlintCliIssuesSettings(logFileContent);
+ }
+ }
+}
diff --git a/src/Cake.Issues.Markdownlint/MarkdownlintIssuesAliases.Markdownlint.cs b/src/Cake.Issues.Markdownlint/MarkdownlintIssuesAliases.Markdownlint.cs
new file mode 100644
index 0000000..b9ecbdb
--- /dev/null
+++ b/src/Cake.Issues.Markdownlint/MarkdownlintIssuesAliases.Markdownlint.cs
@@ -0,0 +1,122 @@
+namespace Cake.Issues.Markdownlint
+{
+ using Cake.Issues.Markdownlint.Markdownlint;
+ using Core;
+ using Core.Annotations;
+ using Core.IO;
+
+#pragma warning disable SA1601 // Partial elements must be documented
+ public static partial class MarkdownlintIssuesAliases
+#pragma warning restore SA1601 // Partial elements must be documented
+ {
+ ///
+ /// Gets the name of the Markdownlint issue provider.
+ /// This name can be used to identify issues based on the property.
+ ///
+ /// The context.
+ /// Name of the Markdownlint issue provider.
+ [CakePropertyAlias]
+ [CakeAliasCategory(IssuesAliasConstants.IssueProviderCakeAliasCategory)]
+ [CakeNamespaceImport("Cake.Issues.Markdownlint.Markdownlint")]
+ public static string MarkdownlintIssuesProviderTypeName(
+ this ICakeContext context)
+ {
+ context.NotNull(nameof(context));
+
+ return Issue.GetProviderTypeName();
+ }
+
+ ///
+ /// Gets an instance of a provider for issues reported by Markdownlint using a log file from disk.
+ ///
+ /// The context.
+ /// Path to the the Markdownlint log file.
+ /// Instance of a provider for issues reported by Markdownlint.
+ ///
+ /// Read issues reported by Markdownlint:
+ ///
+ ///
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory(IssuesAliasConstants.IssueProviderCakeAliasCategory)]
+ [CakeNamespaceImport("Cake.Issues.Markdownlint.Markdownlint")]
+ public static IIssueProvider MarkdownlintIssuesFromFilePath(
+ this ICakeContext context,
+ FilePath logFilePath)
+ {
+ context.NotNull(nameof(context));
+ logFilePath.NotNull(nameof(logFilePath));
+
+ return context.MarkdownlintIssues(MarkdownlintIssuesSettings.FromFilePath(logFilePath));
+ }
+
+ ///
+ /// Gets an instance of a provider for issues reported by Markdownlint using log file content.
+ ///
+ /// The context.
+ /// Content of the the Markdownlint log file.
+ /// Instance of a provider for issues reported by Markdownlint.
+ ///
+ /// Read issues reported by Markdownlint:
+ ///
+ ///
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory(IssuesAliasConstants.IssueProviderCakeAliasCategory)]
+ [CakeNamespaceImport("Cake.Issues.Markdownlint.Markdownlint")]
+ public static IIssueProvider MarkdownlintIssuesFromContent(
+ this ICakeContext context,
+ string logFileContent)
+ {
+ context.NotNull(nameof(context));
+ logFileContent.NotNullOrWhiteSpace(nameof(logFileContent));
+
+ return context.MarkdownlintIssues(MarkdownlintIssuesSettings.FromContent(logFileContent));
+ }
+
+ ///
+ /// Gets an instance of a provider for issues reported by Markdownlint using specified settings.
+ ///
+ /// The context.
+ /// Settings for reading the Markdownlint log.
+ /// Instance of a provider for issues reported by Markdownlint.
+ ///
+ /// Read issues reported by Markdownlint:
+ ///
+ ///
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory(IssuesAliasConstants.IssueProviderCakeAliasCategory)]
+ [CakeNamespaceImport("Cake.Issues.Markdownlint.Markdownlint")]
+ public static IIssueProvider MarkdownlintIssues(
+ this ICakeContext context,
+ MarkdownlintIssuesSettings settings)
+ {
+ context.NotNull(nameof(context));
+ settings.NotNull(nameof(settings));
+
+ return new MarkdownlintIssuesProvider(context.Log, settings);
+ }
+ }
+}
diff --git a/src/Cake.Issues.Markdownlint/MarkdownlintIssuesAliases.MarkdownlintCli.cs b/src/Cake.Issues.Markdownlint/MarkdownlintIssuesAliases.MarkdownlintCli.cs
new file mode 100644
index 0000000..33858a5
--- /dev/null
+++ b/src/Cake.Issues.Markdownlint/MarkdownlintIssuesAliases.MarkdownlintCli.cs
@@ -0,0 +1,125 @@
+namespace Cake.Issues.Markdownlint
+{
+ using Cake.Issues.Markdownlint.MarkdownlintCli;
+ using Core;
+ using Core.Annotations;
+ using Core.IO;
+
+#pragma warning disable SA1601 // Partial elements must be documented
+ public static partial class MarkdownlintIssuesAliases
+#pragma warning restore SA1601 // Partial elements must be documented
+ {
+ ///
+ /// Gets the name of the markdownlint-cli issue provider.
+ /// This name can be used to identify issues based on the property.
+ ///
+ /// The context.
+ /// Name of the markdownlint-cli issue provider.
+ [CakePropertyAlias]
+ [CakeAliasCategory(IssuesAliasConstants.IssueProviderCakeAliasCategory)]
+ [CakeNamespaceImport("Cake.Issues.Markdownlint.MarkdownlintCli")]
+ public static string MarkdownlintCliIssuesProviderTypeName(
+ this ICakeContext context)
+ {
+ context.NotNull(nameof(context));
+
+ return Issue.GetProviderTypeName();
+ }
+
+ ///
+ /// Gets an instance of a provider for issues reported by markdownlint-cli or Cake.Markdownlint
+ /// using a log file from disk.
+ ///
+ /// The context.
+ /// Path to the the markdownlint-cli log file.
+ /// Instance of a provider for issues reported by markdownlint-cli.
+ ///
+ /// Read issues reported by markdownlint-cli or Cake.Markdownlint:
+ ///
+ ///
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory(IssuesAliasConstants.IssueProviderCakeAliasCategory)]
+ [CakeNamespaceImport("Cake.Issues.Markdownlint.MarkdownlintCli")]
+ public static IIssueProvider MarkdownlintCliIssuesFromFilePath(
+ this ICakeContext context,
+ FilePath logFilePath)
+ {
+ context.NotNull(nameof(context));
+ logFilePath.NotNull(nameof(logFilePath));
+
+ return context.MarkdownlintCliIssues(MarkdownlintCliIssuesSettings.FromFilePath(logFilePath));
+ }
+
+ ///
+ /// Gets an instance of a provider for issues reported by markdownlint-cli or Cake.Markdownlint
+ /// using log file content.
+ ///
+ /// The context.
+ /// Content of the the markdownlint-cli log file.
+ /// Instance of a provider for issues reported by markdownlint-cli.
+ ///
+ /// Read issues reported by markdownlint-cli or Cake.Markdownlint:
+ ///
+ ///
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory(IssuesAliasConstants.IssueProviderCakeAliasCategory)]
+ [CakeNamespaceImport("Cake.Issues.Markdownlint.MarkdownlintCli")]
+ public static IIssueProvider MarkdownlintCliIssuesFromContent(
+ this ICakeContext context,
+ string logFileContent)
+ {
+ context.NotNull(nameof(context));
+ logFileContent.NotNullOrWhiteSpace(nameof(logFileContent));
+
+ return context.MarkdownlintCliIssues(MarkdownlintCliIssuesSettings.FromContent(logFileContent));
+ }
+
+ ///
+ /// Gets an instance of a provider for issues reported by markdownlint-cli or Cake.Markdownlint
+ /// using specified settings.
+ ///
+ /// The context.
+ /// Settings for reading the markdownlint-cli log.
+ /// Instance of a provider for issues reported by markdownlint-cli.
+ ///
+ /// Read issues reported by markdownlint-cli or Cake.Markdownlint:
+ ///
+ ///
+ ///
+ ///
+ [CakeMethodAlias]
+ [CakeAliasCategory(IssuesAliasConstants.IssueProviderCakeAliasCategory)]
+ [CakeNamespaceImport("Cake.Issues.Markdownlint.MarkdownlintCli")]
+ public static IIssueProvider MarkdownlintCliIssues(
+ this ICakeContext context,
+ MarkdownlintCliIssuesSettings settings)
+ {
+ context.NotNull(nameof(context));
+ settings.NotNull(nameof(settings));
+
+ return new MarkdownlintCliIssuesProvider(context.Log, settings);
+ }
+ }
+}
diff --git a/src/Cake.Issues.Markdownlint/MarkdownlintIssuesAliases.cs b/src/Cake.Issues.Markdownlint/MarkdownlintIssuesAliases.cs
index cb3bc78..a5320c3 100644
--- a/src/Cake.Issues.Markdownlint/MarkdownlintIssuesAliases.cs
+++ b/src/Cake.Issues.Markdownlint/MarkdownlintIssuesAliases.cs
@@ -1,119 +1,12 @@
namespace Cake.Issues.Markdownlint
{
- using Core;
using Core.Annotations;
- using Core.IO;
///
/// Contains functionality for reading issues from Markdownlint log files.
///
[CakeAliasCategory(IssuesAliasConstants.MainCakeAliasCategory)]
- public static class MarkdownlintIssuesAliases
+ public static partial class MarkdownlintIssuesAliases
{
- ///
- /// Gets the name of the Markdownlint issue provider.
- /// This name can be used to identify issues based on the property.
- ///
- /// The context.
- /// Name of the Markdownlint issue provider.
- [CakePropertyAlias]
- [CakeAliasCategory(IssuesAliasConstants.IssueProviderCakeAliasCategory)]
- public static string MarkdownlintIssuesProviderTypeName(
- this ICakeContext context)
- {
- context.NotNull(nameof(context));
-
- return Issue.GetProviderTypeName();
- }
-
- ///
- /// Gets an instance of a provider for issues reported by Markdownlint using a log file from disk.
- ///
- /// The context.
- /// Path to the the Markdownlint log file.
- /// Instance of a provider for issues reported by Markdownlint.
- ///
- /// Read issues reported by Markdownlint:
- ///
- ///
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory(IssuesAliasConstants.IssueProviderCakeAliasCategory)]
- public static IIssueProvider MarkdownlintIssuesFromFilePath(
- this ICakeContext context,
- FilePath logFilePath)
- {
- context.NotNull(nameof(context));
- logFilePath.NotNull(nameof(logFilePath));
-
- return context.MarkdownlintIssues(MarkdownlintIssuesSettings.FromFilePath(logFilePath));
- }
-
- ///
- /// Gets an instance of a provider for issues reported by Markdownlint using log file content.
- ///
- /// The context.
- /// Content of the the Markdownlint log file.
- /// Instance of a provider for issues reported by Markdownlint.
- ///
- /// Read issues reported by Markdownlint:
- ///
- ///
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory(IssuesAliasConstants.IssueProviderCakeAliasCategory)]
- public static IIssueProvider MarkdownlintIssuesFromContent(
- this ICakeContext context,
- string logFileContent)
- {
- context.NotNull(nameof(context));
- logFileContent.NotNullOrWhiteSpace(nameof(logFileContent));
-
- return context.MarkdownlintIssues(MarkdownlintIssuesSettings.FromContent(logFileContent));
- }
-
- ///
- /// Gets an instance of a provider for issues reported by Markdownlint using specified settings.
- ///
- /// The context.
- /// Settings for reading the Markdownlint log.
- /// Instance of a provider for issues reported by Markdownlint.
- ///
- /// Read issues reported by Markdownlint:
- ///
- ///
- ///
- ///
- [CakeMethodAlias]
- [CakeAliasCategory(IssuesAliasConstants.IssueProviderCakeAliasCategory)]
- public static IIssueProvider MarkdownlintIssues(
- this ICakeContext context,
- MarkdownlintIssuesSettings settings)
- {
- context.NotNull(nameof(context));
- settings.NotNull(nameof(settings));
-
- return new MarkdownlintIssuesProvider(context.Log, settings);
- }
}
}
diff --git a/src/Cake.Issues.Markdownlint/Properties/AssemblyInfo.cs b/src/Cake.Issues.Markdownlint/Properties/AssemblyInfo.cs
index 194ae80..5d2e2c9 100644
--- a/src/Cake.Issues.Markdownlint/Properties/AssemblyInfo.cs
+++ b/src/Cake.Issues.Markdownlint/Properties/AssemblyInfo.cs
@@ -11,7 +11,7 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("BBT Software AG")]
[assembly: AssemblyProduct("Cake.Issues")]
-[assembly: AssemblyCopyright("Copyright © 2017 BBT Software AG and contributors")]
+[assembly: AssemblyCopyright("Copyright © BBT Software AG and contributors")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
diff --git a/src/Cake.Issues.Markdownlint/packages.config b/src/Cake.Issues.Markdownlint/packages.config
index d248840..4bc732a 100644
--- a/src/Cake.Issues.Markdownlint/packages.config
+++ b/src/Cake.Issues.Markdownlint/packages.config
@@ -1,15 +1,14 @@
-
-
+
+
-
-
-
+
+
+
+
-
-
-
+
\ No newline at end of file
diff --git a/tools/packages.config b/tools/packages.config
index 3b95cb1..af3212e 100644
--- a/tools/packages.config
+++ b/tools/packages.config
@@ -1,4 +1,4 @@
-
+
\ No newline at end of file