Skip to content
This repository has been archived by the owner on Dec 26, 2023. It is now read-only.

Commit

Permalink
Merge branch 'release/0.3.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
pascalberger committed Jun 4, 2018
2 parents 6fde1ff + 09936fe commit 8b67912
Show file tree
Hide file tree
Showing 14 changed files with 175 additions and 56 deletions.
2 changes: 1 addition & 1 deletion nuspec/nuget/Cake.Issues.Markdownlint.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ See the Project Site for an overview of the whole ecosystem of addins for workin
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<copyright>Copyright © BBT Software AG and contributors</copyright>
<tags>Cake Script Cake-Issues Cake-IssueProvider Linting Markdownlint</tags>
<releaseNotes>https://github.com/cake-contrib/Cake.Issues.Markdownlint/releases/tag/0.2.0</releaseNotes>
<releaseNotes>https://github.com/cake-contrib/Cake.Issues.Markdownlint/releases/tag/0.3.0</releaseNotes>
</metadata>
<files>
<file src="Cake.Issues.Markdownlint.dll" target="lib\net46" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,17 @@
<CodeAnalysisRuleSet>..\Cake.Issues.Markdownlint.Tests.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="Cake.Core, Version=0.26.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Cake.Core.0.26.0\lib\net46\Cake.Core.dll</HintPath>
<Reference Include="Cake.Core, Version=0.28.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Cake.Core.0.28.0\lib\net46\Cake.Core.dll</HintPath>
</Reference>
<Reference Include="Cake.Issues, Version=0.2.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Cake.Issues.0.2.0\lib\netstandard2.0\Cake.Issues.dll</HintPath>
<Reference Include="Cake.Issues, Version=0.3.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Cake.Issues.0.3.0\lib\netstandard2.0\Cake.Issues.dll</HintPath>
</Reference>
<Reference Include="Cake.Issues.Testing, Version=0.2.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Cake.Issues.Testing.0.2.0\lib\netstandard2.0\Cake.Issues.Testing.dll</HintPath>
<Reference Include="Cake.Issues.Testing, Version=0.3.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Cake.Issues.Testing.0.3.0\lib\netstandard2.0\Cake.Issues.Testing.dll</HintPath>
</Reference>
<Reference Include="Cake.Testing, Version=0.26.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Cake.Testing.0.26.0\lib\net46\Cake.Testing.dll</HintPath>
<Reference Include="Cake.Testing, Version=0.28.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Cake.Testing.0.28.0\lib\net46\Cake.Testing.dll</HintPath>
</Reference>
<Reference Include="Shouldly, Version=3.0.0.0, Culture=neutral, PublicKeyToken=6042cbcb05cbc941, processorArchitecture=MSIL">
<HintPath>..\packages\Shouldly.3.0.0\lib\net451\Shouldly.dll</HintPath>
Expand Down Expand Up @@ -97,12 +97,13 @@
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
<EmbeddedResource Include="Testfiles\markdownlint-cli.log" />
<EmbeddedResource Include="Testfiles\markdownlint-cli-0-8-1.log" />
<EmbeddedResource Include="Testfiles\markdownlint-cli-0.10.0.log" />
</ItemGroup>
<ItemGroup>
<Analyzer Include="..\packages\StyleCop.Analyzers.1.0.2\analyzers\dotnet\cs\StyleCop.Analyzers.CodeFixes.dll" />
<Analyzer Include="..\packages\StyleCop.Analyzers.1.0.2\analyzers\dotnet\cs\StyleCop.Analyzers.dll" />
<Analyzer Include="..\packages\xunit.analyzers.0.8.0\analyzers\dotnet\cs\xunit.analyzers.dll" />
<Analyzer Include="..\packages\xunit.analyzers.0.9.0\analyzers\dotnet\cs\xunit.analyzers.dll" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,23 +57,26 @@ public void Should_Read_Issue_Correct()
3,
"MD010",
"https://github.com/DavidAnson/markdownlint/blob/master/doc/Rules.md#md010",
0,
300,
"Warning",
"Hard tabs");
CheckIssue(
issues[1],
@"bad.md",
1,
"MD018",
"https://github.com/DavidAnson/markdownlint/blob/master/doc/Rules.md#md018",
0,
300,
"Warning",
"No space after hash on atx style header");
CheckIssue(
issues[2],
@"bad.md",
3,
"MD018",
"https://github.com/DavidAnson/markdownlint/blob/master/doc/Rules.md#md018",
0,
300,
"Warning",
"No space after hash on atx style header");
}

