Skip to content

Commit 36190d4

Browse files
authored
Merge pull request #2475 from DamirAinullin/dev
fixes of obvious code mistakes
2 parents 1fcc992 + 5c99d39 commit 36190d4

File tree

16 files changed

+20
-50
lines changed

16 files changed

+20
-50
lines changed

src/ResourceManager/Automation/Commands.Automation/Common/AutomationClient.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -867,7 +867,7 @@ public CredentialInfo CreateCredential(string resourceGroupName, string automati
867867

868868
if (createdCredential == null || createdCredential.StatusCode != HttpStatusCode.Created)
869869
{
870-
new AzureAutomationOperationException(string.Format(Resources.AutomationOperationFailed, "Create",
870+
throw new AzureAutomationOperationException(string.Format(Resources.AutomationOperationFailed, "Create",
871871
"credential", name, automationAccountName));
872872
}
873873
return new CredentialInfo(resourceGroupName, automationAccountName, createdCredential.Credential);
@@ -891,7 +891,7 @@ public CredentialInfo UpdateCredential(string resourceGroupName, string automati
891891

892892
if (credential == null || credential.StatusCode != HttpStatusCode.OK)
893893
{
894-
new AzureAutomationOperationException(string.Format(Resources.AutomationOperationFailed, "Update",
894+
throw new AzureAutomationOperationException(string.Format(Resources.AutomationOperationFailed, "Update",
895895
"credential", name, automationAccountName));
896896
}
897897

src/ResourceManager/AzureBackup/Commands.AzureBackup/Cmdlets/Jobs/GetAzureRMBackupJob.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ public override void ExecuteCmdlet()
9090
throw new Exception(Resources.AzureBackupJobArguementException);
9191
}
9292
WriteDebug(Resources.SettingStartTime);
93-
From = new DateTime();
9493
From = AzureBackupJobHelper.MinimumAllowedDate;
9594
}
9695

@@ -112,7 +111,6 @@ public override void ExecuteCmdlet()
112111
else
113112
{
114113
WriteDebug(Resources.SettingEndTime);
115-
To = new DateTime();
116114
To = AzureBackupJobHelper.MinimumAllowedDate;
117115
}
118116
}

src/ResourceManager/AzureBackup/Commands.AzureBackup/Cmdlets/Jobs/WaitAzureRMBackupJob.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ public override void ExecuteCmdlet()
9696
{
9797
if (!TimeOut.HasValue)
9898
{
99-
TimeOut = new long();
10099
TimeOut = Int64.MaxValue;
101100
}
102101

src/ResourceManager/AzureBatch/Commands.Batch.Test/Tasks/GetBatchTaskCommandTests.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,9 +172,7 @@ public void ListBatchTasksODataTest()
172172
};
173173

174174
RequestInterceptor requestInterceptor = BatchTestHelpers.CreateFakeServiceResponseInterceptor(responseToUse: response, requestAction: extractTaskListAction);
175-
cmdlet.AdditionalBehaviors = new List<BatchClientBehavior>() { requestInterceptor };
176-
177-
cmdlet.AdditionalBehaviors = new List<BatchClientBehavior>() { requestInterceptor };
175+
cmdlet.AdditionalBehaviors = new List<BatchClientBehavior> { requestInterceptor };
178176

179177
cmdlet.ExecuteCmdlet();
180178

src/ResourceManager/Insights/Commands.Insights/OutputClasses/CustomPrinter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ private static void Print(object obj, string name, string currentIndent, StringB
7979

8080
ICollection objAsCollection = obj as ICollection;
8181

82-
propName.Replace(':', ' ');
82+
propName = propName.Replace(':', ' ');
8383
if (!string.IsNullOrWhiteSpace(propName))
8484
{
8585
sb.AppendLine(propName);

src/ResourceManager/Network/Commands.Network/ApplicationGateway/NewAzureApplicationGatewayCommand.cs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -162,61 +162,51 @@ private PSApplicationGateway CreateApplicationGateway()
162162

163163
if (this.GatewayIPConfigurations != null)
164164
{
165-
applicationGateway.GatewayIPConfigurations = new List<PSApplicationGatewayIPConfiguration>();
166165
applicationGateway.GatewayIPConfigurations = this.GatewayIPConfigurations;
167166
}
168167

169168
if (this.SslCertificates != null)
170169
{
171-
applicationGateway.SslCertificates = new List<PSApplicationGatewaySslCertificate>();
172170
applicationGateway.SslCertificates = this.SslCertificates;
173171
}
174172

175173
if (this.FrontendIPConfigurations != null)
176174
{
177-
applicationGateway.FrontendIPConfigurations = new List<PSApplicationGatewayFrontendIPConfiguration>();
178175
applicationGateway.FrontendIPConfigurations = this.FrontendIPConfigurations;
179176
}
180177

181178
if (this.FrontendPorts != null)
182179
{
183-
applicationGateway.FrontendPorts = new List<PSApplicationGatewayFrontendPort>();
184180
applicationGateway.FrontendPorts = this.FrontendPorts;
185181
}
186182

187183
if (this.Probes != null)
188184
{
189-
applicationGateway.Probes = new List<PSApplicationGatewayProbe>();
190185
applicationGateway.Probes = this.Probes;
191186
}
192187

193188
if (this.BackendAddressPools != null)
194189
{
195-
applicationGateway.BackendAddressPools = new List<PSApplicationGatewayBackendAddressPool>();
196190
applicationGateway.BackendAddressPools = this.BackendAddressPools;
197191
}
198192

199193
if (this.BackendHttpSettingsCollection != null)
200194
{
201-
applicationGateway.BackendHttpSettingsCollection = new List<PSApplicationGatewayBackendHttpSettings>();
202195
applicationGateway.BackendHttpSettingsCollection = this.BackendHttpSettingsCollection;
203196
}
204197

205198
if (this.HttpListeners != null)
206199
{
207-
applicationGateway.HttpListeners = new List<PSApplicationGatewayHttpListener>();
208200
applicationGateway.HttpListeners = this.HttpListeners;
209201
}
210202

211203
if (this.UrlPathMaps != null)
212204
{
213-
applicationGateway.UrlPathMaps = new List<PSApplicationGatewayUrlPathMap>();
214205
applicationGateway.UrlPathMaps = this.UrlPathMaps;
215206
}
216207

217208
if (this.RequestRoutingRules != null)
218209
{
219-
applicationGateway.RequestRoutingRules = new List<PSApplicationGatewayRequestRoutingRule>();
220210
applicationGateway.RequestRoutingRules = this.RequestRoutingRules;
221211
}
222212

src/ResourceManager/Network/Commands.Network/ExpressRouteCircuit/NewAzureExpressRouteCircuitCommand.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,7 @@ private PSExpressRouteCircuit CreateExpressRouteCircuit()
161161
circuit.ServiceProviderProperties.BandwidthInMbps = this.BandwidthInMbps;
162162
}
163163

164-
circuit.Peerings = new List<PSPeering>();
165164
circuit.Peerings = this.Peering;
166-
circuit.Authorizations = new List<PSExpressRouteCircuitAuthorization>();
167165
circuit.Authorizations = this.Authorization;
168166
circuit.AllowClassicOperations = this.AllowClassicOperations;
169167

src/ResourceManager/Network/Commands.Network/LoadBalancer/NewAzureLoadBalancerCommand.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -130,37 +130,31 @@ private PSLoadBalancer CreateLoadBalancer()
130130

131131
if (this.FrontendIpConfiguration != null)
132132
{
133-
loadBalancer.FrontendIpConfigurations = new List<PSFrontendIPConfiguration>();
134133
loadBalancer.FrontendIpConfigurations = this.FrontendIpConfiguration;
135134
}
136135

137136
if (this.BackendAddressPool != null)
138137
{
139-
loadBalancer.BackendAddressPools = new List<PSBackendAddressPool>();
140138
loadBalancer.BackendAddressPools = this.BackendAddressPool;
141139
}
142140

143141
if (this.Probe != null)
144142
{
145-
loadBalancer.Probes = new List<PSProbe>();
146143
loadBalancer.Probes = this.Probe;
147144
}
148145

149146
if (this.InboundNatRule != null)
150147
{
151-
loadBalancer.InboundNatRules = new List<PSInboundNatRule>();
152148
loadBalancer.InboundNatRules = this.InboundNatRule;
153149
}
154150

155151
if (this.LoadBalancingRule != null)
156152
{
157-
loadBalancer.LoadBalancingRules = new List<PSLoadBalancingRule>();
158153
loadBalancer.LoadBalancingRules = this.LoadBalancingRule;
159154
}
160155

161156
if (this.InboundNatPool != null)
162157
{
163-
loadBalancer.InboundNatPools = new List<PSInboundNatPool>();
164158
loadBalancer.InboundNatPools = this.InboundNatPool;
165159
}
166160

src/ResourceManager/Network/Commands.Network/VirtualNetwork/NewAzureVirtualNetworkCommand.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ private PSVirtualNetwork CreateVirtualNetwork()
118118
vnet.DhcpOptions.DnsServers = this.DnsServer;
119119
}
120120

121-
vnet.Subnets = new List<PSSubnet>();
122121
vnet.Subnets = this.Subnet;
123122

124123
// Map to the sdk object

src/ResourceManager/Network/Commands.Network/VirtualNetworkGateway/NewAzureVirtualNetworkGatewayCommand.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,6 @@ private PSVirtualNetworkGateway CreateVirtualNetworkGateway()
176176

177177
if (this.IpConfigurations != null)
178178
{
179-
vnetGateway.IpConfigurations = new List<PSVirtualNetworkGatewayIpConfiguration>();
180179
vnetGateway.IpConfigurations = this.IpConfigurations;
181180
}
182181

src/ResourceManager/OperationalInsights/Commands.OperationalInsights/Models/PSSearchListSavedSearchResponse.cs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,17 @@ public PSSearchListSavedSearchResponse()
2626

2727
public PSSearchListSavedSearchResponse(SearchListSavedSearchResponse searchResponse)
2828
{
29-
if (searchResponse != null)
29+
if (searchResponse == null)
3030
{
31-
if (searchResponse == null)
32-
{
33-
throw new ArgumentNullException("saved search response");
34-
}
35-
SearchMetadata m = searchResponse.Metadata;
36-
this.Metadata = new PSSearchMetadata(searchResponse.Metadata);
37-
this.Value = new List<PSSavedSearchValue>();
38-
foreach (SavedSearchValue v in searchResponse.Value)
39-
{
40-
this.Value.Add(new PSSavedSearchValue(v));
41-
}
31+
throw new ArgumentNullException("saved search response");
32+
}
33+
34+
SearchMetadata m = searchResponse.Metadata;
35+
this.Metadata = new PSSearchMetadata(searchResponse.Metadata);
36+
this.Value = new List<PSSavedSearchValue>();
37+
foreach (SavedSearchValue v in searchResponse.Value)
38+
{
39+
this.Value.Add(new PSSavedSearchValue(v));
4240
}
4341
}
4442

src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/SdkClient/ResourceManagerSdkClient.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -351,13 +351,11 @@ private List<DeploymentOperation> GetNewOperations(List<DeploymentOperation> old
351351
Enum.TryParse<HttpStatusCode>(operation.Properties.StatusCode, out statusCode);
352352
if (!statusCode.IsClientFailureRequest())
353353
{
354-
List<DeploymentOperation> newNestedOperations = new List<DeploymentOperation>();
355-
356354
var result = ResourceManagementClient.DeploymentOperations.List(
357355
resourceGroupName: ResourceIdUtility.GetResourceGroupName(operation.Properties.TargetResource.Id),
358356
deploymentName: operation.Properties.TargetResource.ResourceName);
359357

360-
newNestedOperations = GetNewOperations(operations, result);
358+
List<DeploymentOperation> newNestedOperations = GetNewOperations(operations, result);
361359

362360
foreach (DeploymentOperation op in newNestedOperations)
363361
{

src/ResourceManager/Resources/Commands.ResourceManager/Cmdlets/Utilities/TemplateUtility.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ public static class TemplateUtility
3939
/// <returns>The template parameters</returns>
4040
public static RuntimeDefinedParameterDictionary GetTemplateParametersFromFile(string templateFilePath, Hashtable templateParameterObject, string templateParameterFilePath, string[] staticParameters)
4141
{
42-
RuntimeDefinedParameterDictionary dynamicParameters = new RuntimeDefinedParameterDictionary();
4342
string templateContent = null;
4443

4544
if (templateFilePath != null)
@@ -54,7 +53,7 @@ public static RuntimeDefinedParameterDictionary GetTemplateParametersFromFile(st
5453
}
5554
}
5655

57-
dynamicParameters = ParseTemplateAndExtractParameters(templateContent, templateParameterObject, templateParameterFilePath, staticParameters);
56+
RuntimeDefinedParameterDictionary dynamicParameters = ParseTemplateAndExtractParameters(templateContent, templateParameterObject, templateParameterFilePath, staticParameters);
5857

5958
return dynamicParameters;
6059
}

src/ResourceManager/SiteRecovery/Commands.SiteRecovery/ProtectionEntity/StartAzureSiteRecoveryTestFailoverJob.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ private void StartPETestFailover()
236236
}
237237
else
238238
{
239-
new ArgumentException(Properties.Resources.UnsupportedDirectionForTFO);// Throw Unsupported Direction Exception
239+
throw new ArgumentException(Properties.Resources.UnsupportedDirectionForTFO);// Throw Unsupported Direction Exception
240240
}
241241
}
242242

@@ -290,7 +290,7 @@ private void StartRpTestFailover()
290290
}
291291
else
292292
{
293-
new ArgumentException(Properties.Resources.UnsupportedDirectionForTFO);// Throw Unsupported Direction Exception
293+
throw new ArgumentException(Properties.Resources.UnsupportedDirectionForTFO);// Throw Unsupported Direction Exception
294294
}
295295
}
296296
}

