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).
309
301
if(settingsObj!=null)
310
302
{
311
-
// NOTHROW UpdateSettings(object) 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,
327
317
// we use the same strategy for CustomRulePath. So, we take the union of CustomRulePath provided in
328
318
// the settings file and if provided on command line.
329
-
// 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
+1-20Lines changed: 1 addition & 20 deletions
Original file line number
Diff line number
Diff line change
@@ -73,12 +73,10 @@ 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?
77
76
parseSettingsFile(settingsFilePath);
78
77
}
79
78
else
80
79
{
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)
82
80
thrownewArgumentException(
83
81
String.Format(
84
82
CultureInfo.CurrentCulture,
@@ -91,12 +89,10 @@ public Settings(object settings, Func<string, string> presetResolver)
91
89
varsettingsHashtable=settingsasHashtable;
92
90
if(settingsHashtable!=null)
93
91
{
94
-
// QUESTION When does parseSettingsHashtable(Hashtable) throw?
95
92
parseSettingsHashtable(settingsHashtable);
96
93
}
97
94
else
98
95
{
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>
185
181
/// <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.
223
216
catch
224
217
{
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
726
708
// 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