Skip to content

Commit 69e9b43

Browse files
authored
Fix codefactor if part 5 (#19286)
1 parent e5690cb commit 69e9b43

File tree

21 files changed

+273
-66
lines changed

21 files changed

+273
-66
lines changed

src/Microsoft.PowerShell.Commands.Utility/commands/utility/ImplicitRemotingCommands.cs

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2259,19 +2259,40 @@ private string GenerateNewPSSessionOption()
22592259
WSManConnectionInfo wsmanConnectionInfo = _remoteRunspaceInfo.Runspace.ConnectionInfo as WSManConnectionInfo;
22602260
if (wsmanConnectionInfo != null)
22612261
{
2262-
if (!wsmanConnectionInfo.UseCompression) { result.Append("-NoCompression "); }
2262+
if (!wsmanConnectionInfo.UseCompression)
2263+
{
2264+
result.Append("-NoCompression ");
2265+
}
22632266

2264-
if (wsmanConnectionInfo.NoEncryption) { result.Append("-NoEncryption "); }
2267+
if (wsmanConnectionInfo.NoEncryption)
2268+
{
2269+
result.Append("-NoEncryption ");
2270+
}
22652271

2266-
if (wsmanConnectionInfo.NoMachineProfile) { result.Append("-NoMachineProfile "); }
2272+
if (wsmanConnectionInfo.NoMachineProfile)
2273+
{
2274+
result.Append("-NoMachineProfile ");
2275+
}
22672276

2268-
if (wsmanConnectionInfo.UseUTF16) { result.Append("-UseUTF16 "); }
2277+
if (wsmanConnectionInfo.UseUTF16)
2278+
{
2279+
result.Append("-UseUTF16 ");
2280+
}
22692281

2270-
if (wsmanConnectionInfo.SkipCACheck) { result.Append("-SkipCACheck "); }
2282+
if (wsmanConnectionInfo.SkipCACheck)
2283+
{
2284+
result.Append("-SkipCACheck ");
2285+
}
22712286

2272-
if (wsmanConnectionInfo.SkipCNCheck) { result.Append("-SkipCNCheck "); }
2287+
if (wsmanConnectionInfo.SkipCNCheck)
2288+
{
2289+
result.Append("-SkipCNCheck ");
2290+
}
22732291

2274-
if (wsmanConnectionInfo.SkipRevocationCheck) { result.Append("-SkipRevocationCheck "); }
2292+
if (wsmanConnectionInfo.SkipRevocationCheck)
2293+
{
2294+
result.Append("-SkipRevocationCheck ");
2295+
}
22752296

22762297
if (wsmanConnectionInfo.MaximumReceivedDataSizePerCommand.HasValue)
22772298
{

src/Microsoft.PowerShell.ConsoleHost/host/msh/ConsoleHost.cs

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,10 @@ public override PSHostUserInterface UI
611611
/// </summary>
612612
public void PushRunspace(Runspace newRunspace)
613613
{
614-
if (_runspaceRef == null) { return; }
614+
if (_runspaceRef == null)
615+
{
616+
return;
617+
}
615618

616619
RemoteRunspace remoteRunspace = newRunspace as RemoteRunspace;
617620
Dbg.Assert(remoteRunspace != null, "Expected remoteRunspace != null");
@@ -744,7 +747,10 @@ public Runspace Runspace
744747
{
745748
get
746749
{
747-
if (this.RunspaceRef == null) { return null; }
750+
if (this.RunspaceRef == null)
751+
{
752+
return null;
753+
}
748754

749755
return this.RunspaceRef.Runspace;
750756
}
@@ -759,7 +765,10 @@ internal LocalRunspace LocalRunspace
759765
return RunspaceRef.OldRunspace as LocalRunspace;
760766
}
761767

762-
if (RunspaceRef == null) { return null; }
768+
if (RunspaceRef == null)
769+
{
770+
return null;
771+
}
763772

764773
return RunspaceRef.Runspace as LocalRunspace;
765774
}
@@ -964,7 +973,11 @@ public override PSObject PrivateData
964973
{
965974
get
966975
{
967-
if (ui == null) return null;
976+
if (ui == null)
977+
{
978+
return null;
979+
}
980+
968981
return _consoleColorProxy ??= PSObject.AsPSObject(new ConsoleColorProxy(ui));
969982
}
970983
}
@@ -1514,7 +1527,10 @@ private uint DoRunspaceLoop(
15141527
RunspaceCreationEventArgs args = new RunspaceCreationEventArgs(initialCommand, skipProfiles, staMode, configurationName, configurationFilePath, initialCommandArgs);
15151528
CreateRunspace(args);
15161529

1517-
if (ExitCode == ExitCodeInitFailure) { break; }
1530+
if (ExitCode == ExitCodeInitFailure)
1531+
{
1532+
break;
1533+
}
15181534

15191535
if (!_noExit)
15201536
{
@@ -2228,7 +2244,10 @@ private void OnExecutionSuspended(object sender, DebuggerStopEventArgs e)
22282244
{
22292245
// Check local runspace internalHost to see if debugging is enabled.
22302246
LocalRunspace localrunspace = LocalRunspace;
2231-
if ((localrunspace != null) && !localrunspace.ExecutionContext.EngineHostInterface.DebuggerEnabled) { return; }
2247+
if ((localrunspace != null) && !localrunspace.ExecutionContext.EngineHostInterface.DebuggerEnabled)
2248+
{
2249+
return;
2250+
}
22322251

22332252
_debuggerStopEventArgs = e;
22342253
InputLoop baseLoop = null;

src/System.Management.Automation/engine/CmdletParameterBinderController.cs

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1620,7 +1620,10 @@ private void HandleCommandLineDynamicParameters(out ParameterBindingException ou
16201620
}
16211621
catch (Exception e) // Catch-all OK, this is a third-party callout
16221622
{
1623-
if (e is ProviderInvocationException) { throw; }
1623+
if (e is ProviderInvocationException)
1624+
{
1625+
throw;
1626+
}
16241627

16251628
ParameterBindingException bindingException =
16261629
new ParameterBindingException(
@@ -3321,7 +3324,11 @@ private bool BindPipelineParametersPrivate(PSObject inputToOperateOn)
33213324
if (needToPrioritizeOneSpecificParameterSet && i == 0)
33223325
{
33233326
// If the prioritized set can be bound successfully, there is no need to do the second round binding
3324-
if (_currentParameterSetFlag == _parameterSetToBePrioritizedInPipelineBinding) break;
3327+
if (_currentParameterSetFlag == _parameterSetToBePrioritizedInPipelineBinding)
3328+
{
3329+
break;
3330+
}
3331+
33253332
validParameterSets = _currentParameterSetFlag & (~_parameterSetToBePrioritizedInPipelineBinding);
33263333
}
33273334
}
@@ -4379,7 +4386,10 @@ public override bool ContainsKey(object key)
43794386
throw PSTraceSource.NewArgumentNullException(nameof(key));
43804387
}
43814388

4382-
if (!(key is string strKey)) { return false; }
4389+
if (!(key is string strKey))
4390+
{
4391+
return false;
4392+
}
43834393

43844394
string keyAfterTrim = strKey.Trim();
43854395
return base.ContainsKey(keyAfterTrim);
@@ -4448,9 +4458,15 @@ public override object this[object key]
44484458
{
44494459
get
44504460
{
4451-
if (key == null) { throw PSTraceSource.NewArgumentNullException(nameof(key)); }
4461+
if (key == null)
4462+
{
4463+
throw PSTraceSource.NewArgumentNullException(nameof(key));
4464+
}
44524465

4453-
if (!(key is string strKey)) { return null; }
4466+
if (!(key is string strKey))
4467+
{
4468+
return null;
4469+
}
44544470

44554471
string keyAfterTrim = strKey.Trim();
44564472
return base[keyAfterTrim];
@@ -4473,7 +4489,10 @@ public override void Remove(object key)
44734489
throw PSTraceSource.NewArgumentNullException(nameof(key));
44744490
}
44754491

4476-
if (!(key is string strKey)) { return; }
4492+
if (!(key is string strKey))
4493+
{
4494+
return;
4495+
}
44774496

44784497
string keyAfterTrim = strKey.Trim();
44794498
if (base.ContainsKey(keyAfterTrim))

src/System.Management.Automation/engine/ComInterop/VariantArray.cs

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,25 @@ internal static MemberExpression GetStructField(ParameterExpression variantArray
5858
internal static Type GetStructType(int args)
5959
{
6060
Debug.Assert(args >= 0);
61-
if (args <= 1) return typeof(VariantArray1);
62-
if (args <= 2) return typeof(VariantArray2);
63-
if (args <= 4) return typeof(VariantArray4);
64-
if (args <= 8) return typeof(VariantArray8);
61+
if (args <= 1)
62+
{
63+
return typeof(VariantArray1);
64+
}
65+
66+
if (args <= 2)
67+
{
68+
return typeof(VariantArray2);
69+
}
70+
71+
if (args <= 4)
72+
{
73+
return typeof(VariantArray4);
74+
}
75+
76+
if (args <= 8)
77+
{
78+
return typeof(VariantArray8);
79+
}
6580

6681
int size = 1;
6782
while (args > size)

src/System.Management.Automation/engine/Modules/ModuleIntrinsics.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -859,7 +859,10 @@ internal static ExperimentalFeature[] GetExperimentalFeature(string manifestPath
859859
foreach (Hashtable feature in features)
860860
{
861861
string featureName = feature["Name"] as string;
862-
if (string.IsNullOrEmpty(featureName)) { continue; }
862+
if (string.IsNullOrEmpty(featureName))
863+
{
864+
continue;
865+
}
863866

864867
if (ExperimentalFeature.IsModuleFeatureName(featureName, moduleName))
865868
{

src/System.Management.Automation/engine/Modules/PSModuleInfo.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,10 @@ public Dictionary<string, FunctionInfo> ExportedFunctions
545545
// If the module is not binary, it may also have functions...
546546
if (DeclaredFunctionExports != null)
547547
{
548-
if (DeclaredFunctionExports.Count == 0) { return exports; }
548+
if (DeclaredFunctionExports.Count == 0)
549+
{
550+
return exports;
551+
}
549552

550553
foreach (string fn in DeclaredFunctionExports)
551554
{
@@ -707,7 +710,10 @@ public Dictionary<string, CmdletInfo> ExportedCmdlets
707710

708711
if (DeclaredCmdletExports != null)
709712
{
710-
if (DeclaredCmdletExports.Count == 0) { return exports; }
713+
if (DeclaredCmdletExports.Count == 0)
714+
{
715+
return exports;
716+
}
711717

712718
foreach (string fn in DeclaredCmdletExports)
713719
{

src/System.Management.Automation/engine/interpreter/DynamicInstructions.Generated.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@ namespace System.Management.Automation.Interpreter {
2222
internal partial class DynamicInstructionN {
2323
internal static Type GetDynamicInstructionType(Type delegateType) {
2424
Type[] argTypes = delegateType.GetGenericArguments();
25-
if (argTypes.Length == 0) return null;
25+
if (argTypes.Length == 0)
26+
{
27+
return null;
28+
}
29+
2630
Type genericType;
2731
Type[] newArgTypes = argTypes.Skip(1).ToArray();
2832
switch (newArgTypes.Length) {

src/System.Management.Automation/engine/interpreter/LightCompiler.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,10 @@ public bool Matches(Type exceptionType)
6868

6969
public bool IsBetterThan(ExceptionHandler other)
7070
{
71-
if (other == null) return true;
71+
if (other == null)
72+
{
73+
return true;
74+
}
7275

7376
Debug.Assert(StartIndex == other.StartIndex && EndIndex == other.EndIndex, "we only need to compare handlers for the same try block");
7477
return HandlerStartIndex < other.HandlerStartIndex;

src/System.Management.Automation/engine/interpreter/Utilities.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1078,7 +1078,10 @@ internal static bool TrueForAll<T>(this IEnumerable<T> collection, Predicate<T>
10781078

10791079
foreach (T item in collection)
10801080
{
1081-
if (!predicate(item)) return false;
1081+
if (!predicate(item))
1082+
{
1083+
return false;
1084+
}
10821085
}
10831086

10841087
return true;

src/System.Management.Automation/engine/remoting/client/Job.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1011,11 +1011,17 @@ protected virtual void DoUnloadJobStreams()
10111011
/// </summary>
10121012
public void LoadJobStreams()
10131013
{
1014-
if (_jobStreamsLoaded) return;
1014+
if (_jobStreamsLoaded)
1015+
{
1016+
return;
1017+
}
10151018

10161019
lock (syncObject)
10171020
{
1018-
if (_jobStreamsLoaded) return;
1021+
if (_jobStreamsLoaded)
1022+
{
1023+
return;
1024+
}
10191025

10201026
_jobStreamsLoaded = true;
10211027
}

0 commit comments

Comments
 (0)