Skip to content

Commit

Permalink
Update scalafmt config
Browse files Browse the repository at this point in the history
  • Loading branch information
stringbean committed Aug 1, 2023
1 parent 0fdaab5 commit da48268
Show file tree
Hide file tree
Showing 7 changed files with 106 additions and 66 deletions.
34 changes: 33 additions & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,8 +1,40 @@
version = 3.5.9
version = 3.7.11
runner.dialect = scala212source3

maxColumn = 120

rewrite.rules = [
Imports
RedundantBraces
RedundantParens
PreferCurlyFors
]

align.openParenCallSite = false
align.openParenDefnSite = false
danglingParentheses.callSite = false
danglingParentheses.defnSite = false

# don't align arrows in match statements
align.preset = none

rewrite {
imports.sort = scalastyle

redundantBraces {
generalExpressions = false
defnBodies = none
stringInterpolation = true
}
}

docstrings {
style = Asterisk
blankFirstLine = true
removeEmpty = true
wrap = false
}

fileOverride {
# align libraryDependencies in *.sbt
"glob:**/*.sbt" {
Expand Down
69 changes: 36 additions & 33 deletions src/main/scala/com/etsy/sbt/checkstyle/Checkstyle.scala
Original file line number Diff line number Diff line change
Expand Up @@ -14,34 +14,36 @@ import java.util.Properties
import javax.xml.transform.stream.StreamSource
import scala.collection.JavaConverters.*

/** A Scala wrapper around the Checkstyle Java API
*
* @author
* Andrew Johnson <[email protected]>
* @author
* Joseph Earl <[email protected]>
*/
/**
* A Scala wrapper around the Checkstyle Java API
*
* @author
* Andrew Johnson <[email protected]>
* @author
* Joseph Earl <[email protected]>
*/
object Checkstyle {

/** Runs Checkstyle.
*
* Note: any non-Java sources passed to this function will be ignored.
*
* @param sourceFiles
* list of source files to scan.
* @param configLocation
* location of the Checkstyle config to use.
* @param resources
* list of resource files (used if `configLocation` points to the classpath).
* @param outputFile
* file to store the Checkstyle report in.
* @param xsltTransformations
* XML transformations to apply to the Checkstyle report.
* @param severityLevel
* threshold of violations for failing the build if reached.
* @param log
* used to log status of Checkstyle.
*/
/**
* Runs Checkstyle.
*
* Note: any non-Java sources passed to this function will be ignored.
*
* @param sourceFiles
* list of source files to scan.
* @param configLocation
* location of the Checkstyle config to use.
* @param resources
* list of resource files (used if `configLocation` points to the classpath).
* @param outputFile
* file to store the Checkstyle report in.
* @param xsltTransformations
* XML transformations to apply to the Checkstyle report.
* @param severityLevel
* threshold of violations for failing the build if reached.
* @param log
* used to log status of Checkstyle.
*/
def checkstyle(
sourceFiles: Seq[File],
configLocation: CheckstyleConfigLocation,
Expand Down Expand Up @@ -99,13 +101,14 @@ object Checkstyle {
)
}

/** Applies a set of XSLT transformation to the XML file produced by checkstyle
*
* @param input
* The XML file produced by checkstyle
* @param transformations
* The XSLT transformations to be applied
*/
/**
* Applies a set of XSLT transformation to the XML file produced by checkstyle
*
* @param input
* The XML file produced by checkstyle
* @param transformations
* The XSLT transformations to be applied
*/
private def applyXSLT(
input: File,
transformations: Set[CheckstyleXSLTSettings]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ import sbt.File
import java.io.{FileInputStream, InputStream}
import java.net.URLClassLoader

/** Represents a Checkstyle XML configuration located locally, on the class path or remotely at a URL
*
* @author
* Joseph Earl
*/
/**
* Represents a Checkstyle XML configuration located locally, on the class path or remotely at a URL
*
* @author
* Joseph Earl
*/
sealed abstract class CheckstyleConfigLocation {
def load(resources: Seq[File]): InputStream
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ class CheckstyleListener extends AuditListener {

override def addError(event: AuditEvent): Unit = {
event.getSeverityLevel match {
case SeverityLevel.INFO => infoCount += 1
case SeverityLevel.INFO => infoCount += 1
case SeverityLevel.WARNING => warningCount += 1
case SeverityLevel.ERROR => errorCount += 1
case SeverityLevel.IGNORE => // ignore
case SeverityLevel.ERROR => errorCount += 1
case SeverityLevel.IGNORE => // ignore
}
}

Expand Down
30 changes: 16 additions & 14 deletions src/main/scala/com/etsy/sbt/checkstyle/CheckstylePlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@ import sbt.*
import sbt.Def.Initialize
import sbt.Keys.*

/** An SBT plugin to run checkstyle over Java code
*
* @author
* Andrew Johnson <[email protected]>
* @author
* Alejandro Rivera <[email protected]>
* @author
* Joseph Earl <[email protected]>
*/
/**
* An SBT plugin to run checkstyle over Java code
*
* @author
* Andrew Johnson <[email protected]>
* @author
* Alejandro Rivera <[email protected]>
* @author
* Joseph Earl <[email protected]>
*/
object CheckstylePlugin extends AutoPlugin {
override def trigger: PluginTrigger = allRequirements

Expand All @@ -39,11 +40,12 @@ object CheckstylePlugin extends AutoPlugin {
val CheckstyleXSLTSettings: com.etsy.sbt.checkstyle.CheckstyleXSLTSettings.type =
com.etsy.sbt.checkstyle.CheckstyleXSLTSettings

/** Runs checkstyle
*
* @param conf
* The configuration (Compile or Test) in which context to execute the checkstyle command
*/
/**
* Runs checkstyle
*
* @param conf
* The configuration (Compile or Test) in which context to execute the checkstyle command
*/
def checkstyleTask(conf: Configuration): Initialize[Task[Unit]] = Def.task {
Checkstyle.checkstyle(
(conf / sources).value,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package com.etsy.sbt.checkstyle

/** Enumeration of the different Checkstyle severity levels
*
* @author
* Andrew Johnson
*/
/**
* Enumeration of the different Checkstyle severity levels
*
* @author
* Andrew Johnson
*/
object CheckstyleSeverityLevel extends Enumeration {
type CheckstyleSeverityLevel = Value

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ package com.etsy.sbt.checkstyle

import java.io.File

/** Configuration for a single XSLT transformation of the checkstyle output file
*
* @author
* Andrew Johnson
*/
/**
* Configuration for a single XSLT transformation of the checkstyle output file
*
* @author
* Andrew Johnson
*/
final case class CheckstyleXSLTSettings(xslt: File, output: File)

0 comments on commit da48268

Please sign in to comment.