Skip to content

Commit

Permalink
Merge pull request #194 from alexarchambault/fix-scalafmt-scalafix
Browse files Browse the repository at this point in the history
Fix scalafmt / scalafix
  • Loading branch information
alexarchambault authored Oct 7, 2021
2 parents b974ead + 8c5810e commit 936ef0a
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 20 deletions.
2 changes: 2 additions & 0 deletions .scalafix.conf
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ rules = [
ProcedureSyntax
]
DisableSyntax.noFinalize = true
DisableSyntax.noIsInstanceOf = true
DisableSyntax.noReturns = true

// `rules` on compilation
triggered.rules = [
Expand Down
6 changes: 3 additions & 3 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ newlines.beforeMultiline = keep
newlines.afterCurlyLambdaParams = keep
newlines.alwaysBeforeElseAfterCurlyIf = true

DisableSyntax.noIsInstanceOf = true
DisableSyntax.noReturns = true

runner.dialect = scala213

rewrite.rules = [
Expand Down Expand Up @@ -44,6 +41,9 @@ fileOverride {
"glob:**/docs_checker/**" {
runner.dialect = scala3
}
"glob:**/gifs/**" {
runner.dialect = scala3
}
}
project.excludeFilters = [
".metals"
Expand Down
22 changes: 10 additions & 12 deletions gifs/create_missing.sc
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@

import $ivy.`com.lihaoyi::os-lib:0.7.8`

/**
* Small and handy script to generate stubs for .svg files with nice TODO
*/
/** Small and handy script to generate stubs for .svg files with nice TODO
*/

val content = os.read(os.pwd/"website"/"src"/"components"/"features.js")
val Image = """.*image="([^ ]+)" +(title="(.+)")?.*""".r
def needStub(name: String) =
!os.exists(os.pwd/"website"/"static"/"img"/name) && name.endsWith(".svg")
val content = os.read(os.pwd / "website" / "src" / "components" / "features.js")
val Image = """.*image="([^ ]+)" +(title="(.+)")?.*""".r
def needStub(name: String) =
!os.exists(os.pwd / "website" / "static" / "img" / name) && name.endsWith(".svg")

// Look for missing .svg files in out feature list
val stubs = content.linesIterator.collect {
Expand All @@ -28,16 +27,15 @@ val stubs = content.linesIterator.collect {
// ("demo", "general demo of Scala CLI"),
// )

if stubs.nonEmpty then
val scriptBase = os.read(os.pwd/"gifs"/"example.sh")
if stubs.nonEmpty then
val scriptBase = os.read(os.pwd / "gifs" / "example.sh")
stubs.foreach { case (imageName, desc) =>
val scriptName = imageName.stripSuffix(".svg") + ".sh"
val dest = os.pwd/"gifs"/"scenarios"/scriptName
val fullDescr = s"TODO: turn gifs/scenarios/$scriptName into proper scenario $desc"
val dest = os.pwd / "gifs" / "scenarios" / scriptName
val fullDescr = s"TODO: turn gifs/scenarios/$scriptName into proper scenario $desc"
os.write.over(dest, scriptBase.replace("<description>", fullDescr))
os.perms.set(dest, "rwxr-xr-x")
println(s"Wrote: $dest")
}
val names = stubs.map(_._1.stripSuffix(".svg")).mkString(" ")
println(s"To generate svg files run: 'gifs/generate_gif.sh $names'")

Original file line number Diff line number Diff line change
Expand Up @@ -235,10 +235,8 @@ object Operations {
}
}
catch {
case ex: IOException
if ex.getCause.isInstanceOf[NativeErrorException] &&
ignoredErrnos(ex.getCause.asInstanceOf[NativeErrorException].returnCode) =>
logger.debug(s"Error when connecting to $socketFile: ${ex.getMessage}")
case ExCause(ex0: NativeErrorException) if ignoredErrnos(ex0.returnCode) =>
logger.debug(s"Error when connecting to $socketFile: ${ex0.getMessage}")
null
case e: NativeErrorException if ignoredErrnos(e.returnCode) =>
logger.debug(s"Error when connecting to $socketFile: ${e.getMessage}")
Expand Down Expand Up @@ -377,4 +375,9 @@ object Operations {

Await.result(p.future, duration)
}

private object ExCause {
def unapply(ex: Throwable): Option[Throwable] =
Option(ex.getCause)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,10 @@ sealed abstract class TastyName extends Product with Serializable { self =>

final override def toString: String = source

final def isObjectName: Boolean = self.isInstanceOf[ObjectName]
final def isObjectName: Boolean = self match {
case _: ObjectName => true
case _ => false
}

final def asSimpleName: SimpleName = self match {
case self: SimpleName => self
Expand Down

0 comments on commit 936ef0a

Please sign in to comment.