Skip to content

Commit

Permalink
Update NuGet packages
Browse files Browse the repository at this point in the history
Update NuGet packages to their latest versions.
Fix (or suppress) code analysis warnings.
  • Loading branch information
martincostello committed Aug 24, 2019
1 parent d4b1fe8 commit efadb12
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 54 deletions.
7 changes: 4 additions & 3 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
<Project>
<Import Project="version.props" />
<PropertyGroup>
<AnalyzersVersion>2.9.2</AnalyzersVersion>
<AnalyzersVersion>2.9.4</AnalyzersVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0-beta2-19270-01" PrivateAssets="All" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0-beta2-19367-01" PrivateAssets="All" />
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="$(AnalyzersVersion)" PrivateAssets="All" />
<PackageReference Include="Microsoft.CodeQuality.Analyzers" Version="$(AnalyzersVersion)" PrivateAssets="All" />
<PackageReference Include="Microsoft.NetCore.Analyzers" Version="$(AnalyzersVersion)" PrivateAssets="All" />
<PackageReference Include="OpenCover" Version="4.7.922" PrivateAssets="All" />
<PackageReference Include="ReportGenerator" Version="4.1.9" PrivateAssets="All" />
<PackageReference Include="ReportGenerator" Version="4.2.15" PrivateAssets="All" />
</ItemGroup>
<PropertyGroup>
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
<AssemblyOriginatorKeyFile>$(MSBuildThisFileDirectory)justeat-oss.snk</AssemblyOriginatorKeyFile>
<Authors>JUSTEAT_OSS</Authors>
<CodeAnalysisRuleSet>$(MSBuildThisFileDirectory)JustEat.StatsD.ruleset</CodeAnalysisRuleSet>
<Company>Just Eat</Company>
<Copyright>Copyright (c) Just Eat 2015-$([System.DateTime]::Now.ToString(yyyy))</Copyright>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
Expand Down
8 changes: 8 additions & 0 deletions JustEat.StatsD.ruleset
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<RuleSet Name="JustEat.StatsD Rules" Description="This rule set contains rules for the Just Eat JustEat.StatsD solution." ToolsVersion="16.0">
<IncludeAll Action="Warning" />
<Rules AnalyzerId="Microsoft.Analyzers.ManagedCodeAnalysis" RuleNamespace="Microsoft.Rules.Managed">
<Rule Id="CA1062" Action="None" />
<Rule Id="CA1303" Action="None" />
</Rules>
</RuleSet>
12 changes: 7 additions & 5 deletions JustEat.StatsD.sln
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27130.2036

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29215.179
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Assets", "Assets", "{06BE4D4A-B0DF-465D-9BAC-6CC3C9779A37}"
ProjectSection(SolutionItems) = preProject
Expand All @@ -13,12 +14,13 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Assets", "Assets", "{06BE4D
build.sh = build.sh
CHANGELOG.md = CHANGELOG.md
Directory.Build.props = Directory.Build.props
Directory.Build.targets = Directory.Build.targets
global.json = global.json
JustEat.StatsD.ruleset = JustEat.StatsD.ruleset
LICENSE = LICENSE
README.md = README.md
version.props = version.props
Directory.Build.targets = Directory.Build.targets
ReferenceAssemblies.props = ReferenceAssemblies.props
version.props = version.props
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JustEat.StatsD", "src\JustEat.StatsD\JustEat.StatsD.csproj", "{6A338D71-E28B-455A-9E9D-3667EE659542}"
Expand Down
3 changes: 3 additions & 0 deletions src/JustEat.StatsD/SocketTransport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ public void Send(in ArraySegment<byte> metric)
return;
}

#pragma warning disable CA2000
var pool = GetPool(endpoint);
#pragma warning restore CA2000

var socket = pool.PopOrCreate();

try
Expand Down
4 changes: 2 additions & 2 deletions tests/JustEat.StatsD.Tests/JustEat.StatsD.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="2.2.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.1.1" />
<PackageReference Include="Moq" Version="4.11.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
<PackageReference Include="Moq" Version="4.12.0" />
<PackageReference Include="Shouldly" Version="3.0.2" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1" />
Expand Down
6 changes: 4 additions & 2 deletions tests/JustEat.StatsD.Tests/SocketTransportTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ public static void ValidSocketTransportCanBeConstructed()
public static void SocketTransportCanSendOverUdpWithoutError()
{
// using block not used here so the finalizer gets some code coverage
var transport = new SocketTransport(LocalStatsEndpoint(), SocketProtocol.Udp);
transport.Send("teststat:1|c");
using (var transport = new SocketTransport(LocalStatsEndpoint(), SocketProtocol.Udp))
{
transport.Send("teststat:1|c");
}
}

[Fact]
Expand Down
88 changes: 46 additions & 42 deletions tests/JustEat.StatsD.Tests/StatsDPublisherTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,17 @@ public static void Decrement_Sends_Multiple_Metrics()
Prefix = "red",
};

var publisher = new StatsDPublisher(config, mock.Object);

