Description
I have a module to manage the DigitalOcean cloud service. All calls to DigitalOcean are made via REST endpoints using fully qualified URLs. No internal URLs are being used. Yet when I run PSScriptAnalyzer against my module, it generates 15 false positives that shouldn't exist.
The false positives all come from the string '/$1'. That is a single quoted string that I use as the second parameter when using -replace with other strings, to ensure that those strings are properly prefixed with /. This generates the relative URIs that I need that then internally are used to generate the absolute URIs that are needed to make the REST API call. Here's an example:
$internalId = $Id -replace '^([^/])','/$1' -as $Id.GetType()
There is nothing in that command that should cause this warning to appear.
I'm not exactly sure where the error is here, but this is definitely a bug. I don't think PSAvoidUsingInternalURLs should even be looking at a replacement string in a regex -replace call. But that may not be the core issue here.
You can install my DigitalOcean module by invoking Install-Module DoPx and then run Invoke-ScriptAnalyzer against it to see these false positives. Note: it takes about two minutes to process this module, even though it is small, so please be patient while analyzing it and store the results in a variable so that you don't have to do it again.