Skip to content

Allow multiline conditional expressions - #4336

Merged
AArnott merged 3 commits into
DotNetAnalyzers:masterfrom
bgrainger:sa1143
Oct 17, 2026
Merged

AArnott merged 3 commits into
DotNetAnalyzers:masterfrom
bgrainger:sa1143

Conversation

@bgrainger

@bgrainger bgrainger commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #4335

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 behavior change has regression coverage, with only a nonblocking documentation synchronization issue remaining.

1 open issue
What changed in this PR

Updates SA1143 to allow multiline branches in expanded conditional expressions, addressing #4335.

Changes:

  • Relaxes branch-length restrictions while preserving operator placement checks.
  • Adds arithmetic and C# 9 target-typed object creation tests.
  • Documents the allowance with an example.
File Description
test/​StyleCop.Analyzers.Test/​ReadabilityRules/​SA1143UnitTests.cs Covers multiline arithmetic branches.
test/​StyleCop.Analyzers.Test.CSharp9/​ReadabilityRules/​SA1143CSharp9UnitTests.cs Covers multiline target-typed object creation.
src/​StyleCop.Analyzers/​ReadabilityRules/​SA1143ConditionalExpressionsMustBeFormattedConsistently.cs Permits multiline expanded branches.
documentation/​SA1143.md Explains and illustrates the updated layout.

Review effort: Balanced

Comment thread documentation/SA1143.md Resolved
Update localized documentation for the multiline branch allowance.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings October 17, 2026 18:40
AArnott
AArnott previously approved these changes Oct 17, 2026

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.

🟡 Changes recommended

Interpolated-string boundaries still trigger false positives where adding indentation changes the string value.

1 open issue
1 resolved since last review

Review effort: Balanced

@codecov

codecov Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 97.67%. Comparing base (9b0f9e7) to head (69abade).
⚠️ Report is 6 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff            @@
##           master    #4336    +/-   ##
========================================
  Coverage   97.66%   97.67%            
========================================
  Files        1331     1332     +1     
  Lines      147246   147661   +415     
  Branches     4977     4989    +12     
========================================
+ Hits       143813   144222   +409     
- Misses       2176     2178     +2     
- Partials     1257     1261     +4     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@AArnott
AArnott disabled auto-merge October 17, 2026 18:51
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings October 17, 2026 18:53

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 analyzer change has regression coverage and matching documentation, with no unresolved review findings.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

This was referenced Nov 22, 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.

SA1143 multiline is too restrictive

3 participants