PowerShell / PowerShell/PSScriptAnalyzer
Check whether a module references itself in 'NestedModules' field in the .psd1 file
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- C#
- Sterne
- 2.2k
- Forks
- 414
- Ø Merge
- 13 Std. 1 Min.
- Gemergte PRs (30 T.)
- 2
Beschreibung
This feature ask is per discussion in https://github.com/PowerShell/PowerShell/pull/6843#discussion_r187123774.
Importing a ill-structured module could result in a circular nested module. For example, for the following code, you will see 'True' as the output.
$testdir = Join-Path $env:TEMP test
$testpsm1 = Join-Path $testdir test.psm1
$testpsd1 = Join-Path $testdir test.psd1
mkdir $testdir > $null
Set-Content $testpsm1 -Value "function bar {}"
Set-Content $testpsd1 -Value "@{ ModuleVersion = '0.0.1'; RootModule = 'test'; NestedModules = @('test') }"
$m = Import-Module $testpsd1 -Pass
$m -eq $m.NestedModules[0]
> True
So maybe a rule can be written to check the bold part of test.psd1 "@{ ModuleVersion = '0.0.1'; RootModule = 'test'; NestedModules = @('test') }", to make sure the author is warned when a module like test.psd1 has itself as a nested module.
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne damit, das Beispiel eines zirkulären verschachtelten Moduls mit dem gezeigten .psd1-Inhalt zu reproduzieren, und untersuche, wie PSScriptAnalyzer Modulprobleme erkennt und meldet. Die Änderung ist abgeschlossen, wenn ein Modul, dessen Feld NestedModules auf sich selbst verweist, eine Warnung erzeugt, während gültige Deklarationen verschachtelter Module unbeeinträchtigt bleiben; der Payload nennt keine Implementierungsdateien oder Tests.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- powershell
- Bereich
- devtools
- Issue-Typ
- Feature
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100