Skip to content

Commit

Permalink
Fix global patterns location in XML config
Browse files Browse the repository at this point in the history
  • Loading branch information
machadoit committed Mar 2, 2016
1 parent 850640e commit 17585a6
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion src/main/scala/codacy/checkstyle/Checkstyle.scala
Original file line number Diff line number Diff line change
@@ -49,8 +49,11 @@ object Checkstyle extends Tool {
"http://www.puppycrawl.com/dtds/configuration_1_3.dtd" >"""

val xmlConfig = conf.fold(defaultConfig) {
patterns =>
allPatterns =>
val (globalPatterns, patterns) = allPatterns.partition(isGlobalPattern)

<module name="Checker">
{globalPatterns.map(generatePatternConfig)}
<module name="TreeWalker">
{patterns.map(generatePatternConfig)}
</module>
@@ -106,4 +109,26 @@ object Checkstyle extends Tool {
case v => v.toString
}
}

private lazy val globalPatterns: Set[String] = Set(
"SeverityMatchFilter",
"SuppressionCommentFilter",
"SuppressionFilter",
"SuppressWithNearbyCommentFilter",
"Header",
"RegexpHeader",
"JavadocPackage",
"Translation",
"RegexpMultiline",
"RegexpSingleline",
"RegexpOnFilename",
"FileLength",
"FileTabCharacter",
"NewlineAtEndOfFile",
"UniqueProperties"
)

private def isGlobalPattern(pattern: PatternDef) = {
globalPatterns.contains(pattern.patternId.value)
}
}

0 comments on commit 17585a6

Please sign in to comment.