Skip to content

Commit 945d773

Browse files
author
Kapil Borle
committed
Update violation detection logic
1 parent fdf903f commit 945d773

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

Rules/UseCompatibleCmdlets.cs

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -185,24 +185,18 @@ public override AstVisitAction VisitCommand(CommandAst commandAst)
185185
private void GenerateDiagnosticRecords()
186186
{
187187
bool referenceCompatibility = curCmdletCompatibilityMap[reference];
188-
bool requestedCompatibility = ruleParameters.compatibility.Any(x => curCmdletCompatibilityMap[x]);
189188

190-
// If the command is present in reference platform but not in any of the given platforms.
191-
// Or if the command is not present in reference platform but present in any of the given platforms
189+
// If the command is present in reference platform but not in any of the target platforms.
190+
// Or if the command is not present in reference platform but present in any of the target platforms
192191
// then declare it as an incompatible cmdlet.
193-
// If it is present neither in reference platform nor any given platforms, then it is probably a
192+
// If it is present neither in reference platform nor any target platforms, then it is probably a
194193
// non-builtin command and hence do not declare it as an incompatible cmdlet.
195194
// Since we do not check for aliases, the XOR-ing will also make sure that aliases are not flagged
196-
// as they will be found neither in reference platform nor in given platforms
197-
if (!(referenceCompatibility ^ requestedCompatibility))
198-
{
199-
return;
200-
}
201-
195+
// as they will be found neither in reference platform nor in target platforms
202196
foreach (var platform in ruleParameters.compatibility)
203197
{
204198
var curCmdletCompat = curCmdletCompatibilityMap[platform];
205-
if (!curCmdletCompat)
199+
if (!curCmdletCompat && referenceCompatibility)
206200
{
207201
var cmdletName = curCmdletAst.GetCommandName();
208202
var platformInfo = platformSpecMap[platform];

0 commit comments

Comments
 (0)