Skip to content

Commit

Permalink
Update detekt and hashing
Browse files Browse the repository at this point in the history
  • Loading branch information
Drodt committed Nov 21, 2023
1 parent b993be0 commit e0abe7e
Show file tree
Hide file tree
Showing 82 changed files with 1,389 additions and 606 deletions.
13 changes: 7 additions & 6 deletions backend/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
plugins {
kotlin("jvm") version "1.7.20"
kotlin("plugin.serialization") version "1.7.20"
kotlin("plugin.serialization") version "1.9.20"
application
id("org.jmailen.kotlinter") version "3.10.0"
id("io.gitlab.arturbosch.detekt") version "1.21.0"
id("io.gitlab.arturbosch.detekt") version "1.23.3"
id("com.github.johnrengelman.shadow") version "7.1.2"
id("java")
id("jacoco")
Expand All @@ -27,11 +27,13 @@ dependencies {
implementation("org.slf4j:slf4j-simple:2.0.9")

// Hashing
implementation("com.github.komputing:khash:1.1.3")
implementation("com.github.komputing.khash:keccak:1.1.3")

// Testing
testImplementation(kotlin("test-junit5"))
testRuntimeOnly("org.junit.jupiter", "junit-jupiter-engine", "5.10.1")

detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:1.23.3")
}

application {
Expand All @@ -57,13 +59,12 @@ java {

detekt {
toolVersion = "1.23.3"
source = files("src/main/kotlin")
config = files("$projectDir/config/detekt/detekt.yml")
source.setFrom("src/main/kotlin")
config.setFrom("$projectDir/config/detekt/detekt.yml")
}

kotlinter {
ignoreFailures = false
reporters = arrayOf("checkstyle", "plain")
experimentalRules = false
disabledRules = arrayOf("no-wildcard-imports", "filename")
}
97 changes: 43 additions & 54 deletions backend/config/detekt/detekt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ build:

processors:
active: true
exclude:
exclude: []
# - 'DetektProgressListener'
# - 'FunctionCountProcessor'
# - 'PropertyCountProcessor'
Expand Down Expand Up @@ -64,14 +64,14 @@ complexity:
active: false
threshold: 10
includeStaticDeclarations: false
ComplexMethod:
CyclomaticComplexMethod:
active: true
threshold: 13
ignoreSingleWhenExpression: false
ignoreSimpleWhenEntries: false
LabeledExpression:
active: false
ignoredLabels: ""
ignoredLabels: []
LargeClass:
active: true
threshold: 600
Expand All @@ -91,15 +91,15 @@ complexity:
threshold: 4
StringLiteralDuplication:
active: false
excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt"
excludes: ["**/test/**", "**/androidTest/**", "**/*.Test.kt", "**/*.Spec.kt", "**/*.Spek.kt"]
threshold: 3
ignoreAnnotation: true
excludeStringsWithLessThan5Characters: true
ignoreStringsRegex: '$^'
TooManyFunctions:
active: true
excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt"
thresholdInFiles: 11
excludes: ["**/test/**", "**/androidTest/**", "**/*.Test.kt", "**/*.Spec.kt", "**/*.Spek.kt"]
thresholdInFiles: 13
thresholdInClasses: 11
thresholdInInterfaces: 11
thresholdInObjects: 11
Expand Down Expand Up @@ -145,10 +145,10 @@ exceptions:
active: true
ExceptionRaisedInUnexpectedLocation:
active: false
methodNames: 'toString,hashCode,equals,finalize'
methodNames: ['toString', 'hashCode', 'equals', 'finalize']
InstanceOfCheckForException:
active: false
excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt"
excludes: ["**/test/**", "**/androidTest/**", "**/*.Test.kt", "**/*.Spec.kt", "**/*.Spek.kt"]
NotImplementedDeclaration:
active: false
PrintStackTrace:
Expand All @@ -160,20 +160,25 @@ exceptions:
ignoreLabeled: false
SwallowedException:
active: false
ignoredExceptionTypes: 'InterruptedException,NumberFormatException,ParseException,MalformedURLException'
ignoredExceptionTypes: [
'InterruptedException',
'NumberFormatException',
'ParseException',
'MalformedURLException'
]
allowedExceptionNameRegex: "^(_|(ignore|expected).*)"
ThrowingExceptionFromFinally:
active: false
ThrowingExceptionInMain:
active: false
ThrowingExceptionsWithoutMessageOrCause:
active: false
exceptions: 'IllegalArgumentException,IllegalStateException,IOException'
exceptions: ['IllegalArgumentException', 'IllegalStateException', 'IOException']
ThrowingNewInstanceOfSameException:
active: false
TooGenericExceptionCaught:
active: true
excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt"
excludes: ["**/test/**", "**/androidTest/**", "**/*.Test.kt", "**/*.Spec.kt", "**/*.Spek.kt"]
exceptionNames:
- ArrayIndexOutOfBoundsException
- Error
Expand Down Expand Up @@ -217,7 +222,6 @@ formatting:
active: false
autoCorrect: true
indentSize: 4
continuationIndentSize: 4
MaximumLineLength:
active: true
maxLineLength: 120
Expand Down Expand Up @@ -298,42 +302,40 @@ naming:
active: true
ClassNaming:
active: true
excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt"
excludes: ["**/test/**", "**/androidTest/**", "**/*.Test.kt", "**/*.Spec.kt", "**/*.Spek.kt"]
classPattern: '[A-Z$][a-zA-Z0-9$]*'
ConstructorParameterNaming:
active: true
excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt"
excludes: ["**/test/**", "**/androidTest/**", "**/*.Test.kt", "**/*.Spec.kt", "**/*.Spek.kt"]
parameterPattern: '[a-z][A-Za-z0-9]*'
privateParameterPattern: '[a-z][A-Za-z0-9]*'
excludeClassPattern: '$^'
EnumNaming:
active: true
excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt"
excludes: ["**/test/**", "**/androidTest/**", "**/*.Test.kt", "**/*.Spec.kt", "**/*.Spek.kt"]
enumEntryPattern: '^[A-Z][_a-zA-Z0-9]*'
ForbiddenClassName:
active: false
excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt"
forbiddenName: ''
excludes: ["**/test/**", "**/androidTest/**", "**/*.Test.kt", "**/*.Spec.kt", "**/*.Spek.kt"]
forbiddenName: []
FunctionMaxLength:
active: false
excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt"
excludes: ["**/test/**", "**/androidTest/**", "**/*.Test.kt", "**/*.Spec.kt", "**/*.Spek.kt"]
maximumFunctionNameLength: 30
FunctionMinLength:
active: false
excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt"
excludes: ["**/test/**", "**/androidTest/**", "**/*.Test.kt", "**/*.Spec.kt", "**/*.Spek.kt"]
minimumFunctionNameLength: 3
FunctionNaming:
active: true
excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt"
excludes: ["**/test/**", "**/androidTest/**", "**/*.Test.kt", "**/*.Spec.kt", "**/*.Spek.kt"]
functionPattern: '^([a-z$][a-zA-Z$0-9]*)|(`.*`)$'
excludeClassPattern: '$^'
ignoreOverridden: true
FunctionParameterNaming:
active: true
excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt"
excludes: ["**/test/**", "**/androidTest/**", "**/*.Test.kt", "**/*.Spec.kt", "**/*.Spek.kt"]
parameterPattern: '[a-z][A-Za-z0-9]*'
excludeClassPattern: '$^'
ignoreOverridden: true
InvalidPackageDeclaration:
active: false
rootPackage: ''
Expand All @@ -344,55 +346,52 @@ naming:
ignoreOverridden: true
ObjectPropertyNaming:
active: true
excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt"
excludes: ["**/test/**", "**/androidTest/**", "**/*.Test.kt", "**/*.Spec.kt", "**/*.Spek.kt"]
constantPattern: '[A-Za-z][_A-Za-z0-9]*'
propertyPattern: '[A-Za-z][_A-Za-z0-9]*'
privatePropertyPattern: '(_)?[A-Za-z][_A-Za-z0-9]*'
PackageNaming:
active: true
excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt"
excludes: ["**/test/**", "**/androidTest/**", "**/*.Test.kt", "**/*.Spec.kt", "**/*.Spek.kt"]
packagePattern: '^[a-z]+(\.[a-z][A-Za-z0-9]*)*$'
TopLevelPropertyNaming:
active: true
excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt"
excludes: ["**/test/**", "**/androidTest/**", "**/*.Test.kt", "**/*.Spec.kt", "**/*.Spek.kt"]
constantPattern: '[A-Z][_A-Z0-9]*'
propertyPattern: '[A-Za-z][_A-Za-z0-9]*'
privatePropertyPattern: '_?[A-Za-z][_A-Za-z0-9]*'
VariableMaxLength:
active: false
excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt"
excludes: ["**/test/**", "**/androidTest/**", "**/*.Test.kt", "**/*.Spec.kt", "**/*.Spek.kt"]
maximumVariableNameLength: 64
VariableMinLength:
active: false
excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt"
excludes: ["**/test/**", "**/androidTest/**", "**/*.Test.kt", "**/*.Spec.kt", "**/*.Spek.kt"]
minimumVariableNameLength: 1
VariableNaming:
active: true
excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt"
excludes: ["**/test/**", "**/androidTest/**", "**/*.Test.kt", "**/*.Spec.kt", "**/*.Spek.kt"]
variablePattern: '[a-z][A-Za-z0-9]*'
privateVariablePattern: '(_)?[a-z][A-Za-z0-9]*'
excludeClassPattern: '$^'
ignoreOverridden: true

performance:
active: true
ArrayPrimitive:
active: false
ForEachOnRange:
active: true
excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt"
excludes: ["**/test/**", "**/androidTest/**", "**/*.Test.kt", "**/*.Spec.kt", "**/*.Spek.kt"]
SpreadOperator:
active: true
excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt"
excludes: ["**/test/**", "**/androidTest/**", "**/*.Test.kt", "**/*.Spec.kt", "**/*.Spek.kt"]
UnnecessaryTemporaryInstantiation:
active: true

potential-bugs:
active: true
Deprecation:
active: false
DuplicateCaseInWhenExpression:
active: true
EqualsAlwaysReturnsTrueOrFalse:
active: false
EqualsWithHashCodeExist:
Expand All @@ -409,13 +408,9 @@ potential-bugs:
active: false
LateinitUsage:
active: false
excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt"
excludes: ["**/test/**", "**/androidTest/**", "**/*.Test.kt", "**/*.Spec.kt", "**/*.Spek.kt"]
ignoreAnnotated: []
ignoreOnClassesPattern: ""
MissingWhenCase:
active: false
RedundantElseInWhen:
active: false
UnconditionalJumpStatementInLoop:
active: false
UnreachableCode:
Expand All @@ -435,7 +430,7 @@ style:
active: false
DataClassContainsFunctions:
active: false
conversionFunctionPrefix: 'to'
conversionFunctionPrefix: ['to']
DataClassShouldBeImmutable:
active: false
EqualsNullCall:
Expand All @@ -449,11 +444,11 @@ style:
includeLineWrapping: false
ForbiddenComment:
active: true
values: 'TODO:,FIXME:,STOPSHIP:'
comments: ['TODO:', 'FIXME:', 'STOPSHIP:']
allowedPatterns: ""
ForbiddenImport:
active: false
imports: ''
imports: []
forbiddenPatterns: ""
ForbiddenVoid:
active: false
Expand All @@ -462,17 +457,15 @@ style:
FunctionOnlyReturningConstant:
active: false
ignoreOverridableFunction: true
excludedFunctions: 'describeContents'
excludedFunctions: ['describeContents']
ignoreAnnotated: ["dagger.Provides"]
LibraryCodeMustSpecifyReturnType:
active: false
LoopWithTooManyJumpStatements:
active: false
maxJumpCount: 1
MagicNumber:
active: true
excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt"
ignoreNumbers: '-1,0,1,2'
excludes: ["**/test/**", "**/androidTest/**", "**/*.Test.kt", "**/*.Spec.kt", "**/*.Spek.kt"]
ignoreNumbers: ['-1', '0', '1', '2']
ignoreHashCodeFunction: true
ignorePropertyDeclaration: false
ignoreConstantDeclaration: true
Expand All @@ -481,8 +474,6 @@ style:
ignoreNamedArgument: true
ignoreEnums: false
ignoreRanges: false
MandatoryBracesIfStatements:
active: false
MaxLineLength:
active: true
maxLineLength: 135
Expand All @@ -503,8 +494,6 @@ style:
active: true
OptionalUnit:
active: false
OptionalWhenBraces:
active: false
PreferToOverPairSyntax:
active: false
ProtectedMemberInFinalClass:
Expand All @@ -516,7 +505,7 @@ style:
ReturnCount:
active: true
max: 2
excludedFunctions: "equals"
excludedFunctions: ["equals"]
excludeLabeled: false
excludeReturnFromLambda: true
excludeGuardClauses: false
Expand Down Expand Up @@ -574,5 +563,5 @@ style:
active: false
WildcardImport:
active: false
excludes: "**/test/**,**/androidTest/**,**/*.Test.kt,**/*.Spec.kt,**/*.Spek.kt"
excludeImports: 'java.util.*,kotlinx.android.synthetic.*'
excludes: ["**/test/**", "**/androidTest/**", "**/*.Test.kt", "**/*.Spec.kt", "**/*.Spek.kt"]
excludeImports: ['java.util.*', 'kotlinx.android.synthetic.*']
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
package main.kotlin

import io.javalin.Javalin
import kalkulierbar.*
import kalkulierbar.ApiMisuseException
import kalkulierbar.Calculus
import kalkulierbar.KBAR_DEFAULT_PORT
import kalkulierbar.KalkulierbarException
import kalkulierbar.ScoredCalculus
import kalkulierbar.Scores
import kalkulierbar.dpll.DPLL
import kalkulierbar.nonclausaltableaux.NonClausalTableaux
import kalkulierbar.resolution.FirstOrderResolution
Expand Down Expand Up @@ -32,13 +37,15 @@ val endpoints: Set<Calculus> = setOf<Calculus>(

fun main(args: Array<String>) {
// Verify that all calculus implementations have unique names
if (endpoints.size != endpoints.map { it.identifier }.distinct().size)
if (endpoints.size != endpoints.map { it.identifier }.distinct().size) {
throw KalkulierbarException("Set of active calculus implementations contains duplicate identifiers")

}
// Verify that no calculus is overriding /admin and /config endpoints
if (endpoints.any { it.identifier == "admin" || it.identifier == "config" || it.identifier == "stats" })
throw KalkulierbarException("Set of active calculi contains forbidden identifiers \"admin\", \"config\" or \"stats\"")

if (endpoints.any { it.identifier == "admin" || it.identifier == "config" || it.identifier == "stats" }) {
throw KalkulierbarException(
"Set of active calculi contains forbidden identifiers \"admin\", \"config\" or \"stats\""
)
}
// Pass list of available calculi to StateKeeper
StateKeeper.importAvailable(endpoints.map { it.identifier })

Expand Down Expand Up @@ -227,10 +234,11 @@ fun createCalculusEndpoints(app: Javalin, calculus: Calculus) {
fun getParam(map: Map<String, List<String>>, key: String, optional: Boolean = false): String? {
val lst = map[key]

if (lst == null && !optional)
if (lst == null && !optional) {
throw ApiMisuseException("POST parameter '$key' needs to be present")
else if (lst == null)
} else if (lst == null) {
return null
}

return lst[0]
}
Loading

0 comments on commit e0abe7e

Please sign in to comment.