Skip to content

Add RG0043: Warn on files exceeding 1000 lines#114

Merged
ronnygunawan merged 3 commits intomasterfrom
copilot/add-file-analyzer-rule
Nov 23, 2025
Merged

Add RG0043: Warn on files exceeding 1000 lines#114
ronnygunawan merged 3 commits intomasterfrom
copilot/add-file-analyzer-rule

Conversation

Copy link
Contributor

Copilot AI commented Nov 23, 2025

Plan: Add analyzer RG0043 - File should not contain more than 1000 lines

  • Explore repository structure and understand analyzer pattern
  • Build and test to verify current state
  • Add RG0043 diagnostic descriptor in RGDiagnosticAnalyzer.cs
  • Implement file line count analyzer using RegisterSyntaxTreeAction
  • Register the analyzer in Initialize method
  • Add RG0043 to SupportedDiagnostics array
  • Create unit tests in new FileShouldNotExceedLineLimitTests.cs (5 tests)
  • Update README.md with section 43
  • Update AnalyzerReleases.Unshipped.md with RG0043 entry
  • Build and test to verify implementation (261 tests passing)
  • Run code review (no issues found)
  • Run security checks (no alerts)
  • Address PR feedback: Enhanced README example with line number visualization

Summary

Successfully implemented RG0043 analyzer that warns when a file exceeds 1000 lines. The analyzer:

  • Has Info severity as requested
  • Uses Maintainability category
  • Includes descriptive message with file name and actual line count
  • Has comprehensive test coverage (empty, under limit, at limit, over limit scenarios)
  • Documentation added to README.md with improved visualization showing line numbers
  • Release tracking updated in AnalyzerReleases.Unshipped.md

All quality checks passed.

Original prompt

This section details on the original issue you should resolve

<issue_title>New analyzer: file should not contain more than 1000 lines.</issue_title>
<issue_description>Default severity: Info</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: ronnygunawan <3048897+ronnygunawan@users.noreply.github.com>
Copilot AI changed the title [WIP] Add analyzer for file line count limit Add RG0043: Warn on files exceeding 1000 lines Nov 23, 2025
Copilot AI requested a review from ronnygunawan November 23, 2025 16:09
@ronnygunawan ronnygunawan marked this pull request as ready for review November 23, 2025 16:12
Copy link
Owner

@ronnygunawan ronnygunawan left a comment

Choose a reason for hiding this comment

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

Comment on lines +727 to +730
```cs
// In a file with more than 1000 lines:
// RG0043: File 'LargeClass.cs' contains 1523 lines, which exceeds the maximum recommended limit of 1000 lines
```
Copy link
Owner

Choose a reason for hiding this comment

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

Let's visualize the line numbers:

// In a file with more than 1000 lines:
// RG0043: File 'LargeClass.cs' contains 1523 lines, which exceeds the maximum recommended limit of 1000 lines
   1 | using System;
   2 | using System.Collection;

1521 |     }
1522 | }
1523 |

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated the example with line number visualization as suggested in commit d0b4b9e.

Co-authored-by: ronnygunawan <3048897+ronnygunawan@users.noreply.github.com>
Copy link
Owner

@ronnygunawan ronnygunawan left a comment

Choose a reason for hiding this comment

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

@copilot LGTM

@ronnygunawan ronnygunawan merged commit e6a269f into master Nov 23, 2025
2 checks passed
@ronnygunawan ronnygunawan deleted the copilot/add-file-analyzer-rule branch November 23, 2025 16:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

New analyzer: file should not contain more than 1000 lines.

2 participants