You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// NOTE settingsObj cannot be null here since PSSASettings.Create(...) returns exactly `new Settings(settingsFound)`, which can never be null (but can throw).
300
308
if(settingsObj!=null)
301
309
{
310
+
// NOTHROW UpdateSettings can throw an ArgumentNullException, but that will never happen since settingsObj is tested for non-nullity immediately above.
// simultaneously. But since, this was done before with IncludeRules, ExcludeRules and Severity,
316
326
// we use the same strategy for CustomRulePath. So, we take the union of CustomRulePath provided in
317
327
// the settings file and if provided on command line.
328
+
// THROW Helper.ProcessCustomRulePaths(string[], SessionState, bool) throws one of six different exceptions if a settings' custom rule path is invalid somehow (e.g. drive doesn't exit; no wildcards but item doesn't exist; provider throws a lower-level exception; etc.). See the implementation of Helper.ProcessCustomRulePaths(string[], SessionState, bool) for details.
// NOTE Any exception in resolving, getting, parsing, updating, etc. the settings herein results in an contextless WriteWarning(Strings.SettingsNotParsable), regardless of provenance.
// THROW PathIntrinsics.GetResolvedPSPathFromPSPath(rulePath) throws [System.Management.Automation.ProviderNotFoundException] if path is a provider-qualified path and the specified provider does not exist.
1510
+
// THROW PathIntrinsics.GetResolvedPSPathFromPSPath(rulePath) throws [System.Management.Automation.DriveNotFoundException] if path is a drive-qualified path and the specified drive does not exist.
1511
+
// THROW PathIntrinsics.GetResolvedPSPathFromPSPath(rulePath) throws [System.Management.Automation.ProviderInvocationException] if the provider throws an exception when its MakePath gets called.
1512
+
// THROW PathIntrinsics.GetResolvedPSPathFromPSPath(rulePath) throws [System.NotSupportedException] if the provider does not support multiple items.
1513
+
// THROW PathIntrinsics.GetResolvedPSPathFromPSPath(rulePath) throws [System.InvalidOperationException] the home location for the provider is not set and path starts with a "~".
1514
+
// THROW PathIntrinsics.GetResolvedPSPathFromPSPath(rulePath) throws [System.Management.Automation.ItemNotFoundException] if path does not contain wildcard characters and could not be found.
Copy file name to clipboardExpand all lines: Engine/Settings.cs
+20-1Lines changed: 20 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -73,10 +73,12 @@ public Settings(object settings, Func<string, string> presetResolver)
73
73
if(File.Exists(settingsFilePath))
74
74
{
75
75
filePath=settingsFilePath;
76
+
// QUESTION When does parseSettingsFile(string) throw?
76
77
parseSettingsFile(settingsFilePath);
77
78
}
78
79
else
79
80
{
81
+
// THROW ArgumentException(Strings.InvalidPath) if the resolution of the settings argument via GetResolvedProviderPathFromPSPathDelegate is non-null but not an existing file. (e.g. it may be a directory)
80
82
thrownewArgumentException(
81
83
String.Format(
82
84
CultureInfo.CurrentCulture,
@@ -89,10 +91,12 @@ public Settings(object settings, Func<string, string> presetResolver)
89
91
varsettingsHashtable=settingsasHashtable;
90
92
if(settingsHashtable!=null)
91
93
{
94
+
// QUESTION When does parseSettingsHashtable(Hashtable) throw?
92
95
parseSettingsHashtable(settingsHashtable);
93
96
}
94
97
else
95
98
{
99
+
// THROW ArgumentException(Strings.SettingsInvalidType) if settings is not convertible (`as` keyword) to Hashtable.
/// <param name="getResolvedProviderPathFromPSPathDelegate">The GetResolvedProviderPathFromPSPath method from PSCmdlet to resolve relative path including wildcard support.</param>
181
185
/// <returns>An object of Settings type.</returns>
186
+
// THROW Settings.Create(object, string, IOutputWriter, GetResolvedProviderPathFromPSPath) throws only because of the contained invocation to the Settings constructor, which does throw.
// NOTE This catch block effectively makes *any* exception resulting from resolving the settings file path reduce to the case of no settings (by way of null settingsFound). Only a WriteVerbose(Strings.SettingsCannotFindFile) identifies what happened.
216
223
catch
217
224
{
225
+
// TODO Upgrade WriteVerbose(Strings.SettingsCannotFindFile) to WriteWarning(Strings.SettingsCannotFindFile).
226
+
// TODO Perform a ShouldContinue (?) confirmation check in the event that an exception occurred while resolving the settings file path.
// THROW parseSettingsFile throws ArgumentException(Strings.InvalidProfile) if GetSafeValueFromHashtableAst(hashTableAst) throws an InvalidOperationException.
// if settings are not provided explicitly, look for it in the given path
708
726
// check if pssasettings.psd1 exists
727
+
// COMBAK Refactor the magic string literal "PSScriptAnalyzerSettings.psd1" to a public const field on the class. (bare minimum... although will also help open possibility for user-configurable default name)
0 commit comments