Skip to content

Commit 5a3c66b

Browse files
David ReynoldsDavid Reynolds
authored andcommitted
Merge remote-tracking branch 'refs/remotes/PowerShell/development' into AvoidGlobalFunctions
2 parents 3073cde + 77a5690 commit 5a3c66b

21 files changed

+11981
-224
lines changed

CHANGELOG.MD

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,24 @@
1-
## [1.8.0](https://github.com/PowerShell/PSScriptAnalyzer/tree/1.8.0) - 2016-10-06
1+
## [unreleased](https://github.com/PowerShell/PSScriptAnalyzer/tree/development)
2+
### Fixed
3+
- Regular expression in `target` parameter in SuppressMessageAttribute (#638)
4+
- Filtering on severity level for DSC rules (#642)
5+
- PSUseCompatibleCmdlets rule
6+
+ to check for commands in Microsoft.PowerShell.Core snapin
7+
+ to ignore aliases
8+
+ to ignore custom defind commands
9+
- PSUseDeclaredVarsMoreThanAssignments rule to ignore the following special variables (#653)
10+
+ `$PSModuleAutoLoadingPreference`
11+
+ `$InformationPreference`
12+
13+
## [1.8.1](https://github.com/PowerShell/PSScriptAnalyzer/tree/1.8.1) - 2016-10-13
14+
### Added
15+
- Catalog file to play nicely with PowerShellGet, version `1.1.0.0`
16+
17+
### Fixed
18+
- [PSUsePSCredentialType](RuleDocumentation/UsePSCredentialType.md) rule to check for attributes on same line without an whitespace between them.
19+
- [PSUseShouldProcessForStateChangingFunctions](RuleDocumentation/UseShouldProcessForStateChangingFunctions.md) rule to check for `start` verb (#634)
20+
21+
## [1.8.0](https://github.com/PowerShell/PSScriptAnalyzer/tree/1.8.0) - 2016-10-06
222
### Added
323
- New [rule](RuleDocumentation/UseCompatibleCmdlets.md) to check cmdlet compatibility between different PowerShell flavors
424
- New [rule](RuleDocumentation/UseLiteralInitializerForHashtable.md) to warn when using Hashtable constructor

Engine/Generic/RuleSuppression.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
namespace Microsoft.Windows.PowerShell.ScriptAnalyzer.Generic
2121
{
2222
/// <summary>
23-
///
23+
///
2424
/// </summary>
2525
public class RuleSuppression
2626
{
@@ -185,11 +185,11 @@ public RuleSuppression(AttributeAst attrAst, int start, int end)
185185
case 2:
186186
RuleSuppressionID = (positionalArguments[1] as StringConstantExpressionAst).Value;
187187
goto case 1;
188-
188+
189189
case 1:
190190
RuleName = (positionalArguments[0] as StringConstantExpressionAst).Value;
191191
goto default;
192-
192+
193193
default:
194194
break;
195195
}
@@ -281,7 +281,7 @@ public RuleSuppression(AttributeAst attrAst, int start, int end)
281281
RuleName = String.Empty;
282282
Error = Strings.NullRuleNameError;
283283
}
284-
284+
285285
// Must have scope and target together
286286
if (String.IsNullOrWhiteSpace(Scope) && !String.IsNullOrWhiteSpace(Target))
287287
{
@@ -357,8 +357,10 @@ public static List<RuleSuppression> GetSuppressions(IEnumerable<AttributeAst> at
357357
ruleSupp.Target = "*";
358358
}
359359

360+
// According to documentation 'target' supports regular expression. But to maintain compatibility with
361+
// previous implementation we interpret '*' as a glob and therefore replace '*' with '.*'
360362
// regex for wild card *
361-
Regex reg = new Regex(String.Format("^{0}$", Regex.Escape(ruleSupp.Target).Replace(@"\*", ".*")), RegexOptions.IgnoreCase);
363+
Regex reg = new Regex(String.Format("^{0}$", ruleSupp.Target.Replace(@"*", ".*")), RegexOptions.IgnoreCase);
362364
IEnumerable<Ast> targetAsts = null;
363365

364366
switch (ruleSupp.Scope.ToLower())

Engine/PSScriptAnalyzer.psd1

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Author = 'Microsoft Corporation'
1111
RootModule = 'PSScriptAnalyzer.psm1'
1212

1313
# Version number of this module.
14-
ModuleVersion = '1.8.0'
14+
ModuleVersion = '1.8.1'
1515

1616
# ID used to uniquely identify this module
1717
GUID = 'd6245802-193d-4068-a631-8863a4342a18'
@@ -88,19 +88,11 @@ PrivateData = @{
8888
IconUri = ''
8989
ReleaseNotes = @'
9090
### Added
91-
- New rule to check cmdlet compatibility between different PowerShell flavors
92-
- New rule to warn when using Hashtable constructor
93-
- Feature to pass parameters to rules from settings file
94-
- Feature to discover settings file
95-
- Enhancement to PSShouldProcess rule to check for ShouldProcess implementation in downstream functions
96-
- A helper module to create `C#` based builtin rules
91+
- Catalog file to play nicely with PowerShellGet, version `1.1.0.0`
9792
9893
### Fixed
99-
- False negatives for identically named variables
100-
- Passing `*Ast` arguments to external rules
101-
102-
### Changed
103-
- PSShouldProcess rule to not check for presence of `ShouldContinue` when `SupportsShouldProcess` is declared
94+
- [PSUsePSCredentialType](RuleDocumentation/UsePSCredentialType.md) rule to check for attributes on same line without an whitespace between them.
95+
- [PSUseShouldProcessForStateChangingFunctions](RuleDocumentation/UseShouldProcessForStateChangingFunctions.md) rule to check for `start` verb (#634)
10496
'@
10597
}
10698
}
@@ -113,3 +105,4 @@ PrivateData = @{
113105

114106
}
115107

108+

Engine/ScriptAnalyzer.cs

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1895,28 +1895,7 @@ public IEnumerable<DiagnosticRecord> AnalyzeSyntaxTree(
18951895
// Run DSC Class rule
18961896
foreach (IDSCResourceRule dscResourceRule in this.DSCResourceRules)
18971897
{
1898-
bool includeRegexMatch = false;
1899-
bool excludeRegexMatch = false;
1900-
1901-
foreach (Regex include in includeRegexList)
1902-
{
1903-
if (include.IsMatch(dscResourceRule.GetName()))
1904-
{
1905-
includeRegexMatch = true;
1906-
break;
1907-
}
1908-
}
1909-
1910-
foreach (Regex exclude in excludeRegexList)
1911-
{
1912-
if (exclude.IsMatch(dscResourceRule.GetName()))
1913-
{
1914-
excludeRegexMatch = true;
1915-
break;
1916-
}
1917-
}
1918-
1919-
if ((includeRule == null || includeRegexMatch) && (excludeRule == null || excludeRegexMatch))
1898+
if (IsRuleAllowed(dscResourceRule))
19201899
{
19211900
this.outputWriter.WriteVerbose(string.Format(CultureInfo.CurrentCulture, Strings.VerboseRunningMessage, dscResourceRule.GetName()));
19221901

@@ -2014,7 +1993,7 @@ public IEnumerable<DiagnosticRecord> AnalyzeSyntaxTree(
20141993
}
20151994
}
20161995

2017-
foreach (var ruleRecord in this.GetExternalRecord(scriptAst, scriptTokens, exRules.ToArray(), fileName))
1996+
foreach (var ruleRecord in this.GetExternalRecord(scriptAst, scriptTokens, exRules.ToArray(), filePath))
20181997
{
20191998
var records = SuppressRule(ruleSuppressions, ruleRecord);
20201999
foreach (var record in records.Item2)

0 commit comments

Comments
 (0)