diff --git a/zio-http/src/main/scala/zio/http/Method.scala b/zio-http/src/main/scala/zio/http/Method.scala index 232b9c2393..6774ec1e18 100644 --- a/zio-http/src/main/scala/zio/http/Method.scala +++ b/zio-http/src/main/scala/zio/http/Method.scala @@ -36,7 +36,7 @@ sealed trait Method { self => val name: String override def toString: String = - if (name.length == 0) "" else name + if (name.isEmpty) "" else name } object Method { diff --git a/zio-http/src/main/scala/zio/http/Path.scala b/zio-http/src/main/scala/zio/http/Path.scala index a3bc73730f..7c41118256 100644 --- a/zio-http/src/main/scala/zio/http/Path.scala +++ b/zio-http/src/main/scala/zio/http/Path.scala @@ -68,7 +68,7 @@ final case class Path private (flags: Path.Flags, segments: Chunk[String]) { sel */ def addLeadingSlash: Path = if (hasLeadingSlash) self - else if (segments.length == 0) Path(Flags(Flag.LeadingSlash), Chunk.empty) + else if (segments.isEmpty) Path(Flags(Flag.LeadingSlash), Chunk.empty) else Path(Flag.LeadingSlash.add(flags), segments) /** @@ -76,7 +76,7 @@ final case class Path private (flags: Path.Flags, segments: Chunk[String]) { sel */ def addTrailingSlash: Path = if (hasTrailingSlash) self - else if (segments.length == 0) Path(Flags(Flag.TrailingSlash), Chunk.empty) + else if (segments.isEmpty) Path(Flags(Flag.TrailingSlash), Chunk.empty) else Path(Flag.TrailingSlash.add(flags), segments) /** @@ -233,7 +233,7 @@ object Path { * Decodes a path string into a Path. */ def decode(path: String): Path = - if (path.length == 0) Path.empty + if (path.isEmpty) Path.empty else { val chunkBuilder = ChunkBuilder.make[String]() diff --git a/zio-http/src/main/scala/zio/http/codec/internal/EncoderDecoder.scala b/zio-http/src/main/scala/zio/http/codec/internal/EncoderDecoder.scala index 9c4b45aff8..28d4dc2341 100644 --- a/zio-http/src/main/scala/zio/http/codec/internal/EncoderDecoder.scala +++ b/zio-http/src/main/scala/zio/http/codec/internal/EncoderDecoder.scala @@ -278,7 +278,7 @@ private[codec] object EncoderDecoder { else { val segment = segments(j) - if (segment.length != 0) { + if (segment.nonEmpty) { val textCodec = flattened.path(i).erase inputs(i) = textCodec @@ -365,7 +365,7 @@ private[codec] object EncoderDecoder { private def decodeBody(body: Body, inputs: Array[Any])(implicit trace: Trace): Task[Unit] = { if (isByteStream) { ZIO.attempt(inputs(0) = body.asStream.orDie) - } else if (jsonDecoders.length == 0) { + } else if (jsonDecoders.isEmpty) { ZIO.unit } else if (jsonDecoders.length == 1) { jsonDecoders(0)(body).map { result => inputs(0) = result }.mapError { err => @@ -499,7 +499,7 @@ private[codec] object EncoderDecoder { } private def encodeStatus(inputs: Array[Any]): Option[Status] = { - if (flattened.status.length == 0) { + if (flattened.status.isEmpty) { None } else { flattened.status(0) match {