Skip to content

Commit 53a423a

Browse files
committed
Fix static analysis warnings
There are some new warnings coming up when checking StoreBroker with newer versions of [PSScriptAnalyzer](https://github.com/PowerShell/PSScriptAnalyzer). * `PSUseDeclaredVarsMoreThanAssignments` - We had some instances where a variable was being assigned to but never used. For the API instances, we now capture to $null in the instances where we don't want the helper method's results being returned to the user. * `PSUseShouldProcessForStateChangingFunctions` - Two PackageTool methods use the verb "Remove" but have no need for providing ShouldProcess support. Those instances are now suppressed. All remaining warnings are false positives of `PSUseDeclaredVarsMoreThanAssignments`. I have opened two different issues against PSScriptAnalyzer to track these false positives: * [PSUseDeclaredVarsMoreThanAssignment not correctly handling global vars assigned to within functions](PowerShell/PSScriptAnalyzer#698) * [PSUseDeclaredVarsMoreThanAssignment not correctly handling array adds](PowerShell/PSScriptAnalyzer#699) Updated CONTRIBUTING.md to remind users to keep the analyzer module up-to-date. Additionally, the links in PDP.md were invalid. Those have now been fixed.
1 parent 520610f commit 53a423a

10 files changed

+27
-22
lines changed

CONTRIBUTING.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ into the source.
6161

6262
StoreBroker is maintained by:
6363

64-
- **[@HowardWolosky-MSFT](http://github.com/HowardWolosky-MSFT)**
64+
- **[@TheHoward](http://github.com/TheHoward)**
6565
- **[@DanBelcher-MSFT](http://github.com/DanBelcher-MSFT)**
6666

6767
As StoreBroker is a production dependency for Microsoft, we have a couple workflow restrictions:
@@ -135,6 +135,11 @@ with a justification explaining why it's ok to suppress that rule within that pa
135135
Refer to the [PSScriptAnalyzer documentation](https://github.com/PowerShell/PSScriptAnalyzer/) for
136136
more information on how to use that attribute, or look at other existing examples within this module.
137137

138+
> Please ensure that your installation of PSScriptAnalyzer is up-to-date by running:
139+
> `Update-Module -Name PSScriptAnalyzer`
140+
> You should close and re-open your console window if the module was updated as a result of running
141+
> that command.
142+
138143
----------
139144

140145
### Visual Studio

Documentation/GOVERNANCE.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ StoreBroker.
3838

3939
### Current Committee Members
4040

41-
* Howard Wolosky ([HowardWolosky-MSFT](https://github.com/HowardWolosky-MSFT))
42-
* Daniel Belcher ([DanBelcher-MSFT](https://github.com/DanBelcher-MSFT)).
41+
* Howard Wolosky ([@TheHoward](https://github.com/TheHoward))
42+
* Daniel Belcher ([@DanBelcher-MSFT](https://github.com/DanBelcher-MSFT)).
4343

4444
### Committee Member Responsibilities
4545

Documentation/PDP.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -132,13 +132,13 @@ At this time, StoreBroker has two PDP schemas in use:
132132

133133
### Application Submissions
134134
* **Uri**: `http://schemas.microsoft.com/appx/2012/ProductDescription`
135-
* **XSD**: [PDP\ProductDescription.xsd](..\PDP\ProductDescription.xsd)
136-
* **Sample XML**: [PDP\ProductDescription.xml](..\PDP\ProductDescription.xml)
135+
* **XSD**: [PDP\ProductDescription.xsd](../PDP/ProductDescription.xsd)
136+
* **Sample XML**: [PDP\ProductDescription.xml](../PDP/ProductDescription.xml)
137137

138138
### In-App Product (IAP) ("add-on") Submissions
139139
* **Uri**: `http://schemas.microsoft.com/appx/2012/InAppProductDescription`
140-
* **XSD**: [PDP\InAppProductDescription.xsd](..\PDP\InAppProductDescription.xsd)
141-
* **Sample XML**: [PDP\InAppProductDescription.xml](..\PDP\InAppProductDescription.xml)
140+
* **XSD**: [PDP\InAppProductDescription.xsd](../PDP/InAppProductDescription.xsd)
141+
* **Sample XML**: [PDP\InAppProductDescription.xml](../PDP/InAppProductDescription.xml)
142142

143143
----------
144144

Extensions/ConvertFrom-ExistingIapSubmission.ps1

-1
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,6 @@ function Add-Icon
290290
$elementName = "Icon"
291291
[System.Xml.XmlElement] $elementNode = Ensure-RootChild -Xml $Xml -Element $elementName
292292

293-
$maxChars = 200
294293
$paramSet = @{
295294
"Element" = $elementNode;
296295
"Attribute" = @{ 'Filename' = $iconFilename };

StoreBroker/PackageTool.ps1

+2-1
Original file line numberDiff line numberDiff line change
@@ -1568,6 +1568,7 @@ function Remove-DeprecatedProperties
15681568
#>
15691569
[CmdletBinding()]
15701570
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseSingularNouns", "", Justification="This is intended to be where all deprecated properties are removed. It's an accurate name.")]
1571+
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseShouldProcessForStateChangingFunctions", "", Justification="Does not cause any change to system state. No value gained from ShouldProcess in this specific instance.")]
15711572
param(
15721573
[Parameter(Mandatory)]
15731574
[PSCustomObject] $SubmissionRequestBody
@@ -2125,7 +2126,7 @@ filter Remove-Comment
21252126
21262127
"example", "test "
21272128
#>
2128-
2129+
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseShouldProcessForStateChangingFunctions", "", Justification="Does not cause any change to system state. No value gained from ShouldProcess in this specific instance.")]
21292130
param(
21302131
[string] $CommentDelimiter = "//",
21312132

StoreBroker/StoreBroker.psd1

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
CompanyName = 'Microsoft Corporation'
77
Copyright = 'Copyright (C) Microsoft Corporation. All rights reserved.'
88

9-
ModuleVersion = '1.1.2'
9+
ModuleVersion = '1.1.3'
1010
Description = 'Provides command-line access to the Windows Store Submission REST API.'
1111

1212
RootModule = 'StoreIngestionApi'

StoreBroker/StoreIngestionApi.psm1

+4-4
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ function Get-AccessToken
390390
Invoke-RestMethod $url -Method Post -Body $body
391391
}
392392

393-
$job = Start-Job -Name $jobName -ScriptBlock $scriptBlock -Arg @($url, $body)
393+
$null = Start-Job -Name $jobName -ScriptBlock $scriptBlock -Arg @($url, $body)
394394

395395
if ($PSCmdlet.ShouldProcess($jobName, "Wait-JobWithAnimation"))
396396
{
@@ -677,7 +677,7 @@ function Set-SubmissionPackage
677677
$cloudBlockBlob.UploadFromFile($PackagePath, [System.IO.FileMode]::Open)
678678
}
679679

680-
$job = Start-Job -Name $jobName -ScriptBlock $scriptBlock -Arg @($UploadUrl, $PackagePath, $azureStorageDll)
680+
$null = Start-Job -Name $jobName -ScriptBlock $scriptBlock -Arg @($UploadUrl, $PackagePath, $azureStorageDll)
681681

682682
if ($PSCmdlet.ShouldProcess($jobName, "Wait-JobWithAnimation"))
683683
{
@@ -839,7 +839,7 @@ function Get-SubmissionPackage
839839
$cloudBlockBlob.DownloadToFile($PackagePath, [System.IO.FileMode]::OpenOrCreate)
840840
}
841841

842-
$job = Start-Job -Name $jobName -ScriptBlock $scriptBlock -Arg @($UploadUrl, $PackagePath, $azureStorageDll)
842+
$null = Start-Job -Name $jobName -ScriptBlock $scriptBlock -Arg @($UploadUrl, $PackagePath, $azureStorageDll)
843843

844844
if ($PSCmdlet.ShouldProcess($jobName, "Wait-JobWithAnimation"))
845845
{
@@ -1521,7 +1521,7 @@ function Invoke-SBRestMethod
15211521
Invoke-RestMethod @params
15221522
}
15231523

1524-
$job = Start-Job -Name $jobName -ScriptBlock $scriptBlock -Arg @($url, $Method, $headers, $Body)
1524+
$null = Start-Job -Name $jobName -ScriptBlock $scriptBlock -Arg @($url, $Method, $headers, $Body)
15251525

15261526
if ($PSCmdlet.ShouldProcess($jobName, "Wait-JobWithAnimation"))
15271527
{

StoreBroker/StoreIngestionApplicationApi.ps1

+2-2
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@ function Remove-ApplicationSubmission
669669
"NoStatus" = $NoStatus
670670
}
671671

672-
$result = Invoke-SBRestMethod @params
672+
$null = Invoke-SBRestMethod @params
673673
}
674674

675675
function New-ApplicationSubmission
@@ -1666,7 +1666,7 @@ function Complete-ApplicationSubmission
16661666
"NoStatus" = $NoStatus
16671667
}
16681668

1669-
$result = Invoke-SBRestMethod @params
1669+
$null = Invoke-SBRestMethod @params
16701670

16711671
$output = @()
16721672
$output += "The submission has been successfully committed."

StoreBroker/StoreIngestionFlightingApi.ps1

+3-3
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,7 @@ function Remove-ApplicationFlight
544544
"NoStatus" = $NoStatus
545545
}
546546

547-
$result = Invoke-SBRestMethod @params
547+
$null = Invoke-SBRestMethod @params
548548
}
549549

550550
function Get-ApplicationFlightSubmission
@@ -896,7 +896,7 @@ function Remove-ApplicationFlightSubmission
896896
"NoStatus" = $NoStatus
897897
}
898898

899-
$result = Invoke-SBRestMethod @params
899+
$null = Invoke-SBRestMethod @params
900900
}
901901

902902
function New-ApplicationFlightSubmission
@@ -1738,7 +1738,7 @@ function Complete-ApplicationFlightSubmission
17381738
"NoStatus" = $NoStatus
17391739
}
17401740

1741-
$result = Invoke-SBRestMethod @params
1741+
$null = Invoke-SBRestMethod @params
17421742

17431743
$output = @()
17441744
$output += "The submission has been successfully committed."

StoreBroker/StoreIngestionIapApi.ps1

+3-3
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,7 @@ function Remove-InAppProduct
620620
"NoStatus" = $NoStatus
621621
}
622622

623-
$result = Invoke-SBRestMethod @params
623+
$null = Invoke-SBRestMethod @params
624624
}
625625

626626
function Get-InAppProductSubmission
@@ -1012,7 +1012,7 @@ function Remove-InAppProductSubmission
10121012
"NoStatus" = $NoStatus
10131013
}
10141014

1015-
$result = Invoke-SBRestMethod @params
1015+
$null = Invoke-SBRestMethod @params
10161016
}
10171017

10181018
function New-InAppProductSubmission
@@ -1867,7 +1867,7 @@ function Complete-InAppProductSubmission
18671867
"NoStatus" = $NoStatus
18681868
}
18691869

1870-
$result = Invoke-SBRestMethod @params
1870+
$null = Invoke-SBRestMethod @params
18711871

18721872
$output = @()
18731873
$output += "The submission has been successfully committed."

0 commit comments

Comments
 (0)