Skip to content

Commit

Permalink
Merge branch 'release/1.0.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
pascalberger committed Jul 30, 2021
2 parents 5e4866f + c5ad668 commit 73e26e9
Show file tree
Hide file tree
Showing 9 changed files with 139 additions and 87 deletions.
49 changes: 49 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
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:
- ">= 0.36.a, < 0.37"
- dependency-name: Cake.Core
versions:
- ">= 0.37.a, < 0.38"
- dependency-name: Cake.Core
versions:
- ">= 0.38.a, < 0.39"
- dependency-name: Cake.Issues
versions:
- "> 0.9.0, < 0.10"
- dependency-name: Cake.Testing
versions:
- ">= 0.36.a, < 0.37"
- dependency-name: Cake.Testing
versions:
- ">= 0.37.a, < 0.38"
- dependency-name: Cake.Testing
versions:
- ">= 0.38.a, < 0.39"
- dependency-name: Microsoft.NET.Test.Sdk
versions:
- 16.8.3
- 16.9.1
- dependency-name: Cake.Core
versions:
- 1.0.0
- dependency-name: Cake.Testing
versions:
- 1.0.0
- dependency-name: Shouldly
versions:
- 4.0.3
- dependency-name: Microsoft.CodeAnalysis.FxCopAnalyzers
versions:
- 3.3.2
- dependency-name: Cake.Issues.Testing
versions:
- 0.9.1
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ and for general information about the Cake build automation system see the [Cake

- [Documentation](https://cakeissues.net)

## Chat Room
## Discussion

Come join in the conversation about this addin in our Gitter Chat Room.
For questions and to discuss ideas & feature requests, use the [GitHub discussions on the Cake GitHub repository](https://github.com/cake-build/cake/discussions), under the [Extension Q&A](https://github.com/cake-build/cake/discussions/categories/extension-q-a) category.

[![Join the chat at https://gitter.im/cake-contrib/Lobby](https://badges.gitter.im/cake-contrib/Lobby.svg)](https://gitter.im/cake-contrib/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![Join in the discussion on the Cake repository](https://img.shields.io/badge/GitHub-Discussions-green?logo=github)](https://github.com/cake-build/cake/discussions)

## Contributing

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 @@ -23,8 +23,8 @@ See the Project Site for an overview of the whole ecosystem of addins for workin
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<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.9.0</releaseNotes>
<tags>cake cake-addin cake-issues cake-issueprovider codeanalysis dupFinder</tags>
<releaseNotes>https://github.com/cake-contrib/Cake.Issues.DupFinder/releases/tag/1.0.0</releaseNotes>
</metadata>
<files>
<file src="..\..\..\..\nuspec\nuget\icon.png" target="" />
Expand Down
Binary file modified nuspec/nuget/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@
</ItemGroup>

<ItemGroup>
<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="Cake.Issues" Version="1.0.0" />
<PackageReference Include="Cake.Issues.Testing" Version="1.0.0" />
<PackageReference Include="Cake.Testing" Version="1.0.0" />
<PackageReference Include="Shouldly" Version="4.0.3" />
<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.7.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.10.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ public sealed class TheReadIssuesMethod
"<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 @@ -83,8 +82,8 @@ public void Should_Read_Issue_Correct()

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

var issueToVerify = issues.Single(i =>
Expand All @@ -103,6 +102,7 @@ public void Should_Read_Issue_Correct()
.InFile(@"Src\Foo.cs", 16, 232, null, null)
.OfRule("dupFinder")
.WithPriority(IssuePriority.Warning)
.WithAdditionalInformation("cost", "100")
.Create());
}

Expand All @@ -128,7 +128,6 @@ public void ShouldReadBigFileWith1000DuplicatesInUnder200Milliseconds()
sw.ElapsedMilliseconds.ShouldBeLessThan(2000);
}


[Fact]
public void ShouldNotSetTheFileLinkWhenSettingsWereNotProvided()
{
Expand Down Expand Up @@ -179,6 +178,7 @@ public void ShouldAddRealUrlsToMessagesIfFileLinkSettingsWereProvided()
.InFile(@"Src\Foo.cs", 16, 232, null, null)
.OfRule("dupFinder")
.WithPriority(IssuePriority.Warning)
.WithAdditionalInformation("cost", "100")
.Create());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public void Should_Throw_If_LogFilePath_Is_Null()
FilePath logFilePath = null;

// When
// ReSharper disable once ExpressionIsAlwaysNull
var result = Record.Exception(() => new DupFinderIssuesSettings(logFilePath));

// Then
Expand All @@ -30,6 +31,7 @@ public void Should_Throw_If_LogFileContent_Is_Null()
byte[] logFileContent = null;

// When
// ReSharper disable once ExpressionIsAlwaysNull
var result = Record.Exception(() => new DupFinderIssuesSettings(logFileContent));

// Then
Expand Down
6 changes: 3 additions & 3 deletions src/Cake.Issues.DupFinder/Cake.Issues.DupFinder.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Cake.Core" Version="0.33.0" />
<PackageReference Include="Cake.Issues" Version="0.9.0" />
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="3.3.0">
<PackageReference Include="Cake.Core" Version="1.0.0" />
<PackageReference Include="Cake.Issues" Version="1.0.0" />
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="5.0.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
141 changes: 71 additions & 70 deletions src/Cake.Issues.DupFinder/DupFinderIssuesProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ protected override IEnumerable<IIssue> InternalReadIssues()
.InFile(fragment.FilePath, fragment.LineStart, fragment.LineEnd, null, null)
.OfRule("dupFinder")
.WithPriority(IssuePriority.Warning)
.WithAdditionalInformation("cost", cost.ToString())
.Create();

result.Add(issue);
Expand All @@ -82,76 +83,6 @@ private static string GetIdentifier(int cost, IReadOnlyCollection<DuplicateFragm
return $"{fragment.FilePath}-{cost}-{string.Join("-", otherFragments)}";
}

private string GetHtmlMessage(int cost, IReadOnlyCollection<DuplicateFragment> fragments, DuplicateFragment fragment)
{
var builder = new StringBuilder();
builder.Append($"Possible duplicate detected (cost {cost}).");
builder.Append("<br/>The following fragments were found that might be duplicates:");
foreach (var possibleDuplicateFragment in fragments.Where(f => !f.Equals(fragment)))
{
builder.Append("<br/>");

var link = this.ResolveFileLinkForFragment(possibleDuplicateFragment);
builder.Append(
link == null
? $"<code>{possibleDuplicateFragment.FilePath}</code> (Line {possibleDuplicateFragment.LineStart} to {possibleDuplicateFragment.LineEnd})"
: $"<a href='{link}'>{possibleDuplicateFragment.FilePath}</a> (Line {possibleDuplicateFragment.LineStart} to {possibleDuplicateFragment.LineEnd})");
}

return builder.ToString();
}

private string GetMarkdownMessage(int cost, IReadOnlyCollection<DuplicateFragment> fragments, DuplicateFragment fragment)
{
var builder = new StringBuilder();
builder.Append($"Possible duplicate detected (cost {cost}).\r\n");
builder.Append("The following fragments were found that might be duplicates:");
foreach (var possibleDuplicateFragment in fragments.Where(f => !f.Equals(fragment)))
{
builder.Append("\r\n");

var link = this.ResolveFileLinkForFragment(possibleDuplicateFragment);
builder.Append(
link == null
? $"`{possibleDuplicateFragment.FilePath}` (Line {possibleDuplicateFragment.LineStart} to {possibleDuplicateFragment.LineEnd})"
: $"[{possibleDuplicateFragment.FilePath}]({link}) (Line {possibleDuplicateFragment.LineStart} to {possibleDuplicateFragment.LineEnd})");
}

return builder.ToString();
}

private Uri ResolveFileLinkForFragment(DuplicateFragment fragment)
{
if (this.Settings?.FileLinkSettings == null)
{
return null;
}

var issue =
IssueBuilder
.NewIssue(fragment.FilePath, fragment.FilePath, this)
.InFile(fragment.FilePath, fragment.LineStart, fragment.LineEnd, null, null)
.Create();

var resolvedPattern = this.Settings.FileLinkSettings.GetFileLink(issue);
return resolvedPattern;
}

private static string GetSimpleMessage(int cost, IReadOnlyCollection<DuplicateFragment> fragments, DuplicateFragment fragment)
{
var builder = new StringBuilder();
builder.Append($"Possible duplicate detected (cost {cost}).\r\n");
builder.Append("The following fragments were found that might be duplicates:");
foreach (var possibleDuplicateFragment in fragments.Where(f => !f.Equals(fragment)))
{
builder.Append("\r\n");
builder.Append(
$"\"{possibleDuplicateFragment.FilePath}\" (Line {possibleDuplicateFragment.LineStart} to {possibleDuplicateFragment.LineEnd})");
}

return builder.ToString();
}

private static bool TryGetCost(XElement duplicate, out int cost)
{
cost = 0;
Expand Down Expand Up @@ -208,6 +139,76 @@ private static bool TryGetLine(XContainer fragment, out int lineStart, out int l
return true;
}

private static string GetSimpleMessage(int cost, IReadOnlyCollection<DuplicateFragment> fragments, DuplicateFragment fragment)
{
var builder = new StringBuilder();
builder.Append($"Possible duplicate detected (cost {cost}).\r\n");
builder.Append("The following fragments were found that might be duplicates:");
foreach (var possibleDuplicateFragment in fragments.Where(f => !f.Equals(fragment)))
{
builder.Append("\r\n");
builder.Append(
$"\"{possibleDuplicateFragment.FilePath}\" (Line {possibleDuplicateFragment.LineStart} to {possibleDuplicateFragment.LineEnd})");
}

return builder.ToString();
}

private string GetHtmlMessage(int cost, IReadOnlyCollection<DuplicateFragment> fragments, DuplicateFragment fragment)
{
var builder = new StringBuilder();
builder.Append($"Possible duplicate detected (cost {cost}).");
builder.Append("<br/>The following fragments were found that might be duplicates:");
foreach (var possibleDuplicateFragment in fragments.Where(f => !f.Equals(fragment)))
{
builder.Append("<br/>");

var link = this.ResolveFileLinkForFragment(possibleDuplicateFragment);
builder.Append(
link == null
? $"<code>{possibleDuplicateFragment.FilePath}</code> (Line {possibleDuplicateFragment.LineStart} to {possibleDuplicateFragment.LineEnd})"
: $"<a href='{link}'>{possibleDuplicateFragment.FilePath}</a> (Line {possibleDuplicateFragment.LineStart} to {possibleDuplicateFragment.LineEnd})");
}

return builder.ToString();
}

private string GetMarkdownMessage(int cost, IReadOnlyCollection<DuplicateFragment> fragments, DuplicateFragment fragment)
{
var builder = new StringBuilder();
builder.Append($"Possible duplicate detected (cost {cost}).\r\n");
builder.Append("The following fragments were found that might be duplicates:");
foreach (var possibleDuplicateFragment in fragments.Where(f => !f.Equals(fragment)))
{
builder.Append("\r\n");

var link = this.ResolveFileLinkForFragment(possibleDuplicateFragment);
builder.Append(
link == null
? $"`{possibleDuplicateFragment.FilePath}` (Line {possibleDuplicateFragment.LineStart} to {possibleDuplicateFragment.LineEnd})"
: $"[{possibleDuplicateFragment.FilePath}]({link}) (Line {possibleDuplicateFragment.LineStart} to {possibleDuplicateFragment.LineEnd})");
}

return builder.ToString();
}

private Uri ResolveFileLinkForFragment(DuplicateFragment fragment)
{
if (this.Settings?.FileLinkSettings == null)
{
return null;
}

var issue =
IssueBuilder
.NewIssue(fragment.FilePath, fragment.FilePath, this)
.InFile(fragment.FilePath, fragment.LineStart, fragment.LineEnd, null, null)
.Create();

var resolvedPattern = this.Settings.FileLinkSettings.GetFileLink(issue);
return resolvedPattern;
}

private IReadOnlyCollection<DuplicateFragment> GetDuplicateFragments(XContainer duplicate)
{
var items = new List<DuplicateFragment>();
Expand Down

0 comments on commit 73e26e9

Please sign in to comment.