★ wanayoo — archive 1999 https://github.com/PowerShell/PSScriptAnalyzer/issues/1063Nouvelle recherche | Portail wanayoo
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when using Settings have ExcludeRules = @() #1063

Closed
felixfbecker opened this issue Sep 3, 2018 · 3 comments
Closed

Error when using Settings have ExcludeRules = @() #1063

felixfbecker opened this issue Sep 3, 2018 · 3 comments
Labels

Comments

@felixfbecker
Copy link

@felixfbecker felixfbecker commented Sep 3, 2018 •

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.

@felixfbecker felixfbecker changed the title Invoke-Formatter error when using Settings parameter Error when using Settings parameter Sep 3, 2018
@felixfbecker felixfbecker changed the title Error when using Settings parameter Error when using Settings have ExcludeRules = @() Sep 3, 2018
@felixfbecker
Copy link
Author

@felixfbecker felixfbecker commented Sep 3, 2018

Ah, this seems to be caused by ExcludeRules = @().

@bergmeister
Copy link
Collaborator

@bergmeister bergmeister commented Sep 3, 2018

Thanks for logging this. I am unfortunately still busy this week but I will try to come back to this next week, please remind me should I forget

@bergmeister
Copy link
Collaborator

@bergmeister bergmeister commented Sep 14, 2018 •

I can confirm the bug and will investigate the root cause and hopefully issue a fix in the next few days and yes, I can confirm, it comes from ExcludeRules = @()
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

2 participants
You can’t perform that action at this time.