Skip to content

Commit 42280ff

Browse files
authored
Merge pull request #935 from Particular/coderules
Add Particular.CodeRules 0.5.0
2 parents 0ac36e1 + 5dd96a4 commit 42280ff

21 files changed

+1443
-1188
lines changed

src/ServicePulse.Host/Commands/ExtractAndUpdateConstantsCommand.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,7 @@ public static void UpdateVersion(string directoryPath)
6666
static string GetFileVersion()
6767
{
6868
var customAttributes =
69-
typeof(AbstractCommand).Assembly.GetCustomAttributes(typeof(AssemblyInformationalVersionAttribute),
70-
false);
69+
typeof(AbstractCommand).Assembly.GetCustomAttributes(typeof(AssemblyInformationalVersionAttribute), false);
7170

7271
if (customAttributes.Length >= 1)
7372
{

src/ServicePulse.Host/Commands/ExtractCommand.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ public override void Execute(HostArguments args)
1212
{
1313
ExtractResources(args.OutputPath);
1414

15-
if (String.IsNullOrEmpty(args.ServiceControlUrl))
15+
if (string.IsNullOrEmpty(args.ServiceControlUrl))
1616
{
1717
return;
1818
}
1919

2020
ExtractAndUpdateConstantsCommand.UpdateVersion(args.OutputPath);
2121
ExtractAndUpdateConstantsCommand.UpdateConfig(args.OutputPath, args.ServiceControlUrl);
2222

23-
if (!String.IsNullOrEmpty(args.ServiceControlMonitoringUrl))
23+
if (!string.IsNullOrEmpty(args.ServiceControlMonitoringUrl))
2424
{
2525
ExtractAndUpdateConstantsCommand.UpdateMonitoringConfig(args.OutputPath, args.ServiceControlMonitoringUrl);
2626
}
@@ -34,7 +34,7 @@ static void ExtractResources(string directoryPath)
3434
{
3535
using (var resourceStream = assembly.GetManifestResourceStream(resourceName))
3636
{
37-
var fileName = resourceName.Replace(@"app\", String.Empty);
37+
var fileName = resourceName.Replace(@"app\", string.Empty);
3838
var destinationPath = Path.Combine(directoryPath, fileName);
3939
Console.WriteLine("Unpacking '{0}' to '{1}'...", fileName, destinationPath);
4040

src/ServicePulse.Host/Commands/ServiceCommand.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ public void ExecuteInternal(HostArguments args)
3939
serviceProcessInstaller
4040
};
4141

42-
var arguments = String.Empty;
42+
var arguments = string.Empty;
4343

44-
if (!String.IsNullOrEmpty(args.Url))
44+
if (!string.IsNullOrEmpty(args.Url))
4545
{
4646
arguments += string.Format(" --url=\"{0}\"", args.Url);
4747
}
@@ -53,7 +53,7 @@ public void ExecuteInternal(HostArguments args)
5353

5454
var assembly = Assembly.GetEntryAssembly();
5555

56-
var path = String.Format("/assemblypath={0}", assembly.Location);
56+
var path = string.Format("/assemblypath={0}", assembly.Location);
5757
string[] commandLine = {path};
5858

5959
var context = new InstallContext(null, commandLine);
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// This file is used by Code Analysis to maintain SuppressMessage
2+
// attributes that are applied to this project.
3+
// Project-level suppressions either have no target or are given
4+
// a specific target and scoped to a namespace, type, member, etc.
5+
6+
using System.Diagnostics.CodeAnalysis;
7+
8+
[assembly: SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:Elements should be documented", Justification = "Not a public API")]

src/ServicePulse.Host/Hosting/CaseLessOptionSet.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,5 @@ protected override bool Parse(string option, OptionContext c)
3131
}
3232
return base.Parse(newOption, c);
3333
}
34-
3534
}
3635
}

src/ServicePulse.Host/Hosting/Host.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
using Microsoft.Owin.Hosting;
2-
using ServicePulse.Host.Owin;
3-
4-
namespace ServicePulse.Host.Hosting
1+
namespace ServicePulse.Host.Hosting
52
{
63
using System;
74
using System.ServiceProcess;
5+
using Microsoft.Owin.Hosting;
6+
using ServicePulse.Host.Owin;
87

98
internal class Host : ServiceBase
109
{

src/ServicePulse.Host/Hosting/HostArguments.cs

Lines changed: 56 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ public HostArguments(string[] args)
2525
DisplayName = "Particular ServicePulse";
2626
Description = "An Operations Manager's Best Friend in Particular.";
2727
ServiceAccount = ServiceAccount.LocalService;
28-
Username = String.Empty;
29-
Password = String.Empty;
28+
Username = string.Empty;
29+
Password = string.Empty;
3030
OutputPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "app");
3131

3232
#if DEBUG
@@ -42,8 +42,8 @@ public HostArguments(string[] args)
4242
},
4343
{
4444
"url=",
45-
@"Configures ServicePulse to listen on the specified url."
46-
, s => { url = s; }
45+
@"Configures ServicePulse to listen on the specified url.",
46+
s => { url = s; }
4747
}
4848
};
4949

@@ -54,27 +54,27 @@ public HostArguments(string[] args)
5454
},
5555
{
5656
"e|extract",
57-
@"Extract files to be installed in a Web Server."
58-
, s =>
57+
@"Extract files to be installed in a Web Server.",
58+
s =>
5959
{
6060
commands = new List<Type> { typeof(ExtractCommand), typeof(ExtractAndUpdateConstantsCommand) };
6161
executionMode = ExecutionMode.Extract;
6262
}
6363
},
6464
{
6565
"servicecontrolurl=",
66-
@"Configures the service control url."
67-
, s => { serviceControlUrl = s; }
66+
@"Configures the service control url.",
67+
s => { serviceControlUrl = s; }
6868
},
6969
{
7070
"servicecontrolmonitoringurl=",
71-
@"Configures the service control monitoring url."
72-
, s => { serviceControlMonitoringUrl = s; }
71+
@"Configures the service control monitoring url.",
72+
s => { serviceControlMonitoringUrl = s; }
7373
},
7474
{
7575
"outpath=",
76-
@"The output path to extract files to. By default it extracts to the current directory."
77-
, s => { OutputPath = s; }
76+
@"The output path to extract files to. By default it extracts to the current directory.",
77+
s => { OutputPath = s; }
7878
}
7979
};
8080

@@ -85,17 +85,17 @@ public HostArguments(string[] args)
8585
},
8686
{
8787
"u|uninstall",
88-
@"Uninstall the endpoint as a Windows service."
89-
, s =>
88+
@"Uninstall the endpoint as a Windows service.",
89+
s =>
9090
{
9191
commands = new List<Type> {typeof(UninstallCommand)};
9292
executionMode = ExecutionMode.Uninstall;
9393
}
9494
},
9595
{
9696
"servicename=",
97-
@"Specify the service name for the installed service."
98-
, s => { ServiceName = s; }
97+
@"Specify the service name for the installed service.",
98+
s => { ServiceName = s; }
9999
}
100100
};
101101

@@ -108,87 +108,87 @@ public HostArguments(string[] args)
108108
},
109109
{
110110
"i|install",
111-
@"Install the endpoint as a Windows service."
112-
, s =>
111+
@"Install the endpoint as a Windows service.",
112+
s =>
113113
{
114114
commands = new List<Type> { typeof(RemoveDeprecatedOveridesCommand), typeof(ExtractAndUpdateConstantsCommand), typeof(InstallCommand) };
115115
executionMode = ExecutionMode.Install;
116116
}
117117
},
118118
{
119119
"servicename=",
120-
@"Specify the service name for the installed service."
121-
, s => { ServiceName = s; }
120+
@"Specify the service name for the installed service.",
121+
s => { ServiceName = s; }
122122
},
123123
{
124124
"displayname=",
125-
@"Friendly name for the installed service."
126-
, s => { DisplayName = s; }
125+
@"Friendly name for the installed service.",
126+
s => { DisplayName = s; }
127127
},
128128
{
129129
"description=",
130-
@"Description for the service."
131-
, s => { Description = s; }
130+
@"Description for the service.",
131+
s => { Description = s; }
132132
},
133133
{
134134
"username=",
135-
@"Username for the account the service should run under."
136-
, s => { Username = s; }
135+
@"Username for the account the service should run under.",
136+
s => { Username = s; }
137137
},
138138
{
139139
"password=",
140-
@"Password for the service account."
141-
, s => { Password = s; }
140+
@"Password for the service account.",
141+
s => { Password = s; }
142142
},
143143
{
144144
"localservice",
145-
@"Run the service with the local service account."
146-
, s => { ServiceAccount = ServiceAccount.LocalService; }
145+
@"Run the service with the local service account.",
146+
s => { ServiceAccount = ServiceAccount.LocalService; }
147147
},
148148
{
149149
"networkservice",
150-
@"Run the service with the network service permission."
151-
, s => { ServiceAccount = ServiceAccount.NetworkService; }
150+
@"Run the service with the network service permission.",
151+
s => { ServiceAccount = ServiceAccount.NetworkService; }
152152
},
153153
{
154154
"user",
155-
@"Run the service with the specified username and password. Alternative the system will prompt for a valid username and password if values for both the username and password are not specified."
156-
, s => { ServiceAccount = ServiceAccount.User; }
155+
@"Run the service with the specified username and password. Alternative the system will prompt for a valid username and password if values for both the username and password are not specified.",
156+
s => { ServiceAccount = ServiceAccount.User; }
157157
},
158158
{
159159
"delayed",
160-
@"The service should start automatically (delayed)."
161-
, s => { startMode = StartMode.Delay; }
160+
@"The service should start automatically (delayed).",
161+
s => { startMode = StartMode.Delay; }
162162
},
163163
{
164164
"autostart",
165-
@"The service should start automatically (default)."
166-
, s => { startMode = StartMode.Automatic; }
165+
@"The service should start automatically (default).",
166+
s => { startMode = StartMode.Automatic; }
167167
},
168168
{
169169
"disabled",
170-
@"The service should be set to disabled."
171-
, s => { startMode = StartMode.Disabled; }
170+
@"The service should be set to disabled.",
171+
s => { startMode = StartMode.Disabled; }
172172
},
173173
{
174174
"manual",
175-
@"The service should be started manually."
176-
, s => { startMode = StartMode.Manual; }
175+
@"The service should be started manually.",
176+
s => { startMode = StartMode.Manual; }
177177
},
178178
{
179179
"servicecontrolurl=",
180-
@"Configures the service control url."
181-
, s => { serviceControlUrl = s; }
180+
@"Configures the service control url.",
181+
s => { serviceControlUrl = s; }
182182
},
183183
{
184184
"servicecontrolmonitoringurl=",
185-
@"Configures the service control monitoring url."
186-
, s => { serviceControlMonitoringUrl = s; }
185+
@"Configures the service control monitoring url.",
186+
s => { serviceControlMonitoringUrl = s; }
187187
},
188188
{
189189
"url=",
190-
@"Configures ServicePulse to listen on the specified url."
191-
, s => { url = s; }
190+
@"Configures ServicePulse to listen on the specified url.",
191+
s => { url = s; }
192192
}
193193
};
194194

@@ -211,7 +211,7 @@ public HostArguments(string[] args)
211211
return;
212212
}
213213

214-
unknownArgsList = extractOptions.Parse(args);
214+
unknownArgsList = extractOptions.Parse(args);
215215
if (executionMode == ExecutionMode.Extract)
216216
{
217217
ThrowIfUnknownArgs(unknownArgsList);
@@ -250,7 +250,8 @@ void ValidateArgs()
250250
{
251251
case ExecutionMode.Extract:
252252
case ExecutionMode.Install:
253-
if (!string.IsNullOrEmpty(ServiceControlUrl)) // param for sc url is optional.
253+
// param for sc url is optional.
254+
if (!string.IsNullOrEmpty(ServiceControlUrl))
254255
{
255256
Uri scUri;
256257
if ((!Uri.TryCreate(ServiceControlUrl, UriKind.Absolute, out scUri)) || (!validProtocols.Contains(scUri.Scheme, StringComparer.OrdinalIgnoreCase)))
@@ -259,7 +260,8 @@ void ValidateArgs()
259260
}
260261
}
261262

262-
if (!string.IsNullOrEmpty(ServiceControlMonitoringUrl)) // param for sc url is optional.
263+
// param for sc url is optional.
264+
if (!string.IsNullOrEmpty(ServiceControlMonitoringUrl))
263265
{
264266
Uri scUri;
265267
if ((!Uri.TryCreate(ServiceControlMonitoringUrl, UriKind.Absolute, out scUri)) || (!validProtocols.Contains(scUri.Scheme, StringComparer.OrdinalIgnoreCase)))
@@ -272,7 +274,7 @@ void ValidateArgs()
272274

273275
case ExecutionMode.Run:
274276
Uri spUri;
275-
if (!(Uri.TryCreate(Url, UriKind.Absolute, out spUri)) || (!validProtocols.Contains(spUri.Scheme, StringComparer.OrdinalIgnoreCase)))
277+
if (!Uri.TryCreate(Url, UriKind.Absolute, out spUri) || (!validProtocols.Contains(spUri.Scheme, StringComparer.OrdinalIgnoreCase)))
276278
{
277279
throw new Exception("The value specified for 'url' is not a valid URL");
278280
}
@@ -322,8 +324,8 @@ public void PrintUsage()
322324
{
323325
var sb = new StringBuilder();
324326

325-
var helpText = String.Empty;
326-
using (var stream =Assembly.GetCallingAssembly().GetManifestResourceStream("ServicePulse.Host.Hosting.Help.txt"))
327+
var helpText = string.Empty;
328+
using (var stream = Assembly.GetCallingAssembly().GetManifestResourceStream("ServicePulse.Host.Hosting.Help.txt"))
327329
{
328330
if (stream != null)
329331
{

src/ServicePulse.Host/Hosting/HostInstaller.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public override void Install(IDictionary stateSaver)
2424
Registry.LocalMachine.OpenSubKey(
2525
string.Format(@"System\CurrentControlSet\Services\{0}", settings.ServiceName), true))
2626
{
27-
var imagePath = (string) service.GetValue("ImagePath");
27+
var imagePath = (string)service.GetValue("ImagePath");
2828

2929
imagePath += arguments;
3030

0 commit comments

Comments
 (0)