Skip to content

Commit

Permalink
Merge pull request #363 from Lombiq/issue/OSOE-580
Browse files Browse the repository at this point in the history
OSOE-580: Custom analyzer rule for parameter and variable name styling
  • Loading branch information
sarahelsaig authored Jun 30, 2024
2 parents ce33464 + 7f46015 commit f43512d
Show file tree
Hide file tree
Showing 15 changed files with 43 additions and 43 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
param (
param (
[string] $Configuration,
[string] $SolutionOrProject,
[string] $Verbosity,
Expand All @@ -9,9 +9,9 @@ param (
[boolean] $CreateBinaryLog,
[boolean] $WarningsAsErrors)

function ConvertTo-Array([string] $rawInput)
function ConvertTo-Array([string] $RawInput)
{
$rawInput.Replace("`r", '').Split("`n") | ForEach-Object { $PSItem.Trim() } | Where-Object { $PSItem }
$RawInput.Replace("`r", '').Split("`n") | ForEach-Object { $PSItem.Trim() } | Where-Object { $PSItem }
}

Write-Output "Version number for the .NET build products: $Version"
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/build-dotnet/Write-CacheConfiguration.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ $paths | ForEach-Object { New-Item -ItemType Directory -Force $PSItem } | Out-Nu
Set-GitHubOutput 'paths' ($paths -join '{0}')

Set-GitHubOutput 'cache-enabled' 'true'
Set-GitHubOutput 'key' "${RestoreKeys}-${Hash}"
Set-GitHubOutput 'key' "$($RestoreKeys)-$($Hash)"
Set-GitHubOutput 'restore-keys' $RestoreKeys
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[Diagnostics.CodeAnalysis.SuppressMessage(
[Diagnostics.CodeAnalysis.SuppressMessage(
'PSReviewUnusedParameter',
'Summary',
Justification = 'It is actually used. This is a known issue: https://github.com/PowerShell/PSScriptAnalyzer/issues/1891.')]
Expand Down Expand Up @@ -63,7 +63,7 @@ function CreateIssue

function AddLink
{
param($issueKey)
param($IssueKey)

$bodyJson = @{
object = @{
Expand All @@ -74,7 +74,7 @@ function AddLink

try
{
Invoke-JiraApiPost "issue/$issueKey/remotelink" $bodyJson
Invoke-JiraApiPost "issue/$IssueKey/remotelink" $bodyJson
}
catch
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
param(
param(
[String[]] $FileIncludeList
)

Expand All @@ -11,8 +11,8 @@ param(
return $false
}

(Get-Item $PSitem).Directory.GetFiles('action.yml').Count -gt 0 -or
(Get-Item $PSitem).Directory.GetFiles('action.yaml').Count -gt 0
(Get-Item $PSItem).Directory.GetFiles('action.yml').Count -gt 0 -or
(Get-Item $PSItem).Directory.GetFiles('action.yaml').Count -gt 0
}

# GitHub Actions are called by directory name. Get directory and de-duplicate list.
Expand All @@ -22,9 +22,9 @@ param(
[array]$workflows = $FileIncludeList | Where-Object -FilterScript {
try
{
(Get-Item $PSitem).BaseName -ne 'action' -and
((Get-Item $PSitem).Extension -eq '.yml' -or
(Get-Item $PSitem).Extension -eq '.yaml')
(Get-Item $PSItem).BaseName -ne 'action' -and
((Get-Item $PSItem).Extension -eq '.yml' -or
(Get-Item $PSItem).Extension -eq '.yaml')
}
catch
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
param (
param (
[string] $SolutionOrProject,
[string] $Verbosity,
[string] $TreatWarningsAsErrors,
[string] $EnableCodeAnalysis,
[string] $Version,
[string] $Switches)

function ConvertTo-Array([string] $rawInput)
function ConvertTo-Array([string] $RawInput)
{
$rawInput.Replace("`r", '').Split("`n") | ForEach-Object { $PSItem.Trim() } | Where-Object { $PSItem }
$RawInput.Replace("`r", '').Split("`n") | ForEach-Object { $PSItem.Trim() } | Where-Object { $PSItem }
}

nuget restore $SolutionOrProject
Expand Down
12 changes: 6 additions & 6 deletions .github/actions/publish-nuget/New-NuGetPackage.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<#
<#
.SYNOPSIS
Creates a NuGet package from each project in the sln file in the current directory.
.DESCRIPTION
Expand Down Expand Up @@ -100,7 +100,7 @@ foreach ($project in $projects)
continue
}

$PackageValidationParameters = @(
$packageValidationParameters = @(
"-p:EnablePackageValidation=$EnablePackageValidation"
"-p:PackageValidationBaselineVersion=$PackageValidationBaselineVersion"
)
Expand All @@ -119,7 +119,7 @@ foreach ($project in $projects)
{
Write-Output "::warning:: Package version couldn't be added, thus package validation to baseline version won't be done."
dotnet remove TempProject.csproj package $project.BaseName --version $PackageValidationBaselineVersion
$PackageValidationParameters = @(
$packageValidationParameters = @(
"-p:EnablePackageValidation=$EnablePackageValidation"
)
}
Expand All @@ -130,7 +130,7 @@ foreach ($project in $projects)
}
else
{
$PackageValidationParameters = @(
$packageValidationParameters = @(
"-p:EnablePackageValidation=$EnablePackageValidation"
)
}
Expand All @@ -140,11 +140,11 @@ foreach ($project in $projects)
$nuspecFile = (Get-ChildItem *.nuspec).Name
if ($nuspecFile.Count -eq 1)
{
dotnet pack $project -p:NuspecFile="$nuspecFile" @PackParameters @PackageValidationParameters
dotnet pack $project -p:NuspecFile="$nuspecFile" @packParameters @packageValidationParameters
}
else
{
dotnet pack $project @PackParameters @PackageValidationParameters
dotnet pack $project @packParameters @packageValidationParameters
}

if ($LASTEXITCODE -ne 0)
Expand Down
4 changes: 2 additions & 2 deletions .github/actions/set-gha-refs/Set-Called-GHA-Refs.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
param(
param(
[String[]] $CalledRepoBaseIncludeList,
[String[]] $AdditionalPatternIncludeList,
[String[]] $PathIncludeList,
Expand Down Expand Up @@ -33,7 +33,7 @@ else
{
Write-Output "$oldline => $newline"

$filename = $matched.RelativePath($pwd)
$filename = $matched.RelativePath($PWD)
$linenumber = $matched.LineNumber
$title = "GHA Ref pinned to '$ExpectedRef'"

Expand Down
8 changes: 4 additions & 4 deletions .github/actions/setup-sql-server/Initialize-SqlServer.ps1
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
param (
[string]$windowsSqlServerExpressVersion = '2022.16.0.1000',
[string]$linuxSqlServerVersion = '2022'
[string]$WindowsSqlServerExpressVersion = '2022.16.0.1000',
[string]$LinuxSqlServerVersion = '2022'
)

if ($Env:RUNNER_OS -eq 'Windows')
{
choco install sql-server-express --version=$windowsSqlServerExpressVersion --no-progress
choco install sql-server-express --version=$WindowsSqlServerExpressVersion --no-progress
}
else
{
$containerName = 'uitt-sqlserver'
$sqlServerLink = "mcr.microsoft.com/mssql/server:${linuxSqlServerVersion}-latest"
$sqlServerLink = "mcr.microsoft.com/mssql/server:$LinuxSqlServerVersion-latest"

$dockerRunSwitches = @(
'--name', $containerName
Expand Down
4 changes: 2 additions & 2 deletions .github/actions/test-dotnet/Merge-BlameHangDumps.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSReviewUnusedParameter', 'Configuration', Justification = 'The Configuration parameter is in use.')]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSReviewUnusedParameter', 'Configuration', Justification = 'The Configuration parameter is in use.')]
param ($Directory, $Configuration)

$rootDirectory = Resolve-Path $Directory
Expand All @@ -24,7 +24,7 @@ function ItemFilter($Item, $TestConfiguration)
{
if ($Item.IsContainer)
{
return $False
return $false
}

$allow = (($Item.Name -like 'Sequence_*.xml') -or ($Item.Name -like '*_hangdump.dmp'))
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/test-dotnet/Merge-FailureDumps.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ $rootDirectory = (Test-Path -Path $testDirectory) ? $testDirectory : $Directory
Get-ChildItem $rootDirectory -Recurse |
Where-Object { $PSItem.Name -eq 'FailureDumps' } |
ForEach-Object { $PSItem.GetDirectories() } |
ForEach-Object { Move-Item $PSItem.FullName "$Directory/FailureDumps/${_.Name}" }
ForEach-Object { Move-Item $PSItem.FullName "$Directory/FailureDumps/$($PSItem.Name)" }
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
param(
param(
[string] $JiraBaseUrl,
[string] $GitHubRepository,
[string] $Branch,
Expand All @@ -20,12 +20,12 @@ if ($Branch -NotLike '*issue*')

$Branch -match '(\w+-\d+)' | Out-Null

if ($null -eq $matches)
if ($null -eq $Matches)
{
throw "Issue key not found in the branch name '$Branch'!"
}

$issueKey = $matches[0]
$issueKey = $Matches[0]
$issueLink = "[$issueKey]($jiraBrowseUrl$issuekey)"

if ($Title -NotLike "*$issueKey*")
Expand Down
4 changes: 2 additions & 2 deletions .github/actions/verify-gha-refs/Check-Called-GHA-Refs.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
param(
param(
[String[]] $CalledRepoBaseIncludeList,
[String[]] $PathIncludeList,
[String[]] $FileIncludeList,
Expand Down Expand Up @@ -30,7 +30,7 @@ if ($mismatchRefs.Count -gt 0)

foreach ($mismatch in $mismatchRefs)
{
$filename = $mismatch.RelativePath($pwd)
$filename = $mismatch.RelativePath($PWD)
$linenumber = $mismatch.LineNumber
$title = $mismatch.Line

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
param(
param(
[string] $Repository,
[string] $Branch
)
Expand All @@ -11,7 +11,7 @@ if (-not ($Branch -match '(\w+-\d+)'))
# See https://cli.github.com/manual/gh_pr_list and https://cli.github.com/manual/gh_help_formatting
$titles = gh pr list --repo $Repository --limit 100 --json title --template '{{range .}}{{tablerow .title}}{{end}}'

$issueCode = $matches[0]
$lookFor = "${issueCode}:"
$issueCode = $Matches[0]
$lookFor = "$($issueCode):"
if (($titles | Where-Object { $PSItem -and $PSItem.Trim().StartsWith($lookFor) }).Count -gt 0) { exit 0 }
Set-Failed "Couldn't find any pull request whose title starts with `"$lookFor`" in $Repository. Please create one."
4 changes: 2 additions & 2 deletions .github/actions/verify-submodule-pull-request/functions.ps1
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<#
<#
.Synopsis
Fails the current step with the provided message. Same as "core.setFailed()" from the official toolkit
(https://github.com/actions/toolkit).
#>
function Set-Failed([Parameter(Mandatory = $True)] [string] $Message)
function Set-Failed([Parameter(Mandatory = $true)] [string] $Message)
{
Write-Output "::error::$Message"
exit 1
Expand Down
4 changes: 2 additions & 2 deletions Scripts/Get-JiraIssueKeyFromPullRequestTitle.ps1
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
param (
param (
[Parameter(Mandatory = $true, Position = 0)]
[string] $Title
)

$isMatch = $Title -match '^\s*(\w+-\d+)\s*:'
$isMatch ? $matches[1] : ''
$isMatch ? $Matches[1] : ''

0 comments on commit f43512d

Please sign in to comment.