Skip to content

Commit 250e941

Browse files
committed
Reduce indentation level
1 parent 785cb3f commit 250e941

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

Rules/AvoidAlias.cs

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -157,24 +157,26 @@ public IEnumerable<DiagnosticRecord> AnalyzeScript(Ast ast, string fileName)
157157
private DiagnosticRecord CheckForImplicitGetAliasing(string commandName, CommandAst commandAst, string fileName)
158158
{
159159
bool isNativeCommand = Helper.Instance.GetCommandInfo(commandName, CommandTypes.Application | CommandTypes.ExternalScript) != null;
160-
if (!isNativeCommand)
160+
if (isNativeCommand)
161161
{
162-
var commdNameWithGetPrefix = $"Get-{commandName}";
163-
var cmdletNameIfCommandWasMissingGetPrefix = Helper.Instance.GetCommandInfo($"Get-{commandName}");
164-
if (cmdletNameIfCommandWasMissingGetPrefix != null)
165-
{
166-
var diagnosticRecord = new DiagnosticRecord(
167-
string.Format(CultureInfo.CurrentCulture, Strings.AvoidUsingCmdletAliasesMissingGetPrefixError, commandName, commdNameWithGetPrefix),
168-
GetCommandExtent(commandAst),
169-
GetName(),
170-
DiagnosticSeverity.Warning,
171-
fileName,
172-
commandName,
173-
suggestedCorrections: GetCorrectionExtent(commandAst, commdNameWithGetPrefix));
174-
return diagnosticRecord;
175-
}
162+
return null;
163+
}
164+
var commdNameWithGetPrefix = $"Get-{commandName}";
165+
var cmdletNameIfCommandWasMissingGetPrefix = Helper.Instance.GetCommandInfo($"Get-{commandName}");
166+
if (cmdletNameIfCommandWasMissingGetPrefix == null)
167+
{
168+
return null;
176169
}
177-
return null;
170+
171+
var diagnosticRecord = new DiagnosticRecord(
172+
string.Format(CultureInfo.CurrentCulture, Strings.AvoidUsingCmdletAliasesMissingGetPrefixError, commandName, commdNameWithGetPrefix),
173+
GetCommandExtent(commandAst),
174+
GetName(),
175+
DiagnosticSeverity.Warning,
176+
fileName,
177+
commandName,
178+
suggestedCorrections: GetCorrectionExtent(commandAst, commdNameWithGetPrefix));
179+
return diagnosticRecord;
178180
}
179181

180182
/// <summary>

0 commit comments

Comments
 (0)