dsccommunity / dsccommunity/DscResource.Test

Script Analyzer test should make use of multiple custom rule paths

Open
#100 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement help wanted
Dominant language
PowerShell
Stars
6
Forks
9
PR merge metrics
No merged PRs in 30d

Description

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.

Invoke-ScriptAnalyzer -Path .\output\SqlServerDsc\15.0.1\DSCResources\**\*.psm1 -Recurse -Settings .\.vscode\analyzersettings.psd1

But a better option would be to allow custom rule paths to be specified in the build configuration file build.yml under the key DscTest: together with an option to include additional rules (if the rules are not prefixed with Measue-*).

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:

Invoke-ScriptAnalyzer `
    -Path .\output\SqlServerDsc\15.0.1\DSCResources\DSC_SqlTraceFlag\*.psm1 `
    -CustomRulePath @(
        '.\output\RequiredModules\DscResource.AnalyzerRules'
        '.\tests\QA\AnalyzerRules\SqlServerDsc.AnalyzerRules.psm1'
     ) `
    -IncludeRule @('Measure-*')

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with source/Tests/QA/PSSAResource.common.Tests.ps1 and trace how the DscTest settings from build.yml are consumed. Review the existing Invoke-ScriptAnalyzer invocation and determine how custom rule paths and optional additional-rule inclusion should be represented. Done means repository-specific module or module-file paths are passed to Script Analyzer and the configured rule inclusion is honored.

Written by the indexing model from the issue text.

Assessment

Tech stack
powershell
Domain
build-system, testing
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.