Skip to content

Commit

Permalink
Merge pull request #1414 from informalsystems/shon/scalafix-tweaks
Browse files Browse the repository at this point in the history
Improve scalafix configuration
  • Loading branch information
Shon Feder authored Mar 4, 2022
2 parents 72fed8b + 9a4394d commit b908195
Show file tree
Hide file tree
Showing 37 changed files with 165 additions and 236 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ test/tla/%.md: target/test/tla/%.md.corrected
fmt-check:
# TODO: rm if we decide to keep running on all source files
# git fetch origin
sbt scalafmtCheckAll scalafmtSbtCheck || \
sbt scalafmtCheckAll scalafmtSbtCheck scalafixEnable "scalafixAll --check RemoveUnused" || \
( echo "TO FIX: run 'make fmt-fix' and commit the changes" ; \
exit 1 )

fmt-fix:
sbt "scalafix RemoveUnused" scalafmtAll scalafmtSbt
sbt scalafixEnable "scalafixAll RemoveUnused" scalafmtAll scalafmtSbt

clean:
sbt clean
Expand Down
1 change: 0 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ ThisBuild / scalafmtPrintDiff := true
// scalafix
// https://scalacenter.github.io/scalafix/docs/rules/RemoveUnused.html
ThisBuild / scalacOptions ++= Seq("-Ywarn-unused")
ThisBuild / semanticdbEnabled := true
ThisBuild / semanticdbVersion := scalafixSemanticdb.revision

///////////////////////////////
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package at.forsyte.apalache.infra.passes

import org.junit.runner.RunWith
import org.scalatest.funsuite.AnyFunSuite
import org.scalatestplus.easymock.EasyMockSugar
import org.scalatestplus.junit.JUnitRunner
import at.forsyte.apalache.tla.lir.{ModuleProperty, TlaModule}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package at.forsyte.apalache.tla.bmcmt

import java.io.{PrintWriter, StringWriter}
import java.io.StringWriter

