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

Commit 150edba

Browse files
authored
Fix scalafmt errors (#200)
1 parent aee0558 commit 150edba

File tree

11 files changed

+82
-71
lines changed

11 files changed

+82
-71
lines changed

.scalafmt.conf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ align {
55
ifWhileOpenParen = false
66
openParenCallSite = false
77
openParenDefnSite = false
8-
tokens.add = [
8+
tokens."+" = [
99
"%",
1010
"%%",
1111
"<-",
@@ -16,7 +16,7 @@ align {
1616
assumeStandardLibraryStripMargin = true
1717
continuationIndent.defnSite = 2
1818
continuationIndent.callSite = 2
19-
docstrings = JavaDoc
19+
docstrings.style = Asterisk
2020
maxColumn = 110
2121
newlines.implicitParamListModifierPrefer = before
2222
project {

src/main/scala/org/scalastyle/Checker.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,8 @@ class CheckerUtils(classLoader: Option[ClassLoader] = None) {
147147
c match {
148148
case c: FileChecker => c.verify(file, c.level, lines, lines)
149149
case c: ScalariformChecker => c.verify(file, c.level, scalariformAst.ast, lines)
150-
case c: CombinedChecker => c.verify(file, c.level, CombinedAst(scalariformAst.ast, lines), lines)
151-
case _ => Nil
150+
case c: CombinedChecker => c.verify(file, c.level, CombinedAst(scalariformAst.ast, lines), lines)
151+
case _ => Nil
152152
}
153153
)
154154
.filter(m => CommentFilter.filterApplies(m, commentFilters))
@@ -180,8 +180,8 @@ class CheckerUtils(classLoader: Option[ClassLoader] = None) {
180180
}
181181

182182
/**
183-
* if we pass an encoding in, then we only try that encoding.
184-
* If there is no encoding passed, we try the default, then UTF-8, then UTF-16, then ISO-8859-1
183+
* if we pass an encoding in, then we only try that encoding. If there is no encoding passed, we try the
184+
* default, then UTF-8, then UTF-16, then ISO-8859-1
185185
*/
186186
def readFile(file: String, encoding: Option[String])(implicit codec: Codec): String = {
187187
@tailrec

src/main/scala/org/scalastyle/scalariform/CaseBraceChecker.scala

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,10 @@ class CaseBraceChecker extends CombinedChecker {
3333

3434
/**
3535
* Checks, if given case clause contains just block expression, without anything else.
36-
* @param clause case clause to check
37-
* @return position of block's left brace, if block found; None otherwise.
36+
* @param clause
37+
* case clause to check
38+
* @return
39+
* position of block's left brace, if block found; None otherwise.
3840
*/
3941
private def justBlockPosition(clause: CaseClause) = {
4042
import clause.statSeq._

src/main/scala/org/scalastyle/scalariform/ClassNamesChecker.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ class PackageNamesChecker extends ScalariformChecker {
9191
tokens match {
9292
case Nil => (Nil, Nil)
9393
case hd :: tail if hd.tokenType == PACKAGE => tail.span(isPartOfPackageName)
94-
case l: Any => getNextPackageName(l.dropWhile(tok => tok.tokenType != PACKAGE))
94+
case l: Any => getNextPackageName(l.dropWhile(tok => tok.tokenType != PACKAGE))
9595
}
9696

9797
@annotation.tailrec

src/main/scala/org/scalastyle/scalariform/ImportsChecker.scala

Lines changed: 30 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -157,30 +157,27 @@ class ImportGroupingChecker extends ScalariformChecker {
157157
}
158158

159159
/**
160-
* Style checker that enforces import ordering. The following configuration parameters are
161-
* available:
160+
* Style checker that enforces import ordering. The following configuration parameters are available:
162161
*
163-
* - groups: a comma-separated list of group names to consider.
164-
* - maxBlankLines: maximum number of blank lines to allow between groups. The default is "1".
165-
* A value less than 1 disables the blank line limit.
166-
* - group.[groupName]: a regular expression that matches imports that should be in the given
167-
* group.
168-
* - lexicographic: if true, imports are ordered lexicographically (classes, wildcards, then
169-
* packages; case-sensitive ordering within); if false, apply the original
170-
* case-insensitive ordering (with wildcards coming first, before classes).
162+
* - groups: a comma-separated list of group names to consider.
163+
* - maxBlankLines: maximum number of blank lines to allow between groups. The default is "1". A value less
164+
* than 1 disables the blank line limit.
165+
* - group.[groupName]: a regular expression that matches imports that should be in the given group.
166+
* - lexicographic: if true, imports are ordered lexicographically (classes, wildcards, then packages;
167+
* case-sensitive ordering within); if false, apply the original case-insensitive ordering (with wildcards
168+
* coming first, before classes).
171169
*
172-
* For example, to check that "java" and "javax" imports are in a separate group at the top of the
173-
* import list, you'd use this config:
170+
* For example, to check that "java" and "javax" imports are in a separate group at the top of the import
171+
* list, you'd use this config:
174172
*
175-
* <parameter name="groups">java,others</parameter>
176-
* <parameter name="group.java">javax?\..+</parameter>
177-
* <parameter name="group.other">.+</parameter>
173+
* <parameter name="groups">java,others</parameter> <parameter name="group.java">javax?\..+</parameter>
174+
* <parameter name="group.other">.+</parameter>
178175
*
179176
* Other non-configurable rules:
180-
* - Within each group, import clauses are ordered alphabetically if 'lexicographic' is
181-
* specified; else puts wildcards, then classes and packages, with case-insensitive sort.
182-
* - In multi-import statements, entries are ordered alphabetically, with method / packages
183-
* (assumed to be any string starting with a lower case letter) coming before classes.
177+
* - Within each group, import clauses are ordered alphabetically if 'lexicographic' is specified; else puts
178+
* wildcards, then classes and packages, with case-insensitive sort.
179+
* - In multi-import statements, entries are ordered alphabetically, with method / packages (assumed to be
180+
* any string starting with a lower case letter) coming before classes.
184181
*
185182
* Currently, this checker only looks at the top-level list of imports.
186183
*/
@@ -201,7 +198,7 @@ class ImportOrderChecker extends ScalariformChecker {
201198
// Note that any exceptions thrown here are swallowed by CheckerUtils and ignored...
202199
require(parameters.contains("groups"))
203200
groups = parameters("groups").split(",").toSeq.map { name =>
204-
name -> Pattern.compile(parameters(s"group.${name}"))
201+
name -> Pattern.compile(parameters(s"group.$name"))
205202
}
206203
maxBlankLines = parameters.getOrElse("maxBlankLines", "1").toInt
207204
lexicographic = parameters.get("lexicographic").map(_.toBoolean).getOrElse(false)
@@ -295,8 +292,8 @@ class ImportOrderChecker extends ScalariformChecker {
295292
}
296293

297294
/**
298-
* When the current import group changes, checks that there is a single empty line between
299-
* the last import statement in the previous group and the first statement in the new one.
295+
* When the current import group changes, checks that there is a single empty line between the last import
296+
* statement in the previous group and the first statement in the new one.
300297
*/
301298
private def checkGroupSeparation(
302299
lastGroup: Int,
@@ -360,8 +357,7 @@ class ImportOrderChecker extends ScalariformChecker {
360357
/**
361358
* Compares two import statements, comparing each component of the import separately.
362359
*
363-
* The import statements can end with a dangling `.`, meaning they're the start of a
364-
* multi-import block.
360+
* The import statements can end with a dangling `.`, meaning they're the start of a multi-import block.
365361
*/
366362
private[scalariform] def compareImports(imp1: String, imp2: String): Int = {
367363
val imp1Components = imp1.split("[.]")
@@ -388,15 +384,17 @@ class ImportOrderChecker extends ScalariformChecker {
388384
}
389385

390386
/**
391-
* Compares two strings that represent a single imported artifact; this considers lower-case
392-
* names as being "lower" than upper case ones.
387+
* Compares two strings that represent a single imported artifact; this considers lower-case names as being
388+
* "lower" than upper case ones.
393389
*
394-
* @param name1 First name.
395-
* @param name2 Second name.
396-
* @param isImport If true, orders names according to the import statement rules:
397-
* "_" should come before other names, and capital letters should come
398-
* before lower case ones. Otherwise, do the opposite, which are the ordering
399-
* rules for names within a selector.
390+
* @param name1
391+
* First name.
392+
* @param name2
393+
* Second name.
394+
* @param isImport
395+
* If true, orders names according to the import statement rules: "_" should come before other names, and
396+
* capital letters should come before lower case ones. Otherwise, do the opposite, which are the ordering
397+
* rules for names within a selector.
400398
*/
401399
private[scalariform] def compareNames(name1: String, name2: String, isImport: Boolean): Int = {
402400
if (lexicographic && isImport)

src/main/scala/org/scalastyle/scalariform/ScalaDocChecker.scala

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,13 @@ import org.scalastyle.scalariform.VisitorHelper.visit
4242

4343
/**
4444
* Checks that the ScalaDoc exists for all accessible members:
45-
* - classes, traits, case classes and objects
46-
* - methods
47-
* - vals, vars and types
45+
* - classes, traits, case classes and objects
46+
* - methods
47+
* - vals, vars and types
4848
*
49-
* The ScalaDoc's structure must satisfy the parameter of the constructor in case of
50-
* case classes and classes, or the parameter of the methods. The ScalaDoc must include
51-
* the type parameters. Finally, the ScalaDoc must include return description for non-Unit
52-
* returning methods.
49+
* The ScalaDoc's structure must satisfy the parameter of the constructor in case of case classes and classes,
50+
* or the parameter of the methods. The ScalaDoc must include the type parameters. Finally, the ScalaDoc must
51+
* include return description for non-Unit returning methods.
5352
*/
5453
class ScalaDocChecker extends CombinedChecker {
5554
protected val errorKey: String = "scaladoc"
@@ -253,7 +252,7 @@ class ScalaDocChecker extends CombinedChecker {
253252
val skip = t.modifiers.exists {
254253
case AccessModifier(pop, Some(_)) =>
255254
if (pop.text == "private") skipQualifiedPrivate else skipQualifiedProtected
256-
case AccessModifier(pop, None) => if (pop.text == "private") skipPrivate else skipProtected
255+
case AccessModifier(pop, None) => if (pop.text == "private") skipPrivate else skipProtected
257256
case SimpleModifier(tk) if ignoreOverride && tk.text == "override" => true
258257
case _ => false
259258
}
@@ -436,9 +435,12 @@ object ScalaDocChecker {
436435

437436
/**
438437
* Take the ``raw`` and parse an instance of ``ScalaDoc``
439-
* @param raw the token containing the ScalaDoc
440-
* @param offset column number of scaladoc's first string
441-
* @return the parsed instance
438+
* @param raw
439+
* the token containing the ScalaDoc
440+
* @param offset
441+
* column number of scaladoc's first string
442+
* @return
443+
* the parsed instance
442444
*/
443445
// scalastyle:off cyclomatic.complexity
444446
def apply(raw: Token, offset: Int): ScalaDoc = {
@@ -498,19 +500,27 @@ object ScalaDocChecker {
498500

499501
/**
500502
* Models a parameter: either plain or type
501-
* @param name the parameter name
502-
* @param text the parameter text
503+
* @param name
504+
* the parameter name
505+
* @param text
506+
* the parameter text
503507
*/
504508
private case class ScalaDocParameter(name: String, text: String)
505509

506510
/**
507511
* Models the parsed ScalaDoc
508-
* @param text arbitrary text
509-
* @param params the parameters
510-
* @param typeParams the type parameters
511-
* @param returns the returns clause, if present
512-
* @param throws the throws clause, if present
513-
* @param indentStyle doc indent style
512+
* @param text
513+
* arbitrary text
514+
* @param params
515+
* the parameters
516+
* @param typeParams
517+
* the type parameters
518+
* @param returns
519+
* the returns clause, if present
520+
* @param throws
521+
* the throws clause, if present
522+
* @param indentStyle
523+
* doc indent style
514524
*/
515525
private case class ScalaDoc(
516526
text: String,

src/main/scala/org/scalastyle/scalariform/SimplifyBooleanExpressionChecker.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@ class SimplifyBooleanExpressionChecker extends ScalariformChecker {
3636

3737
def verify(ast: CompilationUnit): List[ScalastyleError] = {
3838
val it1 = for {
39-
List(left, right) <- ast.tokens.sliding(2);
39+
List(left, right) <- ast.tokens.sliding(2)
4040
if (left.text == "!" && isBoolean(right))
4141
} yield PositionError(left.offset)
4242

4343
val it2 = for {
44-
t <- localvisit(ast);
44+
t <- localvisit(ast)
4545
if (matches(t))
4646
} yield PositionError(t.position.get)
4747

src/main/scala/org/scalastyle/util/CreateRulesMarkdown.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ object CreateRulesMarkdown {
8787
val header = List(
8888
s"""<a name="${id(c.className)}"></a>""",
8989
"",
90-
s"""### ${c.className} - ${desc}""",
90+
s"""### ${c.className} - $desc""",
9191
"",
9292
" * id - " + c.id,
9393
" * description - " + desc,

src/test/scala/org/scalastyle/file/IndentationCheckerTest.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,8 @@ class A {
171171
}
172172

173173
/**
174-
* Check that we don't accidentally think that val defintions are method defintions just because
175-
* it includes the word def, and complain about subsequent method argument indentation
174+
* Check that we don't accidentally think that val defintions are method defintions just because it includes
175+
* the word def, and complain about subsequent method argument indentation
176176
*/
177177
@Test def testValNotConsideredMethod(): Unit = {
178178
val source =

src/test/scala/org/scalastyle/scalariform/ReturnCheckerTest.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ import org.scalatestplus.junit.AssertionsForJUnit
2525
/**
2626
* Test that checks that return keyword should not be used
2727
*
28-
* @author Galder Zamarreño
28+
* @author
29+
* Galder Zamarreño
2930
*/
3031
class ReturnCheckerTest extends AssertionsForJUnit with CheckerTest {
3132

src/test/scala/org/scalastyle/scalariform/ScalaDocCheckerTest.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ class ScalaDocCheckerTest extends AssertionsForJUnit with CheckerTest {
166166
| * XXX
167167
| */
168168
|trait X {
169-
| %s${access} def foo[A, B, U](a: A, b: B): U = ???
169+
| %s$access def foo[A, B, U](a: A, b: B): U = ???
170170
|}
171171
""".stripMargin
172172
val annotatedFun =
@@ -175,7 +175,7 @@ class ScalaDocCheckerTest extends AssertionsForJUnit with CheckerTest {
175175
| * XXX
176176
| */
177177
|trait X {
178-
| %s${access} def foo[@unchecked A, @annotated B, U](@Field() a: A, @Field("b") b: B): U = ???
178+
| %s$access def foo[@unchecked A, @annotated B, U](@Field() a: A, @Field("b") b: B): U = ???
179179
|}
180180
""".stripMargin
181181
val proc1 =
@@ -184,7 +184,7 @@ class ScalaDocCheckerTest extends AssertionsForJUnit with CheckerTest {
184184
| * XXX
185185
| */
186186
|trait X {
187-
| %s${access} def foo[A, B, U](a: A, b: B): Unit = ()
187+
| %s$access def foo[A, B, U](a: A, b: B): Unit = ()
188188
|}
189189
""".stripMargin
190190
val proc2 =
@@ -193,7 +193,7 @@ class ScalaDocCheckerTest extends AssertionsForJUnit with CheckerTest {
193193
| * XXX
194194
| */
195195
|trait X {
196-
| %s${access} def foo[A, B, U](a: A, b: B) {}
196+
| %s$access def foo[A, B, U](a: A, b: B) {}
197197
|}
198198
""".stripMargin
199199
def doc(proc: Boolean) =
@@ -332,7 +332,7 @@ class ScalaDocCheckerTest extends AssertionsForJUnit with CheckerTest {
332332
s"""
333333
|$tlDoc
334334
|$container Foo {
335-
| %s${what}
335+
| %s$what
336336
|}
337337
""".stripMargin
338338
val doc =

0 commit comments

Comments
 (0)