Skip to content

Commit 9539455

Browse files
committed
Merge pull request #170 from PowerShell/master
Take Master changes to Development
2 parents 1f43e97 + e76671a commit 9539455

37 files changed

+627
-62
lines changed

.gitignore

Lines changed: 208 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,208 @@
1+
## Ignore Visual Studio temporary files, build results, and
2+
## files generated by popular Visual Studio add-ons.
3+
4+
# User-specific files
5+
*.suo
6+
*.user
7+
*.userosscache
8+
*.sln.docstates
9+
10+
# User-specific files (MonoDevelop/Xamarin Studio)
11+
*.userprefs
12+
13+
# Build results
14+
[Dd]ebug/
15+
[Dd]ebugPublic/
16+
[Rr]elease/
17+
[Rr]eleases/
18+
x64/
19+
x86/
20+
build/
21+
bld/
22+
[Bb]in/
23+
[Oo]bj/
24+
25+
# Visual Studo 2015 cache/options directory
26+
.vs/
27+
28+
# MSTest test Results
29+
[Tt]est[Rr]esult*/
30+
[Bb]uild[Ll]og.*
31+
32+
# NUNIT
33+
*.VisualState.xml
34+
TestResult.xml
35+
36+
# Build Results of an ATL Project
37+
[Dd]ebugPS/
38+
[Rr]eleasePS/
39+
dlldata.c
40+
41+
# DNX
42+
project.lock.json
43+
artifacts/
44+
45+
*_i.c
46+
*_p.c
47+
*_i.h
48+
*.ilk
49+
*.meta
50+
*.obj
51+
*.pch
52+
*.pdb
53+
*.pgc
54+
*.pgd
55+
*.rsp
56+
*.sbr
57+
*.tlb
58+
*.tli
59+
*.tlh
60+
*.tmp
61+
*.tmp_proj
62+
*.log
63+
*.vspscc
64+
*.vssscc
65+
.builds
66+
*.pidb
67+
*.svclog
68+
*.scc
69+
70+
# Chutzpah Test files
71+
_Chutzpah*
72+
73+
# Visual C++ cache files
74+
ipch/
75+
*.aps
76+
*.ncb
77+
*.opensdf
78+
*.sdf
79+
*.cachefile
80+
81+
# Visual Studio profiler
82+
*.psess
83+
*.vsp
84+
*.vspx
85+
86+
# TFS 2012 Local Workspace
87+
$tf/
88+
89+
# Guidance Automation Toolkit
90+
*.gpState
91+
92+
# ReSharper is a .NET coding add-in
93+
_ReSharper*/
94+
*.[Rr]e[Ss]harper
95+
*.DotSettings.user
96+
97+
# JustCode is a .NET coding addin-in
98+
.JustCode
99+
100+
# TeamCity is a build add-in
101+
_TeamCity*
102+
103+
# DotCover is a Code Coverage Tool
104+
*.dotCover
105+
106+
# NCrunch
107+
_NCrunch_*
108+
.*crunch*.local.xml
109+
110+
# MightyMoose
111+
*.mm.*
112+
AutoTest.Net/
113+
114+
# Web workbench (sass)
115+
.sass-cache/
116+
117+
# Installshield output folder
118+
[Ee]xpress/
119+
120+
# DocProject is a documentation generator add-in
121+
DocProject/buildhelp/
122+
DocProject/Help/*.HxT
123+
DocProject/Help/*.HxC
124+
DocProject/Help/*.hhc
125+
DocProject/Help/*.hhk
126+
DocProject/Help/*.hhp
127+
DocProject/Help/Html2
128+
DocProject/Help/html
129+
130+
# Click-Once directory
131+
publish/
132+
133+
# Publish Web Output
134+
*.[Pp]ublish.xml
135+
*.azurePubxml
136+
# TODO: Comment the next line if you want to checkin your web deploy settings
137+
# but database connection strings (with potential passwords) will be unencrypted
138+
*.pubxml
139+
*.publishproj
140+
141+
# NuGet Packages
142+
*.nupkg
143+
# The packages folder can be ignored because of Package Restore
144+
**/packages/*
145+
# except build/, which is used as an MSBuild target.
146+
!**/packages/build/
147+
# Uncomment if necessary however generally it will be regenerated when needed
148+
#!**/packages/repositories.config
149+
150+
# Windows Azure Build Output
151+
csx/
152+
*.build.csdef
153+
154+
# Windows Store app package directory
155+
AppPackages/
156+
157+
# Visual Studio cache files
158+
# files ending in .cache can be ignored
159+
*.[Cc]ache
160+
# but keep track of directories ending in .cache
161+
!*.[Cc]ache/
162+
163+
# Others
164+
ClientBin/
165+
[Ss]tyle[Cc]op.*
166+
~$*
167+
*~
168+
*.dbmdl
169+
*.dbproj.schemaview
170+
*.pfx
171+
*.publishsettings
172+
node_modules/
173+
bower_components/
174+
175+
# RIA/Silverlight projects
176+
Generated_Code/
177+
178+
# Backup & report files from converting an old project file
179+
# to a newer Visual Studio version. Backup files are not needed,
180+
# because we have git ;-)
181+
_UpgradeReport_Files/
182+
Backup*/
183+
UpgradeLog*.XML
184+
UpgradeLog*.htm
185+
186+
# SQL Server files
187+
*.mdf
188+
*.ldf
189+
190+
# Business Intelligence projects
191+
*.rdl.data
192+
*.bim.layout
193+
*.bim_*.settings
194+
195+
# Microsoft Fakes
196+
FakesAssemblies/
197+
198+
# Node.js Tools for Visual Studio
199+
.ntvs_analysis.dat
200+
201+
# Visual Studio 6 build log
202+
*.plg
203+
204+
# Visual Studio 6 workspace options file
205+
*.opt
206+
207+
##Our project binplace location
208+
PSScriptAnalyzer/

