Skip to content

Commit 416b58a

Browse files
committed
Enable maintainability rules (and sort rule list)
1 parent 0f8a4d6 commit 416b58a

File tree

6 files changed

+31
-29
lines changed

6 files changed

+31
-29
lines changed

.editorconfig

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ csharp_style_expression_bodied_indexers = true
2222
csharp_style_expression_bodied_accessors = true
2323
csharp_style_expression_bodied_lambdas = when_on_single_line
2424

25+
# TODO: Fix silenced and suggested rules!
26+
2527
# CS0168: The variable 'var' is declared but never used
2628
dotnet_diagnostic.CS0168.severity = error
2729
# CS0169: The private field 'class member' is never used
@@ -30,10 +32,31 @@ dotnet_diagnostic.CS0169.severity = error
3032
dotnet_diagnostic.CS0219.severity = error
3133
# CS0414: The private field 'field' is assigned but its value is never used
3234
dotnet_diagnostic.CS0414.severity = error
35+
# CS0618: A class member was marked with the Obsolete attribute
36+
dotnet_diagnostic.CS0618.severity = suggestion
37+
# CS0649: Uninitialized private or internal field declaration that is never assigned a value
38+
dotnet_diagnostic.CS0649.severity = error
39+
# CS1998: This async method lacks 'await' operators and will run synchronously
40+
dotnet_diagnostic.CS1998.severity = suggestion
41+
# CS4014: Consider applying the await operator to the result of the call
42+
dotnet_diagnostic.CS4014.severity = suggestion
43+
3344
# CA1067: Should override Equals because it implements IEquatable<T>
3445
dotnet_diagnostic.CA1067.severity = silent
3546
# CA1068: CancellationToken parameters must come last
3647
dotnet_diagnostic.CA1068.severity = error
48+
# CA1501: Avoid excessive inheritance
49+
dotnet_diagnostic.CA1501.severity = error
50+
# CA1502: Avoid excessive complexity
51+
dotnet_diagnostic.CA1502.severity = warning
52+
# CA1505: Avoid unmaintainable code
53+
dotnet_diagnostic.CA1505.severity = error
54+
# CA1506: Avoid excessive class coupling
55+
dotnet_diagnostic.CA1506.severity = warning
56+
# CA1507: Use nameof in place of string
57+
dotnet_diagnostic.CA1507.severity = error
58+
# CA1508: Avoid dead conditional code
59+
dotnet_diagnostic.CA1508.severity = error
3760
# CA1822: Mark members as static
3861
dotnet_diagnostic.CA1822.severity = error
3962
# CA1823: Avoid unused private fields
@@ -45,23 +68,6 @@ dotnet_diagnostic.CA2016.severity = error
4568
# CA2254: The logging message template should not vary between calls to 'LoggerExtensions.*'
4669
dotnet_diagnostic.CA2254.severity = silent
4770

48-
# TODO: Enable all maintainability issues (dead code etc.) and enforce
49-
# See: https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/maintainability-warnings
50-
dotnet_analyzer_diagnostic.category-Maintainability.severity = error
51-
52-
# TODO: Fix all of these issues and explicitly ignore the intentional ones!
53-
54-
# CA2016: Forward the CancellationToken parameter to methods that take one
55-
dotnet_diagnostic.CA2016.severity = error
56-
# CS0618: A class member was marked with the Obsolete attribute
57-
dotnet_diagnostic.CS0618.severity = suggestion
58-
# CS0649: Uninitialized private or internal field declaration that is never assigned a value
59-
dotnet_diagnostic.CS0649.severity = error
60-
# CS1998: This async method lacks 'await' operators and will run synchronously
61-
dotnet_diagnostic.CS1998.severity = suggestion
62-
# CS4014: Consider applying the await operator to the result of the call
63-
dotnet_diagnostic.CS4014.severity = suggestion
64-
6571
# RCS1102: Make class static
6672
dotnet_diagnostic.RCS1102.severity = error
6773
# RCS1139: Add summary element to documentation comment

