Skip to content

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
23 changes: 23 additions & 0 deletions .github/workflows/lint.yml
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
27 changes: 27 additions & 0 deletions .github/workflows/resharper.yml
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 }}
27 changes: 27 additions & 0 deletions BadCode.cs
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
Comment on lines +4 to +6
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Multiple using statement formatting violations.

The using statements demonstrate several formatting issues:

  • Extra spaces around keywords and operators
  • Multiple using statements on the same line
  • Misplaced space after "System."
  • Trailing spaces in comments

Apply this diff to fix the using statement formatting:

-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                                
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
🤖 Prompt for AI Agents
In BadCode.cs around lines 4 to 6, fix the using statements by placing each
using directive on its own line without extra spaces, remove the space after
"System." in "System.Linq", and eliminate trailing spaces after comments. Ensure
proper ordering and consistent formatting with no multiple using statements on
the same line.


namespace BadlyFormattedNS { // brace on same line, double spaces
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

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

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
namespace BadlyFormattedNS { // brace on same line, double spaces
namespace BadlyFormattedNS
{
🤖 Prompt for AI Agents
In BadCode.cs at line 8, the namespace declaration has extra spaces and the
opening brace is on the same line, which violates C# formatting conventions.
Remove the extra spaces between the namespace name and the brace, and place the
opening brace on the next line to conform to standard formatting.

public class bad_class // wrong casing + double spaces
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

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

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
public class bad_class // wrong casing + double spaces
public class BadClass
🤖 Prompt for AI Agents
In BadCode.cs at line 9, the class name uses incorrect casing and has extra
spaces. Rename the class to use PascalCase (e.g., BadClass) and remove any extra
spaces around the class keyword and name to comply with C# naming conventions
and formatting standards.

{
private static readonly int ANSWER =42;// field casing, spacing, rogue constant
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

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
In BadCode.cs at line 11, the field declaration has incorrect casing, excessive
spacing, and lacks spaces around the assignment operator. Rename the field to
use camelCase or PascalCase as per conventions, reduce multiple spaces to single
spaces, and add spaces around the '=' operator to improve readability and adhere
to style guidelines.


public BadCode( ) {Console . WriteLine( "Created" );} // spaces everywhere & braces
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

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

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
public BadCode( ) {Console . WriteLine( "Created" );} // spaces everywhere & braces
public BadCode()
{
Console.WriteLine("Created");
}
🤖 Prompt for AI Agents
In BadCode.cs at line 13, the constructor has inconsistent spacing around
parentheses, method call, and braces. Remove extra spaces around the constructor
name and parentheses, place the opening brace on the same line as the
constructor declaration, and format the Console.WriteLine call without spaces
between the method name and parentheses. Ensure the closing brace is on its own
line aligned with the constructor.


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
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Method formatting violations and inconsistent indentation.

The DoStuff method demonstrates multiple formatting issues: parameter spacing, brace placement, inconsistent indentation, and crowded code blocks.

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

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
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}");
}
}
🤖 Prompt for AI Agents
In BadCode.cs around lines 15 to 19, the DoStuff method has inconsistent
indentation, improper brace placement, and excessive spacing in parameters and
code blocks. Fix this by aligning the method signature parameters without extra
spaces, placing the opening brace on the same line as the method declaration,
properly indenting the method body and foreach loop, and ensuring consistent
spacing inside the code block for readability.


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
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

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
In BadCode.cs around lines 21 to 26, fix the async method formatting by removing
extra spaces around generic type parameters, method calls, and braces. Ensure no
spaces exist around dots in method calls, no spaces inside parentheses,
consistent spacing in collections, and place the closing brace correctly without
extra spaces.

} // No newline at end
13 changes: 13 additions & 0 deletions BadCodeProject.csproj
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
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Duplicate / orphaned project file will confuse the build & CI

The repo already contains BadCodeProject/BadCodeProject.csproj, which is the one referenced by the solution and the GitHub-Actions workflows.
This top-level BadCodeProject.csproj is never referenced, points to a different (narrow) set of sources, and will be picked up by dotnet CLI commands that glob for *.csproj.
Expect at least one of these headaches:
dotnet restore / dotnet build executed from repo root will try to restore & build both projects
• conflicting output paths / package assets
• CI time wasted on a project that should not exist

If the intent was to keep only the project under BadCodeProject/, delete this file; otherwise move it to its own directory and reference it from a separate solution.

- BadCodeProject.csproj   ⟵ delete (or move/rename)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<!-- 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>
🤖 Prompt for AI Agents
In BadCodeProject.csproj lines 1 to 13, this top-level project file is a
duplicate and not referenced by the solution or CI workflows, causing build and
restore conflicts. To fix this, delete this top-level BadCodeProject.csproj file
if the intended project is the one under the BadCodeProject/ directory. If you
need to keep it, move this file into its own folder and ensure it is referenced
by a separate solution to avoid conflicts.

18 changes: 18 additions & 0 deletions BadCodeProject.sln
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
10 changes: 10 additions & 0 deletions BadCodeProject/BadCodeProject.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>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

</Project>
76 changes: 76 additions & 0 deletions BadCodeProject/Program.cs
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)

Check failure on line 70 in BadCodeProject/Program.cs

View workflow job for this annotation

GitHub Actions / lint

The name 'condition' does not exist in the current context.
{
Console.WriteLine("Redundant");

Check failure on line 72 in BadCodeProject/Program.cs

View workflow job for this annotation

GitHub Actions / lint

The name 'WriteLine' does not exist in the current context.

Check failure on line 72 in BadCodeProject/Program.cs

View workflow job for this annotation

GitHub Actions / lint

The name 'Console.WriteLine' does not exist in the current context.
}
}
Comment on lines +61 to +74
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

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 if statement is not properly contained within a method.

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");
+            }

Committable suggestion skipped: line range outside the PR's diff.

🧰 Tools
🪛 GitHub Check: lint

[failure] 72-72:
The name 'WriteLine' does not exist in the current context.


[failure] 72-72:
The name 'Console.WriteLine' does not exist in the current context.


[failure] 70-70:
The name 'condition' does not exist in the current context.

🪛 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
In BadCodeProject/Program.cs around lines 61 to 74, the code declares local
variables with access modifiers and places control flow statements outside any
method, causing compilation errors. To fix this, move all variable declarations
and the if statement inside a valid method (e.g., Main or another method),
remove access modifiers from local variables, and ensure all executable code is
within method bodies.

}
}
Loading