Skip to content

Commit 8f89a1b

Browse files
committed
Remove reserved words which do not pose an issue:
assembly, base, command, hidden, in, inlinescript, interface, module, namespace, private, public, static
1 parent 80172fe commit 8f89a1b

File tree

2 files changed

+14
-18
lines changed

2 files changed

+14
-18
lines changed

Rules/AvoidReservedWordsAsFunctionNames.cs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,20 @@ public class AvoidReservedWordsAsFunctionNames : IScriptRule
2626

2727
// The list of PowerShell reserved words.
2828
// https://learn.microsoft.com/en-gb/powershell/module/microsoft.powershell.core/about/about_reserved_words
29+
//
30+
// The Below are omitted as they don't pose an issue being a function
31+
// name:
32+
// assembly, base, command, hidden, in, inlinescript, interface, module,
33+
// namespace, private, public, static
2934
static readonly HashSet<string> reservedWords = new HashSet<string>(
3035
new[] {
31-
"assembly", "base", "begin", "break",
32-
"catch", "class", "command", "configuration",
36+
"begin", "break", "catch", "class", "configuration",
3337
"continue", "data", "define", "do",
3438
"dynamicparam", "else", "elseif", "end",
3539
"enum", "exit", "filter", "finally",
3640
"for", "foreach", "from", "function",
37-
"hidden", "if", "in", "inlinescript",
38-
"interface", "module", "namespace", "parallel",
39-
"param", "private", "process", "public",
40-
"return", "sequence", "static", "switch",
41+
"if", "parallel", "param", "process",
42+
"return", "sequence", "switch",
4143
"throw", "trap", "try", "type",
4244
"until", "using","var", "while", "workflow"
4345
},

Tests/Rules/AvoidReservedWordsAsFunctionNames.tests.ps1

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,25 @@
44
# Keep in sync with the rule's reserved words list in
55
# Rules/AvoidReservedWordsAsFunctionNames.cs
66
$reservedWords = @(
7-
'assembly','base','begin','break',
8-
'catch','class','command','configuration',
7+
'begin','break','catch','class','configuration',
98
'continue','data','define','do',
109
'dynamicparam','else','elseif','end',
1110
'enum','exit','filter','finally',
1211
'for','foreach','from','function',
13-
'hidden','if','in','inlinescript',
14-
'interface','module','namespace','parallel',
15-
'param','private','process','public',
16-
'return','sequence','static','switch',
12+
'if','parallel','param','process',
13+
'return','sequence','switch',
1714
'throw','trap','try','type',
1815
'until','using','var','while','workflow'
1916
)
2017

2118
$randomCasedReservedWords = @(
22-
'aSSeMbLy','bASe','bEgIN','bReAk',
23-
'cAtCh','CLasS','cOMmAnD','cONfiGuRaTioN',
19+
'bEgIN','bReAk','cAtCh','CLasS','cONfiGuRaTioN',
2420
'cONtiNuE','dAtA','dEFInE','Do',
2521
'DyNaMiCpArAm','eLsE','eLsEiF','EnD',
2622
'EnUm','eXiT','fIlTeR','fINaLLy',
2723
'FoR','fOrEaCh','fROm','fUnCtIoN',
28-
'hIdDeN','iF','IN','iNlInEsCrIpT',
29-
'InTeRfAcE','mOdUlE','nAmEsPaCe','pArAlLeL',
30-
'PaRaM','pRiVaTe','pRoCeSs','pUbLiC',
31-
'ReTuRn','sEqUeNcE','StAtIc','SwItCh',
24+
'iF','pArAlLeL','PaRaM','pRoCeSs',
25+
'ReTuRn','sEqUeNcE','SwItCh',
3226
'tHrOw','TrAp','tRy','TyPe',
3327
'uNtIl','UsInG','VaR','wHiLe','wOrKfLoW'
3428
)

0 commit comments

Comments
 (0)