Skip to content

Commit

Permalink
Move analyzer RCS1036 to Formatting.Analyzers (RCS0063) (#1600)
Browse files Browse the repository at this point in the history
  • Loading branch information
josefpihrt authored Feb 8, 2025
1 parent 4b6dcf5 commit 026a949
Show file tree
Hide file tree
Showing 14 changed files with 1,427 additions and 695 deletions.
5 changes: 5 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Affects analyzer [RCS1016](https://josefpihrt.github.io/docs/roslynator/analyzers/RCS1016)
- Affects refacoring [RR0169](https://josefpihrt.github.io/docs/roslynator/refactorings/RR0169)

### Changed

- Move analyzer [RCS1036](https://josefpihrt.github.io/docs/roslynator/analyzers/RCS1036) to Formatting.Analyzers as [RCS0063](https://josefpihrt.github.io/docs/roslynator/analyzers/RCS0063) ([PR](https://github.com/dotnet/roslynator/pull/1600))
- Old analyzer still works but is marked as obsolete.

## [4.12.11] - 2025-01-28

### Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public override ImmutableArray<string> FixableDiagnosticIds
{
return ImmutableArray.Create(
DiagnosticIdentifiers.RemoveTrailingWhitespace,
DiagnosticIdentifiers.RemoveUnnecessaryBlankLine);
DiagnosticIdentifiers.Obsolete_RemoveUnnecessaryBlankLine);
}
}

Expand Down Expand Up @@ -54,7 +54,7 @@ public override async Task RegisterCodeFixesAsync(CodeFixContext context)
context.RegisterCodeFix(codeAction, diagnostic);
break;
}
case DiagnosticIdentifiers.RemoveUnnecessaryBlankLine:
case DiagnosticIdentifiers.Obsolete_RemoveUnnecessaryBlankLine:
{
CodeAction codeAction = CodeAction.Create(
"Remove blank line",
Expand Down
41 changes: 40 additions & 1 deletion src/Analyzers.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1646,6 +1646,43 @@ public class C
<Option Key="arrow_token_new_line" IsRequired="false" />
</ConfigOptions>
</Analyzer>
<Analyzer>
<Id>RCS0063</Id>
<Identifier>RemoveUnnecessaryBlankLine</Identifier>
<Title>Remove unnecessary blank line</Title>
<DefaultSeverity>Info</DefaultSeverity>
<IsEnabledByDefault>false</IsEnabledByDefault>
<Samples>
<Sample>
<Before><![CDATA[public class Foo
{
private string _f;
public bool Bar()
{
return false;
}
}]]></Before>
<After><![CDATA[public class Foo
{
private string _f;
public bool Bar()
{
return false;
}
}]]></After>
</Sample>
</Samples>
<ConfigOptions>
<Option Key="blank_line_between_closing_brace_and_switch_section" />
</ConfigOptions>
</Analyzer>
<Analyzer>
<Id>RCS1001</Id>
<Identifier>AddBracesWhenExpressionSpansOverMultipleLines</Identifier>
Expand Down Expand Up @@ -2488,8 +2525,10 @@ if (f)
</Analyzer>
<Analyzer>
<Id>RCS1036</Id>
<Identifier>RemoveUnnecessaryBlankLine</Identifier>
<Identifier>Obsolete_RemoveUnnecessaryBlankLine</Identifier>
<Title>Remove unnecessary blank line</Title>
<Status>Obsolete</Status>
<ObsoleteMessage>Use RCS0063 instead</ObsoleteMessage>
<DefaultSeverity>Info</DefaultSeverity>
<IsEnabledByDefault>true</IsEnabledByDefault>
<Samples>
Expand Down
4 changes: 2 additions & 2 deletions src/Analyzers/Analysis/WhitespaceAnalyzer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics
Immutable.InterlockedInitialize(
ref _supportedDiagnostics,
DiagnosticRules.RemoveTrailingWhitespace,
DiagnosticRules.RemoveUnnecessaryBlankLine);
DiagnosticRules.Obsolete_RemoveUnnecessaryBlankLine);
}

return _supportedDiagnostics;
Expand Down Expand Up @@ -83,7 +83,7 @@ private static void AnalyzeTrailingTrivia(SyntaxTreeAnalysisContext context)
{
DiagnosticHelpers.ReportDiagnostic(
context,
DiagnosticRules.RemoveUnnecessaryBlankLine,
DiagnosticRules.Obsolete_RemoveUnnecessaryBlankLine,
Location.Create(context.Tree, emptyLines));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public override void Initialize(AnalysisContext context)
Validate(ref context, compilationOptions, options, Flags.ConvertMethodGroupToAnonymousFunction, ref flags, DiagnosticRules.UseAnonymousFunctionOrMethodGroup, ConfigOptions.UseAnonymousFunctionOrMethodGroup, LegacyConfigOptions.ConvertMethodGroupToAnonymousFunction, ConfigOptionValues.UseAnonymousFunctionOrMethodGroup_AnonymousFunction);
Validate(ref context, compilationOptions, options, Flags.RemoveCallToConfigureAwait, ref flags, DiagnosticRules.ConfigureAwait, ConfigOptions.ConfigureAwait, LegacyConfigOptions.RemoveCallToConfigureAwait, "false");
Validate(ref context, compilationOptions, options, Flags.RemoveAccessibilityModifiers, ref flags, DiagnosticRules.AddOrRemoveAccessibilityModifiers, ConfigOptions.AccessibilityModifiers, LegacyConfigOptions.RemoveAccessibilityModifiers, ConfigOptionValues.AccessibilityModifiers_Implicit);
Validate(ref context, compilationOptions, options, Flags.RemoveEmptyLineBetweenClosingBraceAndSwitchSection, ref flags, DiagnosticRules.RemoveUnnecessaryBlankLine, ConfigOptions.BlankLineBetweenClosingBraceAndSwitchSection, LegacyConfigOptions.RemoveEmptyLineBetweenClosingBraceAndSwitchSection, "false");
Validate(ref context, compilationOptions, options, Flags.RemoveEmptyLineBetweenClosingBraceAndSwitchSection, ref flags, DiagnosticRules.Obsolete_RemoveUnnecessaryBlankLine, ConfigOptions.BlankLineBetweenClosingBraceAndSwitchSection, LegacyConfigOptions.RemoveEmptyLineBetweenClosingBraceAndSwitchSection, "false");
Validate(ref context, compilationOptions, options, Flags.RemoveParenthesesFromConditionOfConditionalExpressionWhenExpressionIsSingleToken, ref flags, DiagnosticRules.AddOrRemoveParenthesesFromConditionInConditionalOperator, ConfigOptions.ConditionalOperatorConditionParenthesesStyle, LegacyConfigOptions.RemoveParenthesesFromConditionOfConditionalExpressionWhenExpressionIsSingleToken, ConfigOptionValues.ConditionalOperatorConditionParenthesesStyle_OmitWhenConditionIsSingleToken);
Validate(ref context, compilationOptions, options, Flags.RemoveParenthesesWhenCreatingNewObject, ref flags, DiagnosticRules.UseImplicitOrExplicitObjectCreation, ConfigOptions.ObjectCreationParenthesesStyle, LegacyConfigOptions.RemoveParenthesesWhenCreatingNewObject, ConfigOptionValues.ObjectCreationParenthesesStyle_Omit);
#pragma warning disable CS0618 // Type or member is obsolete
Expand Down
Loading

0 comments on commit 026a949

Please sign in to comment.