Skip to content

Commit

Permalink
Merge pull request #24 from DanielRendox/codebase-linting-refactor
Browse files Browse the repository at this point in the history
Refactor the codebase to resolve lint issues
  • Loading branch information
DanielRendox authored Jul 2, 2024
2 parents 386579d + f19450e commit 46e6e49
Show file tree
Hide file tree
Showing 179 changed files with 1,291 additions and 1,818 deletions.
40 changes: 4 additions & 36 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
indent_size = 4
indent_style = space
insert_final_newline = false
max_line_length = 140
max_line_length = 120

ij_kotlin_allow_trailing_comma = true
ij_kotlin_allow_trailing_comma_on_call_site = true
ij_kotlin_imports_layout = *, ^
ij_kotlin_imports_layout = *
ij_kotlin_packages_to_use_import_on_demand = java.util.*
ij_kotlin_name_count_to_use_star_import = 2147483647
ij_kotlin_name_count_to_use_star_import_for_members = 2147483647
Expand All @@ -17,37 +17,5 @@ ktlint_code_style = android_studio

# disable ktlint_standard_function-naming rule for @Composable functions
ktlint_function_naming_ignore_when_annotated_with = Composable

ktlint_function_signature_rule_force_multiline_when_parameter_count_greater_or_equal_than = 3

ktlint_standard_function-signature = disabled
ktlint_standard_import-ordering = disabled
ktlint_standard_class-signature = disabled
ktlint_standard_function-expression-body = disabled
ktlint_standard_trailing-comma-on-call-site = disabled
ktlint_standard_trailing-comma-on-declaration-site = disabled
ktlint_standard_package-name = disabled
ktlint_standard_final-newline = disabled
ktlint_standard_no-trailing-spaces = disabled
ktlint_standard_no-multi-spaces = disabled
ktlint_standard_argument-list-wrapping = disabled
ktlint_standard_multiline-if-else = disabled
ktlint_standard_no-consecutive-blank-lines = disabled
ktlint_standard_max-line-length = disabled
ktlint_standard_no-semi = disabled
ktlint_standard_chain-wrapping = disabled
ktlint_standard_paren-spacing = disabled
ktlint_standard_colon-spacing = disabled
ktlint_standard_parameter-list-wrapping = disabled
ktlint_standard_indent = disabled
ktlint_standard_condition-wrapping = disabled
ktlint_standard_block-comment-initial-star-alignment = disabled
ktlint_standard_no-empty-first-line-in-method-block = disabled
ktlint_standard_curly-spacing = disabled
ktlint_standard_backing-property-naming = disabled
ktlint_standard_property-naming = disabled
ktlint_standard_parameter-list-spacing = disabled
ktlint_standard_wrapping = disabled
ktlint_standard_binary-expression-wrapping = disabled
ktlint_standard_no-blank-line-before-rbrace = disabled
ktlint_standard_keyword-spacing = disabled
ktlint_function_signature_rule_force_multiline_when_parameter_count_greater_or_equal_than = 2
ktlint_class_signature_rule_force_multiline_when_parameter_count_greater_or_equal_than = 1
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<h1 align="center" style="font-size:28px; line-height:1"><b>Routine Tracker</b></h1>
<h1 style="font-size:28px; line-height:1; text-align:center;"><b>Routine Tracker</b></h1>

