Skip to content

Commit

Permalink
update qoadana config, fix some bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
wadoon committed Oct 24, 2023
1 parent 47882d2 commit 18e06a3
Show file tree
Hide file tree
Showing 16 changed files with 70 additions and 50 deletions.
1 change: 0 additions & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion absintsfc/src/main/kotlin/Lattice.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ abstract class Lattice<T>(

enum class TaintEq { EQUAL, NOT_EQUAL }

class TaintEqLattice : Lattice<TaintEq>(TaintEq.values().toSet()) {
class TaintEqLattice : Lattice<TaintEq>(TaintEq.entries.toSet()) {
override fun cup(a: TaintEq, b: TaintEq): TaintEq {
return when {
a == TaintEq.NOT_EQUAL || b == TaintEq.NOT_EQUAL ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ class DefaultEqualityStrategy(mp: ModularProver) {
val oldSmv = symbex(old)
val newSmv = symbex(new)

val commonOutput = old.block.output.intersect(new.block.output)
val commonOutput = old.block.output.intersect(new.block.output.toSet())
val outVars = commonOutput.map { it.identifier to it.identifier }.toMap()
val r = oldSmv.equal(newSmv, outVars)
if (r)
Expand Down
2 changes: 1 addition & 1 deletion geteta/src/main/java/natorder/NaturalOrderComparator.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ int compareRight(String a, String b)
if (ca < cb) {
bias = -1;
} else if (ca > cb) {
bias = +1;
bias = 1;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class MonitorApp : CliktCommand(name = "ttmonitor",
.flag("--dont-write-header", default = false)

val format by option("--format", "-f", help = "code format, possible values: " +
CodeOutput.values().joinToString(",") { it.name })
CodeOutput.entries.joinToString(",") { it.name })
.convert { CodeOutput.valueOf(it.toUpperCase()) }
.default(CodeOutput.CPP)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,13 +181,13 @@ class TestTableLanguageBuilder(preDefinedTimeConstants: Map<String, Int>) : Test
}

private fun getDataType(symbol: String): AnyDt {
try {
return scope.resolveDataType(symbol)
return try {
scope.resolveDataType(symbol)
} catch (e: DataTypeNotDefinedException) {
if (symbol.startsWith("ENUM_")) {
return EnumerateType(symbol.substring("ENUM_".length), arrayListOf(""))
EnumerateType(symbol.substring("ENUM_".length), arrayListOf(""))
} else {
throw e;
throw e
}
}

Expand Down Expand Up @@ -227,7 +227,7 @@ class RegionVisitor(private val gtt: GeneralizedTestTable,
if (ctx.goto_().isNotEmpty()) {
info("Handling of goto commands in regions currently not supported")
}
val id = ctx.id?.text ?: "g" + (ctx.idi?.text?.toInt() ?: ++currentId)
val id = ctx.id?.text ?: ("g" + (ctx.idi?.text?.toInt() ?: ++currentId))
val r = Region(id)
if (ctx.time() != null) {
r.duration = ctx.time().accept(timeParser)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,4 @@ class ConcreteTableOptions(val properties: MutableMap<String, String>) {
is Duration.ClosedInterval -> (defaultValue.lower + defaultValue.upper) / 2
}
}

init {
/*val nslength = namespace.length + 1
for ((key1, value) in p) {
val key = key1.toString()
if (key.startsWith(namespace)) {
val step = key.substring(nslength)
val count = Integer.parseInt(value.toString())
stepCounter[step] = count
}
}*/
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ class DSLTablePrinter(val stream: CodeWriter) {
stream.printf("row ${r.id} ")
print(r.duration)
stream.printf("{").increaseIndent()
val play = (gtt.programRuns.indices) - r.pauseProgramRuns
val play = (gtt.programRuns.indices) - r.pauseProgramRuns.toSet()
stream.nl().printf("\\play: %s", play.joinToString(", "))
if (r.pauseProgramRuns.isNotEmpty())
stream.nl().printf("\\pause: %s", r.pauseProgramRuns.joinToString(", "))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class None(input: CharStream?) : Lexer(input) {
}
}

@Deprecated("")
@Deprecated("just do not use it")
override fun getTokenNames(): Array<String> {
return Companion.tokenNames
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ private class ProblemModel : ProblemService {

override fun clearProblems(identity: Any) {
map.remove(identity)?.let {
allCurrentProblems.removeAll(it)
allCurrentProblems.removeAll(it.toSet())
}
listeners.forEach { it() }
}

override fun announceProblems(identity: Any, problems: Iterable<Problem>) {
map.remove(identity)?.let { allCurrentProblems.removeAll(it) }
map.remove(identity)?.let { allCurrentProblems.removeAll(it.toSet()) }
val s = problems.toList()
map[identity] = s
allCurrentProblems.addAll(s)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1059,7 +1059,7 @@ class IECParseTreeToAST : IEC61131ParserBaseVisitor<Any>() {

val q = ctx.actionQualifier().IDENTIFIER().text
qualifier.qualifier = SFCActionQualifier.Qualifier.NON_STORED
for (qual in SFCActionQualifier.Qualifier.values()) {
for (qual in SFCActionQualifier.Qualifier.entries) {
if (qual.symbol.equals(q, ignoreCase = true)) qualifier.qualifier = qual
}
currentStep.addAction(qualifier, ctx.actionName.text)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2055,7 +2055,7 @@ data class SFCActionQualifier(

companion object {
fun fromName(qName: String): SFCActionQualifier? {
val qualifier = Qualifier.values().find { it.symbol == qName }
val qualifier = Qualifier.entries.find { it.symbol == qName }
if (qualifier != null) return SFCActionQualifier(qualifier)
else return null
}
Expand Down
42 changes: 42 additions & 0 deletions qodana.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,45 @@ projectJDK: 21 #(Applied in CI/CD pipeline)

#Specify Qodana linter for analysis (Applied in CI/CD pipeline)
linter: jetbrains/qodana-jvm-community:latest

include:
- name: KotlinDeprecation
- name: ClassName
- name: LocalVariableName
- name: PropertyName
- name: CanBeParameter
- name: RemoveCurlyBracesFromTemplate
- name: RedundantModalityModifier
- name: RedundantNullableReturnType
- name: RemoveRedundantQualifierName
- name: RedundantSemicolon
- name: RedundantVisibilityModifier
- name: RemoveEmptyClassBody
- name: UnnecessaryVariable
- name: KotlinUnusedImport
- name: UnusedSymbol
- name: CopyWithoutNamedArguments
- name: ReplacePutWithAssignment
- name: ProtectedInFinal
- name: SimplifiableCallChain
- name: MemberVisibilityCanBePrivate
- name: JavaMapForEach
- name: ReplaceJavaStaticMethodWithKotlinAnalog
- name: MoveLambdaOutsideParentheses
- name: SimplifiableCall
- name: MayBeConstant
- name: NestedLambdaShadowedImplicitParameter
- name: ReplaceManualRangeWithIndicesCalls
- name: ReplaceMapIndexedWithListGenerator
- name: LiftReturnOrAssignment
- name: ConvertToStringTemplate
- name: MoveVariableDeclarationIntoWhen
- name: VerboseNullabilityAndEmptiness


exclude:
- name: All
paths:
- share/**


2 changes: 1 addition & 1 deletion smv/src/main/kotlin/edu/kit/iti/formal/smv/ast.kt
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ enum class SBinaryOperator private constructor(private val symbol: String, priva
companion object {

fun findBySymbol(symbol: String): SBinaryOperator? {
for (op in values()) {
for (op in entries) {
if (op.symbol.equals(symbol, ignoreCase = true)) {
return op
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ class DefaultS2SFunctionTranslator : S2SFunctionTranslator {
= TODO("translation of various functions")

companion object {
internal var logicalOperators: MutableMap<SBinaryOperator, String> = HashMap()
internal var bvuOperators: MutableMap<SBinaryOperator, String> = HashMap()
internal var bvsOperators: MutableMap<SBinaryOperator, String> = HashMap()
internal var arithOperators: MutableMap<SBinaryOperator, String> = HashMap()
internal var logicalOperators: MutableMap<SBinaryOperator, String> = EnumMap(SBinaryOperator::class.java)
internal var bvuOperators: MutableMap<SBinaryOperator, String> = EnumMap(SBinaryOperator::class.java)
internal var bvsOperators: MutableMap<SBinaryOperator, String> = EnumMap(SBinaryOperator::class.java)
internal var arithOperators: MutableMap<SBinaryOperator, String> = EnumMap(SBinaryOperator::class.java)

init {
logicalOperators[SBinaryOperator.AND] = "and"
Expand Down
25 changes: 8 additions & 17 deletions utils-test/src/main/kotlin/utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ object LoadHelp {
return File(dirURL.toURI()).listFiles().map { it.toPath() }
}

if (dirURL == null) {
if (dirURL === null) {
/*
* In case of a jar file, we can't actually find a directory.
* Have to assume the same jar as clazz.
Expand All @@ -75,23 +75,14 @@ object LoadHelp {


fun getResource(path: String, clazz: Class<*> = LoadHelp::class.java): Path? {
var dirURL = clazz.classLoader.getResource(path)
if (dirURL == null) return null
val dirURL = clazz.classLoader.getResource(path)
if (dirURL === null) return null

if (dirURL != null && dirURL.protocol.equals("file")) {
if (dirURL.protocol.equals("file")) {
return File(dirURL.toURI()).toPath()
}

if (dirURL == null) {
/*
* In case of a jar file, we can't actually find a directory.
* Have to assume the same jar as clazz.
*/
val me = clazz.name.replace(".", "/") + ".class"
dirURL = clazz.classLoader.getResource(me)
}

if (dirURL!!.protocol.equals("jar")) {
if (dirURL.protocol.equals("jar")) {
/* A JAR path */
//strip out only the JAR file
var jarPath = dirURL.path.substring(5, dirURL.path.indexOf("!"))
Expand All @@ -105,9 +96,9 @@ object LoadHelp {
}


fun getPrograms() = LoadHelp.getResources("edu/kit/iti/formal/automation/st/programs")
fun getStatements() = LoadHelp.getResources("edu/kit/iti/formal/automation/st/statements")
fun getTypes() = LoadHelp.getResources("edu/kit/iti/formal/automation/st/types")
fun getPrograms() = getResources("edu/kit/iti/formal/automation/st/programs")
fun getStatements() = getResources("edu/kit/iti/formal/automation/st/statements")
fun getTypes() = getResources("edu/kit/iti/formal/automation/st/types")
}

/**
Expand Down

0 comments on commit 18e06a3

Please sign in to comment.