Skip to content

Commit 11838b0

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 443641c commit 11838b0

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

src/PowerShellEditorServices/Analysis/AnalysisService.cs

+16-4
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,21 @@ 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+
"PSMissingModuleManifestField",
37+
"PSAvoidDefaultValueSwitchParameter",
38+
"PSUseDeclaredVarsMoreThanAssigments"
39+
};
40+
2641
#endregion
2742

2843
#region Constructors
@@ -32,8 +47,6 @@ public class AnalysisService : IDisposable
3247
/// </summary>
3348
public AnalysisService()
3449
{
35-
// TODO: Share runspace with PowerShellContext? Probably should always
36-
// run analysis in a local session.
3750
this.analysisRunspace = RunspaceFactory.CreateRunspace(InitialSessionState.CreateDefault2());
3851
this.analysisRunspace.ApartmentState = ApartmentState.STA;
3952
this.analysisRunspace.ThreadOptions = PSThreadOptions.ReuseThread;
@@ -44,8 +57,7 @@ public AnalysisService()
4457
this.analysisRunspace,
4558
new AnalysisOutputWriter(),
4659
null,
47-
null,
48-
new string[] { "DscTestsPresent", "DscExamplesPresent" });
60+
IncludedRules);
4961
}
5062

5163
#endregion

0 commit comments

Comments
 (0)