> ## Documentation Index
> Fetch the complete documentation index at: https://tally.wharflab.com/llms.txt
> Use this file to discover all available pages before exploring further.

# powershell/PSUseConsistentParametersKind

> Use the same pattern when defining parameters.

`powershell/PSUseConsistentParametersKind` is a PSScriptAnalyzer diagnostic emitted by tally for PowerShell snippets embedded in Dockerfiles.

| Property | Value            |
| -------- | ---------------- |
| Severity | Warning          |
| Category | PSScriptAnalyzer |
| Auto-fix | No               |

## Description

All functions should use the same pattern when defining parameters. Possible pattern types are:

1. `Inline`

   ```powershell theme={null}
   function f([Parameter()]$FirstParam) {
       return
   }
   ```

2. `ParamBlock`

   ```powershell theme={null}
   function f {
       param([Parameter()]$FirstParam)
       return
   }
   ```

In simple scenarios, both function definitions shown are considered to be equal. The purpose of this
rule is to enforce consistent code style across the codebase.

## How to Fix

Rewrite function so it defines parameters as specified in the rule

## Examples

When the rule sets parameters definition kind to `Inline`:

```powershell theme={null}
# Correct
function f([Parameter()]$FirstParam) {
    return
}

# Incorrect
function g {
    param([Parameter()]$FirstParam)
    return
}
```

When the rule sets parameters definition kind to `ParamBlock`:

```powershell theme={null}
# Incorrect
function f([Parameter()]$FirstParam) {
    return
}

# Correct
function g {
    param([Parameter()]$FirstParam)
    return
}
```

## Source

This rule documentation is adapted from Microsoft's PSScriptAnalyzer documentation for
[UseConsistentParametersKind](https://github.com/MicrosoftDocs/PowerShell-Docs-Modules/blob/main/reference/docs-conceptual/PSScriptAnalyzer/Rules/UseConsistentParametersKind.md),
licensed under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/).
