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
Setting fields that aren't provided will have sensible defaults, and explicit default options allowing for the same. When rule settings are deserialised for the first time, failures will be reported (I haven't gotten to this part yet, but I would like to make the settings tell users where the failure occurred, what was given and what was expected).
Hashtable settings
Settings provided by Hashtable object will follow exactly the same conventions as those given above for PSD format, except converting from an in-memory hashtable object. A PSD file and its hashtable result in PowerShell will convert to the same settings.
JSON settings
Similar to the PSD settings, the JSON settings will essentially offer a new syntax for rule settings:
Settings in PSD and JSON form will be deserialised to the type requested by the rule they configure. For JSON, this will use Newtonsoft.Json deserialisation, so allowing all attributes it supports. In the case of PSD, those attributes will also be supported. For example:
Love it. I'd also really like it if the formatter had a default settings file you could place in project root, e.g. .psformatter or something similar and Invoke-Formatter looks for that file is not settings are provided.
Uh oh!
There was an error while loading. Please reload this page.
Currently PSScriptAnalyzer settings suffer from the following drawbacks:
Invoke-ScriptAnalyzer
parameters) have ambiguous duplication likeRules
,IncludeRules
andExcludeRules
Enable
rule configuration isfalse
...Instead, PSScriptAnalyzer settings should:
/
characterAs such, the proposed new settings will provide:
PSSA API structure
PSSA will provide an extensible API to provide configurations. This consists of a top level Script Analyzer configuration:
PSScriptAnalyzer/ScriptAnalyzer2/Configuration/IScriptAnalyzerConfiguration.cs
Lines 22 to 31 in 9ee8c0f
An individual rule configuration:
PSScriptAnalyzer/ScriptAnalyzer2/Configuration/IRuleConfiguration.cs
Lines 9 to 49 in 9ee8c0f
And the ability to implement a subclass/implementation of
IRuleConfiguration
and inject it into a rule's constructor by specifying a rule as generic:PSScriptAnalyzer/ScriptAnalyzer2/Rules/Rule.cs
Lines 84 to 91 in 9ee8c0f
Script Analyzer is able to use this configuration type in the generic parameter to deserialise the rule configuration when it is contructed.
PSD settings
Implementing these APIs for PSD format, a typical PSD settings file will look like this:
Setting fields that aren't provided will have sensible defaults, and explicit default options allowing for the same. When rule settings are deserialised for the first time, failures will be reported (I haven't gotten to this part yet, but I would like to make the settings tell users where the failure occurred, what was given and what was expected).
Hashtable settings
Settings provided by Hashtable object will follow exactly the same conventions as those given above for PSD format, except converting from an in-memory hashtable object. A PSD file and its hashtable result in PowerShell will convert to the same settings.
JSON settings
Similar to the PSD settings, the JSON settings will essentially offer a new syntax for rule settings:
Deserialisation to objects
Settings in PSD and JSON form will be deserialised to the type requested by the rule they configure. For JSON, this will use Newtonsoft.Json deserialisation, so allowing all attributes it supports. In the case of PSD, those attributes will also be supported. For example:
PSScriptAnalyzer/Tests/ScriptAnalyzer2.Test/PsdTypedObjectConverterTests.cs
Lines 92 to 95 in 9ee8c0f
The text was updated successfully, but these errors were encountered: