Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename analyzers RCS0030, RCS0033 #1314

Merged
merged 2 commits into from
Dec 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Group code fix "Change accessibility to ..." ([PR](https://github.com/dotnet/roslynator/pull/1305))
- [CLI] Bump Roslyn to 4.8.0 ([PR](https://github.com/dotnet/roslynator/pull/1307)).
- Group refactoring "Remove members above/below'" ([PR](https://github.com/dotnet/roslynator/pull/1308))
- Rename analyzers ([PR](https://github.com/dotnet/roslynator/pull/1314))
- "Add new line before embedded statement" -> "Put embedded statement on its own line" ([RCS0030](https://josefpihrt.github.io/docs/roslynator/analyzers/RCS0030))
- "Add new line before statement" -> "Put statement on its own line" ([RCS0033](https://josefpihrt.github.io/docs/roslynator/analyzers/RCS0033))

### Fixed

Expand Down
8 changes: 4 additions & 4 deletions src/Analyzers.xml
Original file line number Diff line number Diff line change
Expand Up @@ -782,8 +782,8 @@ namespace N
</Analyzer>
<Analyzer>
<Id>RCS0030</Id>
<Identifier>AddNewLineBeforeEmbeddedStatement</Identifier>
<Title>Add new line before embedded statement</Title>
<Identifier>PutEmbeddedStatementOnItsOwnLine</Identifier>
<Title>Put embedded statement on its own line</Title>
<DefaultSeverity>Info</DefaultSeverity>
<IsEnabledByDefault>false</IsEnabledByDefault>
<Samples>
Expand Down Expand Up @@ -850,8 +850,8 @@ namespace N
</Analyzer>
<Analyzer>
<Id>RCS0033</Id>
<Identifier>AddNewLineBeforeStatement</Identifier>
<Title>Add new line before statement</Title>
<Identifier>PutStatementOnItsOwnLine</Identifier>
<Title>Put statement on its own line</Title>
<DefaultSeverity>Info</DefaultSeverity>
<IsEnabledByDefault>false</IsEnabledByDefault>
<Samples>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ public override ImmutableArray<string> FixableDiagnosticIds
get
{
return ImmutableArray.Create(
DiagnosticIdentifiers.AddNewLineBeforeStatement,
DiagnosticIdentifiers.AddNewLineBeforeEmbeddedStatement,
DiagnosticIdentifiers.PutStatementOnItsOwnLine,
DiagnosticIdentifiers.PutEmbeddedStatementOnItsOwnLine,
DiagnosticIdentifiers.AddNewLineAfterSwitchLabel,
DiagnosticIdentifiers.AddBlankLineAfterEmbeddedStatement);
}
Expand All @@ -42,8 +42,8 @@ public override async Task RegisterCodeFixesAsync(CodeFixContext context)

switch (diagnostic.Id)
{
case DiagnosticIdentifiers.AddNewLineBeforeStatement:
case DiagnosticIdentifiers.AddNewLineBeforeEmbeddedStatement:
case DiagnosticIdentifiers.PutStatementOnItsOwnLine:
case DiagnosticIdentifiers.PutEmbeddedStatementOnItsOwnLine:
case DiagnosticIdentifiers.AddNewLineAfterSwitchLabel:
{
CodeAction codeAction = CodeAction.Create(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ public static partial class DiagnosticIdentifiers
public const string PlaceNewLineAfterOrBeforeBinaryOperator = "RCS0027";
public const string PlaceNewLineAfterOrBeforeConditionalOperator = "RCS0028";
public const string PutConstructorInitializerOnItsOwnLine = "RCS0029";
public const string AddNewLineBeforeEmbeddedStatement = "RCS0030";
public const string PutEmbeddedStatementOnItsOwnLine = "RCS0030";
public const string PutEnumMemberOnItsOwnLine = "RCS0031";
public const string PlaceNewLineAfterOrBeforeArrowToken = "RCS0032";
public const string AddNewLineBeforeStatement = "RCS0033";
public const string PutStatementOnItsOwnLine = "RCS0033";
public const string PutTypeParameterConstraintOnItsOwnLine = "RCS0034";
public const string RemoveBlankLineBetweenSingleLineDeclarationsOfSameKind = "RCS0036";
public const string RemoveBlankLineBetweenUsingDirectivesWithSameRootNamespace = "RCS0038";
Expand Down
20 changes: 10 additions & 10 deletions src/Formatting.Analyzers/CSharp/DiagnosticRules.Generated.cs
Original file line number Diff line number Diff line change
Expand Up @@ -298,15 +298,15 @@ public static partial class DiagnosticRules
customTags: Array.Empty<string>());

/// <summary>RCS0030</summary>
public static readonly DiagnosticDescriptor AddNewLineBeforeEmbeddedStatement = DiagnosticDescriptorFactory.Create(
id: DiagnosticIdentifiers.AddNewLineBeforeEmbeddedStatement,
title: "Add new line before embedded statement",
messageFormat: "Add new line before embedded statement",
public static readonly DiagnosticDescriptor PutEmbeddedStatementOnItsOwnLine = DiagnosticDescriptorFactory.Create(
id: DiagnosticIdentifiers.PutEmbeddedStatementOnItsOwnLine,
title: "Put embedded statement on its own line",
messageFormat: "Put embedded statement on its own line",
category: DiagnosticCategories.Roslynator,
defaultSeverity: DiagnosticSeverity.Info,
isEnabledByDefault: false,
description: null,
helpLinkUri: DiagnosticIdentifiers.AddNewLineBeforeEmbeddedStatement,
helpLinkUri: DiagnosticIdentifiers.PutEmbeddedStatementOnItsOwnLine,
customTags: Array.Empty<string>());

/// <summary>RCS0031</summary>
Expand Down Expand Up @@ -334,15 +334,15 @@ public static partial class DiagnosticRules
customTags: Array.Empty<string>());

/// <summary>RCS0033</summary>
public static readonly DiagnosticDescriptor AddNewLineBeforeStatement = DiagnosticDescriptorFactory.Create(
id: DiagnosticIdentifiers.AddNewLineBeforeStatement,
title: "Add new line before statement",
messageFormat: "Add new line before statement",
public static readonly DiagnosticDescriptor PutStatementOnItsOwnLine = DiagnosticDescriptorFactory.Create(
id: DiagnosticIdentifiers.PutStatementOnItsOwnLine,
title: "Put statement on its own line",
messageFormat: "Put statement on its own line",
category: DiagnosticCategories.Roslynator,
defaultSeverity: DiagnosticSeverity.Info,
isEnabledByDefault: false,
description: null,
helpLinkUri: DiagnosticIdentifiers.AddNewLineBeforeStatement,
helpLinkUri: DiagnosticIdentifiers.PutStatementOnItsOwnLine,
customTags: Array.Empty<string>());

/// <summary>RCS0034</summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
namespace Roslynator.Formatting.CSharp;

[DiagnosticAnalyzer(LanguageNames.CSharp)]
public sealed class AddNewLineBeforeEmbeddedStatementAnalyzer : BaseDiagnosticAnalyzer
public sealed class PutEmbeddedStatementOnItsOwnLineAnalyzer : BaseDiagnosticAnalyzer
{
private static ImmutableArray<DiagnosticDescriptor> _supportedDiagnostics;

Expand All @@ -20,7 +20,7 @@ public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics
get
{
if (_supportedDiagnostics.IsDefault)
Immutable.InterlockedInitialize(ref _supportedDiagnostics, DiagnosticRules.AddNewLineBeforeEmbeddedStatement);
Immutable.InterlockedInitialize(ref _supportedDiagnostics, DiagnosticRules.PutEmbeddedStatementOnItsOwnLine);

return _supportedDiagnostics;
}
Expand Down Expand Up @@ -125,7 +125,7 @@ private static void ReportDiagnostic(SyntaxNodeAnalysisContext context, Statemen
{
DiagnosticHelpers.ReportDiagnostic(
context,
DiagnosticRules.AddNewLineBeforeEmbeddedStatement,
DiagnosticRules.PutEmbeddedStatementOnItsOwnLine,
Location.Create(statement.SyntaxTree, statement.Span.WithLength(0)));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
namespace Roslynator.Formatting.CSharp;

[DiagnosticAnalyzer(LanguageNames.CSharp)]
public sealed class AddNewLineBeforeStatementAnalyzer : BaseDiagnosticAnalyzer
public sealed class PutStatementOnItsOwnLineAnalyzer : BaseDiagnosticAnalyzer
{
private static ImmutableArray<DiagnosticDescriptor> _supportedDiagnostics;

Expand All @@ -19,7 +19,7 @@ public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics
get
{
if (_supportedDiagnostics.IsDefault)
Immutable.InterlockedInitialize(ref _supportedDiagnostics, DiagnosticRules.AddNewLineBeforeStatement);
Immutable.InterlockedInitialize(ref _supportedDiagnostics, DiagnosticRules.PutStatementOnItsOwnLine);

return _supportedDiagnostics;
}
Expand Down Expand Up @@ -63,7 +63,7 @@ private static void Analyze(SyntaxNodeAnalysisContext context, SyntaxList<Statem
{
DiagnosticHelpers.ReportDiagnostic(
context,
DiagnosticRules.AddNewLineBeforeStatement,
DiagnosticRules.PutStatementOnItsOwnLine,
Location.Create(statement.SyntaxTree, statement.Span.WithLength(0)));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@

namespace Roslynator.Formatting.CSharp.Tests;

public class RCS0030AddNewLineBeforeEmbeddedStatementTests : AbstractCSharpDiagnosticVerifier<AddNewLineBeforeEmbeddedStatementAnalyzer, StatementCodeFixProvider>
public class RCS0030PutEmbeddedStatementOnItsOwnLineTests : AbstractCSharpDiagnosticVerifier<PutEmbeddedStatementOnItsOwnLineAnalyzer, StatementCodeFixProvider>
{
public override DiagnosticDescriptor Descriptor { get; } = DiagnosticRules.AddNewLineBeforeEmbeddedStatement;
public override DiagnosticDescriptor Descriptor { get; } = DiagnosticRules.PutEmbeddedStatementOnItsOwnLine;

[Fact, Trait(Traits.Analyzer, DiagnosticIdentifiers.AddNewLineBeforeEmbeddedStatement)]
[Fact, Trait(Traits.Analyzer, DiagnosticIdentifiers.PutEmbeddedStatementOnItsOwnLine)]
public async Task Test_If()
{
await VerifyDiagnosticAndFixAsync(@"
Expand All @@ -39,7 +39,7 @@ void M()
");
}

[Fact, Trait(Traits.Analyzer, DiagnosticIdentifiers.AddNewLineBeforeEmbeddedStatement)]
[Fact, Trait(Traits.Analyzer, DiagnosticIdentifiers.PutEmbeddedStatementOnItsOwnLine)]
public async Task Test_Else()
{
await VerifyDiagnosticAndFixAsync(@"
Expand Down Expand Up @@ -70,7 +70,7 @@ void M()
");
}

[Fact, Trait(Traits.Analyzer, DiagnosticIdentifiers.AddNewLineBeforeEmbeddedStatement)]
[Fact, Trait(Traits.Analyzer, DiagnosticIdentifiers.PutEmbeddedStatementOnItsOwnLine)]
public async Task Test_ForEach()
{
await VerifyDiagnosticAndFixAsync(@"
Expand Down Expand Up @@ -103,7 +103,7 @@ void M()
");
}

[Fact, Trait(Traits.Analyzer, DiagnosticIdentifiers.AddNewLineBeforeEmbeddedStatement)]
[Fact, Trait(Traits.Analyzer, DiagnosticIdentifiers.PutEmbeddedStatementOnItsOwnLine)]
public async Task Test_ForEachVariable()
{
await VerifyDiagnosticAndFixAsync(@"
Expand Down Expand Up @@ -136,7 +136,7 @@ void M()
");
}

[Fact, Trait(Traits.Analyzer, DiagnosticIdentifiers.AddNewLineBeforeEmbeddedStatement)]
[Fact, Trait(Traits.Analyzer, DiagnosticIdentifiers.PutEmbeddedStatementOnItsOwnLine)]
public async Task Test_For()
{
await VerifyDiagnosticAndFixAsync(@"
Expand Down Expand Up @@ -169,7 +169,7 @@ void M()
");
}

[Fact, Trait(Traits.Analyzer, DiagnosticIdentifiers.AddNewLineBeforeEmbeddedStatement)]
[Fact, Trait(Traits.Analyzer, DiagnosticIdentifiers.PutEmbeddedStatementOnItsOwnLine)]
public async Task Test_Using()
{
await VerifyDiagnosticAndFixAsync(@"
Expand Down Expand Up @@ -200,7 +200,7 @@ void M()
");
}

[Fact, Trait(Traits.Analyzer, DiagnosticIdentifiers.AddNewLineBeforeEmbeddedStatement)]
[Fact, Trait(Traits.Analyzer, DiagnosticIdentifiers.PutEmbeddedStatementOnItsOwnLine)]
public async Task Test_While()
{
await VerifyDiagnosticAndFixAsync(@"
Expand All @@ -227,7 +227,7 @@ void M()
");
}

[Fact, Trait(Traits.Analyzer, DiagnosticIdentifiers.AddNewLineBeforeEmbeddedStatement)]
[Fact, Trait(Traits.Analyzer, DiagnosticIdentifiers.PutEmbeddedStatementOnItsOwnLine)]
public async Task Test_Do()
{
await VerifyDiagnosticAndFixAsync(@"
Expand Down Expand Up @@ -256,7 +256,7 @@ void M()
");
}

[Fact, Trait(Traits.Analyzer, DiagnosticIdentifiers.AddNewLineBeforeEmbeddedStatement)]
[Fact, Trait(Traits.Analyzer, DiagnosticIdentifiers.PutEmbeddedStatementOnItsOwnLine)]
public async Task Test_Lock()
{
await VerifyDiagnosticAndFixAsync(@"
Expand All @@ -283,7 +283,7 @@ void M()
");
}

[Fact, Trait(Traits.Analyzer, DiagnosticIdentifiers.AddNewLineBeforeEmbeddedStatement)]
[Fact, Trait(Traits.Analyzer, DiagnosticIdentifiers.PutEmbeddedStatementOnItsOwnLine)]
public async Task Test_Fixed()
{
await VerifyDiagnosticAndFixAsync(@"
Expand Down Expand Up @@ -316,7 +316,7 @@ void M()
", options: Options.WithAllowUnsafe(true));
}

[Fact, Trait(Traits.Analyzer, DiagnosticIdentifiers.AddNewLineBeforeEmbeddedStatement)]
[Fact, Trait(Traits.Analyzer, DiagnosticIdentifiers.PutEmbeddedStatementOnItsOwnLine)]
public async Task TestNoDiagnostic_EmbeddedStatement()
{
await VerifyNoDiagnosticAsync(@"
Expand Down Expand Up @@ -367,7 +367,7 @@ private static void M()
", options: Options.WithAllowUnsafe(true));
}

[Fact, Trait(Traits.Analyzer, DiagnosticIdentifiers.AddNewLineBeforeEmbeddedStatement)]
[Fact, Trait(Traits.Analyzer, DiagnosticIdentifiers.PutEmbeddedStatementOnItsOwnLine)]
public async Task TestNoDiagnostic_Block()
{
await VerifyNoDiagnosticAsync(@"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@

namespace Roslynator.Formatting.CSharp.Tests;

public class RCS0033AddNewLineBeforeStatementTests : AbstractCSharpDiagnosticVerifier<AddNewLineBeforeStatementAnalyzer, StatementCodeFixProvider>
public class RCS0033PutStatementOnItsOwnLineTests : AbstractCSharpDiagnosticVerifier<PutStatementOnItsOwnLineAnalyzer, StatementCodeFixProvider>
{
public override DiagnosticDescriptor Descriptor { get; } = DiagnosticRules.AddNewLineBeforeStatement;
public override DiagnosticDescriptor Descriptor { get; } = DiagnosticRules.PutStatementOnItsOwnLine;

[Fact, Trait(Traits.Analyzer, DiagnosticIdentifiers.AddNewLineBeforeStatement)]
[Fact, Trait(Traits.Analyzer, DiagnosticIdentifiers.PutStatementOnItsOwnLine)]
public async Task Test_Block()
{
await VerifyDiagnosticAndFixAsync(@"
Expand All @@ -35,7 +35,7 @@ void M()
");
}

[Fact, Trait(Traits.Analyzer, DiagnosticIdentifiers.AddNewLineBeforeStatement)]
[Fact, Trait(Traits.Analyzer, DiagnosticIdentifiers.PutStatementOnItsOwnLine)]
public async Task Test_Block_SingleLine()
{
await VerifyDiagnosticAndFixAsync(@"
Expand All @@ -55,7 +55,7 @@ void M()
");
}

[Fact, Trait(Traits.Analyzer, DiagnosticIdentifiers.AddNewLineBeforeStatement)]
[Fact, Trait(Traits.Analyzer, DiagnosticIdentifiers.PutStatementOnItsOwnLine)]
public async Task Test_SwitchSection()
{
await VerifyDiagnosticAndFixAsync(@"
Expand Down Expand Up @@ -90,7 +90,7 @@ void M()
");
}

[Fact, Trait(Traits.Analyzer, DiagnosticIdentifiers.AddNewLineBeforeStatement)]
[Fact, Trait(Traits.Analyzer, DiagnosticIdentifiers.PutStatementOnItsOwnLine)]
public async Task TestNoDiagnostic_EmptyStatement()
{
await VerifyNoDiagnosticAsync(@"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ roslynator_analyzers.enabled_by_default = true|false
# Put constructor initializer on its own line
#dotnet_diagnostic.rcs0029.severity = none

# Add new line before embedded statement
# Put embedded statement on its own line
#dotnet_diagnostic.rcs0030.severity = none

# Put enum member on its own line
Expand All @@ -228,7 +228,7 @@ roslynator_analyzers.enabled_by_default = true|false
#dotnet_diagnostic.rcs0032.severity = none
# Options: roslynator_arrow_token_new_line

# Add new line before statement
# Put statement on its own line
#dotnet_diagnostic.rcs0033.severity = none

# Put type parameter constraint on its own line
Expand Down