Skip to content

Commit 07c11d3

Browse files
Copilotpascalberger
andcommitted
Add NuGet packages and complete CodeClimate provider
Co-authored-by: pascalberger <2190718+pascalberger@users.noreply.github.com>
1 parent 306bba2 commit 07c11d3

File tree

7 files changed

+317
-0
lines changed

7 files changed

+317
-0
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Support for reading CodeClimate compatible files using the Cake.Issues addin for Cake Frosting
2+
3+
> **NOTE**:
4+
> This is the version of the addin compatible with [Cake Frosting].
5+
> For addin compatible with [Cake .NET Tool] see [Cake.Issues.CodeClimate](https://www.nuget.org/packages/Cake.Issues.CodeClimate).
6+
7+
The CodeClimate support for the Cake.Issues addin for Cake allows you to read CodeClimate compatible files.
8+
9+
Cake.Issues redefines issue management within the Cake build system by offering a comprehensive, universal, and extensible solution.
10+
The unique capabilities of the addins empower development teams to enforce coding standards, generate insightful reports,
11+
seamlessly incorporate various linting tools, and streamlining the integration with pull requests.
12+
With its [modular architecture] and extensive [set of aliases], Cake.Issues provides a future-proof infrastructure for issue management
13+
in Cake builds, fostering a more efficient and adaptable development process.
14+
15+
For more information and extensive documentation see the [Cake.Issues website](https://cakeissues.net).
16+
For general information about the Cake build automation system see the [Cake website](http://cakebuild.net).
17+
18+
## How to use
19+
20+
Integrating Cake.Issues into your Cake build is straightforward.
21+
With minimal setup, teams can enjoy the benefits of enhanced code quality management seamlessly integrated into their existing build pipeline.
22+
23+
After adding the addin the CodeClimate log file can be parsed:
24+
25+
```csharp
26+
Task("Analyze").Does(() =>
27+
{
28+
var logPath = @"c:\build\log.json";
29+
var repoRootPath = @"c:\repo";
30+
31+
// Read issues.
32+
var issues =
33+
ReadIssues(
34+
CodeClimateIssuesFromFilePath(logPath),
35+
repoRootPath);
36+
37+
Information("{0} issues are found.", issues.Count());
38+
});
39+
```
40+
41+
## Support & Discussion
42+
43+
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/orgs/cake-build/discussions/categories/extension-q-a) category.
44+
45+
## Contributing
46+
47+
Contributions are welcome. See [Contribution Guidelines](https://github.com/cake-contrib/Cake.Issues/blob/develop/CONTRIBUTING.md).
48+
49+
## License
50+
51+
[MIT License - Copyright © Cake Issues contributors](LICENSE)
52+
53+
Binary distributions for some addins contain third-party code which is licensed under its own respective license.
54+
See [LICENSE](https://github.com/cake-contrib/Cake.Issues/blob/develop/LICENSE) for details.
55+
56+
[modular architecture]: https://cakeissues.net/latest/documentation/how-cake-issues-works/
57+
[set of aliases]: https://cakeissues.net/latest/api/
58+
[Cake Frosting]: https://cakebuild.net/docs/running-builds/runners/cake-frosting
59+
[Cake .NET Tool]: https://cakebuild.net/docs/running-builds/runners/dotnet-tool
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<package xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
3+
<metadata xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
4+
<id>Cake.Frosting.Issues.CodeClimate</id>
5+
<title>Cake.Frosting.Issues.CodeClimate</title>
6+
<version>0.0.0</version>
7+
<authors>Cake Issues contributors</authors>
8+
<owners>pascalberger, cake-contrib</owners>
9+
<summary>Support for reading CodeClimate compatible files using the Cake.Issues addin for Cake Frosting</summary>
10+
<description>
11+
The CodeClimate support for the Cake.Issues addin for Cake allows you to read CodeClimate compatible files.
12+
13+
This addin provides the aliases for reading issues from CodeClimate compatible files and providing them to the Cake.Issues addin.
14+
It also requires the core Cake.Issues addin.
15+
16+
There are also additional addins for generating reports or posting issues to pull requests.
17+
18+
See the Project Site for an overview of the whole ecosystem of addins for working with issues in Cake scripts.
19+
20+
NOTE:
21+
This is the version of the addin compatible with Cake Frosting.
22+
For addin compatible with Cake Script Runners see Cake.Issues.CodeClimate.
23+
</description>
24+
<license type="expression">MIT</license>
25+
<projectUrl>https://cakeissues.net</projectUrl>
26+
<icon>icon.png</icon>
27+
<requireLicenseAcceptance>false</requireLicenseAcceptance>
28+
<repository type="git" url="https://github.com/cake-contrib/Cake.Issues.git"/>
29+
<copyright>Copyright © Cake Issues contributors</copyright>
30+
<tags>cake cake-frosting cake-issues cake-issueprovider linting codeclimate</tags>
31+
<readme>docs\README.md</readme>
32+
<releaseNotes>https://github.com/cake-contrib/Cake.Issues/releases/tag/5.6.1</releaseNotes>
33+
<dependencies>
34+
<group targetFramework="net8.0">
35+
</group>
36+
<group targetFramework="net9.0">
37+
</group>
38+
</dependencies>
39+
</metadata>
40+
<files>
41+
<file src="..\..\..\..\nuspec\nuget\icon.png" target="" />
42+
<file src="..\..\..\..\nuspec\nuget\Cake.Frosting.Issues.CodeClimate.md" target="docs\README.md" />
43+
<file src="Release\**\Cake.Issues.CodeClimate.*" target="lib" exclude="**\*.deps.json" />
44+
</files>
45+
</package>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
5+
<PackageId>Cake.Frosting.Issues.CodeClimate</PackageId>
6+
<Title>Cake.Frosting.Issues.CodeClimate</Title>
7+
<Description>Support for reading CodeClimate compatible files using the Cake.Issues addin for Cake Frosting</Description>
8+
<PackageTags>cake cake-frosting cake-issues cake-issueprovider linting codeclimate</PackageTags>
9+
</PropertyGroup>
10+
11+
<ItemGroup>
12+
<PackageReference Include="Cake.Issues.CodeClimate" Version="$(Version)" />
13+
</ItemGroup>
14+
15+
</Project>
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Support for reading CodeClimate compatible files using the Cake.Issues addin for Cake Build Automation System
2+
3+
> **NOTE**:
4+
> This is the version of the addin compatible with [Cake .NET Tool].
5+
> For addin compatible with [Cake Frosting] see [Cake.Frosting.Issues.CodeClimate](https://www.nuget.org/packages/Cake.Frosting.Issues.CodeClimate).
6+
7+
The CodeClimate support for the Cake.Issues addin for Cake allows you to read CodeClimate compatible files.
8+
9+
Cake.Issues redefines issue management within the Cake build system by offering a comprehensive, universal, and extensible solution.
10+
The unique capabilities of the addins empower development teams to enforce coding standards, generate insightful reports,
11+
seamlessly incorporate various linting tools, and streamlining the integration with pull requests.
12+
With its [modular architecture] and extensive [set of aliases], Cake.Issues provides a future-proof infrastructure for issue management
13+
in Cake builds, fostering a more efficient and adaptable development process.
14+
15+
For more information and extensive documentation see the [Cake.Issues website](https://cakeissues.net).
16+
For general information about the Cake build automation system see the [Cake website](http://cakebuild.net).
17+
18+
## How to use
19+
20+
Integrating Cake.Issues into your Cake build is straightforward.
21+
With minimal setup, teams can enjoy the benefits of enhanced code quality management seamlessly integrated into their existing build pipeline.
22+
23+
After adding the addin the CodeClimate log file can be parsed:
24+
25+
```csharp
26+
Task("Analyze").Does(() =>
27+
{
28+
var logPath = @"c:\build\log.json";
29+
var repoRootPath = @"c:\repo";
30+
31+
// Read issues.
32+
var issues =
33+
ReadIssues(
34+
CodeClimateIssuesFromFilePath(logPath),
35+
repoRootPath);
36+
37+
Information("{0} issues are found.", issues.Count());
38+
});
39+
```
40+
41+
## Support & Discussion
42+
43+
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/orgs/cake-build/discussions/categories/extension-q-a) category.
44+
45+
## Contributing
46+
47+
Contributions are welcome. See [Contribution Guidelines](https://github.com/cake-contrib/Cake.Issues/blob/develop/CONTRIBUTING.md).
48+
49+
## License
50+
51+
[MIT License - Copyright © Cake Issues contributors](LICENSE)
52+
53+
Binary distributions for some addins contain third-party code which is licensed under its own respective license.
54+
See [LICENSE](https://github.com/cake-contrib/Cake.Issues/blob/develop/LICENSE) for details.
55+
56+
[modular architecture]: https://cakeissues.net/latest/documentation/how-cake-issues-works/
57+
[set of aliases]: https://cakeissues.net/latest/api/
58+
[Cake Frosting]: https://cakebuild.net/docs/running-builds/runners/cake-frosting
59+
[Cake .NET Tool]: https://cakebuild.net/docs/running-builds/runners/dotnet-tool
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<package xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
3+
<metadata xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
4+
<id>Cake.Issues.CodeClimate</id>
5+
<title>Cake.Issues.CodeClimate</title>
6+
<version>0.0.0</version>
7+
<authors>Cake Issues contributors</authors>
8+
<owners>pascalberger, cake-contrib</owners>
9+
<summary>Support for reading CodeClimate compatible files using the Cake.Issues addin for Cake Build Automation System</summary>
10+
<description>
11+
The CodeClimate support for the Cake.Issues addin for Cake allows you to read CodeClimate compatible files.
12+
13+
This addin provides the aliases for reading issues from CodeClimate compatible files and providing them to the Cake.Issues addin.
14+
It also requires the core Cake.Issues addin.
15+
16+
There are also additional addins for generating reports or posting issues to pull requests.
17+
18+
See the Project Site for an overview of the whole ecosystem of addins for working with issues in Cake scripts.
19+
20+
NOTE:
21+
This is the version of the addin compatible with Cake Script Runners.
22+
For addin compatible with Cake Frosting see Cake.Frosting.Issues.CodeClimate.
23+
</description>
24+
<license type="expression">MIT</license>
25+
<projectUrl>https://cakeissues.net</projectUrl>
26+
<icon>icon.png</icon>
27+
<requireLicenseAcceptance>false</requireLicenseAcceptance>
28+
<repository type="git" url="https://github.com/cake-contrib/Cake.Issues.git"/>
29+
<copyright>Copyright © Cake Issues contributors</copyright>
30+
<tags>cake cake-addin cake-issues cake-issueprovider linting codeclimate</tags>
31+
<readme>docs\README.md</readme>
32+
<releaseNotes>https://github.com/cake-contrib/Cake.Issues/releases/tag/5.6.1</releaseNotes>
33+
<dependencies>
34+
<group targetFramework="net8.0">
35+
</group>
36+
<group targetFramework="net9.0">
37+
</group>
38+
</dependencies>
39+
</metadata>
40+
<files>
41+
<file src="..\..\..\..\nuspec\nuget\icon.png" target="" />
42+
<file src="..\..\..\..\nuspec\nuget\Cake.Issues.CodeClimate.md" target="docs\README.md" />
43+
<file src="Release\**\Cake.Issues.CodeClimate.*" target="lib" exclude="**\*.deps.json" />
44+
</files>
45+
</package>
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
namespace Cake.Issues.CodeClimate.Tests;
2+
3+
public class CodeClimateIntegrationTests
4+
{
5+
[Fact]
6+
public void Should_Parse_Sample_CodeClimate_Output()
7+
{
8+
// Given
9+
var sampleJson = @"[
10+
{
11+
""type"": ""issue"",
12+
""check_name"": ""EditorConfig/indent_style"",
13+
""description"": ""Wrong indentation type (expected: space, found: tab)"",
14+
""categories"": [""Style""],
15+
""location"": {
16+
""path"": ""src/example.js"",
17+
""lines"": {
18+
""begin"": 5,
19+
""end"": 5
20+
}
21+
},
22+
""severity"": ""minor""
23+
},
24+
{
25+
""type"": ""issue"",
26+
""check_name"": ""complexity"",
27+
""description"": ""Function has too many parameters"",
28+
""categories"": [""Complexity""],
29+
""location"": {
30+
""path"": ""src/complex.ts"",
31+
""positions"": {
32+
""begin"": {
33+
""line"": 15,
34+
""column"": 5
35+
},
36+
""end"": {
37+
""line"": 18,
38+
""column"": 10
39+
}
40+
}
41+
},
42+
""severity"": ""critical""
43+
}
44+
]";
45+
46+
var fixture = new CodeClimateIssuesProviderFixture(sampleJson);
47+
48+
// When
49+
var issues = fixture.ReadIssues().ToList();
50+
51+
// Then
52+
issues.Count.ShouldBe(2);
53+
54+
// Check first issue (line-based)
55+
var firstIssue = issues.First(i => i.Rule == "EditorConfig/indent_style");
56+
firstIssue.Message.ShouldBe("Wrong indentation type (expected: space, found: tab)");
57+
firstIssue.AffectedFileRelativePath?.ToString().ShouldBe(@"src\example.js");
58+
firstIssue.Line.ShouldBe(5);
59+
firstIssue.EndLine.ShouldBe(5);
60+
firstIssue.Priority.ShouldBe(IssuePriority.Suggestion);
61+
62+
// Check second issue (position-based)
63+
var secondIssue = issues.First(i => i.Rule == "complexity");
64+
secondIssue.Message.ShouldBe("Function has too many parameters");
65+
secondIssue.AffectedFileRelativePath?.ToString().ShouldBe(@"src\complex.ts");
66+
secondIssue.Line.ShouldBe(15);
67+
secondIssue.EndLine.ShouldBe(18);
68+
secondIssue.Column.ShouldBe(5);
69+
secondIssue.EndColumn.ShouldBe(10);
70+
secondIssue.Priority.ShouldBe(IssuePriority.Error);
71+
}
72+
73+
private sealed class CodeClimateIssuesProviderFixture : BaseConfigurableIssueProviderFixture<CodeClimateIssuesProvider, CodeClimateIssuesSettings>
74+
{
75+
public CodeClimateIssuesProviderFixture(string fileContent)
76+
: base(fileContent)
77+
{
78+
}
79+
80+
protected override string FilePathPrefix => "C:\\build\\";
81+
82+
protected override string FilePathSuffix => "log.json";
83+
}
84+
}

src/Cake.Issues.sln

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,15 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "NuGet", "NuGet", "{EE8D20F0
229229
..\nuspec\nuget\Cake.Issues.Sarif.nuspec = ..\nuspec\nuget\Cake.Issues.Sarif.nuspec
230230
EndProjectSection
231231
EndProject
232+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "NuGet", "NuGet", "{9F6A8B2C-3D4E-5F1A-8B9C-0D1E2F3A4B5C}"
233+
ProjectSection(SolutionItems) = preProject
234+
..\nuspec\nuget\Cake.Frosting.Issues.CodeClimate.md = ..\nuspec\nuget\Cake.Frosting.Issues.CodeClimate.md
235+
..\nuspec\nuget\Cake.Frosting.Issues.CodeClimate.nuspec = ..\nuspec\nuget\Cake.Frosting.Issues.CodeClimate.nuspec
236+
..\nuspec\nuget\Cake.Frosting.Issues.CodeClimate.targets = ..\nuspec\nuget\Cake.Frosting.Issues.CodeClimate.targets
237+
..\nuspec\nuget\Cake.Issues.CodeClimate.md = ..\nuspec\nuget\Cake.Issues.CodeClimate.md
238+
..\nuspec\nuget\Cake.Issues.CodeClimate.nuspec = ..\nuspec\nuget\Cake.Issues.CodeClimate.nuspec
239+
EndProjectSection
240+
EndProject
232241
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "NuGet", "NuGet", "{D5B8697D-48F9-4AE8-A3E2-D0E28444FFB8}"
233242
ProjectSection(SolutionItems) = preProject
234243
..\nuspec\nuget\Cake.Frosting.Issues.Terraform.md = ..\nuspec\nuget\Cake.Frosting.Issues.Terraform.md
@@ -541,6 +550,7 @@ Global
541550
{31C6C8A1-EF5E-42B2-A3B2-691D34154447} = {3E907A2C-F70B-45F7-AF5A-6C55EDBDE4B7}
542551
{CD14F49A-6F1B-43B3-AE96-EFEAEE61CB46} = {9A930DB7-DC39-4983-A979-16547DAB56F5}
543552
{EE8D20F0-C126-46AE-A28B-F0844DF8287D} = {308A600B-0745-464E-9487-9FCFB1BBAC7D}
553+
{9F6A8B2C-3D4E-5F1A-8B9C-0D1E2F3A4B5C} = {8F5B9A1C-8D3E-4F1E-9C2B-5A4B3C2D1E0F}
544554
{D5B8697D-48F9-4AE8-A3E2-D0E28444FFB8} = {9323409D-2A31-4D93-8479-3DBBC154816A}
545555
{CC4B1EB9-CAB1-4459-8E24-F0AE42EFED7A} = {1740ABB7-C3AE-437D-A7A5-0841BEEC3AF0}
546556
{A61E1CBF-0AC9-47CA-ABC0-84F71728FDA4} = {2502A3E6-F9F4-41A9-BCC5-BB815DC3F0FA}

0 commit comments

Comments
 (0)