Add rule for unused namespaces
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 35/100
Direzione di ricerca
Inizia tracciando l’AST radice e le ricerche FindAll per i nodi TypeExpressionAst, TypeConstraintAst, AttributeAst e New-Object CommandAst descritti nell’issue. Determina come vengono risolti i nomi dei tipi e come dovrebbero essere gestiti New-Object, gli acceleratori di tipo e gli eventuali alias. Il lavoro è completo quando l’analizzatore è in grado di identificare le istruzioni using namespace inutilizzate senza rimuovere i namespace a cui si fa riferimento.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Summary of the new feature
It would be nice with a rule to find and remove unused using namespace statements similar to what you can do in C# in editors like VS.
Cleaning up unused namespaces can slightly improve type resolution performance and of course it makes scripts more neat and clean.
Proposed technical implementation details (optional)
Use FindAll on the root AST to find all Asts of the following types: TypeExpressionAst, TypeConstraintAst, AttributeAst and CommandAst where the command name is New-Object and try to resolve the specified TypeNames with GetReflectionType. Compare the written typename with the resolved typename and see if part of the namespace is missing, and if so if that part is listed in the list of namespaces. If it is then that namespace is in use and should stay.
For New-Object we can't use GetReflectionType so I'm not sure how to handle that. Type accelerators and in the future type/namespace aliases should probably also be taken into consideration.
What is the latest version of PSScriptAnalyzer at the point of writing
1.22.0
- Lingua principale
- C#
- Stelle
- 2.2k
- Fork
- 415
- Merge medio
- 13h 1m
- PR unite (30g)
- 2
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di PowerShell/PSScriptAnalyzer
-
Up-for-Grabs
Difficoltà 1/5 1-3 ore Idoneità per principianti 78/100
PowerShell/PSScriptAnalyzer#2213 · 2 commenti ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 72/100
PowerShell/PSScriptAnalyzer#2217 · 1 commento ·
-
PSUseConsistentIndentation double-indents attribute bodies that open a scriptblock (`[Attr({ … })]`) Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 70/100
PowerShell/PSScriptAnalyzer#2216 · 2 commenti ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 68/100
PowerShell/PSScriptAnalyzer#2211 ·
-
`PSPlaceOpenBrace` and `PSPlaceCloseBrace` leave trailing whitespace when expanding one-line blocks Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 70/100
PowerShell/PSScriptAnalyzer#2210 ·
Tutte le issue di PowerShell/PSScriptAnalyzer
Issue simili
-
bug
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 75/100
sillsdev/languageforge-lexbox#2665 ·
-
C: Syntax
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
-
bug documentation frontend
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
azurenoops/spin_agent#975 ·
-
:watch: Not Triaged 11.0 fundamentals/subsvc
Difficoltà 2/5 1-3 ore Idoneità per principianti 92/100
dotnet/AspNetCore.Docs#37699 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
SubtitleEdit/subtitleedit#15108 · 1 commento ·