import at.forsyte.apalache.tla.bmcmt.smt.SolverContext
import at.forsyte.apalache.tla.lir.convenience.tla
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ trait TestArena extends FixtureAnyFunSuite {

test("BOOLEAN has FALSE and TRUE") { _ =>
val arena = Arena.create(solver)
val boolean = arena.cellBooleanSet()
assert(List(arena.cellFalse(), arena.cellTrue()) == arena.getHas(arena.cellBooleanSet()))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,6 @@ trait TestSeqModelCheckerTrait extends FixtureAnyFunSuite {
val checkerInput =
new CheckerInput(mkModuleWithX(), initTrans, nextTrans, None, CheckerInputVC(List((inv, notInv))))
// initialize the model checker
val filter = "0,0,0,0,0,0,0,0,0,0,0" // old syntax
val tuning = Map.empty[String, String] // Map("search.transitionFilter" -> filter)
val params = new ModelCheckerParams(checkerInput, stepsBound = 10, new File("."), tuning, false)
val ctx = new IncrementalExecutionContext(rewriter)
Expand Down Expand Up @@ -813,8 +812,4 @@ trait TestSeqModelCheckerTrait extends FixtureAnyFunSuite {
.typed(types, "b")
}

private def mkNotAssign(varName: String, rhs: BuilderEx, tt: TlaType1): TlaEx = {
eql(prime(name(varName) ? "_tt") ? "_tt", rhs)
.typed(types + ("_tt" -> tt), "b")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ trait TestSymbStateRewriterAssignment extends RewriterBase {

val state = new SymbState(asgn, arena, Binding())
val rewriter = create(rewriterType)
val nextState = rewriter.rewriteUntilDone(state)
rewriter.rewriteUntilDone(state)
assert(rewriter.solverContext.sat())
// there is not much to check here, since it is just a function that returns an integer
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ trait TestSymbStateRewriterBool extends RewriterBase with TestingPredefs {
rewriter.rewriteOnce(state) match {
case SymbStateRewriter.Continue(nextState) =>
nextState.ex match {
case NameEx(name) =>
case NameEx(_) =>
val eq = tla
.eql(cell.toNameEx ? "b", arena.cellFalse().toNameEx ? "b")
.typed(boolTypes, "b")
Expand Down Expand Up @@ -229,7 +229,7 @@ trait TestSymbStateRewriterBool extends RewriterBase with TestingPredefs {
rewriter.rewriteOnce(state) match {
case SymbStateRewriter.Continue(nextState) =>
nextState.ex match {
case NameEx(name) =>
case NameEx(_) =>
assert(solverContext.sat())
solverContext.assertGroundExpr(nextState.ex)
rewriter.push()
Expand Down Expand Up @@ -316,7 +316,7 @@ trait TestSymbStateRewriterBool extends RewriterBase with TestingPredefs {
rewriter.rewriteOnce(state) match {
case SymbStateRewriter.Continue(nextState) =>
nextState.ex match {
case NameEx(name) =>
case NameEx(_) =>
val eq1 = tla
.eql(left.toNameEx ? "b", arena.cellFalse().toNameEx ? "b")
.typed(boolTypes, "b")
Expand Down Expand Up @@ -353,7 +353,7 @@ trait TestSymbStateRewriterBool extends RewriterBase with TestingPredefs {
val rewriter = create(rewriterType)
val nextState = rewriter.rewriteUntilDone(state)
nextState.ex match {
case predEx @ NameEx(name) =>
case predEx @ NameEx(_) =>
solverContext.assertGroundExpr(predEx)
rewriter.push()
// both false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ trait TestSymbStateRewriterChoose extends RewriterBase with TestingPredefs {
.typed(types, "i")
val state = new SymbState(ex, arena, Binding())
val rewriter = create(rewriterType)
val nextState = rewriter.rewriteUntilDone(state)
rewriter.rewriteUntilDone(state)
// the buggy implementation of choose fails on a dynamically empty set
assert(solverContext.sat())
// The semantics of choose does not restrict the outcome on the empty sets,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,6 @@ import at.forsyte.apalache.tla.lir._
import at.forsyte.apalache.tla.lir.oper.ApalacheOper

trait TestSymbStateRewriterFoldSet extends RewriterBase {
private val types = Map(
"b" -> BoolT1(),
"i" -> IntT1(),
"(i)" -> TupT1(IntT1()),
"I" -> SetT1(IntT1()),
"ib" -> TupT1(IntT1(), BoolT1()),
"ibs" -> TupT1(IntT1(), BoolT1(), StrT1()),
"IB" -> SetT1(TupT1(IntT1(), BoolT1())),
"ibI" -> TupT1(IntT1(), BoolT1(), SetT1(IntT1())),
)

test("""FoldSet( LAMBDA x,y: C, v, S ) = C""") { rewriterType: SMTEncoding =>
// A : (a,b) => a
// A(p,q) == 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ trait TestSymbStateRewriterFunSet extends RewriterBase {
val rewriter = create(rewriterType)
val nextState = rewriter.rewriteUntilDone(state)
nextState.ex match {
case NameEx(name) =>
case NameEx(_) =>
val cell = nextState.arena.findCellByNameEx(nextState.ex)
assert(cell.cellType == FinFunSetT(FinSetT(IntT()), FinSetT(BoolT())))
val dom = nextState.arena.getDom(cell)
Expand Down Expand Up @@ -71,7 +71,7 @@ trait TestSymbStateRewriterFunSet extends RewriterBase {
val rewriter = create(rewriterType)
val nextState = rewriter.rewriteUntilDone(state)
nextState.ex match {
case NameEx(name) =>
case NameEx(_) =>
val cell = nextState.arena.findCellByNameEx(nextState.ex)
assert(cell.cellType == FinFunSetT(FinSetT(IntT()), FinSetT(FinSetT(BoolT()))))
val dom = nextState.arena.getDom(cell)
Expand Down Expand Up @@ -242,7 +242,7 @@ trait TestSymbStateRewriterFunSet extends RewriterBase {
val rewriter = create(rewriterType)
val nextState = rewriter.rewriteUntilDone(state)
nextState.ex match {
case NameEx(name) =>
case NameEx(_) =>
val cell = nextState.arena.findCellByNameEx(nextState.ex)
assert(cell.cellType == FinFunSetT(FinSetT(IntT()), FinSetT(BoolT())))
val dom = nextState.arena.getDom(cell)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ trait TestSymbStateRewriterInt extends RewriterBase {
val rewriter = create(rewriterType)
val nextState = rewriter.rewriteUntilDone(state)
nextState.ex match {
case predEx @ NameEx(name) =>
case predEx @ NameEx(_) =>
assert(solverContext.sat())
solverContext.assertGroundExpr(eql(leftInt.as(Int), int(22)).as(Bool))
rewriter.push()
Expand Down Expand Up @@ -95,7 +95,7 @@ trait TestSymbStateRewriterInt extends RewriterBase {
val rewriter = create(rewriterType)
val nextState = rewriter.rewriteUntilDone(state)
nextState.ex match {
case cmpEx @ NameEx(name) =>
case cmpEx @ NameEx(_) =>
assert(solverContext.sat())
solverContext.assertGroundExpr(cmpEx)
solverContext.assertGroundExpr(eql(leftCell.toNameEx.as(Int), int(4)).as(Bool))
Expand Down Expand Up @@ -125,7 +125,7 @@ trait TestSymbStateRewriterInt extends RewriterBase {
val rewriter = create(rewriterType)
val nextState = rewriter.rewriteUntilDone(state)
nextState.ex match {
case cmpEx @ NameEx(name) =>
case cmpEx @ NameEx(_) =>
assert(solverContext.sat())
solverContext.assertGroundExpr(cmpEx)
solverContext.assertGroundExpr(eql(leftCell.toNameEx.as(Int), int(4)).as(Bool))
Expand Down Expand Up @@ -155,7 +155,7 @@ trait TestSymbStateRewriterInt extends RewriterBase {
val rewriter = create(rewriterType)
val nextState = rewriter.rewriteUntilDone(state)
nextState.ex match {
case cmpEx @ NameEx(name) =>
case cmpEx @ NameEx(_) =>
assert(solverContext.sat())
solverContext.assertGroundExpr(cmpEx)
solverContext.assertGroundExpr(eql(leftCell.toNameEx.as(Int), int(4)).as(Bool))
Expand All @@ -182,7 +182,7 @@ trait TestSymbStateRewriterInt extends RewriterBase {
val rewriter = create(rewriterType)
val nextState = rewriter.rewriteUntilDone(state)
nextState.ex match {
case cmpEx @ NameEx(name) =>
case cmpEx @ NameEx(_) =>
assert(solverContext.sat())
rewriter.push()
solverContext.assertGroundExpr(cmpEx)
Expand All @@ -206,7 +206,7 @@ trait TestSymbStateRewriterInt extends RewriterBase {
val rewriter = create(rewriterType)
val nextState = rewriter.rewriteUntilDone(state)
nextState.ex match {
case cmpEx @ NameEx(name) =>
case cmpEx @ NameEx(_) =>
assert(solverContext.sat())
solverContext.assertGroundExpr(cmpEx)
solverContext.assertGroundExpr(eql(leftCell.toNameEx.as(Int), int(4)).as(Bool))
Expand Down Expand Up @@ -236,7 +236,7 @@ trait TestSymbStateRewriterInt extends RewriterBase {
val rewriter = create(rewriterType)
val nextState = rewriter.rewriteUntilDone(state)
nextState.ex match {
case predEx @ NameEx(name) =>
case predEx @ NameEx(_) =>
assert(solverContext.sat())
solverContext.assertGroundExpr(eql(leftInt.as(Int), int(22)).as(Bool))
rewriter.push()
Expand Down Expand Up @@ -273,7 +273,7 @@ trait TestSymbStateRewriterInt extends RewriterBase {
val rewriter = create(rewriterType)
val nextState = rewriter.rewriteUntilDone(state)
nextState.ex match {
case result @ NameEx(name) =>
case result @ NameEx(_) =>
assert(solverContext.sat())
solverContext.assertGroundExpr(eql(leftInt.as(Int), int(1981)).as(Bool))
rewriter.push()
Expand Down Expand Up @@ -301,7 +301,7 @@ trait TestSymbStateRewriterInt extends RewriterBase {
val rewriter = create(rewriterType)
val nextState = rewriter.rewriteUntilDone(state)
nextState.ex match {
case result @ NameEx(name) =>
case result @ NameEx(_) =>
assert(solverContext.sat())
solverContext.assertGroundExpr(eql(leftInt.as(Int), int(2017)).as(Bool))
rewriter.push()
Expand All @@ -327,7 +327,7 @@ trait TestSymbStateRewriterInt extends RewriterBase {
val rewriter = create(rewriterType)
val nextState = rewriter.rewriteUntilDone(state)
nextState.ex match {
case result @ NameEx(name) =>
case result @ NameEx(_) =>
assert(solverContext.sat())
solverContext.assertGroundExpr(eql(leftInt.as(Int), int(2017)).as(Bool))
rewriter.push()
Expand All @@ -353,7 +353,7 @@ trait TestSymbStateRewriterInt extends RewriterBase {
val rewriter = create(rewriterType)
val nextState = rewriter.rewriteUntilDone(state)
nextState.ex match {
case result @ NameEx(name) =>
case result @ NameEx(_) =>
assert(solverContext.sat())
solverContext.assertGroundExpr(eql(leftInt.as(Int), int(7)).as(Bool))
rewriter.push()
Expand Down Expand Up @@ -381,7 +381,7 @@ trait TestSymbStateRewriterInt extends RewriterBase {
val rewriter = create(rewriterType)
val nextState = rewriter.rewriteUntilDone(state)
nextState.ex match {
case result @ NameEx(name) =>
case result @ NameEx(_) =>
assert(solverContext.sat())
solverContext.assertGroundExpr(eql(leftInt.as(Int), int(30)).as(Bool))
rewriter.push()
Expand Down Expand Up @@ -409,7 +409,7 @@ trait TestSymbStateRewriterInt extends RewriterBase {
val rewriter = create(rewriterType)
val nextState = rewriter.rewriteUntilDone(state)
nextState.ex match {
case result @ NameEx(name) =>
case result @ NameEx(_) =>
assert(solverContext.sat())
solverContext.assertGroundExpr(eql(leftInt.as(Int), int(30)).as(Bool))
rewriter.push()
Expand All @@ -436,7 +436,7 @@ trait TestSymbStateRewriterInt extends RewriterBase {
val rewriter = create(rewriterType)
val nextState = rewriter.rewriteUntilDone(state)
nextState.ex match {
case predEx @ NameEx(name) =>
case predEx @ NameEx(_) =>
assert(solverContext.sat())
// check equality
rewriter.push()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ trait TestSymbStateRewriterPowerset extends RewriterBase {
var nextState = rewriter.rewriteUntilDone(state)
val baseCell = nextState.asCell
nextState = new PowSetCtor(rewriter).confringo(nextState, baseCell)
val powCell = nextState.asCell
// check equality
val eq = eql(nextState.ex,
enumSet(enumSet() ? "I", enumSet(int(1)) ? "I", enumSet(int(2)) ? "I", enumSet(int(1), int(2)) ? "I") ? "II")
Expand Down
Loading

0 comments on commit b908195

Please sign in to comment.