src/PowerShellEditorServices/Services/Analysis/AnalysisService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ public async Task<IReadOnlyDictionary<string, IEnumerable<MarkerCorrection>>> Ge
249249
/// <param name="settings">The new language server settings.</param>
250250
public void OnConfigurationUpdated(object _, LanguageServerSettings settings)
251251
{
252-
if (settings.ScriptAnalysis.Enable ?? true)
252+
if (settings.ScriptAnalysis.Enable)
253253
{
254254
InitializeAnalysisEngineToCurrentSettings();
255255
}

src/PowerShellEditorServices/Services/DebugAdapter/Handlers/DisconnectHandler.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,7 @@ await _executionService.ExecutePSCommandAsync(
6767
new PSCommand().AddCommand("Exit-PSHostProcess"),
6868
CancellationToken.None).ConfigureAwait(false);
6969

70-
if (_debugStateService.IsRemoteAttach &&
71-
_runspaceContext.CurrentRunspace.RunspaceOrigin == RunspaceOrigin.EnteredProcess)
70+
if (_debugStateService.IsRemoteAttach)
7271
{
7372
await _executionService.ExecutePSCommandAsync(
7473
new PSCommand().AddCommand("Exit-PSSession"),

src/PowerShellEditorServices/Services/DebugAdapter/Handlers/LaunchAndAttachHandler.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -420,8 +420,7 @@ private async Task OnExecutionCompletedAsync(Task executeTask)
420420
{
421421
await _executionService.ExecutePSCommandAsync(new PSCommand().AddCommand("Exit-PSHostProcess"), CancellationToken.None).ConfigureAwait(false);
422422

423-
if (_debugStateService.IsRemoteAttach &&
424-
_runspaceContext.CurrentRunspace.RunspaceOrigin != RunspaceOrigin.Local)
423+
if (_debugStateService.IsRemoteAttach)
425424
{
426425
await _executionService.ExecutePSCommandAsync(new PSCommand().AddCommand("Exit-PSSession"), CancellationToken.None).ConfigureAwait(false);
427426
}

src/PowerShellEditorServices/Services/Workspace/Handlers/ConfigurationHandler.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,8 @@ public override async Task<Unit> Handle(DidChangeConfigurationParams request, Ca
6464
SendFeatureChangesTelemetry(incomingSettings);
6565

6666
bool profileLoadingPreviouslyEnabled = _configurationService.CurrentSettings.EnableProfileLoading;
67-
bool oldScriptAnalysisEnabled =
68-
_configurationService.CurrentSettings.ScriptAnalysis.Enable ?? false;
69-
string oldScriptAnalysisSettingsPath =
70-
_configurationService.CurrentSettings.ScriptAnalysis?.SettingsPath;
67+
bool oldScriptAnalysisEnabled = _configurationService.CurrentSettings.ScriptAnalysis.Enable;
68+
string oldScriptAnalysisSettingsPath = _configurationService.CurrentSettings.ScriptAnalysis?.SettingsPath;
7169

7270
_configurationService.CurrentSettings.Update(
7371
incomingSettings.Powershell,
@@ -186,10 +184,10 @@ private void SendFeatureChangesTelemetry(LanguageServerSettingsWrapper incomingS
186184

187185
Dictionary<string, bool> configChanges = new();
188186
// Send telemetry if the user opted-out of ScriptAnalysis
189-
if (incomingSettings.Powershell.ScriptAnalysis.Enable == false &&
187+
if (!incomingSettings.Powershell.ScriptAnalysis.Enable &&
190188
_configurationService.CurrentSettings.ScriptAnalysis.Enable != incomingSettings.Powershell.ScriptAnalysis.Enable)
191189
{
192-
configChanges["ScriptAnalysis"] = incomingSettings.Powershell.ScriptAnalysis.Enable ?? false;
190+
configChanges["ScriptAnalysis"] = incomingSettings.Powershell.ScriptAnalysis.Enable;
193191
}
194192

195193
// Send telemetry if the user opted-out of CodeFolding

src/PowerShellEditorServices/Services/Workspace/LanguageServerSettings.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public void Update(
5454
internal class ScriptAnalysisSettings
5555
{
5656
private readonly object updateLock = new();
57-
public bool? Enable { get; set; }
57+
public bool Enable { get; set; }
5858
public string SettingsPath { get; set; }
5959
public ScriptAnalysisSettings() => Enable = true;
6060

0 commit comments

Comments
 (0)