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

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 27, 2021
2 parents 0be730c + f45a0da commit 804ea42
Show file tree
Hide file tree
Showing 8 changed files with 121 additions and 96 deletions.
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,11 @@ and for general information about the Cake build automation system see the [Cake
## Quick Links

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

## 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.

Come join in the conversation about this addin in our Gitter Chat Room.

[![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.MsBuild.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.MsBuild.git"/>
<copyright>Copyright © BBT Software AG and contributors</copyright>
<tags>Cake Script Cake-Issues Cake-IssueProvider CodeAnalysis Linting MsBuild</tags>
<releaseNotes>https://github.com/cake-contrib/Cake.Issues.MsBuild/releases/tag/0.9.1</releaseNotes>
<tags>cake cake-addin cake-issues cake-issueprovider code-analysis linting msbuild</tags>
<releaseNotes>https://github.com/cake-contrib/Cake.Issues.MsBuild/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.
2 changes: 1 addition & 1 deletion recipe.cake
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ BuildParameters.PrintParameters(Context);
ToolSettings.SetToolSettings(
context: Context,
dupFinderExcludePattern: new string[] { BuildParameters.RootDirectoryPath + "/src/Cake.Issues.MsBuild.Tests/**/*.cs", BuildParameters.RootDirectoryPath + "/src/Cake.Issues.MsBuild*/**/*.AssemblyInfo.cs" },
testCoverageFilter: "+[*]* -[xunit.*]* -[Cake.Core]* -[Cake.Testing]* -[*.Tests]* -[Cake.Issues]* -[Cake.Issues.Testing]* -[Shouldly]* -[Microsoft.Build*]* -[StructuredLogger]*",
testCoverageFilter: "+[*]* -[xunit.*]* -[Cake.Core]* -[Cake.Testing]* -[*.Tests]* -[Cake.Issues]* -[Cake.Issues.Testing]* -[Shouldly]* -[Microsoft.Build*]* -[StructuredLogger]* -[DiffEngine]* -[EmptyFiles]*",
testCoverageExcludeByAttribute: "*.ExcludeFromCodeCoverage*",
testCoverageExcludeByFile: "*/*Designer.cs;*/*.g.cs;*/*.g.i.cs");

Expand Down
12 changes: 6 additions & 6 deletions src/Cake.Issues.MsBuild.Tests/Cake.Issues.MsBuild.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
<PackageReference Include="Cake.Core" Version="0.33.0" />
<PackageReference Include="Cake.Testing" Version="0.33.0" />
<PackageReference Include="Cake.Issues" Version="0.9.0" />
<PackageReference Include="Cake.Issues.Testing" Version="0.9.0" />
<PackageReference Include="Shouldly" Version="3.0.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.1" />
<PackageReference Include="Cake.Core" Version="1.0.0" />
<PackageReference Include="Cake.Testing" Version="1.0.0" />
<PackageReference Include="Cake.Issues" Version="1.0.0" />
<PackageReference Include="Cake.Issues.Testing" Version="1.0.0" />
<PackageReference Include="Shouldly" Version="4.0.3" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" />
Expand Down
10 changes: 7 additions & 3 deletions src/Cake.Issues.MsBuild/Cake.Issues.MsBuild.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<PropertyGroup>
<DebugType>full</DebugType>
<DebugSymbols>true</DebugSymbols>
<AnalysisMode>AllEnabledByDefault</AnalysisMode>
<CodeAnalysisRuleSet>..\Cake.Issues.MsBuild.ruleset</CodeAnalysisRuleSet>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
</PropertyGroup>
Expand All @@ -25,9 +26,12 @@
</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>
<PackageReference Include="MSBuild.StructuredLogger" Version="2.0.174" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" />
</ItemGroup>
Expand Down
6 changes: 6 additions & 0 deletions src/Cake.Issues.MsBuild/LogFileFormat/BinaryLogFileFormat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ private IIssue GetIssue(
MsBuildIssuesProvider issueProvider,
IRepositorySettings repositorySettings)
{
this.Log.Verbose("Process error '{0}'...", buildError.Message);

return
this.GetIssue(
IssuePriority.Error,
Expand Down Expand Up @@ -135,6 +137,8 @@ private IIssue GetIssue(
MsBuildIssuesProvider issueProvider,
IRepositorySettings repositorySettings)
{
this.Log.Verbose("Process warning '{0}'...", buildWarning.Message);

return
this.GetIssue(
IssuePriority.Warning,
Expand Down Expand Up @@ -181,6 +185,7 @@ private IIssue GetIssue(
// Ignore warnings or errors without a message.
if (string.IsNullOrWhiteSpace(message))
{
this.Log.Verbose("Skip element since it doesn't contain a message");
return null;
}

Expand All @@ -190,6 +195,7 @@ private IIssue GetIssue(
var (result, fileName) = this.TryGetFile(file, projectFile, repositorySettings);
if (!result)
{
this.Log.Information("Skip element since file path could not be parsed");
return null;
}

Expand Down
176 changes: 96 additions & 80 deletions src/Cake.Issues.MsBuild/LogFileFormat/XmlFileLoggerLogFileFormat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,39 +50,47 @@ public override IEnumerable<IIssue> ReadIssues(

foreach (var element in elements)
{
this.Log.Verbose("Process element '{0}'...", element);

// Ignore warnings or errors without a message.
if (string.IsNullOrWhiteSpace(element.Value))
{
this.Log.Verbose("Skip element since it doesn't contain a message");
continue;
}

// Read affected project from the warning or error.
if (!this.TryGetProject(element, repositorySettings, out string projectFileRelativePath))
{
this.Log.Information("Skip element since project could not be parsed");
continue;
}

// Read affected file from the warning or error.
if (!this.TryGetFile(element, repositorySettings, out string fileName))
{
this.Log.Information("Skip element since file path could not be parsed");
continue;
}

// Read affected line from the warning or error.
if (!TryGetLine(element, out var line))
if (!this.TryGetLine(element, out var line))
{
this.Log.Information("Skip element since line could not be parsed");
continue;
}

// Read affected column from the warning or error.
if (!TryGetColumn(element, out var column))
if (!this.TryGetColumn(element, out var column))
{
this.Log.Information("Skip element since column could not be parsed");
continue;
}

// Read rule code from the warning or error.
if (!TryGetRule(element, out string rule))
if (!this.TryGetRule(element, out string rule))
{
this.Log.Information("Skip element since rule could not be parsed");
continue;
}

Expand All @@ -109,83 +117,6 @@ public override IEnumerable<IIssue> ReadIssues(
return result;
}

/// <summary>
/// Reads the affected line from a warning or error logged in a MsBuild log.
/// </summary>
/// <param name="element">Warning or error element from MsBuild log.</param>
/// <param name="line">Returns line.</param>
/// <returns>True if the line could be parsed.</returns>
private static bool TryGetLine(XElement element, out int? line)
{
line = null;

var lineAttr = element.Attribute("line");

var lineValue = lineAttr?.Value;
if (string.IsNullOrWhiteSpace(lineValue))
{
return false;
}

line = int.Parse(lineValue, CultureInfo.InvariantCulture);

// Convert negative line numbers or line number 0 to null
if (line <= 0)
{
line = null;
}

return true;
}

/// <summary>
/// Reads the affected column from a warning or error logged in a MsBuild log.
/// </summary>
/// <param name="element">Warning or error element from MsBuild log.</param>
/// <param name="column">Returns column.</param>
/// <returns>True if the column could be parsed.</returns>
private static bool TryGetColumn(XElement element, out int? column)
{
column = null;

var columnAttr = element.Attribute("column");

var columnValue = columnAttr?.Value;
if (string.IsNullOrWhiteSpace(columnValue))
{
return false;
}

column = int.Parse(columnValue, CultureInfo.InvariantCulture);

// Convert negative column numbers or column number 0 to null
if (column <= 0)
{
column = null;
}

return true;
}

/// <summary>
/// Reads the rule code from a warning or error logged in a MsBuild log.
/// </summary>
/// <param name="error">Warning or error element from MsBuild log.</param>
/// <param name="rule">Returns the code of the rule.</param>
/// <returns>True if the rule code could be parsed.</returns>
private static bool TryGetRule(XElement error, out string rule)
{
var codeAttr = error.Attribute("code");
if (codeAttr == null)
{
rule = null;
return true;
}

rule = codeAttr.Value;
return !string.IsNullOrWhiteSpace(rule);
}

/// <summary>
/// Determines the project for a warning or error logged in a MsBuild log.
/// </summary>
Expand All @@ -203,18 +134,21 @@ private bool TryGetProject(
var projectNode = element.Ancestors("project").FirstOrDefault();
if (projectNode == null)
{
this.Log.Information("Project not found for element '{0}'", element);
return true;
}

var projectAttr = projectNode.Attribute("file");
if (projectAttr == null)
{
this.Log.Information("File not found for element '{0}'", element);
return true;
}

project = projectAttr.Value;
if (string.IsNullOrWhiteSpace(project))
{
this.Log.Information("Project path not found for element '{0}'", element);
return true;
}

Expand All @@ -241,12 +175,14 @@ private bool TryGetFile(
var fileAttr = element.Attribute("file");
if (fileAttr == null)
{
this.Log.Verbose("File attribute not found for element '{0}'", element);
return true;
}

fileName = fileAttr.Value;
if (string.IsNullOrWhiteSpace(fileName))
{
this.Log.Information("File path not found for element '{0}'", element);
return true;
}

Expand All @@ -270,5 +206,85 @@ private bool TryGetFile(
(result, fileName) = this.ValidateFilePath(fileName, repositorySettings);
return result;
}

/// <summary>
/// Reads the affected line from a warning or error logged in a MsBuild log.
/// </summary>
/// <param name="element">Warning or error element from MsBuild log.</param>
/// <param name="line">Returns line.</param>
/// <returns>True if the line could be parsed.</returns>
private bool TryGetLine(XElement element, out int? line)
{
line = null;

var lineAttr = element.Attribute("line");

var lineValue = lineAttr?.Value;
if (string.IsNullOrWhiteSpace(lineValue))
{
return false;
}

line = int.Parse(lineValue, CultureInfo.InvariantCulture);

// Convert negative line numbers or line number 0 to null
if (line <= 0)
{
this.Log.Information("Ignore value {0} since it is outside of the allowed range for line property.", line);
line = null;
}

return true;
}

/// <summary>
/// Reads the affected column from a warning or error logged in a MsBuild log.
/// </summary>
/// <param name="element">Warning or error element from MsBuild log.</param>
/// <param name="column">Returns column.</param>
/// <returns>True if the column could be parsed.</returns>
private bool TryGetColumn(XElement element, out int? column)
{
column = null;

var columnAttr = element.Attribute("column");

var columnValue = columnAttr?.Value;
if (string.IsNullOrWhiteSpace(columnValue))
{
return false;
}

column = int.Parse(columnValue, CultureInfo.InvariantCulture);

// Convert negative column numbers or column number 0 to null
if (column <= 0)
{
this.Log.Information("Ignore value {0} since it is outside of the allowed range for column property.", column);
column = null;
}

return true;
}

/// <summary>
/// Reads the rule code from a warning or error logged in a MsBuild log.
/// </summary>
/// <param name="element">Warning or error element from MsBuild log.</param>
/// <param name="rule">Returns the code of the rule.</param>
/// <returns>True if the rule code could be parsed.</returns>
private bool TryGetRule(XElement element, out string rule)
{
var codeAttr = element.Attribute("code");
if (codeAttr == null)
{
this.Log.Verbose("code attribute not found for element '{0}'", element);
rule = null;
return true;
}

rule = codeAttr.Value;
return !string.IsNullOrWhiteSpace(rule);
}
}
}

0 comments on commit 804ea42

Please sign in to comment.