Skip to content

Commit ad13c4b

Browse files
authored
Basic linting and formatting updates (Azure#3109)
1 parent 3439959 commit ad13c4b

File tree

73 files changed

+3404
-3477
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+3404
-3477
lines changed

.editorconfig

+5-2
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,19 @@ indent_size = 2
2121
[*.cs]
2222

2323
# Code style defaults
24-
csharp_using_directive_placement = outside_namespace:suggestion
24+
csharp_using_directive_placement = outside_namespace:error
2525
csharp_style_implicit_object_creation_when_type_is_apparent = true:suggestion
2626
csharp_preferred_modifier_order.severity = suggestion
27-
dotnet_sort_system_directives_first = true
27+
dotnet_sort_system_directives_first = true:error
2828
dotnet_style_readonly_field = true:suggestion
2929
dotnet_style_prefer_simplified_boolean_expressions = true:suggestion
3030
dotnet_style_prefer_simplified_interpolation = true:suggestion
31+
csharp_style_namespace_declarations = file_scoped:suggestion
32+
dotnet_diagnostic.IDE0005.severity = error
3133

3234
# License header
3335
file_header_template = Copyright (c) Microsoft Corporation.\nLicensed under the MIT License.
36+
dotnet_diagnostic.IDE0073.severity = error
3437

3538
# Suggest more modern language features when available
3639
dotnet_style_object_initializer = true:suggestion
+68-69
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) Microsoft Corporation.
1+
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT License.
33

44
#if BENCHMARK
@@ -15,101 +15,100 @@
1515
using System.Diagnostics;
1616
using Microsoft.Extensions.CommandLineUtils;
1717

18-
namespace PSRule.Rules.Azure.Benchmark
18+
namespace PSRule.Rules.Azure.Benchmark;
19+
20+
internal static class Program
1921
{
20-
internal static class Program
22+
private static void Main(string[] args)
2123
{
22-
private static void Main(string[] args)
24+
var app = new CommandLineApplication
2325
{
24-
var app = new CommandLineApplication
25-
{
26-
Name = "PSRule for Azure Benchmark",
27-
Description = "A runner for testing PSRule performance"
28-
};
26+
Name = "PSRule for Azure Benchmark",
27+
Description = "A runner for testing PSRule performance"
28+
};
2929

3030
#if !BENCHMARK
31-
// Do profiling
32-
DebugProfile(app);
33-
app.Execute(args);
31+
// Do profiling
32+
DebugProfile(app);
33+
app.Execute(args);
3434
#endif
3535

3636
#if BENCHMARK
37-
RunProfile(app);
38-
app.Execute(args);
37+
RunProfile(app);
38+
app.Execute(args);
3939
#endif
40-
}
40+
}
4141

4242
#if BENCHMARK
4343

