Direct answer

Compare the contexts

Ps1File and TerminalPaste
QuestionPs1FileTerminalPaste
Source unitOne saved script fileInput assembled and submitted by a terminal host or line editor
Top-level param()Binds values during script invocationA bare paste has no script filename invocation
#RequiresDeclares script prerequisitesReplace with deliberate runtime checks or keep the code as a script
Script-path variables$PSScriptRoot and $PSCommandPath describe the executing fileNo executing .ps1 path exists for a direct paste
Multiline inputParser sees the complete fileA host can accept a complete block before a later continuation arrives

The six TerminalPaste-only rules

At PSRafScan 0.2.0-alpha1, 52 active rules apply to both modes and these six apply only to TerminalPaste:

  • FunctionInsidePasteWrapper
  • PasteSensitiveContinuationBlock
  • PasteSensitiveDoWhile
  • RequiresInTerminalPaste
  • ScriptFileVariableInTerminalPaste
  • TopLevelParamInTerminalPaste

Use two questions

  1. Will this exact text be saved and invoked as a .ps1 file? Choose Ps1File.
  2. Will this exact text be entered directly into a live terminal? Choose TerminalPaste.
  3. Is the delivery method still undecided? Decide it before scanning because the contexts are not interchangeable.

Account for the host

PowerShell, PSReadLine, the terminal host, and the paste mechanism can change interactive behavior. TerminalPaste flags source patterns that need a context decision; it does not emulate every host or prove how a later paste will behave.

RSX -Path ./saved-script.ps1 -IntendedUse Ps1File -FailOn Warning
RSX -Path ./paste-candidate.ps1 -IntendedUse TerminalPaste -FailOn Warning