Skip to content

Commit

Permalink
Merge branch 'release/0.9.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
pascalberger committed Aug 22, 2020
2 parents c181b31 + 83f5bae commit 5e4866f
Show file tree
Hide file tree
Showing 7 changed files with 153 additions and 31 deletions.
5 changes: 5 additions & 0 deletions docs/features.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,15 @@ The [Cake.Issues.DupFinder addin] provides the following features:
|--------------------------------------------------------------------|-----------------------------------|----------------------------------|
| <span class="glyphicon glyphicon-ok" style="color:green"></span> | `IIssue.ProviderType` | |
| <span class="glyphicon glyphicon-ok" style="color:green"></span> | `IIssue.ProviderName` | |
| <span class="glyphicon glyphicon-ok" style="color:green"></span> | `IIssue.Run` | Can be set while reading issues |
| <span class="glyphicon glyphicon-ok" style="color:green"></span> | `IIssue.Identifier` | |
| <span class="glyphicon glyphicon-remove" style="color:red"></span> | `IIssue.ProjectName` | |
| <span class="glyphicon glyphicon-remove" style="color:red"></span> | `IIssue.ProjectFileRelativePath` | |
| <span class="glyphicon glyphicon-ok" style="color:green"></span> | `IIssue.AffectedFileRelativePath` | |
| <span class="glyphicon glyphicon-ok" style="color:green"></span> | `IIssue.Line` | |
| <span class="glyphicon glyphicon-ok" style="color:green"></span> | `IIssue.EndLine` | |
| <span class="glyphicon glyphicon-remove" style="color:red"></span> | `IIssue.Column` | |
| <span class="glyphicon glyphicon-remove" style="color:red"></span> | `IIssue.EndColumn` | |
| <span class="glyphicon glyphicon-ok" style="color:green"></span> | `IIssue.MessageText` | |
| <span class="glyphicon glyphicon-ok" style="color:green"></span> | `IIssue.MessageHtml` | |
| <span class="glyphicon glyphicon-ok" style="color:green"></span> | `IIssue.MessageMarkdown` | |
Expand Down
4 changes: 2 additions & 2 deletions nuspec/nuget/Cake.Issues.DupFinder.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ See the Project Site for an overview of the whole ecosystem of addins for workin
<repository type="git" url="https://github.com/cake-contrib/Cake.Issues.DupFinder.git"/>
<copyright>Copyright © janniksam and contributors</copyright>
<tags>Cake Script Cake-Issues Cake-IssueProvider CodeAnalysis Linting DupFinder</tags>
<releaseNotes>https://github.com/cake-contrib/Cake.Issues.DupFinder/releases/tag/0.8.0</releaseNotes>
<releaseNotes>https://github.com/cake-contrib/Cake.Issues.DupFinder/releases/tag/0.9.0</releaseNotes>
</metadata>
<files>
<file src="..\..\..\..\nuspec\nuget\icon.png" target="" />
Expand All @@ -35,4 +35,4 @@ See the Project Site for an overview of the whole ecosystem of addins for workin
<file src="netstandard2.0/Cake.Issues.DupFinder.pdb" target="lib\netstandard2.0" />
<file src="netstandard2.0/Cake.Issues.DupFinder.xml" target="lib\netstandard2.0" />
</files>
</package>
</package>
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Cake.Issues" Version="0.8.0" />
<PackageReference Include="Cake.Issues.Testing" Version="0.8.0" />
<PackageReference Include="Cake.Issues" Version="0.9.0" />
<PackageReference Include="Cake.Issues.Testing" Version="0.9.0" />
<PackageReference Include="Cake.Testing" Version="0.33.0" />
<PackageReference Include="Shouldly" Version="3.0.2" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.6.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
Expand Down
82 changes: 77 additions & 5 deletions src/Cake.Issues.DupFinder.Tests/DupFinderIssuesProviderTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
namespace Cake.Issues.DupFinder.Tests
{
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
Expand Down Expand Up @@ -38,6 +39,9 @@ public void Should_Throw_If_IssueProviderSettings_Are_Null()

public sealed class TheReadIssuesMethod
{
private const string ExpectedIssueIdentifier =
"Src\\Foo.cs-100-Src\\Bar.cs-Src\\FooBar.cs";

private const string ExpectedIssueMessage =
"Possible duplicate detected (cost 100).\r\nThe following fragments were found that might be duplicates:\r\n" +
"\"Src\\Bar.cs\" (Line 17 to 233)\r\n" +
Expand All @@ -55,6 +59,19 @@ public sealed class TheReadIssuesMethod
"<code>Src\\Bar.cs</code> (Line 17 to 233)<br/>" +
"<code>Src\\FooBar.cs</code> (Line 18 to 234)";

private const string ExpectedIssueMarkdownMessageWithResolvedUrl =
"Possible duplicate detected (cost 100).\r\n" +
"The following fragments were found that might be duplicates:\r\n" +
"[Src\\Bar.cs](http://myserver:8080/tfs/_git/myRepository?path=/Src/Bar.cs&version=GBdevelop&line=17&lineEnd=233&lineStartColumn=1&lineEndColumn=2147483647) (Line 17 to 233)\r\n" +
"[Src\\FooBar.cs](http://myserver:8080/tfs/_git/myRepository?path=/Src/FooBar.cs&version=GBdevelop&line=18&lineEnd=234&lineStartColumn=1&lineEndColumn=2147483647) (Line 18 to 234)";

private const string ExpectedIssueHtmlMessageWithResolvedUrl =
"Possible duplicate detected (cost 100).<br/>" +
"The following fragments were found that might be duplicates:<br/>" +
"<a href='http://myserver:8080/tfs/_git/myRepository?path=/Src/Bar.cs&version=GBdevelop&line=17&lineEnd=233&lineStartColumn=1&lineEndColumn=2147483647'>Src\\Bar.cs</a> (Line 17 to 233)<br/>" +
"<a href='http://myserver:8080/tfs/_git/myRepository?path=/Src/FooBar.cs&version=GBdevelop&line=18&lineEnd=234&lineStartColumn=1&lineEndColumn=2147483647'>Src\\FooBar.cs</a> (Line 18 to 234)";


[Fact]
public void Should_Read_Issue_Correct()
{
Expand All @@ -68,28 +85,29 @@ public void Should_Read_Issue_Correct()
issues.Count.ShouldBe(5);
issues.Count(i =>
i.FilePath() == "Src/Foo.cs" &&
i.Line == 16).ShouldBe(1);
i.Line == 16 && i.EndLine == 232).ShouldBe(1);

var issueToVerify = issues.Single(i =>
i.FilePath() == "Src/Foo.cs" &&
i.Line == 16);
i.Line == 16 && i.EndLine == 232);

IssueChecker.Check(
issueToVerify,
IssueBuilder.NewIssue(
ExpectedIssueIdentifier,
ExpectedIssueMessage,
"Cake.Issues.DupFinder.DupFinderIssuesProvider",
"DupFinder")
.WithMessageInMarkdownFormat(ExpectedIssueMarkdownMessage)
.WithMessageInHtmlFormat(ExpectedIssueHtmlMessage)
.InFile(@"Src\Foo.cs", 16)
.InFile(@"Src\Foo.cs", 16, 232, null, null)
.OfRule("dupFinder")
.WithPriority(IssuePriority.Warning)
.Create());
}

[Fact(Timeout = 50)]
public void ShouldReadBigFileWith1000DuplicatesInUnder100ms()
public void ShouldReadBigFileWith1000DuplicatesInUnder200Milliseconds()
{
// Given
var fixture = new DupFinderIssuesProviderFixture("DupFinder1000Duplicates.xml");
Expand All @@ -107,7 +125,61 @@ public void ShouldReadBigFileWith1000DuplicatesInUnder100ms()

// Then
issues.Count.ShouldBe(2885);
sw.ElapsedMilliseconds.ShouldBeLessThan(1000);
sw.ElapsedMilliseconds.ShouldBeLessThan(2000);
}


[Fact]
public void ShouldNotSetTheFileLinkWhenSettingsWereNotProvided()
{
// Given
var fixture = new DupFinderIssuesProviderFixture("DupFinder.xml");

// When
IList<IIssue> issues = fixture.ReadIssues().ToList();
foreach (var issue in issues)
{
issue.FileLink.ShouldBeNull();
}
}

[Fact]
public void ShouldAddRealUrlsToMessagesIfFileLinkSettingsWereProvided()
{
// Given
var repositoryUrl = new Uri("http://myserver:8080/tfs/_git/myRepository");
var branch = "develop";

var fixture = new DupFinderIssuesProviderFixture("DupFinder.xml");
fixture.ReadIssuesSettings.FileLinkSettings =
FileLinkSettings.ForAzureDevOps(repositoryUrl).Branch(branch);

// When
var issues = fixture.ReadIssues().ToList();

// Then
issues.Count.ShouldBe(5);
issues.Count(i =>
i.FilePath() == "Src/Foo.cs" &&
i.Line == 16 && i.EndLine == 232).ShouldBe(1);

var issueToVerify = issues.Single(i =>
i.FilePath() == "Src/Foo.cs" &&
i.Line == 16 && i.EndLine == 232);

IssueChecker.Check(
issueToVerify,
IssueBuilder.NewIssue(
ExpectedIssueIdentifier,
ExpectedIssueMessage,
"Cake.Issues.DupFinder.DupFinderIssuesProvider",
"DupFinder")
.WithMessageInMarkdownFormat(ExpectedIssueMarkdownMessageWithResolvedUrl)
.WithMessageInHtmlFormat(ExpectedIssueHtmlMessageWithResolvedUrl)
.InFile(@"Src\Foo.cs", 16, 232, null, null)
.OfRule("dupFinder")
.WithPriority(IssuePriority.Warning)
.Create());
}
}
}
Expand Down
8 changes: 7 additions & 1 deletion src/Cake.Issues.DupFinder.sln.DotSettings
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ArrangeThisQualifier/@EntryIndexedValue">DO_NOT_SHOW</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateInstanceFields/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String></wpf:ResourceDictionary>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=Method/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb_AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateInstanceFields/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/ThisQualifier/INSTANCE_MEMBERS_QUALIFY_MEMBERS/@EntryValue">Field, Property</s:String>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/TRAILING_COMMA_IN_MULTILINE_LISTS/@EntryValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CSharpUsing/AddImportsToDeepestScope/@EntryValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CSharpUsing/QualifiedUsingAtNestedScope/@EntryValue">True</s:Boolean>
</wpf:ResourceDictionary>
7 changes: 5 additions & 2 deletions src/Cake.Issues.DupFinder/Cake.Issues.DupFinder.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,11 @@

<ItemGroup>
<PackageReference Include="Cake.Core" Version="0.33.0" />
<PackageReference Include="Cake.Issues" Version="0.8.0" />
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.8" />
<PackageReference Include="Cake.Issues" Version="0.9.0" />
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="3.3.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
Expand Down
Loading

0 comments on commit 5e4866f

Please sign in to comment.