Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@ public class UseCultureAttribute : BeforeAfterTestAttribute
{
private readonly Lazy<CultureInfo> culture;

#pragma warning disable IDE0079 // Remove unnecessary suppression
#pragma warning disable SA1305 // Field names should not use Hungarian notation
private readonly Lazy<CultureInfo> uiCulture;
#pragma warning restore SA1305 // Field names should not use Hungarian notation
#pragma warning restore IDE0079 // Remove unnecessary suppression

private CultureInfo originalCulture;

Expand All @@ -55,6 +57,7 @@ public UseCultureAttribute(string culture)
{
}

#pragma warning disable IDE0079 // Remove unnecessary suppression
#pragma warning disable SA1305 // Field names should not use Hungarian notation
/// <summary>
/// Initializes a new instance of the <see cref="UseCultureAttribute"/>
Expand All @@ -64,6 +67,7 @@ public UseCultureAttribute(string culture)
/// <param name="uiCulture">The name of the UI culture.</param>
public UseCultureAttribute(string culture, string uiCulture)
#pragma warning restore SA1305 // Field names should not use Hungarian notation
#pragma warning restore IDE0079 // Remove unnecessary suppression
{
this.culture = new Lazy<CultureInfo>(() => new CultureInfo(culture));
this.uiCulture = new Lazy<CultureInfo>(() => new CultureInfo(uiCulture));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,10 @@ public void TestDebugView()
}
}

#pragma warning disable IDE0079 // Remove unnecessary suppression
#pragma warning disable IDE0060 // Remove unused parameter
private static Type StaticType<T>(T value) => typeof(T);
#pragma warning restore IDE0060 // Remove unused parameter
#pragma warning restore IDE0079 // Remove unnecessary suppression
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@

// Several test methods in this file use the same member data, but in some cases the test does not use all of the
// supported parameters. See https://github.com/xunit/xunit/issues/1556.
#pragma warning disable IDE0079 // Remove unnecessary suppression
#pragma warning disable xUnit1026 // Theory methods should use all of their parameters

namespace StyleCop.Analyzers.Test.ReadabilityRules
#pragma warning restore IDE0079 // Remove unnecessary suppression
{
using System.Collections.Generic;
using System.Threading;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@

// Several test methods in this file use the same member data, but in some cases the test does not use all of the
// supported parameters. See https://github.com/xunit/xunit/issues/1556.
#pragma warning disable IDE0079 // Remove unnecessary suppression
#pragma warning disable xUnit1026 // Theory methods should use all of their parameters

namespace StyleCop.Analyzers.Test.ReadabilityRules
#pragma warning restore IDE0079 // Remove unnecessary suppression
{
using System;
using System.Collections.Generic;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,15 @@ namespace StyleCop.Analyzers.Test.ReadabilityRules

public class SA1130UnitTests
{
#pragma warning disable IDE0079 // Remove unnecessary suppression
[SuppressMessage("MicrosoftCodeAnalysisDesign", "RS1032:Define diagnostic message correctly", Justification = "The message here matches the compiler.")]
#pragma warning restore IDE0079 // Remove unnecessary suppression
private static readonly DiagnosticDescriptor CS1065 =
new DiagnosticDescriptor(nameof(CS1065), "Title", "Default values are not valid in this context.", "Category", DiagnosticSeverity.Error, AnalyzerConstants.EnabledByDefault);

#pragma warning disable IDE0079 // Remove unnecessary suppression
[SuppressMessage("MicrosoftCodeAnalysisDesign", "RS1032:Define diagnostic message correctly", Justification = "The message here matches the compiler.")]
#pragma warning restore IDE0079 // Remove unnecessary suppression
private static readonly DiagnosticDescriptor CS7014 =
new DiagnosticDescriptor(nameof(CS7014), "Title", "Attributes are not valid in this context.", "Category", DiagnosticSeverity.Error, AnalyzerConstants.EnabledByDefault);

Expand Down
37 changes: 14 additions & 23 deletions StyleCop.Analyzers/StyleCop.Analyzers/AnalyzerConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,44 +9,35 @@ namespace StyleCop.Analyzers
internal static class AnalyzerConstants
{
/// <summary>
/// Gets a reference value which can be passed to
/// <see cref="DiagnosticDescriptor(string, string, string, string, DiagnosticSeverity, bool, string, string, string[])"/>
/// to indicate that the diagnostic is disabled by default because it is an alternative to a reference StyleCop
/// rule.
/// Gets a value indicating whether the diagnostic is disabled by default because it is an alternative to a standard
/// StyleCop rule. It is used with
/// <see cref="DiagnosticDescriptor(string, string, string, string, DiagnosticSeverity, bool, string, string, string[])"/>.
/// </summary>
/// <value>
/// A reference value which can be passed to
/// <see cref="DiagnosticDescriptor(string, string, string, string, DiagnosticSeverity, bool, string, string, string[])"/>
/// to indicate that the diagnostic is disabled by default because it is an alternative to a reference StyleCop
/// rule.
/// A value indicating the diagnostic is disabled by default because it is an alternative to a standard StyleCop rule.
/// It is used with
/// <see cref="DiagnosticDescriptor(string, string, string, string, DiagnosticSeverity, bool, string, string, string[])"/>.
/// </value>
[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1623:Property summary documentation should match accessors.", Justification = "This property behaves more like an opaque value than a Boolean.")]
internal static bool DisabledAlternative => false;

/// <summary>
/// Gets a reference value which can be passed to
/// <see cref="DiagnosticDescriptor(string, string, string, string, DiagnosticSeverity, bool, string, string, string[])"/>
/// to indicate that the diagnostic should be enabled by default.
/// Gets a value indicating whether the diagnostic should be enabled by default. It is used with
/// <see cref="DiagnosticDescriptor(string, string, string, string, DiagnosticSeverity, bool, string, string, string[])"/>.
/// </summary>
/// <value>
/// A reference value which can be passed to
/// <see cref="DiagnosticDescriptor(string, string, string, string, DiagnosticSeverity, bool, string, string, string[])"/>
/// to indicate that the diagnostic should be enabled by default.
/// A value indicating whether the diagnostic should be enabled by default. It is used with
/// <see cref="DiagnosticDescriptor(string, string, string, string, DiagnosticSeverity, bool, string, string, string[])"/>.
/// </value>
[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1623:Property summary documentation should match accessors.", Justification = "This property behaves more like an opaque value than a Boolean.")]
internal static bool EnabledByDefault => true;

/// <summary>
/// Gets a reference value which can be passed to
/// <see cref="DiagnosticDescriptor(string, string, string, string, DiagnosticSeverity, bool, string, string, string[])"/>
/// to indicate that the diagnostic should be disabled by default.
/// Gets a value indicating whether the diagnostic should be disabled by default. It is used with
/// <see cref="DiagnosticDescriptor(string, string, string, string, DiagnosticSeverity, bool, string, string, string[])"/>.
/// </summary>
/// <value>
/// A reference value which can be passed to
/// <see cref="DiagnosticDescriptor(string, string, string, string, DiagnosticSeverity, bool, string, string, string[])"/>
/// to indicate that the diagnostic should be disabled by default.
/// A value indicating whether the diagnostic should be disabled by default. It is used with
/// <see cref="DiagnosticDescriptor(string, string, string, string, DiagnosticSeverity, bool, string, string, string[])"/>.
/// </value>
[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1623:Property summary documentation should match accessors.", Justification = "This property behaves more like an opaque value than a Boolean.")]
internal static bool DisabledByDefault => false;
}
}
2 changes: 0 additions & 2 deletions StyleCop.Analyzers/StyleCop.Analyzers/AnalyzerExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ internal static class AnalyzerExtensions
/// </summary>
/// <param name="context">The analysis context.</param>
/// <param name="action">Action to be executed at completion of parsing of a document.</param>
[SuppressMessage("MicrosoftCodeAnalysisPerformance", "RS1012:Start action has no registered actions", Justification = "This is not a start action")]
public static void RegisterSyntaxTreeAction(this CompilationStartAnalysisContext context, Action<SyntaxTreeAnalysisContext, StyleCopSettings> action)
{
var settingsFile = context.GetStyleCopSettingsFile(context.CancellationToken);
Expand Down Expand Up @@ -69,7 +68,6 @@ public static void RegisterSyntaxNodeAction<TLanguageKindEnum>(this CompilationS
/// <param name="syntaxKinds">The kinds of syntax that should be analyzed.</param>
/// <typeparam name="TLanguageKindEnum">Enum type giving the syntax node kinds of the source language for which
/// the action applies.</typeparam>
[SuppressMessage("MicrosoftCodeAnalysisPerformance", "RS1012:Start action has no registered actions", Justification = "This is not a start action")]
public static void RegisterSyntaxNodeAction<TLanguageKindEnum>(this CompilationStartAnalysisContext context, Action<SyntaxNodeAnalysisContext, StyleCopSettings> action, ImmutableArray<TLanguageKindEnum> syntaxKinds)
where TLanguageKindEnum : struct
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,24 @@ internal class SA1603DocumentationMustContainValidXml : DiagnosticAnalyzer
private static readonly LocalizableString Description = new LocalizableResourceString(nameof(DocumentationResources.SA1603Description), DocumentationResources.ResourceManager, typeof(DocumentationResources));

private static readonly DiagnosticDescriptor Descriptor =
#pragma warning disable IDE0079 // Remove unnecessary suppression
#pragma warning disable RS2000 // Add analyzer diagnostic IDs to analyzer release.
new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.DocumentationRules, DiagnosticSeverity.Warning, AnalyzerConstants.DisabledByDefault, Description, HelpLink, WellKnownDiagnosticTags.NotConfigurable);
#pragma warning restore RS2000 // Add analyzer diagnostic IDs to analyzer release.
#pragma warning restore IDE0079 // Remove unnecessary suppression

/// <inheritdoc/>
public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics { get; } =
ImmutableArray.Create(Descriptor);

/// <inheritdoc/>
#pragma warning disable IDE0079 // Remove unnecessary suppression
#pragma warning disable RS1025 // Configure generated code analysis
#pragma warning disable RS1026 // Enable concurrent execution
public override void Initialize(AnalysisContext context)
#pragma warning restore RS1026 // Enable concurrent execution
#pragma warning restore RS1025 // Configure generated code analysis
#pragma warning restore IDE0079 // Remove unnecessary suppression
{
// This diagnostic is not implemented (by design) in StyleCopAnalyzers.
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ protected override void HandleXmlElement(SyntaxNodeAnalysisContext context, Styl

if (parentParameters.Length <= index || parentParameters[index] != parentParameter)
{
#pragma warning disable IDE0079 // Remove unnecessary suppression
#pragma warning disable RS1005 // ReportDiagnostic invoked with an unsupported DiagnosticDescriptor (https://github.com/dotnet/roslyn-analyzers/issues/4103)
context.ReportDiagnostic(
Diagnostic.Create(
Expand All @@ -120,6 +121,7 @@ protected override void HandleXmlElement(SyntaxNodeAnalysisContext context, Styl
nameAttributeText,
parentParameters.IndexOf(parentParameter) + 1));
#pragma warning restore RS1005 // ReportDiagnostic invoked with an unsupported DiagnosticDescriptor
#pragma warning restore IDE0079 // Remove unnecessary suppression
}
}

Expand Down Expand Up @@ -185,6 +187,7 @@ protected override void HandleCompleteDocumentation(SyntaxNodeAnalysisContext co

if (parentParameters.Length <= index || parentParameters[index] != parentParameter)
{
#pragma warning disable IDE0079 // Remove unnecessary suppression
#pragma warning disable RS1005 // ReportDiagnostic invoked with an unsupported DiagnosticDescriptor (https://github.com/dotnet/roslyn-analyzers/issues/4103)
context.ReportDiagnostic(
Diagnostic.Create(
Expand All @@ -193,6 +196,7 @@ protected override void HandleCompleteDocumentation(SyntaxNodeAnalysisContext co
nameAttributeText,
parentParameters.IndexOf(parentParameter) + 1));
#pragma warning restore RS1005 // ReportDiagnostic invoked with an unsupported DiagnosticDescriptor
#pragma warning restore IDE0079 // Remove unnecessary suppression
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,20 +49,24 @@ internal class SA1628DocumentationTextMustBeginWithACapitalLetter : DiagnosticAn
private static readonly LocalizableString Description = new LocalizableResourceString(nameof(DocumentationResources.SA1628Description), DocumentationResources.ResourceManager, typeof(DocumentationResources));

private static readonly DiagnosticDescriptor Descriptor =
#pragma warning disable IDE0079 // Remove unnecessary suppression
#pragma warning disable RS2000 // Add analyzer diagnostic IDs to analyzer release.
new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.DocumentationRules, DiagnosticSeverity.Warning, AnalyzerConstants.DisabledByDefault, Description, HelpLink, WellKnownDiagnosticTags.NotConfigurable);
#pragma warning restore RS2000 // Add analyzer diagnostic IDs to analyzer release.
#pragma warning restore IDE0079 // Remove unnecessary suppression

/// <inheritdoc/>
public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics { get; } =
ImmutableArray.Create(Descriptor);

/// <inheritdoc/>
#pragma warning disable IDE0079 // Remove unnecessary suppression
#pragma warning disable RS1025 // Configure generated code analysis
#pragma warning disable RS1026 // Enable concurrent execution
public override void Initialize(AnalysisContext context)
#pragma warning restore RS1026 // Enable concurrent execution
#pragma warning restore RS1025 // Configure generated code analysis
#pragma warning restore IDE0079 // Remove unnecessary suppression
{
// This diagnostic is not implemented (by design) in StyleCopAnalyzers.
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,20 +49,24 @@ internal class SA1630DocumentationTextMustContainWhitespace : DiagnosticAnalyzer
private static readonly LocalizableString Description = new LocalizableResourceString(nameof(DocumentationResources.SA1630Description), DocumentationResources.ResourceManager, typeof(DocumentationResources));

private static readonly DiagnosticDescriptor Descriptor =
#pragma warning disable IDE0079 // Remove unnecessary suppression
#pragma warning disable RS2000 // Add analyzer diagnostic IDs to analyzer release.
new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.DocumentationRules, DiagnosticSeverity.Warning, AnalyzerConstants.DisabledByDefault, Description, HelpLink, WellKnownDiagnosticTags.NotConfigurable);
#pragma warning restore RS2000 // Add analyzer diagnostic IDs to analyzer release.
#pragma warning restore IDE0079 // Remove unnecessary suppression

/// <inheritdoc/>
public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics { get; } =
ImmutableArray.Create(Descriptor);

/// <inheritdoc/>
#pragma warning disable IDE0079 // Remove unnecessary suppression
#pragma warning disable RS1025 // Configure generated code analysis
#pragma warning disable RS1026 // Enable concurrent execution
public override void Initialize(AnalysisContext context)
#pragma warning restore RS1026 // Enable concurrent execution
#pragma warning restore RS1025 // Configure generated code analysis
#pragma warning restore IDE0079 // Remove unnecessary suppression
{
// This diagnostic is not implemented (by design) in StyleCopAnalyzers.
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,24 @@ internal class SA1631DocumentationMustMeetCharacterPercentage : DiagnosticAnalyz
private static readonly LocalizableString Description = new LocalizableResourceString(nameof(DocumentationResources.SA1631Description), DocumentationResources.ResourceManager, typeof(DocumentationResources));

private static readonly DiagnosticDescriptor Descriptor =
#pragma warning disable IDE0079 // Remove unnecessary suppression
#pragma warning disable RS2000 // Add analyzer diagnostic IDs to analyzer release.
new DiagnosticDescriptor(DiagnosticId, Title, MessageFormat, AnalyzerCategory.DocumentationRules, DiagnosticSeverity.Warning, AnalyzerConstants.DisabledByDefault, Description, HelpLink, WellKnownDiagnosticTags.NotConfigurable);
#pragma warning restore RS2000 // Add analyzer diagnostic IDs to analyzer release.
#pragma warning restore IDE0079 // Remove unnecessary suppression

/// <inheritdoc/>
public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics { get; } =
ImmutableArray.Create(Descriptor);

/// <inheritdoc/>
#pragma warning disable IDE0079 // Remove unnecessary suppression
#pragma warning disable RS1025 // Configure generated code analysis
#pragma warning disable RS1026 // Enable concurrent execution
public override void Initialize(AnalysisContext context)
#pragma warning restore RS1026 // Enable concurrent execution
#pragma warning restore RS1025 // Configure generated code analysis
#pragma warning restore IDE0079 // Remove unnecessary suppression
{
// This diagnostic is not implemented (by design) in StyleCopAnalyzers.
}
Expand Down
Loading
Loading