Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ reported a the [GibHub repository](https://github.com/dotnet-project-file-analyz
## Generic
* [**Proj3000** Only use UTF-8 without BOM](rules/Proj3000.md)
* [**Proj3001** Track uses of "TODO" tags](rules/Proj3001.md)
* [**Proj3002** Remove commented-out code](rules/Proj3002.md)

## INI
* [**Proj4000** Invalid INI file](rules/Proj4000.md)
Expand Down
51 changes: 51 additions & 0 deletions rules/Proj3002.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---
parent: Generic
ancestor: Rules
---

# Proj3002: Remove commented-out code
Commented-out code adds noise to a code file and makes it harder to follow the
actual code that should be executed. Comments should be reserved to explain
difficult to understand code or the reason for doing something out of the
ordinary.

For code that is not longer needed, [version control](https://en.wikipedia.org/wiki/Version_control)
should be used instead.

## Non-compliant
```
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<!-- ImplicitUsings>enable</ImplicitUsings -->
</PropertyGroup>

<ItemGroup>
<!-- Reconsider adding this
<PackageReference Include="DotNetProjectFile.Analyzers" Version="1.5.8" PrivateAssets="all" />
-->
<PackageReference Include="PolySharp" Version="1.15.0" PrivateAssets="all" />
</ItemGroup>

</Project>
```

## Compliant
```
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="PolySharp" Version="1.15.0" PrivateAssets="all" />
</ItemGroup>

</Project>
```

## Similar rules
This rule has been implemented for C#:
* [S125](https://rules.sonarsource.com/csharp/RSPEC-125) (Sonar)
Loading