Open johlju opened 3 years ago
I have mixed feelings about this. Adding extra files/rules, ok why not but it should not conflict/replace HQRM tests (that's the goal here, after all). So if someone wants to amend the HQRM tests being run for a pipeline, it should only been done via the build.yaml so that it's clear from a reviewer's perspective.
We could definitely add an array of analyzer rules to the build.yaml. The scenario is that we added repository specific analyzer rules to the SqlServerDsc repo:
As a workaround we added a test that runs the analyzer rules:
Analyzer rules: https://github.com/dsccommunity/SqlServerDsc/blob/main/tests/QA/ScriptAnalyzer.Tests.ps1
The QA test is run in the pipeline here: https://github.com/dsccommunity/SqlServerDsc/blob/49f78a8b12c0f540ef76cdcbf6605fffa30c17fa/azure-pipelines.yml#L65-L70
It would have been cleaner that these were run during the regular HQRM tests.
The PSSA test
source/Tests/QA/PSSAResource.common.Tests.ps1
currently ignores a repository's Script Analyzer file. I Script Analyzer file can be used to add additional custom rules that should only be run for the repository.Script Analyzer is run with a settings file like this.
But a better option would be to allow custom rule paths to be specified in the build configuration file
build.yml
under the keyDscTest:
together with an option to include additional rules (if the rules are not prefixed withMeasue-*
).The custom rule paths that is set must point to one or more module or module files. Since Script Analyzer must be called like this: