From 70a4ce526b014009b6e796209ddb8c235a6c3a84 Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Sun, 11 Mar 2018 19:59:40 +0000 Subject: [PATCH 1/2] Remove and sort usings --- Engine/Commands/GetScriptAnalyzerRuleCommand.cs | 2 +- Engine/EditableText.cs | 8 ++------ Engine/Generic/CorrectionExtent.cs | 5 ----- Engine/Generic/DiagnosticRecord.cs | 1 - Engine/Generic/RuleSuppression.cs | 4 ++-- Engine/Helper.cs | 8 +++----- Engine/Loggers/WriteObjectsLogger.cs | 1 - Engine/VariableAnalysis.cs | 2 +- Engine/VariableAnalysisBase.cs | 6 +++--- Rules/AvoidNullOrEmptyHelpMessageAttribute.cs | 1 - Rules/AvoidReservedCharInCmdlet.cs | 1 - Rules/AvoidTrailingWhitespace.cs | 1 - Rules/AvoidUserNameAndPasswordParams.cs | 1 - Rules/AvoidUsingComputerNameHardcoded.cs | 1 - Rules/AvoidUsingPlainTextForPassword.cs | 2 -- Rules/DscExamplesPresent.cs | 2 +- Rules/DscTestsPresent.cs | 2 +- Rules/LoggerInfo.cs | 5 ----- Rules/MissingModuleManifestField.cs | 1 - Rules/PlaceOpenBrace.cs | 1 - Rules/ProvideCommentHelp.cs | 2 -- Rules/ReturnCorrectTypesForDSCFunctions.cs | 2 +- Rules/UseCompatibleCmdlets.cs | 3 +-- Rules/UseIdenticalParametersDSC.cs | 2 +- Rules/UseLiteralInitializerForHashtable.cs | 3 +-- Rules/UsePSCredentialType.cs | 1 - Rules/UseStandardDSCFunctionsInResource.cs | 2 +- Rules/UseToExportFieldsInManifest.cs | 1 - Rules/UseVerboseMessageInDSCResource.cs | 3 +-- rules/UseSupportsShouldProcess.cs | 1 - 30 files changed, 20 insertions(+), 55 deletions(-) diff --git a/Engine/Commands/GetScriptAnalyzerRuleCommand.cs b/Engine/Commands/GetScriptAnalyzerRuleCommand.cs index e60ff8500..4a1fe7e6a 100644 --- a/Engine/Commands/GetScriptAnalyzerRuleCommand.cs +++ b/Engine/Commands/GetScriptAnalyzerRuleCommand.cs @@ -10,13 +10,13 @@ // THE SOFTWARE. // +using Microsoft.Windows.PowerShell.ScriptAnalyzer.Generic; using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; using System.Management.Automation; -using Microsoft.Windows.PowerShell.ScriptAnalyzer.Generic; namespace Microsoft.Windows.PowerShell.ScriptAnalyzer.Commands { diff --git a/Engine/EditableText.cs b/Engine/EditableText.cs index 5d77862d2..30ad5d4c8 100644 --- a/Engine/EditableText.cs +++ b/Engine/EditableText.cs @@ -1,12 +1,8 @@ -using System; -using System.Collections; -using System.Collections.Generic; +using Microsoft.Windows.PowerShell.ScriptAnalyzer.Extensions; +using System; using System.Collections.ObjectModel; using System.Globalization; using System.Linq; -using System.Management.Automation.Language; -using System.Text; -using Microsoft.Windows.PowerShell.ScriptAnalyzer.Extensions; namespace Microsoft.Windows.PowerShell.ScriptAnalyzer { diff --git a/Engine/Generic/CorrectionExtent.cs b/Engine/Generic/CorrectionExtent.cs index cab9f1ff6..1a5709f3f 100644 --- a/Engine/Generic/CorrectionExtent.cs +++ b/Engine/Generic/CorrectionExtent.cs @@ -10,13 +10,8 @@ // THE SOFTWARE. // -using System; using System.Collections.Generic; -using System.IO; -using System.Linq; using System.Management.Automation.Language; -using System.Text; -using System.Threading.Tasks; namespace Microsoft.Windows.PowerShell.ScriptAnalyzer.Generic { diff --git a/Engine/Generic/DiagnosticRecord.cs b/Engine/Generic/DiagnosticRecord.cs index 2aedeedf8..8710807cd 100644 --- a/Engine/Generic/DiagnosticRecord.cs +++ b/Engine/Generic/DiagnosticRecord.cs @@ -12,7 +12,6 @@ -using System; using System.Collections.Generic; using System.Management.Automation.Language; diff --git a/Engine/Generic/RuleSuppression.cs b/Engine/Generic/RuleSuppression.cs index 2cfee6311..7c86adf4a 100644 --- a/Engine/Generic/RuleSuppression.cs +++ b/Engine/Generic/RuleSuppression.cs @@ -11,11 +11,11 @@ // using System; +using System.Collections.Generic; +using System.Globalization; using System.Linq; using System.Management.Automation.Language; -using System.Collections.Generic; using System.Text.RegularExpressions; -using System.Globalization; namespace Microsoft.Windows.PowerShell.ScriptAnalyzer.Generic { diff --git a/Engine/Helper.cs b/Engine/Helper.cs index 31120ed99..261d00491 100644 --- a/Engine/Helper.cs +++ b/Engine/Helper.cs @@ -10,18 +10,16 @@ // THE SOFTWARE. // +using Microsoft.Windows.PowerShell.ScriptAnalyzer.Generic; using System; +using System.Collections; using System.Collections.Generic; using System.Collections.ObjectModel; +using System.Globalization; using System.IO; using System.Linq; using System.Management.Automation; using System.Management.Automation.Language; -using System.Globalization; -using Microsoft.Windows.PowerShell.ScriptAnalyzer.Generic; -using System.Management.Automation.Runspaces; -using System.Collections; -using System.Reflection; namespace Microsoft.Windows.PowerShell.ScriptAnalyzer { diff --git a/Engine/Loggers/WriteObjectsLogger.cs b/Engine/Loggers/WriteObjectsLogger.cs index 118280fb9..70c22fc43 100644 --- a/Engine/Loggers/WriteObjectsLogger.cs +++ b/Engine/Loggers/WriteObjectsLogger.cs @@ -19,7 +19,6 @@ using System.Globalization; using System.Reflection; using System.Resources; -using System.Threading; namespace Microsoft.Windows.PowerShell.ScriptAnalyzer.Loggers { diff --git a/Engine/VariableAnalysis.cs b/Engine/VariableAnalysis.cs index 2c988a9c2..23c6b642f 100644 --- a/Engine/VariableAnalysis.cs +++ b/Engine/VariableAnalysis.cs @@ -12,9 +12,9 @@ using System; using System.Collections.Generic; +using System.Globalization; using System.Linq; using System.Management.Automation.Language; -using System.Globalization; namespace Microsoft.Windows.PowerShell.ScriptAnalyzer { diff --git a/Engine/VariableAnalysisBase.cs b/Engine/VariableAnalysisBase.cs index 2ace1910e..0eeb63024 100644 --- a/Engine/VariableAnalysisBase.cs +++ b/Engine/VariableAnalysisBase.cs @@ -14,11 +14,11 @@ using System.Collections; using System.Collections.Generic; using System.Collections.ObjectModel; +using System.Globalization; using System.Linq; -using System.Reflection; -using System.Management.Automation.Language; using System.Management.Automation; -using System.Globalization; +using System.Management.Automation.Language; +using System.Reflection; namespace Microsoft.Windows.PowerShell.ScriptAnalyzer { diff --git a/Rules/AvoidNullOrEmptyHelpMessageAttribute.cs b/Rules/AvoidNullOrEmptyHelpMessageAttribute.cs index 6a43f0e18..e8d9d88f5 100644 --- a/Rules/AvoidNullOrEmptyHelpMessageAttribute.cs +++ b/Rules/AvoidNullOrEmptyHelpMessageAttribute.cs @@ -12,7 +12,6 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Management.Automation.Language; using Microsoft.Windows.PowerShell.ScriptAnalyzer.Generic; #if !CORECLR diff --git a/Rules/AvoidReservedCharInCmdlet.cs b/Rules/AvoidReservedCharInCmdlet.cs index 9e64a167a..dc5008add 100644 --- a/Rules/AvoidReservedCharInCmdlet.cs +++ b/Rules/AvoidReservedCharInCmdlet.cs @@ -15,7 +15,6 @@ using System.Linq; using System.Management.Automation.Language; using Microsoft.Windows.PowerShell.ScriptAnalyzer.Generic; -using Microsoft.Windows.PowerShell.ScriptAnalyzer; #if !CORECLR using System.ComponentModel.Composition; #endif diff --git a/Rules/AvoidTrailingWhitespace.cs b/Rules/AvoidTrailingWhitespace.cs index f9fb86b68..f4de9ec70 100644 --- a/Rules/AvoidTrailingWhitespace.cs +++ b/Rules/AvoidTrailingWhitespace.cs @@ -15,7 +15,6 @@ using System.ComponentModel.Composition; #endif using System.Globalization; -using System.Linq; using System.Management.Automation.Language; using Microsoft.Windows.PowerShell.ScriptAnalyzer.Generic; diff --git a/Rules/AvoidUserNameAndPasswordParams.cs b/Rules/AvoidUserNameAndPasswordParams.cs index b784e3a79..d94661d1b 100644 --- a/Rules/AvoidUserNameAndPasswordParams.cs +++ b/Rules/AvoidUserNameAndPasswordParams.cs @@ -20,7 +20,6 @@ using System.ComponentModel.Composition; #endif using System.Globalization; -using System.Reflection; namespace Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules { diff --git a/Rules/AvoidUsingComputerNameHardcoded.cs b/Rules/AvoidUsingComputerNameHardcoded.cs index 2f3ac858a..daac14bd7 100644 --- a/Rules/AvoidUsingComputerNameHardcoded.cs +++ b/Rules/AvoidUsingComputerNameHardcoded.cs @@ -17,7 +17,6 @@ using System.ComponentModel.Composition; #endif using System.Globalization; -using System.Collections.Generic; using System.Linq; namespace Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules diff --git a/Rules/AvoidUsingPlainTextForPassword.cs b/Rules/AvoidUsingPlainTextForPassword.cs index 918a5b70b..427102bcd 100644 --- a/Rules/AvoidUsingPlainTextForPassword.cs +++ b/Rules/AvoidUsingPlainTextForPassword.cs @@ -18,8 +18,6 @@ using System.ComponentModel.Composition; #endif using System.Globalization; -using System.Reflection; -using System.Text; namespace Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules { diff --git a/Rules/DscExamplesPresent.cs b/Rules/DscExamplesPresent.cs index 28b008173..222d765ad 100644 --- a/Rules/DscExamplesPresent.cs +++ b/Rules/DscExamplesPresent.cs @@ -30,7 +30,7 @@ namespace Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules /// For class based resources it should be present at the same folder level as resource psm1 file. /// Examples folder should contain sample configuration for given resource - file name should contain resource's name. /// - #if !CORECLR +#if !CORECLR [Export(typeof(IDSCResourceRule))] #endif public class DscExamplesPresent : IDSCResourceRule diff --git a/Rules/DscTestsPresent.cs b/Rules/DscTestsPresent.cs index d3591af03..b51a9d4ad 100644 --- a/Rules/DscTestsPresent.cs +++ b/Rules/DscTestsPresent.cs @@ -30,7 +30,7 @@ namespace Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules /// For class based resources it should be present at the same folder level as resource psm1 file. /// Tests folder should contain test script for given resource - file name should contain resource's name. /// - #if !CORECLR +#if !CORECLR [Export(typeof(IDSCResourceRule))] #endif public class DscTestsPresent : IDSCResourceRule diff --git a/Rules/LoggerInfo.cs b/Rules/LoggerInfo.cs index 8c7cdb1c2..51b5357df 100644 --- a/Rules/LoggerInfo.cs +++ b/Rules/LoggerInfo.cs @@ -10,11 +10,6 @@ // THE SOFTWARE. // -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Diagnostics.CodeAnalysis; namespace Microsoft.Windows.Powershell.ScriptAnalyzer.Generic diff --git a/Rules/MissingModuleManifestField.cs b/Rules/MissingModuleManifestField.cs index 114c7bb94..7ced83f10 100644 --- a/Rules/MissingModuleManifestField.cs +++ b/Rules/MissingModuleManifestField.cs @@ -19,7 +19,6 @@ using System.ComponentModel.Composition; #endif using System.Globalization; -using System.Text; namespace Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules { diff --git a/Rules/PlaceOpenBrace.cs b/Rules/PlaceOpenBrace.cs index eac527f46..4257f2d2e 100644 --- a/Rules/PlaceOpenBrace.cs +++ b/Rules/PlaceOpenBrace.cs @@ -14,7 +14,6 @@ using System.ComponentModel.Composition; #endif using System.Globalization; -using System.Linq; using System.Management.Automation.Language; using System.Text; using Microsoft.Windows.PowerShell.ScriptAnalyzer.Generic; diff --git a/Rules/ProvideCommentHelp.cs b/Rules/ProvideCommentHelp.cs index 66aa87cdb..751471180 100644 --- a/Rules/ProvideCommentHelp.cs +++ b/Rules/ProvideCommentHelp.cs @@ -19,9 +19,7 @@ using System.ComponentModel.Composition; #endif using System.Globalization; -using System.Management.Automation; using System.Text; -using System.IO; namespace Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules { diff --git a/Rules/ReturnCorrectTypesForDSCFunctions.cs b/Rules/ReturnCorrectTypesForDSCFunctions.cs index ad856e3b2..0cf6e5d93 100644 --- a/Rules/ReturnCorrectTypesForDSCFunctions.cs +++ b/Rules/ReturnCorrectTypesForDSCFunctions.cs @@ -25,7 +25,7 @@ namespace Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules /// /// ReturnCorrectTypeDSCFunctions: Check that DSC functions return the correct type. /// - #if !CORECLR +#if !CORECLR [Export(typeof(IDSCResourceRule))] #endif public class ReturnCorrectTypesForDSCFunctions : IDSCResourceRule diff --git a/Rules/UseCompatibleCmdlets.cs b/Rules/UseCompatibleCmdlets.cs index bd922e074..6cae8f277 100644 --- a/Rules/UseCompatibleCmdlets.cs +++ b/Rules/UseCompatibleCmdlets.cs @@ -17,7 +17,6 @@ using System.IO; using System.Linq; using System.Management.Automation.Language; -using System.Reflection; using System.Text.RegularExpressions; using Microsoft.Windows.PowerShell.ScriptAnalyzer.Generic; @@ -28,7 +27,7 @@ namespace Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules /// /// A class to check if a script uses Cmdlets compatible with a given version and edition of PowerShell. /// - #if !CORECLR +#if !CORECLR [Export(typeof(IScriptRule))] #endif public class UseCompatibleCmdlets : AstVisitor, IScriptRule diff --git a/Rules/UseIdenticalParametersDSC.cs b/Rules/UseIdenticalParametersDSC.cs index 4698653c9..c43c5f4c9 100644 --- a/Rules/UseIdenticalParametersDSC.cs +++ b/Rules/UseIdenticalParametersDSC.cs @@ -26,7 +26,7 @@ namespace Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules /// UseIdenticalParametersDSC: Check that the Test-TargetResource and /// Set-TargetResource have identical parameters. /// - #if !CORECLR +#if !CORECLR [Export(typeof(IDSCResourceRule))] #endif public class UseIdenticalParametersDSC : IDSCResourceRule diff --git a/Rules/UseLiteralInitializerForHashtable.cs b/Rules/UseLiteralInitializerForHashtable.cs index 1d1f5f641..e0d247f7f 100644 --- a/Rules/UseLiteralInitializerForHashtable.cs +++ b/Rules/UseLiteralInitializerForHashtable.cs @@ -16,7 +16,6 @@ using System.ComponentModel.Composition; #endif using System.Globalization; -using System.Linq; using System.Management.Automation.Language; using Microsoft.Windows.PowerShell.ScriptAnalyzer.Generic; @@ -25,7 +24,7 @@ namespace Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules /// /// A class to walk an AST to check if hashtable is not initialized using [hashtable]::new or new-object hashtable /// - #if !CORECLR +#if !CORECLR [Export(typeof(IScriptRule))] #endif public class UseLiteralInitializerForHashtable : AstVisitor, IScriptRule diff --git a/Rules/UsePSCredentialType.cs b/Rules/UsePSCredentialType.cs index 5e61c9ba5..f465a876d 100644 --- a/Rules/UsePSCredentialType.cs +++ b/Rules/UsePSCredentialType.cs @@ -11,7 +11,6 @@ // using System; -using System.Reflection; using System.Linq; using System.Collections.Generic; using System.Management.Automation; diff --git a/Rules/UseStandardDSCFunctionsInResource.cs b/Rules/UseStandardDSCFunctionsInResource.cs index e6938afe3..cff18e13a 100644 --- a/Rules/UseStandardDSCFunctionsInResource.cs +++ b/Rules/UseStandardDSCFunctionsInResource.cs @@ -25,7 +25,7 @@ namespace Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules /// /// UseStandardDSCFunctionsInResource: Checks if the DSC resource uses standard Get/Set/Test TargetResource functions. /// - #if !CORECLR +#if !CORECLR [Export(typeof(IDSCResourceRule))] #endif public class UseStandardDSCFunctionsInResource : IDSCResourceRule diff --git a/Rules/UseToExportFieldsInManifest.cs b/Rules/UseToExportFieldsInManifest.cs index 2641cae62..9d9d7a534 100644 --- a/Rules/UseToExportFieldsInManifest.cs +++ b/Rules/UseToExportFieldsInManifest.cs @@ -19,7 +19,6 @@ #if !CORECLR using System.ComponentModel.Composition; #endif -using System.Text.RegularExpressions; using System.Diagnostics; using System.Text; using System.Globalization; diff --git a/Rules/UseVerboseMessageInDSCResource.cs b/Rules/UseVerboseMessageInDSCResource.cs index 1e52d5ec5..677e675b6 100644 --- a/Rules/UseVerboseMessageInDSCResource.cs +++ b/Rules/UseVerboseMessageInDSCResource.cs @@ -19,14 +19,13 @@ using System.ComponentModel.Composition; #endif using System.Globalization; -using System.Management.Automation; namespace Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules { /// /// UseVerboseMessageInDSCResource: Analyzes the ast to check that Write-Verbose is called for DSC Resources. /// - #if !CORECLR +#if !CORECLR [Export(typeof(IDSCResourceRule))] #endif public class UseVerboseMessageInDSCResource : SkipNamedBlock, IDSCResourceRule diff --git a/rules/UseSupportsShouldProcess.cs b/rules/UseSupportsShouldProcess.cs index 06b10b32f..3173a4d2c 100644 --- a/rules/UseSupportsShouldProcess.cs +++ b/rules/UseSupportsShouldProcess.cs @@ -10,7 +10,6 @@ using System; using System.Linq; -using System.Text; using System.Collections.Generic; #if !CORECLR using System.ComponentModel.Composition; From 0f0f705d887c064c924ab9a68b295e71201b72fc Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Sun, 11 Mar 2018 20:06:28 +0000 Subject: [PATCH 2/2] re-add accidentally removed using --- Engine/Loggers/WriteObjectsLogger.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/Engine/Loggers/WriteObjectsLogger.cs b/Engine/Loggers/WriteObjectsLogger.cs index 70c22fc43..118280fb9 100644 --- a/Engine/Loggers/WriteObjectsLogger.cs +++ b/Engine/Loggers/WriteObjectsLogger.cs @@ -19,6 +19,7 @@ using System.Globalization; using System.Reflection; using System.Resources; +using System.Threading; namespace Microsoft.Windows.PowerShell.ScriptAnalyzer.Loggers {