Skip to content
This repository was archived by the owner on Dec 18, 2023. It is now read-only.

Commit 39adfd0

Browse files
fix all stelycop warnings except documentation (#40)
* fix all warnings except documentation * fix few more naming issues
1 parent 6fa9ba7 commit 39adfd0

File tree

145 files changed

+1265
-1089
lines changed

Some content is hidden

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

145 files changed

+1265
-1089
lines changed

src/OpenCensus/Api/Stats/IMeasure.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ namespace OpenCensus.Stats
2121

2222
public interface IMeasure
2323
{
24-
T Match<T>(
25-
Func<IMeasureDouble, T> p0,
26-
Func<IMeasureLong, T> p1,
27-
Func<IMeasure, T> defaultFunction);
28-
2924
string Name { get; }
3025

3126
string Description { get; }
3227

3328
string Unit { get; }
29+
30+
T Match<T>(
31+
Func<IMeasureDouble, T> p0,
32+
Func<IMeasureLong, T> p1,
33+
Func<IMeasure, T> defaultFunction);
3434
}
3535
}

src/OpenCensus/Api/Stats/MeasureUnit.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public static class MeasureUnit
2828

2929
public static string Tarabyte { get; } = "terabytes";
3030

31-
private static string Minutes { get; } = "minutes";
31+
public static string Minutes { get; } = "minutes";
3232

3333
public static string Seconds { get; } = "seconds";
3434

src/OpenCensus/Api/Tags/ITagger.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ public interface ITagger
2626

2727
ITagContextBuilder EmptyBuilder { get; }
2828

29-
ITagContextBuilder ToBuilder(ITagContext tags);
30-
3129
ITagContextBuilder CurrentBuilder { get; }
3230

3331
IScope WithTagContext(ITagContext tags);
32+
33+
ITagContextBuilder ToBuilder(ITagContext tags);
3434
}
3535
}

src/OpenCensus/Api/Trace/Export/ISampledSpanStore.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ public interface ISampledSpanStore
2222
{
2323
ISampledSpanStoreSummary Summary { get; }
2424

25+
ISet<string> RegisteredSpanNamesForCollection { get; }
26+
2527
IList<ISpanData> GetLatencySampledSpans(ISampledSpanStoreLatencyFilter filter);
2628

2729
IList<ISpanData> GetErrorSampledSpans(ISampledSpanStoreErrorFilter filter);
@@ -30,8 +32,6 @@ public interface ISampledSpanStore
3032

3133
void UnregisterSpanNamesForCollection(IList<string> spanNames);
3234

33-
ISet<string> RegisteredSpanNamesForCollection { get; }
34-
3535
void ConsiderForSampling(ISpan span);
3636
}
3737
}

src/OpenCensus/Api/Trace/Propagation/ISetter.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616

1717
namespace OpenCensus.Trace.Propagation
1818
{
19-
public interface ISetter<C>
19+
public interface ISetter<T>
2020
{
21-
void Put(C carrier, string key, string value);
21+
void Put(T carrier, string key, string value);
2222
}
2323
}

src/OpenCensus/Api/Trace/Propagation/ITextFormat.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ public interface ITextFormat
2222
{
2323
IList<string> Fields { get; }
2424

25-
void Inject<C>(ISpanContext spanContext, C carrier, ISetter<C> setter);
25+
void Inject<T>(ISpanContext spanContext, T carrier, ISetter<T> setter);
2626

27-
ISpanContext Extract<C>(C carrier, IGetter<C> getter);
27+
ISpanContext Extract<T>(T carrier, IGetter<T> getter);
2828
}
2929
}

