Skip to content
This repository has been archived by the owner on Jan 5, 2023. It is now read-only.

Commit

Permalink
Fix line count issue.
Browse files Browse the repository at this point in the history
  • Loading branch information
gchallen committed Jan 24, 2022
1 parent eb5f379 commit 480d53b
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 9 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ plugins {
}
subprojects {
group = "com.github.cs125-illinois.questioner"
version = "2022.1.3"
version = "2022.1.4"
tasks.withType<KotlinCompile> {
kotlinOptions {
jvmTarget = JavaVersion.VERSION_16.toString()
Expand Down
2 changes: 1 addition & 1 deletion lib/src/main/kotlin/Question.kt
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ data class Question(
val importWhitelist: Set<String>,
val importBlacklist: Set<String>,
val slug: String,
val kotlinSolution: FlatFile? = alternativeSolutions.find { it.language == Language.kotlin },
val kotlinSolution: FlatFile?,
val detemplatedJavaStarter: String? = incorrect.find { it.language == Language.java && it.starter }?.contents,
val detemplatedKotlinStarter: String? = incorrect.find { it.language == Language.kotlin && it.starter }?.contents,
val hasKotlin: Boolean =
Expand Down
6 changes: 1 addition & 5 deletions lib/src/main/kotlin/QuestionHelpers.kt
Original file line number Diff line number Diff line change
Expand Up @@ -299,11 +299,7 @@ fun Question.computeComplexity(contents: String, language: Question.Language): T
}

fun Question.computeLineCounts(contents: String, language: Question.Language): TestResults.LineCountComparison {
val solutionLineCount = if (language == Question.Language.java) {
correct.lineCount
} else {
alternativeSolutions.filter { it.language == language }.mapNotNull { it.lineCount }.minByOrNull { it.source }
}
val solutionLineCount = published.lineCounts[language]
check(solutionLineCount != null) { "Solution line count not available" }
val type = when (language) {
Question.Language.java -> Source.FileType.JAVA
Expand Down
3 changes: 2 additions & 1 deletion plugin/src/main/kotlin/save/SaveQuestions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,8 @@ fun List<ParsedJavaFile>.findQuestions(
kotlinTemplate,
solution.whitelist.toSet(),
solution.blacklist.toSet(),
solution.correct.path ?: slugify.slugify(solution.correct.name)
solution.correct.path ?: slugify.slugify(solution.correct.name),
kotlinSolution?.toAlternateFile(kotlinCleanSpec)
)
} catch (e: Exception) {
throw Exception("Process ${solution.path} failed: $e", e)
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version=2022.1.3
version=2022.1.4

0 comments on commit 480d53b

Please sign in to comment.