44-
private static void RunProfile(CommandLineApplication app)
44+
private static void RunProfile(CommandLineApplication app)
45+
{
46+
var config = ManualConfig.CreateEmpty()
47+
.AddLogger(ConsoleLogger.Default)
48+
.AddColumnProvider(DefaultColumnProviders.Instance)
49+
.AddAnalyser(EnvironmentAnalyser.Default)
50+
.AddAnalyser(OutliersAnalyser.Default)
51+
.AddAnalyser(MinIterationTimeAnalyser.Default)
52+
.AddAnalyser(MultimodalDistributionAnalyzer.Default)
53+
.AddAnalyser(RuntimeErrorAnalyser.Default)
54+
.AddAnalyser(ZeroMeasurementAnalyser.Default);
55+
56+
app.Command("benchmark", cmd =>
4557
{
46-
var config = ManualConfig.CreateEmpty()
47-
.AddLogger(ConsoleLogger.Default)
48-
.AddColumnProvider(DefaultColumnProviders.Instance)
49-
.AddAnalyser(EnvironmentAnalyser.Default)
50-
.AddAnalyser(OutliersAnalyser.Default)
51-
.AddAnalyser(MinIterationTimeAnalyser.Default)
52-
.AddAnalyser(MultimodalDistributionAnalyzer.Default)
53-
.AddAnalyser(RuntimeErrorAnalyser.Default)
54-
.AddAnalyser(ZeroMeasurementAnalyser.Default);
55-
56-
app.Command("benchmark", cmd =>
58+
var output = cmd.Option("-o | --output", "The path to store report output.", CommandOptionType.SingleValue);
59+
cmd.OnExecute(() =>
5760
{
58-
var output = cmd.Option("-o | --output", "The path to store report output.", CommandOptionType.SingleValue);
59-
cmd.OnExecute(() =>
61+
if (output.HasValue())
6062
{
61-
if (output.HasValue())
62-
{
63-
config.WithArtifactsPath(output.Value());
64-
}
65-
66-
// Do benchmarks
67-
BenchmarkRunner.Run<PSRule>(config);
68-
return 0;
69-
});
70-
cmd.HelpOption("-? | -h | --help");
63+
config.WithArtifactsPath(output.Value());
64+
}
65+
66+
// Do benchmarks
67+
BenchmarkRunner.Run<PSRule>(config);
68+
return 0;
7169
});
72-
app.HelpOption("-? | -h | --help");
73-
}
70+
cmd.HelpOption("-? | -h | --help");
71+
});
72+
app.HelpOption("-? | -h | --help");
73+
}
7474

7575
#endif
7676

77-
private const int DebugIterations = 100;
77+
private const int DebugIterations = 100;
7878

79-
private static void DebugProfile(CommandLineApplication app)
79+
private static void DebugProfile(CommandLineApplication app)
80+
{
81+
app.Command("benchmark", cmd =>
8082
{
81-
app.Command("benchmark", cmd =>
83+
cmd.OnExecute(() =>
8284
{
83-
cmd.OnExecute(() =>
84-
{
85-
Console.WriteLine("Press ENTER to start.");
86-
Console.ReadLine();
87-
RunDebug();
88-
return 0;
89-
});
85+
Console.WriteLine("Press ENTER to start.");
86+
Console.ReadLine();
87+
RunDebug();
88+
return 0;
9089
});
91-
}
90+
});
91+
}
9292

93-
private static void RunDebug()
94-
{
95-
var profile = new PSRule();
96-
profile.Prepare();
93+
private static void RunDebug()
94+
{
95+
var profile = new PSRule();
96+
profile.Prepare();
9797

98-
ProfileBlock();
99-
for (var i = 0; i < DebugIterations; i++)
100-
profile.Template();
98+
ProfileBlock();
99+
for (var i = 0; i < DebugIterations; i++)
100+
profile.Template();
101101

102-
for (var i = 0; i < DebugIterations; i++)
103-
profile.PropertyCopyLoop();
102+
for (var i = 0; i < DebugIterations; i++)
103+
profile.PropertyCopyLoop();
104104

105-
for (var i = 0; i < DebugIterations; i++)
106-
profile.UserDefinedFunctions();
107-
}
105+
for (var i = 0; i < DebugIterations; i++)
106+
profile.UserDefinedFunctions();
107+
}
108108

109-
[DebuggerStepThrough]
110-
private static void ProfileBlock()
111-
{
112-
// Do nothing
113-
}
109+
[DebuggerStepThrough]
110+
private static void ProfileBlock()
111+
{
112+
// Do nothing
114113
}
115114
}

src/PSRule.Rules.Azure/Common/JsonCommentWriter.cs

-29
This file was deleted.

src/PSRule.Rules.Azure/Common/LocationHelper.cs

-84
This file was deleted.

src/PSRule.Rules.Azure/Common/OutputEncodingExtensions.cs

-29
This file was deleted.

src/PSRule.Rules.Azure/Common/PSObjectExtensions.cs

-54
This file was deleted.

0 commit comments

Comments
 (0)