Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .vscode/PSScriptAnalyzerSettings.psd1
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
@{
Rules = @{
PSReviewUnusedParameter = @{
CommandsToTraverse = @(
'SearchAncestors'
'Using-Location'
)
}
}
IncludeRules = @('*')
ExcludeRules = @('PSUseApprovedVerbs')
}

8 changes: 5 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{
"powershell.codeFormatting.pipelineIndentationStyle": "IncreaseIndentationForFirstPipeline",
"powershell.codeFormatting.newLineAfterCloseBrace": false,
"editor.renderWhitespace": "all"
"editor.renderWhitespace": "all",
"powershell.codeFormatting.newLineAfterCloseBrace": false,
"powershell.codeFormatting.pipelineIndentationStyle": "IncreaseIndentationForFirstPipeline",
"powershell.scriptAnalysis.enable": true,
"powershell.scriptAnalysis.settingsPath": ".vscode/PSScriptAnalyzerSettings.psd1"
}
18 changes: 18 additions & 0 deletions Build/RunScriptAnalyzer.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#Requires -PSEdition Core

[CmdletBinding()]
param(
)

Set-StrictMode -Version Latest
$ErrorActionPreference = 'Stop'

$WorkingDirectory = $PSScriptRoot
$RepositoryRoot = Resolve-Path -Path (& git -C $WorkingDirectory rev-parse '--show-toplevel')
$SettingsFile = Join-Path -Path $RepositoryRoot -ChildPath '.vscode\PSScriptAnalyzerSettings.psd1'
& git -C $RepositoryRoot ls-files *.ps1 *.psm1 *.psd1 |
ForEach-Object { Get-Item -Path (Join-Path -Path $RepositoryRoot -ChildPath $_) } |
ForEach-Object { Invoke-ScriptAnalyzer -Path $_ -Settings $SettingsFile } |
ForEach-Object {
"$($_.ScriptPath):$($_.Line):$($_.Column) [$($_.RuleName)] $($_.Message)"
}
6 changes: 3 additions & 3 deletions PSCMake/Common/CMake.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ function ResolvePresetProperty {
$Presets,
$PropertyName
)
SearchAncestors $Preset $Presets {
SearchAncestors -Preset $Preset -Presets $Presets {
param($CurrentPreset)
Get-MemberValue -InputObject $CurrentPreset -Name $PropertyName
}
Expand All @@ -228,7 +228,7 @@ function EvaluatePresetCondition {
$Preset,
$Presets
)
$Result = SearchAncestors $Preset $Presets {
$Result = SearchAncestors -Preset $Preset -Presets $Presets {
param($CurrentPreset)
$PresetConditionJson = Get-MemberValue $CurrentPreset 'condition'
if (($PresetConditionJson) -and
Expand Down Expand Up @@ -306,7 +306,7 @@ function GetBinaryDirectory {
$CMakePresetsJson,
$ConfigurePreset
)
$BinaryDirectory = ResolvePresetProperty $ConfigurePreset $CMakePresetsJson.configurePresets 'binaryDir'
$BinaryDirectory = ResolvePresetProperty -Preset $ConfigurePreset -Presets $CMakePresetsJson.configurePresets -PropertyName 'binaryDir'

# Perform macro-replacement
$Result = MacroReplacement $BinaryDirectory $ConfigurePreset
Expand Down
1 change: 1 addition & 0 deletions Tests/Build-CMakeBuild.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ BeforeAll {
[string] $CMakePath,
[string[]] $Arguments
)
$null = $CMakePath
$script:CMakeCalls += , $Arguments
}
}
Expand Down