From 7fc45fad930a738594444f44d4b3ab646afb9ce3 Mon Sep 17 00:00:00 2001 From: Matt Kotsenas Date: Fri, 14 Jun 2024 07:32:46 -0700 Subject: [PATCH 1/4] Move suppression of SA1633 to .editorconfig --- .editorconfig | 1 + Source/Moq.Analyzers.Test/GlobalSuppressions.cs | 1 - Source/Moq.Analyzers/GlobalSuppressions.cs | 1 - 3 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.editorconfig b/.editorconfig index 666d479ee..3577dbccc 100644 --- a/.editorconfig +++ b/.editorconfig @@ -38,6 +38,7 @@ insert_final_newline = true dotnet_separate_import_directive_groups = false dotnet_sort_system_directives_first = true file_header_template = unset +dotnet_diagnostic.SA1633.severity = silent # A C# code file is missing a standard file header. https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1633.md # this. and Me. preferences dotnet_style_qualification_for_event = false:silent diff --git a/Source/Moq.Analyzers.Test/GlobalSuppressions.cs b/Source/Moq.Analyzers.Test/GlobalSuppressions.cs index 47a706e8e..f10514b14 100644 --- a/Source/Moq.Analyzers.Test/GlobalSuppressions.cs +++ b/Source/Moq.Analyzers.Test/GlobalSuppressions.cs @@ -3,7 +3,6 @@ // Project-level suppressions either have no target or are given // a specific target and scoped to a namespace, type, member, etc. -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1633:File must have header", Justification = "Not required")] [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1652:Enable XML documentation output", Justification = "Not required")] [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.LayoutRules", "SA1503:Braces must not be omitted", Justification = "Not required")] [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.ReadabilityRules", "SA1101:Prefix local calls with this", Justification = "Not required")] diff --git a/Source/Moq.Analyzers/GlobalSuppressions.cs b/Source/Moq.Analyzers/GlobalSuppressions.cs index 47a706e8e..f10514b14 100644 --- a/Source/Moq.Analyzers/GlobalSuppressions.cs +++ b/Source/Moq.Analyzers/GlobalSuppressions.cs @@ -3,7 +3,6 @@ // Project-level suppressions either have no target or are given // a specific target and scoped to a namespace, type, member, etc. -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1633:File must have header", Justification = "Not required")] [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1652:Enable XML documentation output", Justification = "Not required")] [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.LayoutRules", "SA1503:Braces must not be omitted", Justification = "Not required")] [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.ReadabilityRules", "SA1101:Prefix local calls with this", Justification = "Not required")] From b2db83f2bf21d70f8316ee397a937922d3725ea4 Mon Sep 17 00:00:00 2001 From: Matt Kotsenas Date: Fri, 14 Jun 2024 07:44:04 -0700 Subject: [PATCH 2/4] Clean up XMLDocs warnings --- .editorconfig | 4 ++++ Source/Moq.Analyzers.Test/GlobalSuppressions.cs | 2 -- .../Moq.Analyzers/ConstructorArgumentsShouldMatchAnalyzer.cs | 1 + Source/Moq.Analyzers/GlobalSuppressions.cs | 2 -- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.editorconfig b/.editorconfig index 3577dbccc..d477e166e 100644 --- a/.editorconfig +++ b/.editorconfig @@ -85,6 +85,10 @@ dotnet_code_quality_unused_parameters = all:suggestion # Suppression preferences dotnet_remove_unnecessary_suppression_exclusions = none +# XMLDocs preferences +# SA1600: Elements should be documented. We disable this it requires xmldocs for _all_ members. CS1591 already covers documenting public members. +dotnet_diagnostic.SA1600.severity = silent + #### C# Coding Conventions #### [*.cs] diff --git a/Source/Moq.Analyzers.Test/GlobalSuppressions.cs b/Source/Moq.Analyzers.Test/GlobalSuppressions.cs index f10514b14..969c4f25c 100644 --- a/Source/Moq.Analyzers.Test/GlobalSuppressions.cs +++ b/Source/Moq.Analyzers.Test/GlobalSuppressions.cs @@ -3,7 +3,5 @@ // Project-level suppressions either have no target or are given // a specific target and scoped to a namespace, type, member, etc. -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1652:Enable XML documentation output", Justification = "Not required")] [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.LayoutRules", "SA1503:Braces must not be omitted", Justification = "Not required")] [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.ReadabilityRules", "SA1101:Prefix local calls with this", Justification = "Not required")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:Elements should be documented", Justification = "Not required")] diff --git a/Source/Moq.Analyzers/ConstructorArgumentsShouldMatchAnalyzer.cs b/Source/Moq.Analyzers/ConstructorArgumentsShouldMatchAnalyzer.cs index 2f57141ff..b08d5c99d 100644 --- a/Source/Moq.Analyzers/ConstructorArgumentsShouldMatchAnalyzer.cs +++ b/Source/Moq.Analyzers/ConstructorArgumentsShouldMatchAnalyzer.cs @@ -27,6 +27,7 @@ public override ImmutableArray SupportedDiagnostics get { return ImmutableArray.Create(Rule); } } + /// public override void Initialize(AnalysisContext context) { context.EnableConcurrentExecution(); diff --git a/Source/Moq.Analyzers/GlobalSuppressions.cs b/Source/Moq.Analyzers/GlobalSuppressions.cs index f10514b14..969c4f25c 100644 --- a/Source/Moq.Analyzers/GlobalSuppressions.cs +++ b/Source/Moq.Analyzers/GlobalSuppressions.cs @@ -3,7 +3,5 @@ // Project-level suppressions either have no target or are given // a specific target and scoped to a namespace, type, member, etc. -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1652:Enable XML documentation output", Justification = "Not required")] [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.LayoutRules", "SA1503:Braces must not be omitted", Justification = "Not required")] [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.ReadabilityRules", "SA1101:Prefix local calls with this", Justification = "Not required")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:Elements should be documented", Justification = "Not required")] From 64dfc8588cf61ae8b3250088e6e041288548f2ac Mon Sep 17 00:00:00 2001 From: Matt Kotsenas Date: Fri, 14 Jun 2024 07:50:38 -0700 Subject: [PATCH 3/4] Clean up dead TODOs --- Source/Moq.Analyzers.Test/AsAcceptOnlyInterfaceAnalyzerTests.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/Source/Moq.Analyzers.Test/AsAcceptOnlyInterfaceAnalyzerTests.cs b/Source/Moq.Analyzers.Test/AsAcceptOnlyInterfaceAnalyzerTests.cs index fd7f54edd..870c03832 100644 --- a/Source/Moq.Analyzers.Test/AsAcceptOnlyInterfaceAnalyzerTests.cs +++ b/Source/Moq.Analyzers.Test/AsAcceptOnlyInterfaceAnalyzerTests.cs @@ -9,11 +9,9 @@ public static IEnumerable TestData() { return new object[][] { - // TODO: .As and .As feels redundant ["""new Mock().As<{|Moq1300:BaseSampleClass|}>();"""], ["""new Mock().As<{|Moq1300:SampleClass|}>();"""], ["""new Mock().As();"""], - // TODO: Testing with .Setup() and .Returns() seems unnecessary. ["""new Mock().As().Setup(x => x.Calculate(It.IsAny(), It.IsAny())).Returns(10);"""], }.WithNamespaces().WithReferenceAssemblyGroups(); } From aa30448abc9b9c754c683e3145c4a921b64d0ae7 Mon Sep 17 00:00:00 2001 From: Matt Kotsenas Date: Fri, 14 Jun 2024 08:00:53 -0700 Subject: [PATCH 4/4] Move SA1101 to .editorconfig --- .editorconfig | 1 + Source/Moq.Analyzers.Test/GlobalSuppressions.cs | 1 - Source/Moq.Analyzers/GlobalSuppressions.cs | 1 - 3 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.editorconfig b/.editorconfig index d477e166e..e7d7b1352 100644 --- a/.editorconfig +++ b/.editorconfig @@ -45,6 +45,7 @@ dotnet_style_qualification_for_event = false:silent dotnet_style_qualification_for_field = false:silent dotnet_style_qualification_for_method = false:silent dotnet_style_qualification_for_property = false:silent +dotnet_diagnostic.SA1101.severity = silent # SA1101: Prefix local calls with this # Language keywords vs BCL types preferences dotnet_style_predefined_type_for_locals_parameters_members = true:silent diff --git a/Source/Moq.Analyzers.Test/GlobalSuppressions.cs b/Source/Moq.Analyzers.Test/GlobalSuppressions.cs index 969c4f25c..15348aa5c 100644 --- a/Source/Moq.Analyzers.Test/GlobalSuppressions.cs +++ b/Source/Moq.Analyzers.Test/GlobalSuppressions.cs @@ -4,4 +4,3 @@ // a specific target and scoped to a namespace, type, member, etc. [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.LayoutRules", "SA1503:Braces must not be omitted", Justification = "Not required")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.ReadabilityRules", "SA1101:Prefix local calls with this", Justification = "Not required")] diff --git a/Source/Moq.Analyzers/GlobalSuppressions.cs b/Source/Moq.Analyzers/GlobalSuppressions.cs index 969c4f25c..15348aa5c 100644 --- a/Source/Moq.Analyzers/GlobalSuppressions.cs +++ b/Source/Moq.Analyzers/GlobalSuppressions.cs @@ -4,4 +4,3 @@ // a specific target and scoped to a namespace, type, member, etc. [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.LayoutRules", "SA1503:Braces must not be omitted", Justification = "Not required")] -[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("StyleCop.CSharp.ReadabilityRules", "SA1101:Prefix local calls with this", Justification = "Not required")]