src/ServiceManagement/Compute/Sync/Download/BlobHandle.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ private IEnumerable<IndexRange> GetPageRanges()
7070
{
7171
pageBlob.FetchAttributes(new AccessCondition(), blobRequestOptions);
7272
IEnumerable<PageRange> pageRanges = pageBlob.GetPageRanges(null, null, new AccessCondition(), blobRequestOptions);
73-
pageRanges.OrderBy(range => range.StartOffset);
73+
pageRanges = pageRanges.OrderBy(range => range.StartOffset);
7474
return pageRanges.Select(pr => new IndexRange(pr.StartOffset, pr.EndOffset));
7575
}
7676

src/Storage/Commands.Storage/Common/StorageCloudCmdletBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ internal virtual bool TryGetStorageAccount(IAzureProfile profile, out string acc
297297
account = null;
298298
bool result = false;
299299
//Storage Context is empty and have already set the current storage account in subscription
300-
if (Context == null && profile != null && profile.Context != null && profile.Context.Subscription != null && profile.Context.Subscription != null)
300+
if (Context == null && profile != null && profile.Context != null && profile.Context.Subscription != null)
301301
{
302302
account = profile.Context.Subscription.GetProperty(AzureSubscription.Property.StorageAccount);
303303
result = !string.IsNullOrWhiteSpace(account);

0 commit comments

Comments
 (0)