CHANGELOG.MD

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## Unreleased (May.7, 2015)
1+
## Released v1.0.1 (May.8, 2015)
22
###Features:
33
- Integrated with waffle.io for Project Management.
44
- Added documentation for writing script rules.
@@ -12,11 +12,12 @@
1212

1313
- PSProvideVerboseMessage only throws warnings in non-advanced functions.
1414
- Fix the issue in importing customized rule
15+
- Fix Function Member Ast cast error
1516

1617

1718

1819

19-
##Relesed on Apr.24, 2015
20+
##Released v1.0.0 on Apr.24, 2015
2021

2122
###Features:
2223
- Finalized three levels of Severity - Error/Warning/Information.

Engine/Commands/GetScriptAnalyzerRuleCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ protected override void ProcessRecord()
142142
{
143143
if (severity != null)
144144
{
145-
var ruleSeverity = severity.Select(item => Enum.Parse(typeof (RuleSeverity), item));
145+
var ruleSeverity = severity.Select(item => Enum.Parse(typeof (RuleSeverity), item, true));
146146
rules = rules.Where(item => ruleSeverity.Contains(item.GetSeverity())).ToList();
147147
}
148148

Engine/Commands/InvokeScriptAnalyzerCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,7 @@ private void AnalyzeFile(string filePath)
581581

582582
if (severity != null)
583583
{
584-
var diagSeverity = severity.Select(item => Enum.Parse(typeof(DiagnosticSeverity), item));
584+
var diagSeverity = severity.Select(item => Enum.Parse(typeof(DiagnosticSeverity), item, true));
585585
diagnostics = diagnostics.Where(item => diagSeverity.Contains(item.Severity)).ToList();
586586
}
587587

Engine/PSScriptAnalyzer.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Author = 'Microsoft Corporation'
1111
RootModule = 'Microsoft.Windows.Powershell.ScriptAnalyzer.dll'
1212

1313
# Version number of this module.
14-
ModuleVersion = '1.0'
14+
ModuleVersion = '1.0.1'
1515

1616
# ID used to uniquely identify this module
1717
GUID = '324fc715-36bf-4aee-8e58-72e9b4a08ad9'

Engine/ScriptAnalyzer.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,12 @@ public List<ExternalRule> GetExternalRule(string[] moduleNames)
231231
string script = string.Format(CultureInfo.CurrentCulture, "Get-Module -Name '{0}' -ListAvailable", moduleName);
232232
shortModuleName = posh.AddScript(script).Invoke<PSModuleInfo>().First().Name;
233233

234+
// Invokes Update-Help for this module
235+
// Required since when invoking Get-Help later on, the cmdlet prompts for Update-Help interactively
236+
// By invoking Update-Help first, Get-Help will not prompt for downloading help later
237+
script = string.Format(CultureInfo.CurrentCulture, "Update-Help -Module '{0}' -Force", shortModuleName);
238+
posh.AddScript(script).Invoke();
239+
234240
// Invokes Get-Command and Get-Help for each functions in the module.
235241
script = string.Format(CultureInfo.CurrentCulture, "Get-Command -Module '{0}'", shortModuleName);
236242
var psobjects = posh.AddScript(script).Invoke();

Engine/SpecialVars.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ static SpecialVars()
9191
internal const string WhatIfPreference = "WhatIfPreference";
9292
internal const string WarningPreference = "WarningPreference";
9393
internal const string ConfirmPreference = "ConfirmPreference";
94+
internal const string ProgressPreference = "ProgressPreference";
9495

9596
internal static readonly string[] PreferenceVariables = new string[]
9697
{
@@ -99,7 +100,8 @@ static SpecialVars()
99100
ErrorActionPreference,
100101
WhatIfPreference,
101102
WarningPreference,
102-
ConfirmPreference,
103+
ConfirmPreference,
104+
ProgressPreference
103105
};
104106

105107
internal static readonly Type[] PreferenceVariableTypes = new Type[]
@@ -109,7 +111,8 @@ static SpecialVars()
109111
/* ErrorPreference */ typeof(ActionPreference),
110112
/* WhatIfPreference */ typeof(SwitchParameter),
111113
/* WarningPreference */ typeof(ActionPreference),
112-
/* ConfirmPreference */ typeof(ConfirmImpact),
114+
/* ConfirmPreference */ typeof(ConfirmImpact),
115+
/* ProgressPreference */ typeof(Enum),
113116
};
114117

115118
internal enum AutomaticVariable

Engine/VariableAnalysis.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,8 @@ public bool IsUninitialized(VariableExpressionAst varTarget)
339339
}
340340

341341
return analysis.DefinedBlock == null
342-
&& !SpecialVars.InitializedVariables.Contains(analysis.Name, StringComparer.OrdinalIgnoreCase)
342+
&& !(SpecialVars.InitializedVariables.Contains(analysis.Name, StringComparer.OrdinalIgnoreCase) ||
343+
SpecialVars.InitializedVariables.Contains(analysis.RealName, StringComparer.OrdinalIgnoreCase))
343344
&& !IsGlobalOrEnvironment(varTarget);
344345
}
345346

0 commit comments

Comments
 (0)