<div align="center">
<img alt="Routine Tracker logo" src="images/app_logo.svg" height="150px">
Expand Down
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ dependencies {
implementation(project(":core:ui"))
implementation(project(":core:domain"))
implementation(project(":core:logic"))
implementation(project(":feature:addeditroutine"))

implementation(project(":feature:add_edit_routine"))
implementation(project(":feature:agenda"))
implementation(project(":feature:routine_details"))
implementation(project(":feature:routinedetails"))

testImplementation(project(":core:testcommon"))

Expand Down
2 changes: 0 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
<application
android:name=".RoutineTrackerApp"
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
import androidx.core.view.WindowCompat
import com.rendox.routinetracker.app.navigation.RoutineTrackerNavHost
import com.rendox.routinetracker.core.ui.theme.RoutineTrackerTheme
import com.rendox.routinetracker.feature.agenda.navigation.agendaNavRoute
import com.rendox.routinetracker.feature.agenda.navigation.AGENDA_NAV_ROUTE

class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
Expand All @@ -34,7 +34,7 @@ class MainActivity : ComponentActivity() {
) {
RoutineTrackerNavHost(
modifier = Modifier.fillMaxSize(),
startDestination = agendaNavRoute,
startDestination = AGENDA_NAV_ROUTE,
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@ import com.rendox.routinetracker.core.domain.di.domainModule
import com.rendox.routinetracker.core.domain.di.habitDomainModule
import com.rendox.routinetracker.core.domain.di.streakDomainModule
import com.rendox.routinetracker.feature.agenda.di.agendaScreenModule
import com.rendox.routinetracker.routine_details.di.routineDetailsModule
import com.rendox.routinetracker.routinedetails.di.routineDetailsModule
import kotlin.coroutines.CoroutineContext
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.SupervisorJob
import kotlinx.coroutines.launch
import org.koin.android.ext.android.inject
import org.koin.android.ext.koin.androidContext
import org.koin.core.context.startKoin
import org.koin.core.qualifier.named
import kotlin.coroutines.CoroutineContext

class RoutineTrackerApp: Application() {
class RoutineTrackerApp : Application() {
private val ioDispatcher by inject<CoroutineContext>(qualifier = named("ioDispatcher"))
private val applicationScope = CoroutineScope(SupervisorJob())
private val databasePrepopulator by inject<DatabasePrepopulator>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.rememberNavController
import com.rendox.routinetracker.add_edit_routine.navigation.addRoutineScreen
import com.rendox.routinetracker.add_edit_routine.navigation.navigateToAddRoutine
import com.rendox.routinetracker.feature.agenda.navigation.agendaNavRoute
import com.rendox.routinetracker.addeditroutine.navigation.addRoutineScreen
import com.rendox.routinetracker.addeditroutine.navigation.navigateToAddRoutine
import com.rendox.routinetracker.feature.agenda.navigation.AGENDA_NAV_ROUTE
import com.rendox.routinetracker.feature.agenda.navigation.agendaScreen
import com.rendox.routinetracker.feature.agenda.navigation.navigateToAgenda
import com.rendox.routinetracker.routine_details.navigation.navigateToRoutineDetails
import com.rendox.routinetracker.routine_details.navigation.routineDetailsScreen
import com.rendox.routinetracker.routinedetails.navigation.navigateToRoutineDetails
import com.rendox.routinetracker.routinedetails.navigation.routineDetailsScreen

@Composable
fun RoutineTrackerNavHost(
Expand All @@ -26,12 +26,12 @@ fun RoutineTrackerNavHost(
addRoutineScreen(
navigateBackAndRecreate = {
navController.navigateToAgenda {
popUpTo(route = agendaNavRoute) { inclusive = true }
popUpTo(route = AGENDA_NAV_ROUTE) { inclusive = true }
}
},
navigateBack = {
navController.navigateUp()
}
},
)
agendaScreen(
onRoutineClick = {
Expand All @@ -41,12 +41,12 @@ fun RoutineTrackerNavHost(
},
onAddRoutineClick = { navController.navigateToAddRoutine() },
)
routineDetailsScreen (
routineDetailsScreen(
popBackStack = {
navController.navigateToAgenda {
popUpTo(route = agendaNavRoute) { inclusive = true }
popUpTo(route = AGENDA_NAV_ROUTE) { inclusive = true }
}
}
},
)
}
}
13 changes: 0 additions & 13 deletions app/src/main/res/xml/backup_rules.xml

This file was deleted.

19 changes: 0 additions & 19 deletions app/src/main/res/xml/data_extraction_rules.xml

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.rendox.routinetracker.core.data

import com.rendox.routinetracker.core.database.completion_history.CompletionHistoryLocalDataSource
import com.rendox.routinetracker.core.database.completionhistory.CompletionHistoryLocalDataSource
import com.rendox.routinetracker.core.database.habit.HabitLocalDataSource
import com.rendox.routinetracker.core.database.vacation.VacationLocalDataSource

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import com.rendox.routinetracker.core.logic.time.today
import com.rendox.routinetracker.core.model.Habit
import com.rendox.routinetracker.core.model.Schedule
import com.rendox.routinetracker.core.model.Vacation
import kotlinx.datetime.DayOfWeek
import kotlinx.datetime.LocalDate
import kotlinx.datetime.daysUntil
import kotlin.math.roundToInt
import kotlin.random.Random
import kotlin.random.nextInt
import kotlinx.datetime.DayOfWeek
import kotlinx.datetime.LocalDate
import kotlinx.datetime.daysUntil

class RandomHabitsGenerator(
private val numOfHabits: Int,
Expand Down Expand Up @@ -82,39 +82,49 @@ class RandomHabitsGenerator(
val scheduleTypeIndex = Random.nextInt(6)
val startDate = startDateRange.random()
if (scheduleTypeIndex == 0) return Schedule.EveryDaySchedule(startDate = startDate)
if (scheduleTypeIndex == 1) return Schedule.WeeklyScheduleByNumOfDueDays(
startDate = startDate,
numOfDueDays = Random.nextInt(1..6),
)
if (scheduleTypeIndex == 2) return Schedule.MonthlyScheduleByNumOfDueDays(
startDate = startDate,
numOfDueDays = Random.nextInt(1..30),
)
if (scheduleTypeIndex == 1) {
return Schedule.WeeklyScheduleByNumOfDueDays(
startDate = startDate,
numOfDueDays = Random.nextInt(1..6),
)
}
if (scheduleTypeIndex == 2) {
return Schedule.MonthlyScheduleByNumOfDueDays(
startDate = startDate,
numOfDueDays = Random.nextInt(1..30),
)
}
val backlogEnabled = Random.nextBoolean()
val completingAheadEnabled = Random.nextBoolean()
if (scheduleTypeIndex == 3) return Schedule.WeeklyScheduleByDueDaysOfWeek(
startDate = startDate,
dueDaysOfWeek = DayOfWeek.entries.shuffled().take(Random.nextInt(1..6)),
backlogEnabled = backlogEnabled,
completingAheadEnabled = completingAheadEnabled,
)
if (scheduleTypeIndex == 4) return Schedule.MonthlyScheduleByDueDatesIndices(
startDate = startDate,
dueDatesIndices = (1..31).shuffled().take(Random.nextInt(1..30)),
includeLastDayOfMonth = Random.nextBoolean(),
backlogEnabled = backlogEnabled,
completingAheadEnabled = completingAheadEnabled,
)
if (scheduleTypeIndex == 3) {
return Schedule.WeeklyScheduleByDueDaysOfWeek(
startDate = startDate,
dueDaysOfWeek = DayOfWeek.entries.shuffled().take(Random.nextInt(1..6)),
backlogEnabled = backlogEnabled,
completingAheadEnabled = completingAheadEnabled,
)
}
if (scheduleTypeIndex == 4) {
return Schedule.MonthlyScheduleByDueDatesIndices(
startDate = startDate,
dueDatesIndices = (1..31).shuffled().take(Random.nextInt(1..30)),
includeLastDayOfMonth = Random.nextBoolean(),
backlogEnabled = backlogEnabled,
completingAheadEnabled = completingAheadEnabled,
)
}
val numOfDueDays = Random.nextInt(1..Schedule.AlternateDaysSchedule.MAX_NUM_OF_DUE_DAYS)
val numOfNotDueDays =
Random.nextInt(1..Schedule.AlternateDaysSchedule.MAX_NUM_OF_NOT_DUE_DAYS)
if (scheduleTypeIndex == 5) return Schedule.AlternateDaysSchedule(
startDate = startDate,
numOfDueDays = numOfDueDays,
numOfDaysInPeriod = numOfDueDays + numOfNotDueDays,
backlogEnabled = backlogEnabled,
completingAheadEnabled = completingAheadEnabled,
)
if (scheduleTypeIndex == 5) {
return Schedule.AlternateDaysSchedule(
startDate = startDate,
numOfDueDays = numOfDueDays,
numOfDaysInPeriod = numOfDueDays + numOfNotDueDays,
backlogEnabled = backlogEnabled,
completingAheadEnabled = completingAheadEnabled,
)
}
throw IllegalStateException("Unknown schedule type index: $scheduleTypeIndex")
}
}

This file was deleted.

This file was deleted.

Loading

0 comments on commit 46e6e49

Please sign in to comment.