Upgrade stylecop to 1.2.0-beta.354 (#2602)

This commit is contained in:
Reiley Yang 2021-11-12 11:20:41 -08:00 committed by GitHub
parent 427e50a38a
commit df756ee50d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 37 additions and 41 deletions

View File

@ -40,7 +40,7 @@
<OpenTracingPkgVer>[0.12.1,0.13)</OpenTracingPkgVer>
<OTelPreviousStableVer>1.1.0</OTelPreviousStableVer>
<StackExchangeRedisPkgVer>[2.1.58,3.0)</StackExchangeRedisPkgVer>
<StyleCopAnalyzersPkgVer>[1.1.118,2.0)</StyleCopAnalyzersPkgVer>
<StyleCopAnalyzersPkgVer>[1.2.0-beta.354,2.0)</StyleCopAnalyzersPkgVer>
<SystemCollectionsImmutablePkgVer>1.4.0</SystemCollectionsImmutablePkgVer>
<SystemDiagnosticSourcePkgVer>6.0.0</SystemDiagnosticSourcePkgVer>
<SystemReflectionEmitLightweightPkgVer>4.7.0</SystemReflectionEmitLightweightPkgVer>

View File

@ -5,8 +5,7 @@
<Description Resource="OpenTelemetrySDKRules_Description" />
</Localization>
<Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.Analyzers">
<!-- SA1000 KeywordsMustBeSpacedCorrectly https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3214 -->
<Rule Id="SA1000" Action="None" />
<Rule Id="SA1000" Action="Warning" />
<Rule Id="SA1001" Action="Warning" />
<Rule Id="SA1002" Action="Warning" />
<Rule Id="SA1003" Action="Warning" />
@ -126,7 +125,7 @@
<Rule Id="SA1515" Action="None" />
<Rule Id="SA1516" Action="Warning" />
<Rule Id="SA1517" Action="Warning" />
<Rule Id="SA1518" Action="Warning" />
<Rule Id="SA1518" Action="None" />
<Rule Id="SA1519" Action="Warning" />
<Rule Id="SA1520" Action="Warning" />
<Rule Id="SA1600" Action="None" />

View File

@ -5,11 +5,10 @@
<Description Resource="OpenTelemetrySDKRules_Description" />
</Localization>
<Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.Analyzers">
<!-- SA1000 KeywordsMustBeSpacedCorrectly https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3214 -->
<Rule Id="SA1000" Action="None" />
<Rule Id="SA1200" Action="None" />
<Rule Id="SA1401" Action="None" />
<Rule Id="SA1512" Action="None" />
<Rule Id="SA1518" Action="None" />
<Rule Id="SA1600" Action="None" />
</Rules>
</RuleSet>

View File

@ -6,8 +6,6 @@
</Localization>
<Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.Analyzers">
<Rule Id="SA0001" Action="None" />
<!-- SA1000 KeywordsMustBeSpacedCorrectly https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3214 -->
<Rule Id="SA1000" Action="None" />
<Rule Id="SA1200" Action="None" />
<Rule Id="SA1401" Action="None" />
<Rule Id="SA1512" Action="None" />

View File

@ -99,7 +99,7 @@ namespace Examples.Console
{
"grpc" => OtlpExportProtocol.Grpc,
"http/protobuf" => OtlpExportProtocol.HttpProtobuf,
_ => null
_ => null,
};
}
}

View File

@ -22,12 +22,12 @@ namespace OpenTelemetry.Exporter.Jaeger.Implementation
internal enum JaegerSpanRefType
{
/// <summary>
/// A child span
/// A child span.
/// </summary>
CHILD_OF = 0,
/// <summary>
/// A sibling span
/// A sibling span.
/// </summary>
FOLLOWS_FROM = 1,
}

View File

@ -22,27 +22,27 @@ namespace OpenTelemetry.Exporter.Jaeger.Implementation
internal enum JaegerTagType
{
/// <summary>
/// Tag contains a string
/// Tag contains a string.
/// </summary>
STRING = 0,
/// <summary>
/// Tag contains a double
/// Tag contains a double.
/// </summary>
DOUBLE = 1,
/// <summary>
/// Tag contains a boolean
/// Tag contains a boolean.
/// </summary>
BOOL = 2,
/// <summary>
/// Tag contains a long
/// Tag contains a long.
/// </summary>
LONG = 3,
/// <summary>
/// Tag contains binary data
/// Tag contains binary data.
/// </summary>
BINARY = 4,
}

View File

@ -92,7 +92,7 @@ namespace OpenTelemetry.Exporter
{
OtlpExportProtocol.Grpc => new OtlpGrpcTraceExportClient(options),
OtlpExportProtocol.HttpProtobuf => new OtlpHttpTraceExportClient(options),
_ => throw new NotSupportedException($"Protocol {options.Protocol} is not supported.")
_ => throw new NotSupportedException($"Protocol {options.Protocol} is not supported."),
};
public static OtlpExportProtocol? ToOtlpExportProtocol(this string protocol) =>
@ -100,7 +100,7 @@ namespace OpenTelemetry.Exporter
{
"grpc" => OtlpExportProtocol.Grpc,
"http/protobuf" => OtlpExportProtocol.HttpProtobuf,
_ => null
_ => null,
};
public static Uri AppendPathIfNotPresent(this Uri uri, string path)

View File