src/OpenCensus/Impl/Common/Duration.cs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ namespace OpenCensus.Common
1818
{
1919
public class Duration : IDuration
2020
{
21-
private const long MAX_SECONDS = 315576000000L;
22-
private const int MAX_NANOS = 999999999;
23-
private static readonly IDuration ZERO = new Duration(0, 0);
21+
private const long MaxSeconds = 315576000000L;
22+
private const int MaxNanos = 999999999;
23+
private static readonly IDuration Zero = new Duration(0, 0);
2424

2525
public Duration(long seconds, int nanos)
2626
{
@@ -34,19 +34,19 @@ public Duration(long seconds, int nanos)
3434

3535
public static IDuration Create(long seconds, int nanos)
3636
{
37-
if (seconds < -MAX_SECONDS || seconds > MAX_SECONDS)
37+
if (seconds < -MaxSeconds || seconds > MaxSeconds)
3838
{
39-
return ZERO;
39+
return Zero;
4040
}
4141

42-
if (nanos < -MAX_NANOS || nanos > MAX_NANOS)
42+
if (nanos < -MaxNanos || nanos > MaxNanos)
4343
{
44-
return ZERO;
44+
return Zero;
4545
}
4646

4747
if ((seconds < 0 && nanos > 0) || (seconds > 0 && nanos < 0))
4848
{
49-
return ZERO;
49+
return Zero;
5050
}
5151

5252
return new Duration(seconds, nanos);
@@ -63,6 +63,7 @@ public int CompareTo(IDuration other)
6363
return (this.Nanos < other.Nanos) ? -1 : ((this.Nanos > other.Nanos) ? 1 : 0);
6464
}
6565

66+
/// <inheritdoc/>
6667
public override string ToString()
6768
{
6869
return "Duration{"
@@ -71,6 +72,7 @@ public override string ToString()
7172
+ "}";
7273
}
7374

75+
/// <inheritdoc/>
7476
public override bool Equals(object o)
7577
{
7678
if (o == this)
@@ -87,6 +89,7 @@ public override bool Equals(object o)
8789
return false;
8890
}
8991

92+
/// <inheritdoc/>
9093
public override int GetHashCode()
9194
{
9295
long h = 1;

src/OpenCensus/Impl/Common/Timestamp.cs

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ namespace OpenCensus.Common
2020

2121
public class Timestamp : ITimestamp
2222
{
23-
private const long MAX_SECONDS = 315576000000L;
24-
private const int MAX_NANOS = 999999999;
25-
private const long MILLIS_PER_SECOND = 1000L;
26-
private const long NANOS_PER_MILLI = 1000 * 1000;
27-
private const long NANOS_PER_SECOND = NANOS_PER_MILLI * MILLIS_PER_SECOND;
23+
private const long MaxSeconds = 315576000000L;
24+
private const int MaxNanos = 999999999;
25+
private const long MillisPerSecond = 1000L;
26+
private const long NanosPerMilli = 1000 * 1000;
27+
private const long NanosPerSecond = NanosPerMilli * MillisPerSecond;
2828

2929
internal Timestamp(long seconds, int nanos)
3030
{
@@ -39,12 +39,12 @@ internal Timestamp(long seconds, int nanos)
3939
public static ITimestamp Create(long seconds, int nanos)
4040
{
4141
// TODO:
42-
if (seconds < -MAX_SECONDS || seconds > MAX_SECONDS)
42+
if (seconds < -MaxSeconds || seconds > MaxSeconds)
4343
{
4444
return new Timestamp(0, 0);
4545
}
4646

47-
if (nanos < 0 || nanos > MAX_NANOS)
47+
if (nanos < 0 || nanos > MaxNanos)
4848
{
4949
return new Timestamp(0, 0);
5050
}
@@ -55,7 +55,7 @@ public static ITimestamp Create(long seconds, int nanos)
5555
public static ITimestamp FromMillis(long millis)
5656
{
5757
Timestamp zero = new Timestamp(0, 0);
58-
long nanos = millis * NANOS_PER_MILLI;
58+
long nanos = millis * NanosPerMilli;
5959
return zero.Plus(0, nanos);
6060
}
6161

@@ -76,12 +76,12 @@ public IDuration SubtractTimestamp(ITimestamp timestamp)
7676
if (durationSeconds < 0 && durationNanos > 0)
7777
{
7878
durationSeconds += 1;
79-
durationNanos = (int)(durationNanos - NANOS_PER_SECOND);
79+
durationNanos = (int)(durationNanos - NanosPerSecond);
8080
}
8181
else if (durationSeconds > 0 && durationNanos < 0)
8282
{
8383
durationSeconds -= 1;
84-
durationNanos = (int)(durationNanos + NANOS_PER_SECOND);
84+
durationNanos = (int)(durationNanos + NanosPerSecond);
8585
}
8686

8787
return Duration.Create(durationSeconds, durationNanos);
@@ -98,6 +98,7 @@ public int CompareTo(ITimestamp other)
9898
return (this.Nanos < other.Nanos) ? -1 : ((this.Nanos > other.Nanos) ? 1 : 0);
9999
}
100100

101+
/// <inheritdoc/>
101102
public override string ToString()
102103
{
103104
return "Timestamp{"
@@ -106,6 +107,7 @@ public override string ToString()
106107
+ "}";
107108
}
108109

110+
/// <inheritdoc/>
109111
public override bool Equals(object o)
110112
{
111113
if (o == this)
@@ -122,6 +124,7 @@ public override bool Equals(object o)
122124
return false;
123125
}
124126

127+
/// <inheritdoc/>
125128
public override int GetHashCode()
126129
{
127130
long h = 1;
@@ -134,9 +137,9 @@ public override int GetHashCode()
134137

135138
private static ITimestamp OfSecond(long seconds, long nanoAdjustment)
136139
{
137-
long floor = (long)Math.Floor((double)nanoAdjustment / NANOS_PER_SECOND);
140+
long floor = (long)Math.Floor((double)nanoAdjustment / NanosPerSecond);
138141
long secs = seconds + floor;
139-
long nos = nanoAdjustment - (floor * NANOS_PER_SECOND);
142+
long nos = nanoAdjustment - (floor * NanosPerSecond);
140143
return Create(secs, (int)nos);
141144
}
142145

@@ -148,7 +151,7 @@ private ITimestamp Plus(long secondsToAdd, long nanosToAdd)
148151
}
149152

150153
long sec = this.Seconds + secondsToAdd;
151-
long nanoSeconds = Math.DivRem(nanosToAdd, NANOS_PER_SECOND, out long nanosSpill);
154+
long nanoSeconds = Math.DivRem(nanosToAdd, NanosPerSecond, out long nanosSpill);
152155
sec = sec + nanoSeconds;
153156
long nanoAdjustment = this.Nanos + nanosSpill;
154157
return OfSecond(sec, nanoAdjustment);

src/OpenCensus/Impl/Internal/VarInt.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ namespace OpenCensus.Internal
2222
public static class VarInt
2323
{
2424
/** Maximum encoded size of 32-bit positive integers (in bytes) */
25-
public const int MAX_VARINT_SIZE = 5;
25+
public const int MaxVarintSize = 5;
2626

2727
/** maximum encoded size of 64-bit longs, and negative 32-bit ints (in bytes) */
28-
public const int MAX_VARLONG_SIZE = 10;
28+
public const int MaxVarlongSize = 10;
2929

3030
public static int VarIntSize(int i)
3131
{

src/OpenCensus/Impl/Stats/Aggregation.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@ namespace OpenCensus.Stats
2121

2222
public abstract class Aggregation : IAggregation
2323
{
24-
public abstract M Match<M>(Func<ISum, M> p0, Func<ICount, M> p1, Func<IMean, M> p2, Func<IDistribution, M> p3, Func<ILastValue, M> p4, Func<IAggregation, M> p5);
24+
public abstract T Match<T>(Func<ISum, T> p0, Func<ICount, T> p1, Func<IMean, T> p2, Func<IDistribution, T> p3, Func<ILastValue, T> p4, Func<IAggregation, T> p5);
2525
}
2626
}

0 commit comments

Comments
 (0)