EcoCode 1.5.3
EcoCode has been renamed to Creedengo
dotnet add package EcoCode --version 1.5.3
NuGet\Install-Package EcoCode -Version 1.5.3
<PackageReference Include="EcoCode" Version="1.5.3" />
paket add EcoCode --version 1.5.3
#r "nuget: EcoCode, 1.5.3"
// Install EcoCode as a Cake Addin #addin nuget:?package=EcoCode&version=1.5.3 // Install EcoCode as a Cake Tool #tool nuget:?package=EcoCode&version=1.5.3
Creedengo-C#
creedengo is a collective project aiming to reduce environmental footprint of software at the code level. The goal of the project is to provide a list of static code analyzers to highlight code structures that may have a negative ecological impact: energy and resources over-consumption, "fatware", shortening terminals' lifespan, etc.
creedengo is based on evolving catalogs of good practices, for various technologies. This set of Roslyn analyzers implements these catalogs as rules for scanning your C# projects.
🚀 Getting Started
There are several ways you can use the creedengo C# analyzers in your .Net projects:
- As a NuGet package
- As a .NET tool
- As an analyzer for SonarQube.
<a name="nugetPackage"></a>🧩 NuGet package
The package is available on nuget.org at this address : https://www.nuget.org/packages/EcoCode, and can be added to your projects/solutions like any NuGet package. Once referenced and restored, the creedengo analyzers are automatically integrated in your IDE/compilation process, and will list any applicable info/alert.
Pre-requisite : .Net Standard 2.0, which can be used in a wide range of projects. See Microsoft documentation for details about the supported Frameworks.
<a name="dotnetTool"></a>🧩 .Net tool
The .Net tool is available on nuget.org at this address : https://www.nuget.org/packages/EcoCode.Tool, and can be fetched on your machine using the following command :
dotnet tool install --global EcoCode.Tool
See .Net tools documentation for additional information.
Once installed, you can launch an analyzis on an existing codebase like this :
ecocode-cli analyze path/to/mySolution.sln path/to/myReport.html
.
The file to analyze can be a .sln, a .slnx or a .csproj. The report format depends on it's required extension, the following are currently supported : .html, .json and .csv.
Pre-requisite : .Net 8 SDK.
<a name="sonarQube"></a>🧩 Analyzer for SonarQube
Creedengo C# can use SonarScanner for .Net to integrate with SonarQube, and uses a custom import addition to enrich what is reported to Sonar (severity, description, url page, category, and so on). See our dedicated repository for more information.
🌿 Creedengo Rules
Id | Description | Severity | Code fix |
---|---|---|---|
GCI69 | Don’t call loop invariant functions in loop conditions | ⚠️ | ❌ |
GCI72 | Don’t execute SQL queries in loops | ⚠️ | ❌ |
GCI75 | Don’t concatenate strings in loops |
⚠️ | ❌ |
GCI81 | Specify struct layouts |
⚠️ | ✔️ |
GCI82 | Variable can be made constant | ℹ️ | ✔️ |
GCI83 | Replace Enum ToString() with nameof |
⚠️ | ✔️ |
GCI84 | Avoid async void methods |
⚠️ | ✔️ |
GCI85 | Make type sealed |
ℹ️ | ✔️ |
GCI86 | GC.Collect should not be called |
⚠️ | ❌ |
GCI87 | Use collection indexer | ⚠️ | ✔️ |
GCI88 | Dispose resource asynchronously | ⚠️ | ✔️ |
GCI91 | Use Where before OrderBy |
⚠️ | ✔️ |
GCI92 | Use Length to test empty strings |
⚠️ | ✔️ |
GCI93 | Return Task directly |
ℹ️ | ✔️ |
🌿 Customized Roslyn Rules
Creedengo C# customizes the severity of the following native Roslyn rules.
Id | Description | Old Severity | New Severity |
---|---|---|---|
CA1001 | Types that own disposable fields should be disposable | 💤 | ⚠️ |
CA1802 | Use Literals Where Appropriate | 💤 | ⚠️ |
CA1805 | Do not initialize unnecessarily | 💤 | ⚠️ |
CA1813 | Avoid unsealed attributes | 💤 | ⚠️ |
CA1816 | Call GC.SuppressFinalize correctly | ℹ️ | ⚠️ |
CA1821 | Remove empty finalizers | ℹ️ | ⚠️ |
CA1822 | Mark members as static | ℹ️ | ⚠️ |
CA1824 | Mark assemblies with NeutralResourcesLanguageAttribute | ℹ️ | ⚠️ |
CA1825 | Avoid zero-length array allocations | ℹ️ | ⚠️ |
CA1826 | Use property instead of Linq Enumerable method | ℹ️ | ⚠️ |
CA1827 | Do not use Count()/LongCount() when Any() can be used | ℹ️ | ⚠️ |
CA1828 | Do not use CountAsync/LongCountAsync when AnyAsync can be used | ℹ️ | ⚠️ |
CA1829 | Use Length/Count property instead of Enumerable.Count method | ℹ️ | ⚠️ |
CA1830 | Prefer strongly-typed Append and Insert method overloads on StringBuilder | ℹ️ | ⚠️ |
CA1832 | Use AsSpan or AsMemory instead of Range-based indexers for getting ReadOnlySpan or ReadOnlyMemory portion of an array | ℹ️ | ⚠️ |
CA1833 | Use AsSpan or AsMemory instead of Range-based indexers for getting Span or Memory portion of an array | ℹ️ | ⚠️ |
CA1834 | Use StringBuilder.Append(char) for single character strings | ℹ️ | ⚠️ |
CA1835 | Prefer the memory-based overloads of ReadAsync/WriteAsync methods in stream-based classes | ℹ️ | ⚠️ |
CA1836 | Prefer IsEmpty over Count when available | ℹ️ | ⚠️ |
CA1837 | Use Environment.ProcessId instead of Process.GetCurrentProcess().Id | ℹ️ | ⚠️ |
CA1838 | Avoid StringBuilder parameters for P/Invokes | 💤 | ⚠️ |
CA1839 | Use Environment.ProcessPath instead of Process.GetCurrentProcess().MainModule.FileName | ℹ️ | ⚠️ |
CA1840 | Use Environment.CurrentManagedThreadId instead of Thread.CurrentThread.ManagedThreadId | ℹ️ | ⚠️ |
CA1841 | Prefer Dictionary Contains methods | ℹ️ | ⚠️ |
CA1842 | Do not use 'WhenAll' with a single task | ℹ️ | ⚠️ |
CA1843 | Do not use 'WaitAll' with a single task | ℹ️ | ⚠️ |
CA1844 | Provide memory-based overrides of async methods when subclassing 'Stream' | ℹ️ | ⚠️ |
CA1845 | Use span-based 'string.Concat' | ℹ️ | ⚠️ |
CA1846 | Prefer AsSpan over Substring | ℹ️ | ⚠️ |
CA1847 | Use String.Contains(char) instead of String.Contains(string) with single characters | ℹ️ | ⚠️ |
CA1850 | Prefer static HashData method over ComputeHash | ℹ️ | ⚠️ |
CA1853 | Unnecessary call to 'Dictionary.ContainsKey(key)' | ℹ️ | ⚠️ |
CA1854 | Prefer the IDictionary.TryGetValue(TKey, out TValue) method | ℹ️ | ⚠️ |
CA1855 | Use Span<T>.Clear() instead of Span<T>.Fill() | ℹ️ | ⚠️ |
CA1858 | Use StartsWith instead of IndexOf | ℹ️ | ⚠️ |
CA1859 | Prefer concrete types when possible for improved performance | ℹ️ | ⚠️ |
CA1860 | Avoid using 'Enumerable.Any()' extension method | ℹ️ | ⚠️ |
CA1863 | Use 'CompositeFormat' | 💤 | ⚠️ |
CA1864 | Prefer the 'IDictionary.TryAdd(TKey, TValue)' method | ℹ️ | ⚠️ |
CA1865-7 | Use 'string.Method(char)' instead of 'string.Method(string)' for string with single char | ℹ️ | ⚠️ |
CA1868 | Unnecessary call to 'Contains' for sets | ℹ️ | ⚠️ |
CA1869 | Cache and reuse 'JsonSerializerOptions' instances | ℹ️ | ⚠️ |
CA1870 | Use a cached 'SearchValues' instance | ℹ️ | ⚠️ |
CA1871 | Do not pass a nullable struct to 'ArgumentNullException.ThrowIfNull' | ℹ️ | ⚠️ |
CA1872 | Prefer 'Convert.ToHexString' and 'Convert.ToHexStringLower' over call chains based on 'BitConverter.ToString' | ℹ️ | ⚠️ |
CA2009 | Do not call ToImmutableCollection on an ImmutableCollection value | ℹ️ | ⚠️ |
CA2215 | Dispose methods should call base class dispose | 💤 | ⚠️ |
CA2218 | Override GetHashCode on overriding Equals | ℹ️ | ⚠️ |
CA2251 | Use String.Equals over String.Compare | 💤 | ⚠️ |
CA2264 | Do not pass a non-nullable value to 'ArgumentNullException.ThrowIfNull' | ℹ️ | ⚠️ |
🤝 Contribution
See contribution on the central repository.
🤓 Main contributors
See main contributors on the central repository.
Learn more about Target Frameworks and .NET Standard.
This package has no dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated | |
---|---|---|---|
1.5.3 | 297 | 1/1/2025 | |
1.5.3-beta1 | 93 | 1/1/2025 | |
1.5.2 | 457 | 11/9/2024 | |
1.5.1 | 285 | 8/1/2024 | |
1.5.0 | 139 | 7/13/2024 | |
1.5.0-beta1 | 101 | 7/13/2024 | |
1.4.0 | 159 | 6/24/2024 | |
1.3.0 | 125 | 6/24/2024 | |
1.3.0-beta4 | 112 | 6/23/2024 | |
1.3.0-beta3 | 112 | 6/8/2024 | |
1.3.0-beta2 | 97 | 6/8/2024 | |
1.3.0-beta1 | 121 | 6/8/2024 | |
1.2.0 | 141 | 6/4/2024 | |
1.2.0-beta6 | 110 | 6/3/2024 | |
1.2.0-beta5 | 118 | 6/2/2024 | |
1.2.0-beta4 | 117 | 6/1/2024 | |
1.2.0-beta3 | 115 | 5/30/2024 | |
1.2.0-beta2 | 118 | 5/30/2024 | |
1.2.0-beta1 | 124 | 5/19/2024 | |
1.1.0 | 233 | 5/19/2024 | |
1.1.0-beta3 | 111 | 5/19/2024 | |
1.1.0-beta2 | 110 | 5/18/2024 | |
1.1.0-beta1 | 108 | 5/18/2024 | |
1.0.8 | 132 | 5/13/2024 | |
1.0.7 | 113 | 5/13/2024 | |
1.0.6 | 175 | 5/4/2024 | |
1.0.6-beta3 | 126 | 4/29/2024 | |
1.0.6-beta2 | 102 | 4/28/2024 | |
1.0.6-beta1 | 134 | 4/27/2024 | |
1.0.5 | 140 | 4/26/2024 | |
1.0.4 | 217 | 4/16/2024 | |
1.0.3 | 172 | 4/11/2024 | |
1.0.2 | 175 | 4/3/2024 | |
1.0.1 | 180 | 3/23/2024 | |
1.0.1-beta8 | 170 | 3/23/2024 | |
1.0.1-beta7 | 173 | 3/17/2024 | |
1.0.1-beta5 | 173 | 3/14/2024 | |
1.0.1-beta4 | 152 | 3/14/2024 | |
1.0.1-beta3 | 135 | 3/14/2024 | |
1.0.1-beta2 | 129 | 3/14/2024 |