Scala

Scala

Made by DeepSource

Consider using .dropRight instead of .substring when the lower-bound is 0 SC-R1027

Anti-pattern
Minor

String.dropRight provides a convenient way to remove an n character suffix from a string. Consider rewriting .substring(0, ub) as .dropRight(n); this is more succinct and clear.

Bad practice

val substr = str.substring(0, n - 3)

Recommended

val substr = str.dropRight(3)