From a9bdcc4f0fdd4b85c72c15c9e8925c16e14acba4 Mon Sep 17 00:00:00 2001 From: Dale Wijnand Date: Wed, 31 Jan 2018 10:20:33 +0000 Subject: [PATCH] Fix Codacy issue in ServerSpec --- sbt/src/test/scala/sbt/ServerSpec.scala | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/sbt/src/test/scala/sbt/ServerSpec.scala b/sbt/src/test/scala/sbt/ServerSpec.scala index 648d88203..9adeabcc8 100644 --- a/sbt/src/test/scala/sbt/ServerSpec.scala +++ b/sbt/src/test/scala/sbt/ServerSpec.scala @@ -108,9 +108,8 @@ object ServerSpec { val chunk0 = buffer.take(delimPos) buffer = buffer.drop(delimPos + 1) // remove \r at the end of line. - if (chunk0.size > 0 && chunk0.indexOf(RetByte) == chunk0.size - 1) - Some(new String(chunk0.dropRight(1).toArray, "utf-8")) - else Some(new String(chunk0.toArray, "utf-8")) + val chunk1 = if (chunk0.isEmpty || chunk0.last != RetByte) chunk0 else chunk0.dropRight(1) + Some(new String(chunk1.toArray, "utf-8")) } else None // no EOL yet, so skip this turn. }