From 92f13b9b60e794be1ba34a68d46f654ceaa3c056 Mon Sep 17 00:00:00 2001 From: Reece Dunham Date: Wed, 19 Jun 2019 13:56:34 -0400 Subject: [PATCH] Fix minor CodeFactor style issues in ModuleCmdletBase (#9915) --- .../engine/Modules/ModuleCmdletBase.cs | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/src/System.Management.Automation/engine/Modules/ModuleCmdletBase.cs b/src/System.Management.Automation/engine/Modules/ModuleCmdletBase.cs index 0d89b007c..855f0ddcc 100644 --- a/src/System.Management.Automation/engine/Modules/ModuleCmdletBase.cs +++ b/src/System.Management.Automation/engine/Modules/ModuleCmdletBase.cs @@ -585,7 +585,6 @@ namespace Microsoft.PowerShell.Commands // Check for PowerShell Version before checking other keys // If a PowerShellVersion exists and does not match the requirements, then the error is InsufficientPowerShellVersion // Else, the error is InvalidManifestMember - Version powerShellVersion; Version currentPowerShellVersion = PSVersionInfo.PSVersion; if (GetScalarFromData(data, moduleManifestPath, "PowerShellVersion", manifestProcessingFlags, out powerShellVersion) && @@ -1482,21 +1481,16 @@ namespace Microsoft.PowerShell.Commands // START: Check if the ModuleToProcess is already loaded..if it is, ignore the this load manifest // call and return - string moduleToProcess = null; - if ( - !GetScalarFromData(data, moduleManifestPath, "ModuleToProcess", manifestProcessingFlags, - out moduleToProcess)) + if (!GetScalarFromData(data, moduleManifestPath, "ModuleToProcess", manifestProcessingFlags, out moduleToProcess)) { containedErrors = true; if (bailOnFirstError) return null; } string rootModule = null; - if ( - !GetScalarFromData(data, moduleManifestPath, "RootModule", manifestProcessingFlags, - out rootModule)) + if (!GetScalarFromData(data, moduleManifestPath, "RootModule", manifestProcessingFlags, out rootModule)) { containedErrors = true; if (bailOnFirstError) return null; @@ -1651,7 +1645,6 @@ namespace Microsoft.PowerShell.Commands } // END: Check if the ModuleToProcess is already loaded.. - string author = string.Empty; if (!GetScalarFromData(data, moduleManifestPath, "Author", manifestProcessingFlags, out author)) { @@ -4474,9 +4467,7 @@ namespace Microsoft.PowerShell.Commands // After input from GP team for this behavior, need to revisit the commented out part // if ((status & ModuleLoggingGroupPolicyStatus.Enabled) != 0) // { - // } - if (((status & ModuleLoggingGroupPolicyStatus.Enabled) != 0) && moduleNames != null) { foreach (string currentGPModuleName in moduleNames) @@ -4927,7 +4918,6 @@ namespace Microsoft.PowerShell.Commands // First remove cmdlets from the session state // (can't just go through module.ExportedCmdlets // because the names of the cmdlets might have been changed by the -Prefix parameter of Import-Module) - List keysToRemoveFromCmdletCache = new List(); foreach (KeyValuePair> cmdlet in Context.EngineSessionState.GetCmdletTable()) { @@ -6009,7 +5999,6 @@ namespace Microsoft.PowerShell.Commands // If we are in module analysis and the parent module declares non-wildcarded exports, then we don't need to // actually process the script module. - if (parentModule != null) { if (shouldProcessModule && (parentModule.DeclaredFunctionExports != null) && (parentModule.DeclaredFunctionExports.Count > 0)) @@ -6545,7 +6534,6 @@ namespace Microsoft.PowerShell.Commands // Passing module as a parameter here so that the providers can have the module property populated. // For engine providers, the module should point to top-level module name // For FileSystem, the module is Microsoft.PowerShell.Core and not System.Management.Automation - if (parentModule != null && InitialSessionState.IsEngineModule(parentModule.Name)) { iss.ImportCmdletsFromAssembly(assemblyToLoad, parentModule); @@ -6653,7 +6641,6 @@ namespace Microsoft.PowerShell.Commands // Passing module as a parameter here so that the providers can have the module property populated. // For engine providers, the module should point to top-level module name // For FileSystem, the module is Microsoft.PowerShell.Core and not System.Management.Automation - if (parentModule != null && InitialSessionState.IsEngineModule(parentModule.Name)) { iss.ImportCmdletsFromAssembly(assembly, parentModule); @@ -6696,7 +6683,6 @@ namespace Microsoft.PowerShell.Commands } // Add the types table entries - List typesFileNames = new List(); foreach (SessionStateTypeEntry sste in iss.Types) { @@ -6709,7 +6695,6 @@ namespace Microsoft.PowerShell.Commands } // Add the format file entries - List formatsFileNames = new List(); foreach (SessionStateFormatEntry ssfe in iss.Formats) {