Skip to content

Commit

Permalink
(cake-contribGH-41) Update Cake.Issues to 0.8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
pascalberger committed Oct 12, 2019
1 parent ae4df0a commit 136f4e1
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 54 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Cake.Issues">
<Version>0.7.0</Version>
<Version>0.8.0-beta0001</Version>
</PackageReference>
<PackageReference Include="Cake.Issues.Testing">
<Version>0.7.0</Version>
<Version>0.8.0-beta0001</Version>
</PackageReference>
<PackageReference Include="Cake.Testing">
<Version>0.33.0</Version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<Version>0.33.0</Version>
</PackageReference>
<PackageReference Include="Cake.Issues">
<Version>0.7.0</Version>
<Version>0.8.0-beta0001</Version>
</PackageReference>
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers">
<Version>2.9.6</Version>
Expand Down
51 changes: 11 additions & 40 deletions src/Cake.Issues.GitRepository/GitRepositoryIssuesProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,18 +74,18 @@ public GitRepositoryIssuesProvider(
protected GitRepositoryIssuesSettings IssueProviderSettings { get; private set; }

/// <inheritdoc />
protected override IEnumerable<IIssue> InternalReadIssues(IssueCommentFormat format)
protected override IEnumerable<IIssue> InternalReadIssues()
{
var result = new List<IIssue>();

if (this.IssueProviderSettings.CheckBinaryFilesTrackedByLfs)
{
result.AddRange(this.CheckForBinaryFilesNotTrackedByLfs(format));
result.AddRange(this.CheckForBinaryFilesNotTrackedByLfs());
}

if (this.IssueProviderSettings.CheckFilesPathLength)
{
result.AddRange(this.CheckForFilesPathLength(format));
result.AddRange(this.CheckForFilesPathLength());
}

return result;
Expand All @@ -94,9 +94,8 @@ protected override IEnumerable<IIssue> InternalReadIssues(IssueCommentFormat for
/// <summary>
/// Checks for binary files which are not tracked by LFS.
/// </summary>
/// <param name="format">Preferred format of the messages.</param>
/// <returns>List of issues for binary files which are not tracked by LFS.</returns>
private IEnumerable<IIssue> CheckForBinaryFilesNotTrackedByLfs(IssueCommentFormat format)
private IEnumerable<IIssue> CheckForBinaryFilesNotTrackedByLfs()
{
if (!this.allFiles.Value.Any())
{
Expand All @@ -115,25 +114,13 @@ private IEnumerable<IIssue> CheckForBinaryFilesNotTrackedByLfs(IssueCommentForma
var result = new List<IIssue>();
foreach (var file in binaryFilesNotTrackedByLfs)
{
string message = null;
switch (format)
{
case IssueCommentFormat.Markdown:
message = $"The binary file `{file}` is not tracked by Git LFS";
break;
case IssueCommentFormat.Html:
message = $"The binary file <pre>{file}</pre> is not tracked by Git LFS";
break;
default:
message = $"The binary file \"{file}\" is not tracked by Git LFS";
break;
}

var ruleDescription = new BinaryFileNotTrackedByLfsRuleDescription();

result.Add(
IssueBuilder
.NewIssue(message, this)
.NewIssue($"The binary file \"{file}\" is not tracked by Git LFS", this)
.WithMessageInHtmlFormat($"The binary file <pre>{file}</pre> is not tracked by Git LFS")
.WithMessageInMarkdownFormat($"The binary file `{file}` is not tracked by Git LFS")
.InFile(file)
.OfRule(ruleDescription)
.Create());
Expand All @@ -145,9 +132,8 @@ private IEnumerable<IIssue> CheckForBinaryFilesNotTrackedByLfs(IssueCommentForma
/// <summary>
/// Checks for files path length.
/// </summary>
/// <param name="format">Preferred format of the messages.</param>
/// <returns>List of issues for repository files with paths exceeding the allowed maximum.</returns>
private IEnumerable<IIssue> CheckForFilesPathLength(IssueCommentFormat format)
private IEnumerable<IIssue> CheckForFilesPathLength()
{
if (!this.allFiles.Value.Any())
{
Expand All @@ -159,28 +145,13 @@ private IEnumerable<IIssue> CheckForFilesPathLength(IssueCommentFormat format)
{
if (file.Length > this.IssueProviderSettings.MaxFilePathLength)
{
string message = null;
switch (format)
{
case IssueCommentFormat.Markdown:
message =
$"The path for the file `{file}` is too long. Maximum allowed path length is {this.IssueProviderSettings.MaxFilePathLength}, actual path length is {file.Length}.";
break;
case IssueCommentFormat.Html:
message =
$"The path for the file <pre>{file}</pre> is too long. Maximum allowed path length is {this.IssueProviderSettings.MaxFilePathLength}, actual path length is {file.Length}.";
break;
default:
message =
$"The path for the file \"{file}\" is too long. Maximum allowed path length is {this.IssueProviderSettings.MaxFilePathLength}, actual path length is {file.Length}.";
break;
}

var ruleDescription = new FilePathTooLongRuleDescription();

result.Add(
IssueBuilder
.NewIssue(message, this)
.NewIssue($"The path for the file \"{file}\" is too long. Maximum allowed path length is {this.IssueProviderSettings.MaxFilePathLength}, actual path length is {file.Length}.", this)
.WithMessageInHtmlFormat($"The path for the file <pre>{file}</pre> is too long. Maximum allowed path length is {this.IssueProviderSettings.MaxFilePathLength}, actual path length is {file.Length}.")
.WithMessageInMarkdownFormat($"The path for the file `{file}` is too long. Maximum allowed path length is {this.IssueProviderSettings.MaxFilePathLength}, actual path length is {file.Length}.")
.InFile(file)
.OfRule(ruleDescription)
.Create());
Expand Down
16 changes: 5 additions & 11 deletions tests/integration/tests.cake
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#addin nuget:?package=Cake.Issues
#addin nuget:?package=Cake.Issues.Reporting
#addin nuget:?package=Cake.Issues.Reporting.Generic
#addin nuget:?package=Cake.Issues&prerelease
#addin nuget:?package=Cake.Issues.Reporting&prerelease
#addin nuget:?package=Cake.Issues.Reporting.Generic&prerelease
#reference "../../tools/Addins/Cake.Issues.GitRepository/lib/netstandard2.0/Cake.Issues.GitRepository.dll"

//////////////////////////////////////////////////
Expand Down Expand Up @@ -38,10 +38,7 @@ Task("CheckBinaryFilesTrackedByLfs")
{
CheckBinaryFilesTrackedByLfs = true
}),
new ReadIssuesSettings(repoRootDir)
{
Format = IssueCommentFormat.Html
});
new ReadIssuesSettings(repoRootDir));

var reportDir =
repoRootDir.Combine("BuildArtifacts").Combine("TestResults").Combine("Integration");
Expand Down Expand Up @@ -70,10 +67,7 @@ Task("CheckFilesPathLength")
CheckFilesPathLength = true,
MaxFilePathLength = 60
}),
new ReadIssuesSettings(repoRootDir)
{
Format = IssueCommentFormat.Html
});
new ReadIssuesSettings(repoRootDir));

var reportDir =
repoRootDir.Combine("BuildArtifacts").Combine("TestResults").Combine("Integration");
Expand Down

0 comments on commit 136f4e1

Please sign in to comment.