// Act
publisher.Decrement(10, "black");
publisher.Decrement(-10, "yellow");
publisher.Decrement(10, 1, "pink");
publisher.Decrement(-10, 1, "orange");
publisher.Decrement(10, 1, new[] { "white", "blue" });
publisher.Decrement(10, 1, new List<string>() { "green", "red" });
publisher.Decrement(10, 1, null as IEnumerable<string>);
using (var publisher = new StatsDPublisher(config, mock.Object))
{
// Act
publisher.Decrement(10, "black");
publisher.Decrement(-10, "yellow");
publisher.Decrement(10, 1, "pink");
publisher.Decrement(-10, 1, "orange");
publisher.Decrement(10, 1, new[] { "white", "blue" });
publisher.Decrement(10, 1, new List<string>() { "green", "red" });
publisher.Decrement(10, 1, null as IEnumerable<string>);
}

// Assert
mock.Verify((p) => p.Send(It.Ref<ArraySegment<byte>>.IsAny), Times.Exactly(8));
Expand All @@ -44,16 +45,17 @@ public static void Increment_Sends_Multiple_Metrics()
Prefix = "red",
};

var publisher = new StatsDPublisher(config, mock.Object);

// Act
publisher.Increment(10, "black");
publisher.Increment(-10, "yellow");
publisher.Increment(10, 1, "pink");
publisher.Increment(-10, 1, "orange");
publisher.Increment(10, 1, new[] { "white", "blue" });
publisher.Increment(10, 1, new List<string>() { "green", "red" });
publisher.Increment(10, 1, null as IEnumerable<string>);
using (var publisher = new StatsDPublisher(config, mock.Object))
{
// Act
publisher.Increment(10, "black");
publisher.Increment(-10, "yellow");
publisher.Increment(10, 1, "pink");
publisher.Increment(-10, 1, "orange");
publisher.Increment(10, 1, new[] { "white", "blue" });
publisher.Increment(10, 1, new List<string>() { "green", "red" });
publisher.Increment(10, 1, null as IEnumerable<string>);
}

// Assert
mock.Verify((p) => p.Send(It.Ref<ArraySegment<byte>>.IsAny), Times.Exactly(8));
Expand All @@ -66,23 +68,24 @@ public static void Metrics_Not_Sent_If_Array_Is_Null_Or_Empty()
var mock = new Mock<IStatsDTransport>();
var config = new StatsDConfiguration();

var publisher = new StatsDPublisher(config, mock.Object);

// Act
publisher.Decrement(-1, 1, null as string[]);
publisher.Increment(-1, 1, null as string[]);
publisher.Decrement(1, 1, null as string[]);
publisher.Increment(1, 1, null as string[]);
publisher.Decrement(1, 1, Array.Empty<string>());
publisher.Increment(1, 1, Array.Empty<string>());
publisher.Decrement(-1, 1, Array.Empty<string>());
publisher.Increment(-1, 1, Array.Empty<string>());
publisher.Decrement(-1, 1, new List<string>());
publisher.Increment(-1, 1, new List<string>());
publisher.Decrement(1, 1, null as IEnumerable<string>);
publisher.Increment(1, 1, null as IEnumerable<string>);
publisher.Decrement(1, 1, new[] { string.Empty });
publisher.Increment(1, 1, new[] { string.Empty });
using (var publisher = new StatsDPublisher(config, mock.Object))
{
// Act
publisher.Decrement(-1, 1, null as string[]);
publisher.Increment(-1, 1, null as string[]);
publisher.Decrement(1, 1, null as string[]);
publisher.Increment(1, 1, null as string[]);
publisher.Decrement(1, 1, Array.Empty<string>());
publisher.Increment(1, 1, Array.Empty<string>());
publisher.Decrement(-1, 1, Array.Empty<string>());
publisher.Increment(-1, 1, Array.Empty<string>());
publisher.Decrement(-1, 1, new List<string>());
publisher.Increment(-1, 1, new List<string>());
publisher.Decrement(1, 1, null as IEnumerable<string>);
publisher.Increment(1, 1, null as IEnumerable<string>);
publisher.Decrement(1, 1, new[] { string.Empty });
publisher.Increment(1, 1, new[] { string.Empty });
}

// Assert
mock.Verify((p) => p.Send(It.IsAny<ArraySegment<byte>>()), Times.Never());
Expand All @@ -95,11 +98,12 @@ public static void Metrics_Not_Sent_If_No_Metrics()
var mock = new Mock<IStatsDTransport>();
var config = new StatsDConfiguration();

var publisher = new StatsDPublisher(config, mock.Object);

// Act
publisher.Decrement(1, 0, new[] { "foo" });
publisher.Increment(1, 0, new[] { "bar" });
using (var publisher = new StatsDPublisher(config, mock.Object))
{
// Act
publisher.Decrement(1, 0, new[] { "foo" });
publisher.Increment(1, 0, new[] { "bar" });
}

// Assert
mock.Verify((p) => p.Send(It.IsAny<ArraySegment<byte>>()), Times.Never());
Expand Down

0 comments on commit efadb12

Please sign in to comment.