Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
alexcoderabbitai wants to merge2 commits intomain
base:main
Choose a base branch
Loading
frompreview/check-run
Open
Show file tree
Hide file tree
Changes fromall 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
View file
Open in desktop
Original file line numberDiff line numberDiff 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
View file
Open in desktop
Original file line numberDiff line numberDiff 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 deletionsBadCode.cs
View file
Open in desktop
Original file line numberDiff line numberDiff 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

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
usingSystem;usingSystem.Collections.Generic;// extra spaces + wrong on-line ordering
usingSystem.Linq;// misplaced space after “System.”
usingSystem.Threading.Tasks;// comment trailing spaces
usingSystem;
usingSystem.Collections.Generic;
usingSystem.Linq;
usingSystem.Threading.Tasks;
🤖 Prompt for AI Agents
In BadCode.cs around lines 4 to 6, fix the using statements by placing eachusing directive on its own line without extra spaces, remove the space after"System." in "System.Linq", and eliminate trailing spaces after comments. Ensureproper ordering and consistent formatting with no multiple using statements onthe same line.


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

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
namespaceBadlyFormattedNS{// brace on same line, double spaces
namespaceBadlyFormattedNS
{
🤖 Prompt for AI Agents
In BadCode.cs at line 8, the namespace declaration has extra spaces and theopening brace is on the same line, which violates C# formatting conventions.Remove the extra spaces between the namespace name and the brace, and place theopening brace on the next line to conform to standard formatting.

public class bad_class // wrong casing + double spaces

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
publicclassbad_class// wrong casing + double spaces
publicclassBadClass
🤖 Prompt for AI Agents
In BadCode.cs at line 9, the class name uses incorrect casing and has extraspaces. Rename the class to use PascalCase (e.g., BadClass) and remove any extraspaces around the class keyword and name to comply with C# naming conventionsand formatting standards.

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

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, excessivespacing, and lacks spaces around the assignment operator. Rename the field touse camelCase or PascalCase as per conventions, reduce multiple spaces to singlespaces, and add spaces around the '=' operator to improve readability and adhereto style guidelines.


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

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
publicBadCode(){Console.WriteLine("Created");}// spaces everywhere & braces
publicBadCode()
{
Console.WriteLine("Created");
}
🤖 Prompt for AI Agents
In BadCode.cs at line 13, the constructor has inconsistent spacing aroundparentheses, method call, and braces. Remove extra spaces around the constructorname and parentheses, place the opening brace on the same line as theconstructor declaration, and format the Console.WriteLine call without spacesbetween the method name and parentheses. Ensure the closing brace is on its ownline 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

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.

TheDoStuff 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
publicvoidDoStuff(IDictionary<string,List<int>>data)
{if(data==null){thrownewArgumentNullException(nameof(data));}
foreach(varkvpindata){
Console.WriteLine($"Key:{kvp.Key}, Count ={kvp.Value.Count}");}/* crowded */
}// incorrect indentation + brace style
publicvoidDoStuff(IDictionary<string,List<int>>data)
{
if(data==null)
{
thrownewArgumentNullException(nameof(data));
}
foreach(varkvpindata)
{
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 inconsistentindentation, improper brace placement, and excessive spacing in parameters andcode blocks. Fix this by aligning the method signature parameters without extraspaces, placing the opening brace on the same line as the method declaration,properly indenting the method body and foreach loop, and ensuring consistentspacing 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

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 removingextra spaces around generic type parameters, method calls, and braces. Ensure nospaces exist around dots in method calls, no spaces inside parentheses,consistent spacing in collections, and place the closing brace correctly withoutextra spaces.

} // No newline at end
13 changes: 13 additions & 0 deletionsBadCodeProject.csproj
View file
Open in desktop
Original file line numberDiff line numberDiff 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

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 containsBadCodeProject/BadCodeProject.csproj, which is the one referenced by the solution and the GitHub-Actions workflows.
This top-levelBadCodeProject.csproj is never referenced, points to a different (narrow) set of sources, and will be picked up bydotnet 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 & buildboth 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 underBadCodeProject/, 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-->
<ProjectSdk="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>
<CompileInclude="BadCode.cs" />
</ItemGroup>
</Project>
🤖 Prompt for AI Agents
In BadCodeProject.csproj lines 1 to 13, this top-level project file is aduplicate and not referenced by the solution or CI workflows, causing build andrestore conflicts. To fix this, delete this top-level BadCodeProject.csproj fileif the intended project is the one under the BadCodeProject/ directory. If youneed to keep it, move this file into its own folder and ensure it is referencedby a separate solution to avoid conflicts.

18 changes: 18 additions & 0 deletionsBadCodeProject.sln
View file
Open in desktop
Original file line numberDiff line numberDiff 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 deletionsBadCodeProject/BadCodeProject.csproj
View file
Open in desktop
Original file line numberDiff line numberDiff 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 deletionsBadCodeProject/Program.cs
View file
Open in desktop
Original file line numberDiff line numberDiff 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

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 theif 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 localvariables with access modifiers and places control flow statements outside anymethod, causing compilation errors. To fix this, move all variable declarationsand the if statement inside a valid method (e.g., Main or another method),remove access modifiers from local variables, and ensure all executable code iswithin method bodies.

}
}
Loading

[8]ページ先頭

©2009-2025 Movatter.jp