You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@avro.apache.org by GitBox <gi...@apache.org> on 2022/04/20 13:51:56 UTC

[GitHub] [avro] zcsizmadia commented on a diff in pull request #1653: AVRO-3497 Simplify conditional expression

zcsizmadia commented on code in PR #1653:
URL: https://github.com/apache/avro/pull/1653#discussion_r854160044


##########
lang/csharp/src/apache/main/Generic/GenericEnum.cs:
##########
@@ -70,10 +70,12 @@ public GenericEnum(EnumSchema schema, string value)
         /// <inheritdoc/>
         public override bool Equals(object obj)
         {
-            if (obj == this) return true;
-            return (obj != null && obj is GenericEnum)
-                ? Value.Equals((obj as GenericEnum).Value, System.StringComparison.Ordinal)
-                : false;
+            if (obj == this)
+            {
+                return true;
+            }
+
+            return obj != null && obj is GenericEnum && Value.Equals((obj as GenericEnum).Value, System.StringComparison.Ordinal);

Review Comment:
   This might be more readable:
   
   ```
       if (obj is GenericEnum ge)
       {
           return Value.Equals(ge.Value, System.StringComparison.Ordinal);
       }
   
       return false;
   ```



##########
lang/csharp/src/apache/main/Generic/GenericEnum.cs:
##########
@@ -70,10 +70,12 @@ public GenericEnum(EnumSchema schema, string value)
         /// <inheritdoc/>
         public override bool Equals(object obj)
         {
-            if (obj == this) return true;
-            return (obj != null && obj is GenericEnum)
-                ? Value.Equals((obj as GenericEnum).Value, System.StringComparison.Ordinal)
-                : false;
+            if (obj == this)
+            {
+                return true;
+            }
+
+            return obj != null && obj is GenericEnum && Value.Equals((obj as GenericEnum).Value, System.StringComparison.Ordinal);
         }

Review Comment:
   Are the CodeQL warnings any concern?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@avro.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org