From e368a8b16aff5a1fdb11d08a6a3f00d228fd634d Mon Sep 17 00:00:00 2001 From: Paul Schaub Date: Sun, 15 Aug 2021 15:44:28 +0200 Subject: [PATCH] Reduce complexity of statements --- .../pgpainless/key/parsing/KeyRingReader.java | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/pgpainless-core/src/main/java/org/pgpainless/key/parsing/KeyRingReader.java b/pgpainless-core/src/main/java/org/pgpainless/key/parsing/KeyRingReader.java index c13ee9cb..4e283d73 100644 --- a/pgpainless-core/src/main/java/org/pgpainless/key/parsing/KeyRingReader.java +++ b/pgpainless-core/src/main/java/org/pgpainless/key/parsing/KeyRingReader.java @@ -111,7 +111,7 @@ public class KeyRingReader { do { next = objectFactory.nextObject(); if (next == null) { - break; + return null; } if (next instanceof PGPMarker) { continue; @@ -120,8 +120,6 @@ public class KeyRingReader { return (PGPPublicKeyRing) next; } } while (true); - - return null; } public static PGPPublicKeyRingCollection readPublicKeyRingCollection(@Nonnull InputStream inputStream) @@ -136,7 +134,7 @@ public class KeyRingReader { do { next = objectFactory.nextObject(); if (next == null) { - break; + return new PGPPublicKeyRingCollection(rings); } if (next instanceof PGPMarker) { continue; @@ -152,8 +150,6 @@ public class KeyRingReader { } } } while (true); - - return new PGPPublicKeyRingCollection(rings); } public static PGPSecretKeyRing readSecretKeyRing(@Nonnull InputStream inputStream) throws IOException { @@ -166,7 +162,7 @@ public class KeyRingReader { do { next = objectFactory.nextObject(); if (next == null) { - break; + return null; } if (next instanceof PGPMarker) { continue; @@ -176,8 +172,6 @@ public class KeyRingReader { return (PGPSecretKeyRing) next; } } while (true); - - return null; } public static PGPSecretKeyRingCollection readSecretKeyRingCollection(@Nonnull InputStream inputStream) @@ -192,7 +186,7 @@ public class KeyRingReader { do { next = objectFactory.nextObject(); if (next == null) { - break; + return new PGPSecretKeyRingCollection(rings); } if (next instanceof PGPMarker) { continue; @@ -208,8 +202,6 @@ public class KeyRingReader { } } } while (true); - - return new PGPSecretKeyRingCollection(rings); } public static PGPKeyRingCollection readKeyRingCollection(@Nonnull InputStream inputStream, boolean isSilent)