-
Notifications
You must be signed in to change notification settings - Fork 3
preview/check-run #51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
name: C# Linter | ||
|
||
# ───────────── TRIGGER ───────────── | ||
on: | ||
pull_request: | ||
|
||
# ───────────── JOBS ───────────── | ||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- uses: actions/setup-dotnet@v4 | ||
with: | ||
dotnet-version: '8.0.x' # .NET 8 already contains 'dotnet format'; no extra tool install needed | ||
|
||
# Restore & analyze the new project | ||
- name: Restore packages | ||
run: dotnet restore BadCodeProject.csproj | ||
|
||
- name: Run dotnet format | ||
run: dotnet format BadCodeProject.csproj --verify-no-changes --severity info |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: ReSharper Inspection | ||
|
||
on: | ||
pull_request: | ||
|
||
jobs: | ||
inspection: | ||
runs-on: ubuntu-latest | ||
name: ReSharper Code Inspection | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup .NET | ||
id: setup-dotnet | ||
uses: actions/setup-dotnet@v4 | ||
with: | ||
dotnet-version: '8.0.x' | ||
|
||
- name: Restore | ||
run: dotnet restore BadCodeProject.sln | ||
|
||
- name: Inspect code with ReSharper | ||
uses: muno92/resharper_inspectcode@v1 | ||
with: | ||
solutionPath: ./BadCodeProject.sln | ||
dotnetVersion: ${{ steps.setup-dotnet.outputs.dotnet-version }} |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,27 @@ | ||||||||||||||||||||||||||||||||||||
// Intentionally terrible C# to demonstrate linter failures | ||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
using System; using System.Collections.Generic; // extra spaces + wrong on-line ordering | ||||||||||||||||||||||||||||||||||||
using System. Linq; // misplaced space after “System.” | ||||||||||||||||||||||||||||||||||||
using System.Threading.Tasks; // comment trailing spaces | ||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
namespace BadlyFormattedNS { // brace on same line, double spaces | ||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Namespace declaration formatting violations. The namespace declaration has inconsistent spacing and incorrect brace placement according to C# conventions. Apply this diff to fix the namespace formatting: -namespace BadlyFormattedNS { // brace on same line, double spaces
+namespace BadlyFormattedNS
+{ 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
||||||||||||||||||||||||||||||||||||
public class bad_class // wrong casing + double spaces | ||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Class naming and formatting violations. The class declaration violates C# naming conventions and has formatting issues. Apply this diff to fix the class declaration: -public class bad_class // wrong casing + double spaces
+public class BadClass 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||
private static readonly int ANSWER =42;// field casing, spacing, rogue constant | ||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Field declaration formatting and naming violations. The field declaration has multiple issues: incorrect casing, excessive spacing, and missing space around assignment operator. Apply this diff to fix the field declaration: - private static readonly int ANSWER =42;// field casing, spacing, rogue constant
+ private static readonly int Answer = 42; 🤖 Prompt for AI Agents
|
||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
public BadCode( ) {Console . WriteLine( "Created" );} // spaces everywhere & braces | ||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Constructor formatting violations. The constructor has multiple formatting issues: spacing around parentheses, method call formatting, and brace placement. Apply this diff to fix the constructor: - public BadCode( ) {Console . WriteLine( "Created" );} // spaces everywhere & braces
+ public BadCode()
+ {
+ Console.WriteLine("Created");
+ } 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
public void DoStuff( IDictionary< string ,List <int>> data ) | ||||||||||||||||||||||||||||||||||||
{ if(data==null){throw new ArgumentNullException ( nameof ( data ) );} | ||||||||||||||||||||||||||||||||||||
foreach( var kvp in data ){ | ||||||||||||||||||||||||||||||||||||
Console.WriteLine( $"Key:{kvp.Key}, Count = {kvp.Value.Count}"); } /* crowded */ | ||||||||||||||||||||||||||||||||||||
} // incorrect indentation + brace style | ||||||||||||||||||||||||||||||||||||
Comment on lines
+15
to
+19
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Method formatting violations and inconsistent indentation. The Apply this diff to fix the method formatting: - public void DoStuff( IDictionary< string ,List <int>> data )
- { if(data==null){throw new ArgumentNullException ( nameof ( data ) );}
- foreach( var kvp in data ){
- Console.WriteLine( $"Key:{kvp.Key}, Count = {kvp.Value.Count}"); } /* crowded */
- } // incorrect indentation + brace style
+ public void DoStuff(IDictionary<string, List<int>> data)
+ {
+ if (data == null)
+ {
+ throw new ArgumentNullException(nameof(data));
+ }
+
+ foreach (var kvp in data)
+ {
+ Console.WriteLine($"Key:{kvp.Key}, Count = {kvp.Value.Count}");
+ }
+ } 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
internal static async Task < IEnumerable < int > >GetValuesAsync( ) | ||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||
await Task . Delay (100 ) ; // spaces around dot + inside parentheses | ||||||||||||||||||||||||||||||||||||
return new List<int>{1 ,2,3 , 4}; // inconsistent spacing | ||||||||||||||||||||||||||||||||||||
} // extra spaces before brace | ||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||
Comment on lines
+21
to
+26
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Async method formatting violations. The async method has multiple formatting issues: spacing around generic type parameters, method call formatting, and brace placement. Apply this diff to fix the async method: - internal static async Task < IEnumerable < int > >GetValuesAsync( )
-{
- await Task . Delay (100 ) ; // spaces around dot + inside parentheses
- return new List<int>{1 ,2,3 , 4}; // inconsistent spacing
-} // extra spaces before brace
+ internal static async Task<IEnumerable<int>> GetValuesAsync()
+ {
+ await Task.Delay(100);
+ return new List<int> { 1, 2, 3, 4 };
+ } 🤖 Prompt for AI Agents
|
||||||||||||||||||||||||||||||||||||
} // No newline at end |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,13 @@ | ||||||||||||||||||||||||||||
<!-- BadCodeProject.csproj --> | ||||||||||||||||||||||||||||
<Project Sdk="Microsoft.NET.Sdk"> | ||||||||||||||||||||||||||||
<PropertyGroup> | ||||||||||||||||||||||||||||
<TargetFramework>net8.0</TargetFramework> | ||||||||||||||||||||||||||||
<Nullable>enable</Nullable> | ||||||||||||||||||||||||||||
<ImplicitUsings>enable</ImplicitUsings> | ||||||||||||||||||||||||||||
</PropertyGroup> | ||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||
<!-- explicitly include the demo file so the project builds --> | ||||||||||||||||||||||||||||
<ItemGroup> | ||||||||||||||||||||||||||||
<Compile Include="BadCode.cs" /> | ||||||||||||||||||||||||||||
</ItemGroup> | ||||||||||||||||||||||||||||
</Project> | ||||||||||||||||||||||||||||
Comment on lines
+1
to
+13
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Duplicate / orphaned project file will confuse the build & CI The repo already contains If the intent was to keep only the project under - BadCodeProject.csproj ⟵ delete (or move/rename) 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 17 | ||
VisualStudioVersion = 17.0.31903.59 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BadCodeProject", "BadCodeProject\BadCodeProject.csproj", "{12345678-1234-1234-1234-123456789012}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{12345678-1234-1234-1234-123456789012}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{12345678-1234-1234-1234-123456789012}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{12345678-1234-1234-1234-123456789012}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{12345678-1234-1234-1234-123456789012}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
EndGlobal |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
</Project> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
|
||
namespace BadCodeProject | ||
{ | ||
public class Program | ||
{ | ||
public static void Main(string[] args) | ||
{ | ||
// Unused variable | ||
int unusedVariable = 42; | ||
|
||
// Redundant type specification | ||
List<string> strings = new List<string>(); | ||
|
||
// Possible null reference | ||
string? nullableString = null; | ||
Console.WriteLine(nullableString.Length); | ||
|
||
// Inconsistent naming | ||
int my_variable = 10; | ||
int myVariable = 20; | ||
|
||
// Unused parameter | ||
void UnusedParameter(int unusedParam) | ||
{ | ||
Console.WriteLine("Hello"); | ||
} | ||
|
||
// Redundant parentheses | ||
int result = (1 + (2 * 3)); | ||
|
||
// Magic number | ||
if (result > 7) | ||
{ | ||
Console.WriteLine("Too high"); | ||
} | ||
|
||
// Inconsistent string literal | ||
Console.WriteLine("Hello" + " " + "World"); | ||
|
||
// Unnecessary boxing | ||
object boxed = 42; | ||
|
||
// Redundant ToString() call | ||
string number = 42.ToString(); | ||
|
||
// Unused method | ||
void UnusedMethod() | ||
{ | ||
Console.WriteLine("Never called"); | ||
} | ||
|
||
// Possible multiple enumeration | ||
var numbers = Enumerable.Range(1, 10); | ||
var sum = numbers.Sum(); | ||
var count = numbers.Count(); | ||
|
||
// Inconsistent access modifiers | ||
private int privateField = 0; | ||
public int publicField = 0; | ||
|
||
// Unnecessary cast | ||
object obj = "string"; | ||
string str = (string)obj; | ||
|
||
// Redundant conditional | ||
bool condition = true; | ||
if (condition == true) | ||
{ | ||
Console.WriteLine("Redundant"); | ||
Check failure on line 72 in BadCodeProject/Program.cs
|
||
} | ||
} | ||
Comment on lines
+61
to
+74
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Critical compilation errors due to invalid syntax. The code has multiple compilation errors because local variables and control flow statements are incorrectly placed outside of method scope. Local variables cannot have access modifiers, and the Apply this diff to fix the compilation errors: - // Inconsistent access modifiers
- private int privateField = 0;
- public int publicField = 0;
-
- // Unnecessary cast
- object obj = "string";
- string str = (string)obj;
-
- // Redundant conditional
- bool condition = true;
- if (condition == true)
- {
- Console.WriteLine("Redundant");
- }
+ // Inconsistent access modifiers (corrected - local variables cannot have access modifiers)
+ int privateField = 0;
+ int publicField = 0;
+
+ // Unnecessary cast
+ object obj = "string";
+ string str = (string)obj;
+
+ // Redundant conditional
+ bool condition = true;
+ if (condition == true)
+ {
+ Console.WriteLine("Redundant");
+ }
🧰 Tools🪛 GitHub Check: lint[failure] 72-72: [failure] 72-72: [failure] 70-70: 🪛 GitHub Actions: C# Linter[error] 61-74: dotnet format detected whitespace formatting errors including deletions of characters at multiple lines. [error] 70-70: IDE1007: The name 'condition' does not exist in the current context. [warning] 61-69: IDE0044: Make field readonly. 🪛 GitHub Actions: ReSharper Inspection[error] 70-70: CS1519: Invalid token 'if' in class, record, struct, or interface member declaration [error] 70-70: CS8124: Tuple must contain at least two elements. [error] 70-70: CS1026: ) expected [error] 70-70: CS1519: Invalid token '==' in class, record, struct, or interface member declaration [error] 72-72: CS1519: Invalid token '(' in class, record, struct, or interface member declaration [error] 72-72: CS1031: Type expected [error] 72-72: CS8124: Tuple must contain at least two elements. [error] 72-72: CS1026: ) expected [error] 72-72: CS1519: Invalid token '"Redundant"' in class, record, struct, or interface member declaration 🤖 Prompt for AI Agents
|
||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Multiple using statement formatting violations.
The using statements demonstrate several formatting issues:
Apply this diff to fix the using statement formatting:
📝 Committable suggestion
🤖 Prompt for AI Agents