Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
Message: use Seq, not List (allows varargs)
Browse files Browse the repository at this point in the history
  • Loading branch information
Albert Meltzer committed Jul 15, 2021
1 parent d2931f3 commit d3b0a76
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
19 changes: 7 additions & 12 deletions src/main/scala/org/scalastyle/Message.scala
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class MessageHelper(config: Config) {
def label(key: String): String = getMessage(key + ".label", List())
def description(key: String): String = getMessage(key + ".description", List())

private[this] def getMessage(key: String, args: List[String]) = {
private[this] def getMessage(key: String, args: Seq[String]) = {
try {
val pattern = config.getString(key)
MessageFormat.format(pattern, args.map(_.asInstanceOf[AnyRef]): _*)
Expand All @@ -47,7 +47,7 @@ class MessageHelper(config: Config) {
}
}

def message(key: String, args: List[String]): String =
def message(key: String, args: Seq[String]): String =
// Use ClassLoader of the class from which the message came
getMessage(key + ".message", args)
}
Expand All @@ -65,7 +65,7 @@ case class StyleError[+T <: FileSpec](
clazz: Class[_ <: Checker[_]],
key: String,
level: Level,
args: List[String],
args: Seq[String],
lineNumber: Option[Int] = None,
column: Option[Int] = None,
customMessage: Option[String] = None
Expand All @@ -84,15 +84,10 @@ case class StyleException[+T <: FileSpec](
) extends Message[T]

sealed abstract class ScalastyleError
case class PositionError(position: Int, args: List[String] = List[String](), errorKey: Option[String] = None)
case class PositionError(position: Int, args: Seq[String] = Nil, errorKey: Option[String] = None)
extends ScalastyleError
case class FileError(args: List[String] = List[String](), errorKey: Option[String] = None)
case class FileError(args: Seq[String] = Nil, errorKey: Option[String] = None) extends ScalastyleError
case class LineError(line: Int, args: Seq[String] = Nil, errorKey: Option[String] = None)
extends ScalastyleError
case class LineError(line: Int, args: List[String] = List[String](), errorKey: Option[String] = None)
case class ColumnError(line: Int, column: Int, args: Seq[String] = Nil, errorKey: Option[String] = None)
extends ScalastyleError
case class ColumnError(
line: Int,
column: Int,
args: List[String] = List[String](),
errorKey: Option[String] = None
) extends ScalastyleError
2 changes: 1 addition & 1 deletion src/main/scala/org/scalastyle/Output.scala
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ object Output {
def findMessage(
messageHelper: MessageHelper,
key: String,
args: List[String],
args: Seq[String],
customMessage: Option[String]
): String = {
customMessage match {
Expand Down

0 comments on commit d3b0a76

Please sign in to comment.