This is an automated email from the ASF dual-hosted git repository. blachniet pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/avro.git
commit ded1087822b590ac5106cf58bef51c8476653743 Author: Brian Lachniet <[email protected]> AuthorDate: Sun Aug 18 11:56:35 2019 -0400 AVRO-2454: Fix SA1119 - StatementMustNotUseUnnecessaryParenthesis --- lang/csharp/Avro.ruleset | 1 - lang/csharp/src/apache/main/File/DataFileReader.cs | 2 +- lang/csharp/src/apache/main/File/DeflateCodec.cs | 2 +- lang/csharp/src/apache/main/File/NullCodec.cs | 2 +- lang/csharp/src/apache/main/Generic/GenericDatumReader.cs | 2 +- lang/csharp/src/apache/main/Generic/GenericDatumWriter.cs | 4 ++-- lang/csharp/src/apache/main/Generic/GenericWriter.cs | 4 ++-- lang/csharp/src/apache/main/Generic/PreresolvingDatumWriter.cs | 2 +- lang/csharp/src/apache/main/IO/BinaryEncoder.cs | 2 +- lang/csharp/src/apache/main/Protocol/Protocol.cs | 6 +++--- lang/csharp/src/apache/main/Schema/Field.cs | 2 +- lang/csharp/src/apache/main/Schema/RecordSchema.cs | 2 +- lang/csharp/src/apache/main/Schema/Schema.cs | 2 +- lang/csharp/src/apache/main/Specific/SpecificDatumReader.cs | 2 +- lang/csharp/src/apache/main/Specific/SpecificDatumWriter.cs | 4 ++-- lang/csharp/src/apache/main/Specific/SpecificWriter.cs | 4 ++-- 16 files changed, 21 insertions(+), 22 deletions(-) diff --git a/lang/csharp/Avro.ruleset b/lang/csharp/Avro.ruleset index 7029d96..329a5fc 100644 --- a/lang/csharp/Avro.ruleset +++ b/lang/csharp/Avro.ruleset @@ -95,7 +95,6 @@ <Rule Id="SA1106" Action="Info" /> <Rule Id="SA1107" Action="Info" /> <Rule Id="SA1108" Action="Info" /> - <Rule Id="SA1119" Action="Info" /> <Rule Id="SA1121" Action="Info" /> <Rule Id="SA1122" Action="Info" /> <Rule Id="SA1128" Action="Info" /> diff --git a/lang/csharp/src/apache/main/File/DataFileReader.cs b/lang/csharp/src/apache/main/File/DataFileReader.cs index 784bf10..d1f8452 100644 --- a/lang/csharp/src/apache/main/File/DataFileReader.cs +++ b/lang/csharp/src/apache/main/File/DataFileReader.cs @@ -239,7 +239,7 @@ namespace Avro.File /// <inheritdoc/> public bool PastSync(long position) { - return ((_blockStart >= position + DataFileConstants.SyncSize) || (_blockStart >= _stream.Length)); + return (_blockStart >= position + DataFileConstants.SyncSize) || (_blockStart >= _stream.Length); } /// <inheritdoc/> diff --git a/lang/csharp/src/apache/main/File/DeflateCodec.cs b/lang/csharp/src/apache/main/File/DeflateCodec.cs index 77f9ee8..7ee1ade 100644 --- a/lang/csharp/src/apache/main/File/DeflateCodec.cs +++ b/lang/csharp/src/apache/main/File/DeflateCodec.cs @@ -76,7 +76,7 @@ namespace Avro.File { if (this == other) return true; - return (this.GetType().Name == other.GetType().Name); + return this.GetType().Name == other.GetType().Name; } /// <inheritdoc/> diff --git a/lang/csharp/src/apache/main/File/NullCodec.cs b/lang/csharp/src/apache/main/File/NullCodec.cs index 873047d..875f679 100644 --- a/lang/csharp/src/apache/main/File/NullCodec.cs +++ b/lang/csharp/src/apache/main/File/NullCodec.cs @@ -52,7 +52,7 @@ namespace Avro.File { if (this == other) return true; - return (this.GetType().Name == other.GetType().Name); + return this.GetType().Name == other.GetType().Name; } /// <inheritdoc/> diff --git a/lang/csharp/src/apache/main/Generic/GenericDatumReader.cs b/lang/csharp/src/apache/main/Generic/GenericDatumReader.cs index 199453a..1edb765 100644 --- a/lang/csharp/src/apache/main/Generic/GenericDatumReader.cs +++ b/lang/csharp/src/apache/main/Generic/GenericDatumReader.cs @@ -210,7 +210,7 @@ namespace Avro.Generic public void AddElements(object mapObj, int elements, ReadItem itemReader, Decoder decoder, bool reuse) { - var map = ((IDictionary<string, object>)mapObj); + var map = (IDictionary<string, object>)mapObj; for (int i = 0; i < elements; i++) { var key = decoder.ReadString(); diff --git a/lang/csharp/src/apache/main/Generic/GenericDatumWriter.cs b/lang/csharp/src/apache/main/Generic/GenericDatumWriter.cs index 94100bf..e7d1138 100644 --- a/lang/csharp/src/apache/main/Generic/GenericDatumWriter.cs +++ b/lang/csharp/src/apache/main/Generic/GenericDatumWriter.cs @@ -49,7 +49,7 @@ namespace Avro.Generic /// <inheritdoc/> protected override void EnsureRecordObject( RecordSchema recordSchema, object value ) { - if( value == null || !( value is GenericRecord ) || !( ( value as GenericRecord ).Schema.Equals( recordSchema ) ) ) + if( value == null || !( value is GenericRecord ) || ! ( value as GenericRecord ).Schema.Equals( recordSchema ) ) { throw TypeMismatch( value, "record", "GenericRecord" ); } @@ -66,7 +66,7 @@ namespace Avro.Generic { return (v,e) => { - if( v == null || !(v is GenericEnum) || !((v as GenericEnum).Schema.Equals(es))) + if( v == null || !(v is GenericEnum) || !(v as GenericEnum).Schema.Equals(es)) throw TypeMismatch(v, "enum", "GenericEnum"); e.WriteEnum(es.Ordinal((v as GenericEnum ).Value)); }; diff --git a/lang/csharp/src/apache/main/Generic/GenericWriter.cs b/lang/csharp/src/apache/main/Generic/GenericWriter.cs index 7a08b68..f2fb24a 100644 --- a/lang/csharp/src/apache/main/Generic/GenericWriter.cs +++ b/lang/csharp/src/apache/main/Generic/GenericWriter.cs @@ -222,7 +222,7 @@ namespace Avro.Generic /// <param name="value">Ensure this object is a record</param> protected virtual void EnsureRecordObject(RecordSchema s, object value) { - if (value == null || !(value is GenericRecord) || !((value as GenericRecord).Schema.Equals(s))) + if (value == null || !(value is GenericRecord) || !(value as GenericRecord).Schema.Equals(s)) { throw TypeMismatch(value, "record", "GenericRecord"); } @@ -251,7 +251,7 @@ namespace Avro.Generic /// <param name="encoder">Encoder for serialization</param> protected virtual void WriteEnum(EnumSchema es, object value, Encoder encoder) { - if (value == null || !(value is GenericEnum) || !((value as GenericEnum).Schema.Equals(es))) + if (value == null || !(value is GenericEnum) || !(value as GenericEnum).Schema.Equals(es)) throw TypeMismatch(value, "enum", "GenericEnum"); encoder.WriteEnum(es.Ordinal((value as GenericEnum).Value)); } diff --git a/lang/csharp/src/apache/main/Generic/PreresolvingDatumWriter.cs b/lang/csharp/src/apache/main/Generic/PreresolvingDatumWriter.cs index 247a9ae..7b52721 100644 --- a/lang/csharp/src/apache/main/Generic/PreresolvingDatumWriter.cs +++ b/lang/csharp/src/apache/main/Generic/PreresolvingDatumWriter.cs @@ -445,7 +445,7 @@ namespace Avro.Generic /// <inheritdoc/> public void WriteMapValues(object map, WriteItem valueWriter, Encoder encoder) { - foreach (DictionaryEntry entry in ((IDictionary)map)) + foreach (DictionaryEntry entry in (IDictionary)map) { encoder.StartItem(); encoder.WriteString(entry.Key.ToString()); diff --git a/lang/csharp/src/apache/main/IO/BinaryEncoder.cs b/lang/csharp/src/apache/main/IO/BinaryEncoder.cs index 5a2b409..f09a7a6 100644 --- a/lang/csharp/src/apache/main/IO/BinaryEncoder.cs +++ b/lang/csharp/src/apache/main/IO/BinaryEncoder.cs @@ -106,7 +106,7 @@ namespace Avro.IO { long bits = BitConverter.DoubleToInt64Bits(value); - writeByte((byte)((bits) & 0xFF)); + writeByte((byte)(bits & 0xFF)); writeByte((byte)((bits >> 8) & 0xFF)); writeByte((byte)((bits >> 16) & 0xFF)); writeByte((byte)((bits >> 24) & 0xFF)); diff --git a/lang/csharp/src/apache/main/Protocol/Protocol.cs b/lang/csharp/src/apache/main/Protocol/Protocol.cs index 94fa51c..51c672c 100644 --- a/lang/csharp/src/apache/main/Protocol/Protocol.cs +++ b/lang/csharp/src/apache/main/Protocol/Protocol.cs @@ -165,9 +165,9 @@ namespace Avro { using (Newtonsoft.Json.JsonTextWriter writer = new Newtonsoft.Json.JsonTextWriter(sw)) { - #if(DEBUG) +#if DEBUG writer.Formatting = Newtonsoft.Json.Formatting.Indented; - #endif +#endif WriteJson(writer, new SchemaNames()); writer.Flush(); @@ -291,7 +291,7 @@ namespace Avro { int hash = Messages.Count; foreach (KeyValuePair<string, Message> pair in Messages) - hash += (pair.Key.GetHashCode() + pair.Value.GetHashCode()); + hash += pair.Key.GetHashCode() + pair.Value.GetHashCode(); return hash; } } diff --git a/lang/csharp/src/apache/main/Schema/Field.cs b/lang/csharp/src/apache/main/Schema/Field.cs index eef8d20..1d5bedb 100644 --- a/lang/csharp/src/apache/main/Schema/Field.cs +++ b/lang/csharp/src/apache/main/Schema/Field.cs @@ -213,7 +213,7 @@ namespace Avro { if (null == this.Props) return null; string v; - return (this.Props.TryGetValue(key, out v)) ? v : null; + return this.Props.TryGetValue(key, out v) ? v : null; } /// <summary> diff --git a/lang/csharp/src/apache/main/Schema/RecordSchema.cs b/lang/csharp/src/apache/main/Schema/RecordSchema.cs index 3c6010b..c485f5d 100644 --- a/lang/csharp/src/apache/main/Schema/RecordSchema.cs +++ b/lang/csharp/src/apache/main/Schema/RecordSchema.cs @@ -180,7 +180,7 @@ namespace Avro { if (string.IsNullOrEmpty(name)) throw new ArgumentNullException("name"); Field field; - return (fieldLookup.TryGetValue(name, out field)) ? field : null; + return fieldLookup.TryGetValue(name, out field) ? field : null; } } diff --git a/lang/csharp/src/apache/main/Schema/Schema.cs b/lang/csharp/src/apache/main/Schema/Schema.cs index db0cb66..fe0729a 100644 --- a/lang/csharp/src/apache/main/Schema/Schema.cs +++ b/lang/csharp/src/apache/main/Schema/Schema.cs @@ -327,7 +327,7 @@ namespace Avro { if (null == this.Props) return null; string v; - return (this.Props.TryGetValue(key, out v)) ? v : null; + return this.Props.TryGetValue(key, out v) ? v : null; } /// <summary> diff --git a/lang/csharp/src/apache/main/Specific/SpecificDatumReader.cs b/lang/csharp/src/apache/main/Specific/SpecificDatumReader.cs index 2b98229..6de1b2e 100644 --- a/lang/csharp/src/apache/main/Specific/SpecificDatumReader.cs +++ b/lang/csharp/src/apache/main/Specific/SpecificDatumReader.cs @@ -227,7 +227,7 @@ namespace Avro.Specific public void AddElements(object mapObj, int elements, ReadItem itemReader, Decoder decoder, bool reuse) { - var map = ((IDictionary)mapObj); + var map = (IDictionary)mapObj; for (int i = 0; i < elements; i++) { var key = decoder.ReadString(); diff --git a/lang/csharp/src/apache/main/Specific/SpecificDatumWriter.cs b/lang/csharp/src/apache/main/Specific/SpecificDatumWriter.cs index f41849a..ebf1121 100644 --- a/lang/csharp/src/apache/main/Specific/SpecificDatumWriter.cs +++ b/lang/csharp/src/apache/main/Specific/SpecificDatumWriter.cs @@ -137,7 +137,7 @@ namespace Avro.Specific case Schema.Type.Error: case Schema.Type.Record: return obj is ISpecificRecord && - (((obj as ISpecificRecord).Schema) as RecordSchema).SchemaName.Equals((sc as RecordSchema).SchemaName); + ((obj as ISpecificRecord).Schema as RecordSchema).SchemaName.Equals((sc as RecordSchema).SchemaName); case Schema.Type.Enumeration: return obj.GetType().IsEnum && (sc as EnumSchema).Symbols.Contains(obj.ToString()); case Schema.Type.Array: @@ -148,7 +148,7 @@ namespace Avro.Specific return false; // Union directly within another union not allowed! case Schema.Type.Fixed: return obj is SpecificFixed && - (((obj as SpecificFixed).Schema) as FixedSchema).SchemaName.Equals((sc as FixedSchema).SchemaName); + ((obj as SpecificFixed).Schema as FixedSchema).SchemaName.Equals((sc as FixedSchema).SchemaName); default: throw new AvroException("Unknown schema type: " + sc.Tag); } diff --git a/lang/csharp/src/apache/main/Specific/SpecificWriter.cs b/lang/csharp/src/apache/main/Specific/SpecificWriter.cs index 50fe46e..89f256b 100644 --- a/lang/csharp/src/apache/main/Specific/SpecificWriter.cs +++ b/lang/csharp/src/apache/main/Specific/SpecificWriter.cs @@ -207,7 +207,7 @@ namespace Avro.Specific case Schema.Type.Error: case Schema.Type.Record: return obj is ISpecificRecord && - (((obj as ISpecificRecord).Schema) as RecordSchema).SchemaName.Equals((sc as RecordSchema).SchemaName); + ((obj as ISpecificRecord).Schema as RecordSchema).SchemaName.Equals((sc as RecordSchema).SchemaName); case Schema.Type.Enumeration: return obj.GetType().IsEnum && (sc as EnumSchema).Symbols.Contains(obj.ToString()); case Schema.Type.Array: @@ -218,7 +218,7 @@ namespace Avro.Specific return false; // Union directly within another union not allowed! case Schema.Type.Fixed: return obj is SpecificFixed && - (((obj as SpecificFixed).Schema) as FixedSchema).SchemaName.Equals((sc as FixedSchema).SchemaName); + ((obj as SpecificFixed).Schema as FixedSchema).SchemaName.Equals((sc as FixedSchema).SchemaName); default: throw new AvroException("Unknown schema type: " + sc.Tag); }
