Skip to content

bug: False positive with the rule 'PSReviewUnusedParameter' #1753

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
insomnimus opened this issue Dec 5, 2021 · 3 comments
Closed

bug: False positive with the rule 'PSReviewUnusedParameter' #1753

insomnimus opened this issue Dec 5, 2021 · 3 comments

Comments

@insomnimus
Copy link

Steps to reproduce

$script = {
	function Run-Example {
		param(
			$repeatme
		)
		1..5 | foreach-object {
			$repeatme
		}
	}
}

# Disable default values just in case.
$PSDefaultParameterValues["disabled"] = $true
Invoke-ScriptAnalyzer -IncludeRule PSReviewUnusedParameter -ScriptDefinition "$script"

Expected behavior

No output.

Actual behavior


RuleName                            Severity     ScriptName Line  Message
--------                            --------     ---------- ----  -------
PSReviewUnusedParameter             Warning                 4     The parameter 'repeatme' has been declared but not used. 

Environment Data

> $PSVersionTable
Name                           Value
----                           -----
PSVersion                      7.2.0
PSEdition                      Core
GitCommitId                    7.2.0
OS                             Microsoft Windows 10.0.19041
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

> (Get-Module -ListAvailable PSScriptAnalyzer).Version | ForEach-Object { $_.ToString() }
1.20.0
@SydneyhSmith
Copy link
Collaborator

Thanks @insomnimus this looks like a duplicate of #1643

@insomnimus
Copy link
Author

Oh whoops, sorry about that.

I could close this one if it's polluting the issue tracker?

@ghost
Copy link

ghost commented Dec 10, 2021

This issue has been marked as duplicate and has not had any activity for 1 day. It will be closed for housekeeping purposes.

@ghost ghost closed this as completed Dec 10, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants