Skip to content

Commit

Permalink
Make everything FxCop clean (within reason) so we can more easily res…
Browse files Browse the repository at this point in the history
…olve FxCop issues.
  • Loading branch information
analogrelay committed Oct 8, 2013
1 parent 009470b commit 74dcbb5
Show file tree
Hide file tree
Showing 49 changed files with 301 additions and 128 deletions.
208 changes: 208 additions & 0 deletions src/Backend.ruleset
Original file line number Diff line number Diff line change
@@ -0,0 +1,208 @@
<?xml version="1.0" encoding="utf-8"?>
<RuleSet Name="NuGet Backend Analysis Rules" ToolsVersion="12.0">
<Include Path="basiccorrectnessrules.ruleset" Action="Default" />
<Include Path="basicdesignguidelinerules.ruleset" Action="Default" />
<Include Path="extendedcorrectnessrules.ruleset" Action="Default" />
<Include Path="globalizationrules.ruleset" Action="Default" />
<Include Path="minimumrecommendedrules.ruleset" Action="Default" />
<Include Path="securityrules.ruleset" Action="Default" />
<Rules AnalyzerId="Microsoft.Analyzers.ManagedCodeAnalysis" RuleNamespace="Microsoft.Rules.Managed">
<Rule Id="CA1000" Action="None" />
<Rule Id="CA1001" Action="None" />
<Rule Id="CA1002" Action="None" />
<Rule Id="CA1003" Action="None" />
<Rule Id="CA1004" Action="None" />
<Rule Id="CA1005" Action="None" />
<Rule Id="CA1006" Action="None" />
<Rule Id="CA1007" Action="None" />
<Rule Id="CA1008" Action="None" />
<Rule Id="CA1009" Action="None" />
<Rule Id="CA1010" Action="None" />
<Rule Id="CA1011" Action="None" />
<Rule Id="CA1012" Action="None" />
<Rule Id="CA1013" Action="None" />
<Rule Id="CA1014" Action="None" />
<Rule Id="CA1016" Action="None" />
<Rule Id="CA1017" Action="None" />
<Rule Id="CA1018" Action="None" />
<Rule Id="CA1019" Action="None" />
<Rule Id="CA1023" Action="None" />
<Rule Id="CA1024" Action="None" />
<Rule Id="CA1025" Action="None" />
<Rule Id="CA1026" Action="None" />
<Rule Id="CA1027" Action="None" />
<Rule Id="CA1028" Action="None" />
<Rule Id="CA1030" Action="None" />
<Rule Id="CA1031" Action="None" />
<Rule Id="CA1032" Action="None" />
<Rule Id="CA1033" Action="None" />
<Rule Id="CA1034" Action="None" />
<Rule Id="CA1035" Action="None" />
<Rule Id="CA1036" Action="None" />
<Rule Id="CA1038" Action="None" />
<Rule Id="CA1039" Action="None" />
<Rule Id="CA1041" Action="None" />
<Rule Id="CA1043" Action="None" />
<Rule Id="CA1044" Action="None" />
<Rule Id="CA1046" Action="None" />
<Rule Id="CA1047" Action="None" />
<Rule Id="CA1048" Action="None" />
<Rule Id="CA1049" Action="None" />
<Rule Id="CA1050" Action="None" />
<Rule Id="CA1051" Action="None" />
<Rule Id="CA1052" Action="None" />
<Rule Id="CA1053" Action="None" />
<Rule Id="CA1054" Action="None" />
<Rule Id="CA1055" Action="None" />
<Rule Id="CA1056" Action="None" />
<Rule Id="CA1057" Action="None" />
<Rule Id="CA1058" Action="None" />
<Rule Id="CA1059" Action="None" />
<Rule Id="CA1060" Action="None" />
<Rule Id="CA1061" Action="None" />
<Rule Id="CA1063" Action="None" />
<Rule Id="CA1064" Action="None" />
<Rule Id="CA1065" Action="None" />
<Rule Id="CA1300" Action="Error" />
<Rule Id="CA1301" Action="Error" />
<Rule Id="CA1302" Action="Error" />
<Rule Id="CA1303" Action="None" />
<Rule Id="CA1304" Action="None" />
<Rule Id="CA1305" Action="None" />
<Rule Id="CA1306" Action="None" />
<Rule Id="CA1307" Action="Error" />
<Rule Id="CA1308" Action="None" />
<Rule Id="CA1309" Action="Error" />
<Rule Id="CA1400" Action="None" />
<Rule Id="CA1401" Action="None" />
<Rule Id="CA1402" Action="None" />
<Rule Id="CA1403" Action="None" />
<Rule Id="CA1404" Action="None" />
<Rule Id="CA1405" Action="None" />
<Rule Id="CA1406" Action="None" />
<Rule Id="CA1407" Action="None" />
<Rule Id="CA1408" Action="None" />
<Rule Id="CA1409" Action="None" />
<Rule Id="CA1410" Action="None" />
<Rule Id="CA1411" Action="None" />
<Rule Id="CA1412" Action="None" />
<Rule Id="CA1413" Action="None" />
<Rule Id="CA1414" Action="None" />
<Rule Id="CA1415" Action="None" />
<Rule Id="CA1500" Action="Error" />
<Rule Id="CA1502" Action="None" />
<Rule Id="CA1600" Action="Error" />
<Rule Id="CA1601" Action="Error" />
<Rule Id="CA1708" Action="Error" />
<Rule Id="CA1716" Action="Error" />
<Rule Id="CA1801" Action="Error" />
<Rule Id="CA1804" Action="Error" />
<Rule Id="CA1806" Action="Error" />
<Rule Id="CA1809" Action="Error" />
<Rule Id="CA1810" Action="Error" />
<Rule Id="CA1811" Action="Error" />
<Rule Id="CA1812" Action="Error" />
<Rule Id="CA1813" Action="Error" />
<Rule Id="CA1814" Action="Error" />
<Rule Id="CA1815" Action="Error" />
<Rule Id="CA1816" Action="Error" />
<Rule Id="CA1819" Action="None" />
<Rule Id="CA1820" Action="Error" />
<Rule Id="CA1821" Action="Error" />
<Rule Id="CA1822" Action="Error" />
<Rule Id="CA1823" Action="Error" />
<Rule Id="CA1824" Action="Error" />
<Rule Id="CA1900" Action="Error" />
<Rule Id="CA1901" Action="Error" />
<Rule Id="CA1903" Action="Error" />
<Rule Id="CA2001" Action="Error" />
<Rule Id="CA2002" Action="Error" />
<Rule Id="CA2003" Action="Error" />
<Rule Id="CA2004" Action="Error" />
<Rule Id="CA2006" Action="Error" />
<Rule Id="CA2100" Action="None" />
<Rule Id="CA2101" Action="Error" />
<Rule Id="CA2102" Action="Error" />
<Rule Id="CA2103" Action="Error" />
<Rule Id="CA2104" Action="Error" />
<Rule Id="CA2105" Action="Error" />
<Rule Id="CA2106" Action="Error" />
<Rule Id="CA2107" Action="Error" />
<Rule Id="CA2108" Action="Error" />
<Rule Id="CA2109" Action="Error" />
<Rule Id="CA2111" Action="Error" />
<Rule Id="CA2112" Action="Error" />
<Rule Id="CA2114" Action="Error" />
<Rule Id="CA2115" Action="Error" />
<Rule Id="CA2116" Action="Error" />
<Rule Id="CA2117" Action="Error" />
<Rule Id="CA2118" Action="Error" />
<Rule Id="CA2119" Action="Error" />
<Rule Id="CA2120" Action="Error" />
<Rule Id="CA2121" Action="Error" />
<Rule Id="CA2122" Action="Error" />
<Rule Id="CA2123" Action="Error" />
<Rule Id="CA2124" Action="Error" />
<Rule Id="CA2126" Action="Error" />
<Rule Id="CA2130" Action="Error" />
<Rule Id="CA2131" Action="Error" />
<Rule Id="CA2132" Action="Error" />
<Rule Id="CA2133" Action="Error" />
<Rule Id="CA2134" Action="Error" />
<Rule Id="CA2135" Action="Error" />
<Rule Id="CA2136" Action="Error" />
<Rule Id="CA2137" Action="Error" />
<Rule Id="CA2138" Action="Error" />
<Rule Id="CA2139" Action="Error" />
<Rule Id="CA2140" Action="Error" />
<Rule Id="CA2141" Action="Error" />
<Rule Id="CA2142" Action="Error" />
<Rule Id="CA2143" Action="Error" />
<Rule Id="CA2144" Action="Error" />
<Rule Id="CA2145" Action="Error" />
<Rule Id="CA2146" Action="Error" />
<Rule Id="CA2147" Action="Error" />
<Rule Id="CA2149" Action="Error" />
<Rule Id="CA2200" Action="Error" />
<Rule Id="CA2201" Action="None" />
<Rule Id="CA2202" Action="Error" />
<Rule Id="CA2204" Action="None" />
<Rule Id="CA2205" Action="Error" />
<Rule Id="CA2207" Action="Error" />
<Rule Id="CA2208" Action="Error" />
<Rule Id="CA2210" Action="None" />
<Rule Id="CA2211" Action="Error" />
<Rule Id="CA2212" Action="Error" />
<Rule Id="CA2213" Action="Error" />
<Rule Id="CA2214" Action="None" />
<Rule Id="CA2215" Action="Error" />
<Rule Id="CA2216" Action="Error" />
<Rule Id="CA2217" Action="Error" />
<Rule Id="CA2218" Action="Error" />
<Rule Id="CA2219" Action="Error" />
<Rule Id="CA2220" Action="Error" />
<Rule Id="CA2221" Action="Error" />
<Rule Id="CA2222" Action="Error" />
<Rule Id="CA2223" Action="Error" />
<Rule Id="CA2224" Action="Error" />
<Rule Id="CA2225" Action="Error" />
<Rule Id="CA2226" Action="Error" />
<Rule Id="CA2227" Action="None" />
<Rule Id="CA2228" Action="Error" />
<Rule Id="CA2229" Action="Error" />
<Rule Id="CA2230" Action="Error" />
<Rule Id="CA2231" Action="Error" />
<Rule Id="CA2232" Action="Error" />
<Rule Id="CA2233" Action="None" />
<Rule Id="CA2234" Action="None" />
<Rule Id="CA2235" Action="Error" />
<Rule Id="CA2236" Action="Error" />
<Rule Id="CA2237" Action="Error" />
<Rule Id="CA2238" Action="Error" />
<Rule Id="CA2239" Action="Error" />
<Rule Id="CA2240" Action="Error" />
<Rule Id="CA2241" Action="Error" />
<Rule Id="CA2242" Action="Error" />
<Rule Id="CA2243" Action="None" />
</Rules>
</RuleSet>
4 changes: 2 additions & 2 deletions src/CommonAssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@
[assembly: AssemblyFileVersion("2.13.0805")]
[assembly: AssemblyInformationalVersion("2.13.0805-alpha")]

[assembly: AssemblyMetadata("Branch", "dev")]
[assembly: AssemblyMetadata("CommitId", "077b46fa093ab839d3f92be0863bf6ebc0cba9a3")]
[assembly: AssemblyMetadata("Branch", "anurse/buildfix")]
[assembly: AssemblyMetadata("CommitId", "009470bbd557f044080ecd3375ca831cbda40167")]
4 changes: 2 additions & 2 deletions src/CodeAnalysis.ruleset → src/Frontend.ruleset
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<RuleSet Name="CodeAnalysis" ToolsVersion="12.0">
<RuleSet Name="NuGet Frontend Analysis Rules" ToolsVersion="12.0">
<Include Path="basiccorrectnessrules.ruleset" Action="Default" />
<Include Path="basicdesignguidelinerules.ruleset" Action="Default" />
<Include Path="extendedcorrectnessrules.ruleset" Action="Default" />
Expand Down Expand Up @@ -166,7 +166,7 @@
<Rule Id="CA2200" Action="Error" />
<Rule Id="CA2201" Action="Error" />
<Rule Id="CA2202" Action="Error" />
<Rule Id="CA2204" Action="Error" />
<Rule Id="CA2204" Action="None" />
<Rule Id="CA2205" Action="Error" />
<Rule Id="CA2207" Action="Error" />
<Rule Id="CA2208" Action="Error" />
Expand Down
2 changes: 2 additions & 0 deletions src/NuGetGallery.Backend/DebugHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
using Microsoft.WindowsAzure.StorageClient;
using System;
using System.IO;
using System.Diagnostics.CodeAnalysis;

