Skip to content

Commit

Permalink
detekt
Browse files Browse the repository at this point in the history
  • Loading branch information
alyssaruth committed Feb 13, 2024
1 parent 0d84d59 commit 975e0cb
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
5 changes: 2 additions & 3 deletions src/main/kotlin/dartzee/reporting/ReportingUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ import java.sql.ResultSet
import java.sql.Timestamp
import javax.swing.JCheckBox

fun <T> grabIfSelected(checkbox: JCheckBox, getter: () -> T): T? {
return if (checkbox.isSelected) getter() else null
}
fun <T> grabIfSelected(checkbox: JCheckBox, getter: () -> T) =
if (checkbox.isSelected) getter() else null

fun runReport(rp: ReportParameters?): List<ReportResultWrapper> {
rp ?: return emptyList()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,8 @@ class PlayerParametersPanel : JPanel(), ActionListener {
fun generateParameters(): IncludedPlayerParameters {
val finalScore = grabIfSelected(chckbxFinalScore) { spinner.value as Int }
val finalScoreComparator =
grabIfSelected(chckbxFinalScore) { comboBox.selectedItem as String } ?: ""
val finishingPosition =
grabIfSelected(chckbxPosition) { getFinishingPositions() } ?: emptyList()
grabIfSelected(chckbxFinalScore) { comboBox.selectedItem as String }.orEmpty()
val finishingPosition = grabIfSelected(chckbxPosition) { getFinishingPositions() }.orEmpty()

return IncludedPlayerParameters(finishingPosition, finalScoreComparator, finalScore)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ class ReportingGameTab : JPanel(), ActionListener {

fun generateReportParameters(): ReportParametersGame {
val gameType = grabIfSelected(checkBoxGameType) { comboBox.getGameType() }
val gameParams = grabIfSelected(cbType) { panelGameParams.getGameParams() } ?: ""
val gameParams = grabIfSelected(cbType) { panelGameParams.getGameParams() }.orEmpty()
val dtStartFrom = grabIfSelected(cbStartDate) { dateFilterPanelStart.getSqlDtFrom() }
val dtStartTo = grabIfSelected(cbStartDate) { dateFilterPanelStart.getSqlDtTo() }
val unfinishedOnly = grabIfSelected(cbFinishDate) { rdbtnUnfinished.isSelected } ?: false
Expand Down

0 comments on commit 975e0cb

Please sign in to comment.