@ -143,20 +143,20 @@ namespace OpenTelemetry.Exporter.Prometheus
if (TryGetMetric(ref enumerator, out var state))
{
await WriteMetric(stream, getUtcNowDateTimeOffset, buffer, metricInfo, metricInfo.HistogramSumUtf8, state.keys, state.values, state.sum).ConfigureAwait(false);
await WriteMetric(stream, getUtcNowDateTimeOffset, buffer, metricInfo, metricInfo.HistogramSumUtf8, state.Keys, state.Values, state.Sum).ConfigureAwait(false);
await WriteMetric(stream, getUtcNowDateTimeOffset, buffer, metricInfo, metricInfo.HistogramCountUtf8, state.keys, state.values, state.count).ConfigureAwait(false);
await WriteMetric(stream, getUtcNowDateTimeOffset, buffer, metricInfo, metricInfo.HistogramCountUtf8, state.Keys, state.Values, state.Count).ConfigureAwait(false);
if (state.explicitBounds != null)
if (state.ExplicitBounds != null)
{
long totalCount = 0;
for (int i = 0; i < state.explicitBounds.Length + 1; i++)
for (int i = 0; i < state.ExplicitBounds.Length + 1; i++)
{
totalCount += state.bucketCounts[i];
totalCount += state.BucketCounts[i];
byte[] bucketValueUtf8 = i == state.explicitBounds.Length
byte[] bucketValueUtf8 = i == state.ExplicitBounds.Length
? PrometheusHistogramBucketLabelPositiveInfinityUtf8
: metricInfo.GetBucketUtf8(state.explicitBounds[i]);
: metricInfo.GetBucketUtf8(state.ExplicitBounds[i]);
await WriteMetric(
stream,
@ -164,8 +164,8 @@ namespace OpenTelemetry.Exporter.Prometheus
buffer,
metricInfo,
metricInfo.HistogramBucketUtf8,
state.keys,
state.values,
state.Keys,
state.Values,
totalCount,
additionalKvp: new KeyValuePair<byte[], byte[]>(PrometheusHistogramBucketLabelLessThanUtf8, bucketValueUtf8)).ConfigureAwait(false);
}
@ -174,7 +174,7 @@ namespace OpenTelemetry.Exporter.Prometheus
static bool TryGetMetric(
ref BatchMetricPoint.Enumerator enumerator,
out (string[] keys, object[] values, double sum, long count, double[] explicitBounds, long[] bucketCounts) state)
out (string[] Keys, object[] Values, double Sum, long Count, double[] ExplicitBounds, long[] BucketCounts) state)
{
if (!enumerator.MoveNext())
{

View File

@ -29,12 +29,12 @@ namespace OpenTelemetry.Exporter.Prometheus
{
#if NETCOREAPP3_1_OR_GREATER
private static readonly SpanAction<char, (string, Func<char, bool, bool>)> CreateName
= (Span<char> data, (string name, Func<char, bool, bool> isCharacterAllowedFunc) state) =>
= (Span<char> data, (string Name, Func<char, bool, bool> IsCharacterAllowedFunc) state) =>
{
for (var i = 0; i < state.name.Length; i++)
for (var i = 0; i < state.Name.Length; i++)
{
var c = state.name[i];
data[i] = state.isCharacterAllowedFunc(c, i == 0)
var c = state.Name[i];
data[i] = state.IsCharacterAllowedFunc(c, i == 0)
? c
: '_';
}

View File

@ -13,6 +13,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
// </copyright>
using System.Collections.Generic;
using System.Text.Json;
@ -54,11 +55,11 @@ namespace OpenTelemetry.Exporter.Zipkin.Implementation
return new ZipkinEndpoint(serviceName);
}
public static ZipkinEndpoint Create((string name, int port) serviceNameAndPort)
public static ZipkinEndpoint Create((string Name, int Port) serviceNameAndPort)
{
var serviceName = serviceNameAndPort.port == default
? serviceNameAndPort.name
: $"{serviceNameAndPort.name}:{serviceNameAndPort.port}";
var serviceName = serviceNameAndPort.Port == default
? serviceNameAndPort.Name
: $"{serviceNameAndPort.Name}:{serviceNameAndPort.Port}";
return new ZipkinEndpoint(serviceName);
}

View File

@ -403,7 +403,7 @@ namespace OpenTelemetry.Trace
{
SamplingDecision.RecordAndSample => ActivitySamplingResult.AllDataAndRecorded,
SamplingDecision.RecordOnly => ActivitySamplingResult.AllData,
_ => ActivitySamplingResult.PropagationData
_ => ActivitySamplingResult.PropagationData,
};
if (activitySamplingResult != ActivitySamplingResult.PropagationData)

View File

@ -101,7 +101,8 @@ public partial class Program
output = $"Loops: {cntLoopsNew:n0}, Loops/Second: {nLoopsPerSecond:n0}, CPU Cycles/Loop: {nCpuCyclesPerLoop:n0}";
Console.Title = output;
}
}, () =>
},
() =>
{
Parallel.For(0, concurrency, (i) =>
{

View File

@ -518,9 +518,7 @@ namespace OpenTelemetry.Resources.Tests
var endInd = endIndex == 0 ? keyValuePairs.Length - 1 : endIndex;
for (var i = startIndex; i <= endInd; ++i)
{
Assert.Contains(
new KeyValuePair<string, object>(
$"{KeyName}{i}", $"{ValueName}{i}"), keyValuePairs);
Assert.Contains(new KeyValuePair<string, object>($"{KeyName}{i}", $"{ValueName}{i}"), keyValuePairs);
}
}