Skip to content

Commit

Permalink
Add Roslynator linter (#3155)
Browse files Browse the repository at this point in the history
* Add Roslynator linter

* Fix linter issue

* Fix test

* fix files filter

* Run build.sh

---------

Co-authored-by: nvuillam <[email protected]>
  • Loading branch information
bdovaz and nvuillam authored Nov 29, 2023
1 parent 8fc6cb2 commit 75df660
Show file tree
Hide file tree
Showing 166 changed files with 972 additions and 298 deletions.
20 changes: 20 additions & 0 deletions .automation/generated/linter-helps.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions .automation/generated/linter-links-previews.json
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,11 @@
"image": null,
"title": "revive - fast & configurable linter for Go"
},
"roslynator": {
"description": "Roslynator is a set of code analysis tools for C#, powered by Roslyn. - GitHub - dotnet/roslynator: Roslynator is a set of code analysis tools for C#, powered by Roslyn.",
"image": "https://repository-images.githubusercontent.com/57153744/57b7135a-1505-4930-98d1-acfd619f1457",
"title": "GitHub - dotnet/roslynator: Roslynator is a set of code analysis tools for C#, powered by Roslyn."
},
"rst-lint": {
"description": "reStructuredText linter. Contribute to twolfson/restructuredtext-lint development by creating an account on GitHub.",
"image": "https://avatars2.githubusercontent.com/u/902488?s=400&v=4",
Expand Down
1 change: 1 addition & 0 deletions .automation/generated/linter-versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
"raku": "2020.10",
"remark-lint": "14.0.2",
"revive": "1.3.4",
"roslynator": "0.8.0.0",
"rst-lint": "1.4.0",
"rstcheck": "6.2.0",
"rstfmt": "0.0.14",
Expand Down
8 changes: 8 additions & 0 deletions .automation/test/csharp_roslynator/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[*.cs]
dotnet_analyzer_diagnostic.category-roslynator.severity = error

roslynator_analyzers.enabled_by_default = true

roslynator_refactorings.enabled = true

roslynator_empty_string_style = field
11 changes: 11 additions & 0 deletions .automation/test/csharp_roslynator/bad/csharp_bad_01.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using System;

namespace HelloWorld
{
class Program {
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
}
}
}
13 changes: 13 additions & 0 deletions .automation/test/csharp_roslynator/bad/csharp_bad_02.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System;

namespace HelloWorld
{
class Program2
{
static void Main2 (string[] args)
{
Console.WriteLine ("Hello World!");
var value = 3 * 4 + 5;
}
}
}
10 changes: 10 additions & 0 deletions .automation/test/csharp_roslynator/bad/csharp_bad_project.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

</Project>
10 changes: 10 additions & 0 deletions .automation/test/csharp_roslynator/fix/csharp_fix_01.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace HelloWorld
{
class Program
{
static void Main(string[] _)
{
Console.WriteLine("Hello World!");
}
}
}
10 changes: 10 additions & 0 deletions .automation/test/csharp_roslynator/fix/csharp_fix_02.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace HelloWorld
{
class Program2
{
public static void Test()
{
Console.WriteLine("Hello World!");
}
}
}
21 changes: 21 additions & 0 deletions .automation/test/csharp_roslynator/fix/csharp_fix_project.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Roslynator.Analyzers" Version="4.6.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Roslynator.Formatting.Analyzers" Version="4.6.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

</Project>
10 changes: 10 additions & 0 deletions .automation/test/csharp_roslynator/good/csharp_good_01.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace HelloWorld
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
}
}
}
10 changes: 10 additions & 0 deletions .automation/test/csharp_roslynator/good/csharp_good_02.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace HelloWorld
{
class Program2
{
static void Main2(string[] args)
{
Console.WriteLine("Hello World!");
}
}
}
10 changes: 10 additions & 0 deletions .automation/test/csharp_roslynator/good/csharp_good_project.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

</Project>
1 change: 1 addition & 0 deletions .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -1224,6 +1224,7 @@
"rodjek",
"rogalmic",
"rogress",
"roslynator",
"rspec",
"rsplit",
"rstcheck",
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/deploy-BETA-linters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ jobs:
"cpp_clang_format",
"csharp_dotnet_format",
"csharp_csharpier",
"csharp_roslynator",
"css_stylelint",
"css_scss_lint",
"dart_dartanalyzer",
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/deploy-DEV-linters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ jobs:
"cpp_clang_format",
"csharp_dotnet_format",
"csharp_csharpier",
"csharp_roslynator",
"css_stylelint",
"css_scss_lint",
"dart_dartanalyzer",
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/deploy-RELEASE-linters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ jobs:
"cpp_clang_format",
"csharp_dotnet_format",
"csharp_csharpier",
"csharp_roslynator",
"css_stylelint",
"css_scss_lint",
"dart_dartanalyzer",
Expand Down
9 changes: 9 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,15 @@ RUN curl --retry 5 --retry-delay 5 -sLO "${ARM_TTK_URI}" \
# csharpier installation
&& /usr/share/dotnet/dotnet tool install -g csharpier \

# roslynator installation
# Next line commented because already managed by another linter
# RUN wget --tries=5 -q -O dotnet-install.sh https://dot.net/v1/dotnet-install.sh \
# && chmod +x dotnet-install.sh \
# && ./dotnet-install.sh --install-dir /usr/share/dotnet -channel 6.0 -version latest
# Next line commented because already managed by another linter
# ENV PATH="${PATH}:/root/.dotnet/tools:/usr/share/dotnet"
&& /usr/share/dotnet/dotnet tool install -g roslynator.dotnet.cli \

# dartanalyzer installation
&& wget --tries=5 https://storage.googleapis.com/dart-archive/channels/stable/release/${DART_VERSION}/sdk/dartsdk-linux-x64-release.zip -O - -q | unzip -q - \
&& chmod +x dart-sdk/bin/dart* \
Expand Down
Loading

0 comments on commit 75df660

Please sign in to comment.