]> www.infradead.org Git - users/dwmw2/openconnect.git/commitdiff
Squash two identical `if` branches
authorDimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com>
Sun, 26 Sep 2021 13:06:35 +0000 (15:06 +0200)
committerDimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com>
Sat, 26 Feb 2022 15:51:04 +0000 (16:51 +0100)
This fixes a DeepSource alert:

Branches of the `if` statement have similar implementation

For the highlighted `if` statements, all the `elif`/`else` branches have
the same body as `if`. It is recommended to refactor this snippet.

If the if-chain is performing the same action in every case, it shouldn't
be used there at all.

Signed-off-by: Dimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com>
trojans/tncc-emulate.py

index 7a876a42153d6be98bf1a6e6170f8c46690112c3..227be35e0a0b5c857d7ed68499f9ea4605189591 100755 (executable)
@@ -499,10 +499,8 @@ class tncc:
             msg += '\npolicy:%s\nstatus:' % policy
             if 'Unsupported' in policy or 'Deny' in policy:
                 msg += 'NOTOK\nerror:Unknown error'
-            elif 'Required' in policy:
-                msg += 'OK\n'
             else:
-                # Default action
+                # Default action, including 'Required'
                 msg += 'OK\n'
 
         return encode_0ce7(msg.encode(), MSG_POLICY)