Skip to content

Commit

Permalink
Fix analyzer RCS0061 (#1376)
Browse files Browse the repository at this point in the history
  • Loading branch information
josefpihrt committed Jan 24, 2024
1 parent 7ebf415 commit 296142b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 17 deletions.
1 change: 1 addition & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fix analyzer [RCS1261](https://josefpihrt.github.io/docs/roslynator/analyzers/RCS1261) ([PR](https://github.com/dotnet/roslynator/pull/1374))
- Fix analyzer [RCS0056](https://josefpihrt.github.io/docs/roslynator/analyzers/RCS0056) ([PR](https://github.com/dotnet/roslynator/pull/1373))
- Fix analyzer [RCS1211](https://josefpihrt.github.io/docs/roslynator/analyzers/RCS1211) ([PR](https://github.com/dotnet/roslynator/pull/1377))
- Fix analyzer [RCS0061](https://josefpihrt.github.io/docs/roslynator/analyzers/RCS0061) ([PR](https://github.com/dotnet/roslynator/pull/1376))

## [4.9.0] - 2024-01-10

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,30 +55,30 @@ private static void AnalyzeSwitchStatement(SyntaxNodeAnalysisContext context)
{
TriviaBlock block = TriviaBlock.FromBetween(previousSection, en.Current);

if (!block.Success)
continue;

if (block.Kind == TriviaBlockKind.BlankLine)
if (block.Success)
{
if (option == BlankLineBetweenSwitchSections.Omit)
if (block.Kind == TriviaBlockKind.BlankLine)
{
if (option == BlankLineBetweenSwitchSections.Omit)
{
ReportDiagnostic(context, block, "Remove");
}
else if (option == BlankLineBetweenSwitchSections.OmitAfterBlock
&& previousLastStatement.IsKind(SyntaxKind.Block))
{
ReportDiagnostic(context, block, "Remove");
}
}
else if (option == BlankLineBetweenSwitchSections.Include)
{
ReportDiagnostic(context, block, "Remove");
ReportDiagnostic(context, block, "Add");
}
else if (option == BlankLineBetweenSwitchSections.OmitAfterBlock
&& previousLastStatement.IsKind(SyntaxKind.Block))
&& !previousLastStatement.IsKind(SyntaxKind.Block))
{
ReportDiagnostic(context, block, "Remove");
ReportDiagnostic(context, block, "Add");
}
}
else if (option == BlankLineBetweenSwitchSections.Include)
{
ReportDiagnostic(context, block, "Add");
}
else if (option == BlankLineBetweenSwitchSections.OmitAfterBlock
&& !previousLastStatement.IsKind(SyntaxKind.Block))
{
ReportDiagnostic(context, block, "Add");
}

previousSection = en.Current;
previousLastStatement = previousSection.Statements.LastOrDefault();
Expand Down

0 comments on commit 296142b

Please sign in to comment.