Skip to content

Commit f9d8015

Browse files
committed
Use a minimal set of Script Analyzer rules
This change greatly reduces the set of Script Analyzer rules that are used by default in the analysis service. In the future, this list of rules will be fully configurable by the user. This change is meant to simplify the ruleset in the meantime.
1 parent 7d864df commit f9d8015

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

src/PowerShellEditorServices/Analysis/AnalysisService.cs

+17-4
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,22 @@ public class AnalysisService : IDisposable
2323
private Runspace analysisRunspace;
2424
private ScriptAnalyzer scriptAnalyzer;
2525

26+
/// <summary>
27+
/// Defines the list of Script Analyzer rules to include by default.
28+
/// In the future, a default rule set from Script Analyzer may be used.
29+
/// </summary>
30+
private static readonly string[] IncludedRules = new string[]
31+
{
32+
"PSUseApprovedVerbs",
33+
"PSReservedCmdletChar",
34+
"PSReservedParams",
35+
"PSShouldProcess",
36+
"PSUseShouldProcessForStateChangingFunctions",
37+
"PSUseSingularNouns",
38+
"PSMissingModuleManifestField",
39+
"PSAvoidDefaultValueSwitchParameter"
40+
};
41+
2642
#endregion
2743

2844
#region Constructors
@@ -32,8 +48,6 @@ public class AnalysisService : IDisposable
3248
/// </summary>
3349
public AnalysisService()
3450
{
35-
// TODO: Share runspace with PowerShellContext? Probably should always
36-
// run analysis in a local session.
3751
this.analysisRunspace = RunspaceFactory.CreateRunspace(InitialSessionState.CreateDefault2());
3852
this.analysisRunspace.ApartmentState = ApartmentState.STA;
3953
this.analysisRunspace.ThreadOptions = PSThreadOptions.ReuseThread;
@@ -44,8 +58,7 @@ public AnalysisService()
4458
this.analysisRunspace,
4559
new AnalysisOutputWriter(),
4660
null,
47-
null,
48-
new string[] { "DscTestsPresent", "DscExamplesPresent" });
61+
IncludedRules);
4962
}
5063

5164
#endregion

0 commit comments

Comments
 (0)