Closed
Description
If I pass it a string path to a PSScriptAnalyzerSettings.psd1 file, I get
System.NullReferenceException: Object reference not set to an instance of an object.
at Microsoft.Windows.PowerShell.ScriptAnalyzer.Settings.GetHashtableFromHashTableAst(HashtableAst hashTableAst)
at Microsoft.Windows.PowerShell.ScriptAnalyzer.Settings.parseSettingsFile(String settingsFilePath)
at Microsoft.Windows.PowerShell.ScriptAnalyzer.Settings.Create(Object settingsObj, String cwd, IOutputWriter outputWriter, GetResolvedProviderPathFromPSPath`3 getResolvedProviderPathFromPSPathDelegate)
at Microsoft.Windows.PowerShell.ScriptAnalyzer.Commands.InvokeFormatterCommand.BeginProcessing()
If I pass it the parsed settings file with Import-PowerShellDataFile
, I get
Invoke-Formatter : Cannot parse settings. Will abort the invocation.
Here's my settings file:
@{
ExcludeRules = @()
Rules = @{
PSPlaceOpenBrace = @{
Enable = $true
OnSameLine = $true
NewLineAfter = $true
IgnoreOneLineBlock = $true
}
PSPlaceCloseBrace = @{
Enable = $true
NewLineAfter = $false
IgnoreOneLineBlock = $true
NoEmptyLineBefore = $true
}
PSUseConsistentIndentation = @{
Enable = $true
Kind = 'space'
IndentationSize = 4
}
PSUseConsistentWhitespace = @{
Enable = $true
CheckOpenBrace = $true
CheckOpenParen = $true
CheckOperator = $true
CheckSeparator = $true
}
PSAlignAssignmentStatement = @{
Enable = $false
}
PSUseShouldProcessForStateChangingFunctions = @{
Enable = $true
}
}
}
The same happens with Invoke-ScriptAnalyzer
.