namespace NuGetGallery.Backend
{
internal static class DebugHelper
{
[SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Justification="Calls to this are added as needed during debugging")]
public static void WriteDebugBlob(string blobName, string message)
{
string destinationAccountName = "";
Expand Down
Binary file added src/NuGetGallery.Backend/GlobalSuppressions.cs
Binary file not shown.
14 changes: 7 additions & 7 deletions src/NuGetGallery.Backend/JobRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
namespace NuGetGallery.Backend
{
[Export]
public class JobRunner
public class JobRunner : IDisposable
{
private AsyncSubject<Unit> _subject = new AsyncSubject<Unit>();
private Logger _logger = LogManager.GetLogger("JobRunner");
Expand Down Expand Up @@ -39,6 +39,12 @@ public JobRunner([Import(AllowDefault = true)] Settings settings, [ImportMany] I
}
}

public void Dispose()
{
_subject.Dispose();
GC.SuppressFinalize(this);
}

public void Stop()
{
_subject.OnCompleted();
Expand Down Expand Up @@ -136,18 +142,12 @@ private void RunJob(string name, WorkerJob job)
{
_logger.Debug("Executing Job '{0}'", name);

DateTime before = DateTime.UtcNow;

try
{
job.RunOnce();

DateTime after = DateTime.UtcNow;
}
catch (Exception ex)
{
DateTime after = DateTime.UtcNow;

_logger.ErrorException(String.Format("Error Executing Job '{0}': {1}", name, ex.Message), ex);
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/NuGetGallery.Backend/NuGetGallery.Backend.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>..\Backend.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
Expand Down Expand Up @@ -109,6 +110,7 @@
<Link>Properties\CommonAssemblyInfo.cs</Link>
</Compile>
<Compile Include="DebugHelper.cs" />
<Compile Include="GlobalSuppressions.cs" />
<Compile Include="JobRunner.cs" />
<Compile Include="Jobs\CleanJobLogsJob.cs" />
<Compile Include="Jobs\BackupPackagesJob.cs" />
Expand Down
2 changes: 1 addition & 1 deletion src/NuGetGallery.Core/NuGetGallery.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<CodeAnalysisRuleSet>..\CodeAnalysis.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRuleSet>..\Frontend.ruleset</CodeAnalysisRuleSet>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
Expand Down
6 changes: 4 additions & 2 deletions src/NuGetGallery.Core/SemanticVersionExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text.RegularExpressions;
using System.Web;
Expand All @@ -25,11 +26,12 @@ public static string Normalize(string version)
public static string ToNormalizedString(this SemanticVersion self)
{
// SemanticVersion normalizes the missing components to 0.
return String.Format("{0}.{1}.{2}{3}{4}",
return String.Format(CultureInfo.InvariantCulture,
"{0}.{1}.{2}{3}{4}",
self.Version.Major,
self.Version.Minor,
self.Version.Build,
self.Version.Revision > 0 ? ("." + self.Version.Revision.ToString()) : String.Empty,
self.Version.Revision > 0 ? ("." + self.Version.Revision.ToString(CultureInfo.InvariantCulture)) : String.Empty,
!String.IsNullOrEmpty(self.SpecialVersion) ? ("-" + self.SpecialVersion) : String.Empty);

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ protected AzureStorageMonitorBase(string accountName, string sharedAccessSignatu
SharedAccessSignature = sharedAccessSignature;
}

private Uri GetFullEndpoint(string accountName, string type, bool useHttps)
private static Uri GetFullEndpoint(string accountName, string type, bool useHttps)
{
return new Uri(String.Format("{0}://{1}.{2}.core.windows.net", useHttps ? "https" : "http", accountName, type));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
<CodeAnalysisRuleSet>..\Backend.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
Expand Down Expand Up @@ -88,12 +89,6 @@
<Compile Include="AzureStorageMonitorBase.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\NuGetGallery.Monitoring\NuGetGallery.Monitoring.csproj">
<Project>{dff0089e-4918-4a12-992b-b9dd2c070b0f}</Project>
<Name>NuGetGallery.Monitoring</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="NuGetGallery.Monitoring.Azure.nuspec" />
Expand Down
Loading

0 comments on commit 74dcbb5

Please sign in to comment.