Expand All @@ -84,8 +87,12 @@ private static void CheckIssue(
string rule,
string ruleUrl,
int priority,
string priorityName,
string message)
{
issue.ProviderType.ShouldBe("Cake.Issues.Markdownlint.Markdownlint.MarkdownlintIssuesProvider");
issue.ProviderName.ShouldBe("markdownlint");

if (issue.AffectedFileRelativePath == null)
{
affectedFileRelativePath.ShouldBeNull();
Expand All @@ -109,6 +116,7 @@ private static void CheckIssue(
}

issue.Priority.ShouldBe(priority);
issue.PriorityName.ShouldBe(priorityName);
issue.Message.ShouldBe(message);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ public void Should_Throw_If_Settings_Are_Null()
public sealed class TheReadIssuesMethod
{
[Fact]
public void Should_Read_Issue_Correct()
public void Should_Read_Issue_Correct_0_8_1()
{
// Given
var fixture = new MarkdownlintCliIssuesProviderFixture("markdownlint-cli.log");
var fixture = new MarkdownlintCliIssuesProviderFixture("markdownlint-cli-0-8-1.log");

// When
var issues = fixture.ReadIssues().ToList();
Expand All @@ -57,75 +57,172 @@ public void Should_Read_Issue_Correct()
1,
"MD022",
"https://github.com/DavidAnson/markdownlint/blob/master/doc/Rules.md#md022",
0,
300,
"Warning",
"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,
300,
"Warning",
"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,
300,
"Warning",
"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,
300,
"Warning",
"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,
300,
"Warning",
"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,
300,
"Warning",
"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,
300,
"Warning",
"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,
300,
"Warning",
"Trailing spaces [Expected: 2; Actual: 1]");
}

[Fact]
public void Should_Read_Issue_Correct_0_10_0()
{
// Given
var fixture = new MarkdownlintCliIssuesProviderFixture("markdownlint-cli-0.10.0.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",
300,
"Warning",
"Headings 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",
300,
"Warning",
"Trailing spaces [Expected: 0 or 2; Actual: 1]");
CheckIssue(
issues[2],
@"docs/index.md",
2,
"MD013",
"https://github.com/DavidAnson/markdownlint/blob/master/doc/Rules.md#md013",
300,
"Warning",
"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",
300,
"Warning",
"Headings 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",
300,
"Warning",
"Multiple top level headings 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",
300,
"Warning",
"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",
300,
"Warning",
"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",
300,
"Warning",
"Trailing spaces [Expected: 0 or 2; Actual: 1]");
}

private static void CheckIssue(
IIssue issue,
string affectedFileRelativePath,
int? line,
string rule,
string ruleUrl,
int priority,
string priorityName,
string message)
{
issue.ProviderType.ShouldBe("Cake.Issues.Markdownlint.MarkdownlintCli.MarkdownlintCliIssuesProvider");
issue.ProviderName.ShouldBe("markdownlint");

if (issue.AffectedFileRelativePath == null)
{
affectedFileRelativePath.ShouldBeNull();
Expand All @@ -149,6 +246,7 @@ private static void CheckIssue(
}

issue.Priority.ShouldBe(priority);
issue.PriorityName.ShouldBe(priorityName);
issue.Message.ShouldBe(message);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public void Should_Read_File_From_Disk()
// Given
string expected;
using (var ms = new MemoryStream())
using (var stream = this.GetType().Assembly.GetManifestResourceStream("Cake.Issues.Markdownlint.Tests.Testfiles.markdownlint-cli.log"))
using (var stream = this.GetType().Assembly.GetManifestResourceStream("Cake.Issues.Markdownlint.Tests.Testfiles.markdownlint-cli-0-8-1.log"))
{
stream.CopyTo(ms);
var data = ms.ToArray();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
C:/Git/Test/Cake.Prca/docs/index.md: 1: MD022/blanks-around-headings/blanks-around-headers Headings should be surrounded by blank lines [Context: "# foo"]
C:/Git/Test/Cake.Prca/docs/index.md: 2: MD009/no-trailing-spaces Trailing spaces [Expected: 0 or 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-headings/blanks-around-headers Headings should be surrounded by blank lines [Context: "# bar"]
C:/Git/Test/Cake.Prca/docs/index.md: 4: MD025/single-h1 Multiple top level headings 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: 0 or 2; Actual: 1]
10 changes: 5 additions & 5 deletions src/Cake.Issues.Markdownlint.Tests/packages.config
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Cake.Core" version="0.26.0" targetFramework="net461" />
<package id="Cake.Issues" version="0.2.0" targetFramework="net461" />
<package id="Cake.Issues.Testing" version="0.2.0" targetFramework="net461" />
<package id="Cake.Testing" version="0.26.0" targetFramework="net461" />
<package id="Cake.Core" version="0.28.0" targetFramework="net461" />
<package id="Cake.Issues" version="0.3.0" targetFramework="net461" />
<package id="Cake.Issues.Testing" version="0.3.0" targetFramework="net461" />
<package id="Cake.Testing" version="0.28.0" targetFramework="net461" />
<package id="Shouldly" version="3.0.0" targetFramework="net46" />
<package id="StyleCop.Analyzers" version="1.0.2" targetFramework="net46" developmentDependency="true" />
<package id="xunit" version="2.3.1" targetFramework="net46" />
<package id="xunit.abstractions" version="2.0.1" targetFramework="net46" />
<package id="xunit.analyzers" version="0.8.0" targetFramework="net46" />
<package id="xunit.analyzers" version="0.9.0" targetFramework="net461" />
<package id="xunit.assert" version="2.3.1" targetFramework="net46" />
<package id="xunit.core" version="2.3.1" targetFramework="net46" />
<package id="xunit.extensibility.core" version="2.3.1" targetFramework="net46" />
Expand Down
12 changes: 6 additions & 6 deletions src/Cake.Issues.Markdownlint/Cake.Issues.Markdownlint.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,18 @@
<CodeAnalysisRuleSet>..\Cake.Issues.Markdownlint.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="Cake.Core, Version=0.26.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Cake.Core.0.26.0\lib\net46\Cake.Core.dll</HintPath>
<Reference Include="Cake.Core, Version=0.28.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Cake.Core.0.28.0\lib\net46\Cake.Core.dll</HintPath>
</Reference>
<Reference Include="Cake.Issues, Version=0.2.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Cake.Issues.0.2.0\lib\netstandard2.0\Cake.Issues.dll</HintPath>
<Reference Include="Cake.Issues, Version=0.3.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Cake.Issues.0.3.0\lib\netstandard2.0\Cake.Issues.dll</HintPath>
</Reference>
<Reference Include="Costura, Version=1.6.2.0, Culture=neutral, PublicKeyToken=9919ef960d84173d, processorArchitecture=MSIL">
<HintPath>..\packages\Costura.Fody.1.6.2\lib\dotnet\Costura.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
<Reference Include="Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.11.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ public MarkdownlintIssuesProvider(ICakeLog log, MarkdownlintIssuesSettings setti
this.settings = settings;
}

/// <inheritdoc />
public override string ProviderName => "markdownlint";

/// <inheritdoc />
protected override IEnumerable<IIssue> InternalReadIssues(IssueCommentFormat format)
{
Expand All @@ -38,13 +41,12 @@ from entry in file.Value
let
rule = (string)entry.SelectToken("ruleName")
select
new Issue<MarkdownlintIssuesProvider>(
file.Key,
(int)entry.SelectToken("lineNumber"),
(string)entry.SelectToken("ruleDescription"),
0,
rule,
MarkdownlintRuleUrlResolver.Instance.ResolveRuleUrl(rule));
IssueBuilder
.NewIssue((string)entry.SelectToken("ruleDescription"), this)
.InFile(file.Key, (int)entry.SelectToken("lineNumber"))
.WithPriority(IssuePriority.Warning)
.OfRule(rule, MarkdownlintRuleUrlResolver.Instance.ResolveRuleUrl(rule))
.Create();
}
}
}
Loading

0 comments on commit 8b67912

Please sign in to comment.