Skip to content

SA1114: Allow comment lines before parameter and argument lists - #4270

Merged
AArnott merged 1 commit into
masterfrom
aarnott-sa1114-comments
Oct 13, 2026
Merged

AArnott merged 1 commit into
masterfrom
aarnott-sa1114-comments

Conversation

@AArnott

@AArnott AArnott commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

Fixes #2917

SA1114 compared the opening bracket and first item's line numbers directly, incorrectly treating comment lines as blank lines. The analyzer now checks the intervening trivia only when the existing line-distance check would report. Comments are allowed, while blank lines before or after comments still report at the first item. The check is shared across SA1114's parameter, argument, attribute, and array-rank lists; existing directive handling is preserved. The English, Russian, and Czech rule documentation describes this exemption.

The exact grouped-string-and-number argument regression was added first and fails on master 5fb0ffaf999434bf5b78b7c8bb86c8334ac46b37: expected 0 diagnostics, actual SA1114 at line 9, column 1 (the first string argument). Before any product changes, the base rule suite had 36 comment-only regression failures and 131 passes, including the blank-line near misses. Additional coverage checks all seven list shapes, single-line and multiline comments, comments starting on the opening-bracket line, blank lines around comments, blank lines inside block comments, and unchanged conditional-directive behavior.

Performance: No new registrations, semantic-model calls, allocations, or tree walks. Same-line and immediately-next-line lists follow the unchanged fast path. Only existing diagnostic candidates inspect the opening token's trailing trivia and first item's leading trivia, stopping at the first blank line or unsupported trivia. Cost is linear in those two trivia lists; no benchmark-based speed claim.

Validation: SDK 10.0.401; dotnet build -c Release -maxcpucount:1 succeeded with zero warnings and errors. All SA1114 tests passed in Release on net10.0 for C# 6–15 (2,862 tests total), plus the C# 6 and C# 15 suites on net472 (568 tests). The base Debug rule suite also passed after the initial fix. PR intentionally remains draft for CI and human review.

Allow comment-only gaps before the first list item without allowing blank lines or changing directive handling. Add the regression for #2917 and coverage for every affected list kind.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@codecov

codecov Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 99.03846% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 97.61%. Comparing base (5fb0ffa) to head (c5359e2).
⚠️ Report is 10 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #4270   +/-   ##
=======================================
  Coverage   97.61%   97.61%           
=======================================
  Files        1285     1285           
  Lines      137307   137404   +97     
  Branches     4451     4461   +10     
=======================================
+ Hits       134029   134125   +96     
  Misses       2113     2113           
- Partials     1165     1166    +1     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@AArnott
AArnott marked this pull request as ready for review October 13, 2026 16:08
Copilot AI balanced review requested due to automatic review settings October 13, 2026 16:08
@AArnott
AArnott merged commit dbd2d85 into master Oct 13, 2026
30 checks passed
@AArnott
AArnott deleted the aarnott-sa1114-comments branch October 13, 2026 16:08

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

The focused implementation preserves existing fast paths and is comprehensively covered across affected syntax shapes and edge cases.

0 open findings

What changed in this PR

Updates SA1114 so comment-only lines do not count as blank lines, while preserving diagnostics for actual blank lines and directives.

Changes:

  • Adds trivia-based comment detection across supported list types.
  • Adds comprehensive regression and boundary tests.
  • Documents the exemption in English, Russian, and Czech.
File Description
SA1114UnitTests.cs Adds comment, blank-line, list-shape, and directive coverage.
SA1114ParameterListMustFollowDeclaration.cs Implements comment-aware blank-line detection.
documentation/​SA1114.md Documents the exemption in English.
documentation/​ru-ru/​SA1114.md Adds Russian documentation.
documentation/​cs-cz/​SA1114.md Adds Czech documentation.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

This was referenced Nov 11, 2026
This was referenced Nov 20, 2026
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.

SA1114: ParameterListMustFollowDeclaration and case with comments

2 participants