Scala

Scala

Made by DeepSource

Consider using AutoCloseable for closing resources SC-R1052

Anti-pattern
Major

The highlighted close method functionally resembles that of AutoCloseable's. AutoCloseable is an interface that classes can inherit in scenarios where they hold resources that are to be closed. Consider refactoring your code to utilize this interface if possible.

Bad practice

class C {
  def close(): Unit = {
    //
  }
}

Recommended

class C extends AutoCloseable {
  override def close(): Unit = {
    //
  }
}

// Usage
Using(new C()) {c =>
  //
}