Skip to content

Commit

Permalink
feat(CA1825): upgrade CA1825 severity to warning (#55)
Browse files Browse the repository at this point in the history
  • Loading branch information
Florent-LAVAUD authored May 30, 2024
1 parent b149f12 commit 948002c
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 2 deletions.
4 changes: 4 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,8 @@
<ItemGroup>
<Compile Include="..\..\SharedAssemblyInfo.cs" Link="Properties\SharedAssemblyInfo.cs" />
</ItemGroup>

<ItemGroup>
<GlobalAnalyzerConfigFiles Include="$(MSBuildThisFileDirectory)\src\EcoCode.Package\EcoCode.globalconfig" />
</ItemGroup>
</Project>
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ There are several ways you can use the ecoCode analyzers in your .Net projects:

Both the EcoCode NuGet package and Visual Studio extension target .Net Standard 2.0 and can be used in a wide range of projects. See [Microsoft documentation](https://learn.microsoft.com/en-us/dotnet/standard/net-standard?tabs=net-standard-2-0#select-net-standard-version) for details about the supported .Net Frameworks in .Net Standard 2.0.

🌿 Rules
🌿 EcoCode Rules
-------------------

|Id|Description|Severity|Enabled|Code fix|
|--|-----------|:------:|:--------:|:------:|
|--|-----------|:------:|:-----:|:------:|
|[EC69](https://github.com/green-code-initiative/ecoCode/blob/main/ecocode-rules-specifications/src/main/rules/EC69/csharp/EC69.asciidoc)|Don’t call loop invariant functions in loop conditions|⚠️|✔️||
|[EC72](https://github.com/green-code-initiative/ecoCode/blob/main/ecocode-rules-specifications/src/main/rules/EC72/csharp/EC72.asciidoc)|Don’t execute SQL queries in loops|⚠️|✔️||
|[EC75](https://github.com/green-code-initiative/ecoCode/blob/main/ecocode-rules-specifications/src/main/rules/EC75/csharp/EC75.asciidoc)|Don’t concatenate `strings` in loops|⚠️|✔️||
Expand All @@ -45,6 +45,15 @@ Both the EcoCode NuGet package and Visual Studio extension target .Net Standard
|[EC87](https://github.com/green-code-initiative/ecoCode/blob/main/ecocode-rules-specifications/src/main/rules/EC87/csharp/EC87.asciidoc)|Use collection indexer|⚠️|✔️|✔️|
|[EC88](https://github.com/green-code-initiative/ecoCode/blob/main/ecocode-rules-specifications/src/main/rules/EC88/csharp/EC88.asciidoc)|Dispose resource asynchronously|⚠️|✔️|✔️|

🌿 Roslyn Rules
-------------------

This plugin customizes the severity of certain Roslyn rules.

|Id|Description|Old Severity|New Severity|Enabled|Code fix|
|--|-----------|:----------:|:----------:|:-----:|:------:|
|[CA1825](https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1825)|Avoid zero-length array allocations|ℹ️|⚠️|✔️|✔️|

🤝 Contribution
---------------

Expand Down
2 changes: 2 additions & 0 deletions src/EcoCode.Package/EcoCode.Package.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@

<ItemGroup>
<None Include="..\EcoCode.Core\bin\$(Configuration)\$(TargetFramework)\EcoCode.Core.dll" Pack="true" PackagePath="analyzers/dotnet/cs" />
<None Include="EcoCode.globalconfig" Pack="true" PackagePath="analyzers/config" CopyToOutputDirectory="PreserveNewest" />
<None Include="EcoCode.props" Pack="true" PackagePath="build" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>

<ItemGroup>
Expand Down
4 changes: 4 additions & 0 deletions src/EcoCode.Package/EcoCode.globalconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
is_global = true

# CA1825: Avoid zero-length array allocations
dotnet_diagnostic.CA1825.severity = warning
5 changes: 5 additions & 0 deletions src/EcoCode.Package/EcoCode.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<Project>
<ItemGroup>
<GlobalAnalyzerConfigFiles Include="$(MSBuildThisFileDirectory)../analyzers/config/EcoCode.globalconfig" />
</ItemGroup>
</Project>

0 comments on commit 948002c

Please sign in to comment.