Skip to content

Commit 2d59c01

Browse files
committed
feat: configure ktlint
1 parent c649400 commit 2d59c01

63 files changed

Lines changed: 2143 additions & 1914 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

app/build.gradle.kts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,13 @@ plugins {
44
id("com.google.devtools.ksp")
55
id("org.jetbrains.kotlin.plugin.compose")
66
id("dagger.hilt.android.plugin")
7+
alias(libs.plugins.ktlint)
78
}
89

9-
10-
10+
ktlint {
11+
android.set(true)
12+
outputToConsole.set(true)
13+
}
1114

1215
android {
1316
namespace = "com.opennotes"
@@ -36,8 +39,8 @@ android {
3639
isMinifyEnabled = true
3740
isShrinkResources = true
3841
proguardFiles(
39-
getDefaultProguardFile("proguard-android-optimize.txt"),
40-
"proguard-rules.pro"
42+
getDefaultProguardFile("proguard-android-optimize.txt"),
43+
"proguard-rules.pro",
4144
)
4245
}
4346
}

app/src/androidTest/java/com/opennotes/ExampleInstrumentedTest.kt

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
package com.opennotes
22

3-
import androidx.test.platform.app.InstrumentationRegistry
43
import androidx.test.ext.junit.runners.AndroidJUnit4
5-
4+
import androidx.test.platform.app.InstrumentationRegistry
5+
import org.junit.Assert.assertEquals
66
import org.junit.Test
77
import org.junit.runner.RunWith
88

9-
import org.junit.Assert.*
10-
119
/**
1210
* Instrumented test, which will execute on an Android device.
1311
*
@@ -21,4 +19,4 @@ class ExampleInstrumentedTest {
2119
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
2220
assertEquals("com.plcoding.cleanarchitecturenoteapp", appContext.packageName)
2321
}
24-
}
22+
}

app/src/main/java/com/opennotes/OpenNotes.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,5 @@ package com.opennotes
2121
import android.app.Application
2222
import dagger.hilt.android.HiltAndroidApp
2323

24-
2524
@HiltAndroidApp
26-
class OpenNotes: Application()
25+
class OpenNotes : Application()

app/src/main/java/com/opennotes/di/AppModule.kt

Lines changed: 17 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
package com.opennotes.di
2020

2121
import android.app.Application
22-
22+
import androidx.room.Room
2323
import com.opennotes.feature_node.data.data_source.NoteDatabase
2424
import com.opennotes.feature_node.data.repository.AndroidFileHandler
2525
import com.opennotes.feature_node.data.repository.FileHandler
@@ -31,7 +31,6 @@ import com.opennotes.feature_node.domain.use_case.AddNote
3131
import com.opennotes.feature_node.domain.use_case.DeleteNote
3232
import com.opennotes.feature_node.domain.use_case.ExportUseCases
3333
import com.opennotes.feature_node.domain.use_case.GetNote
34-
import androidx.room.Room
3534
import com.opennotes.feature_node.domain.use_case.GetNotes
3635
import com.opennotes.feature_node.domain.use_case.ImportUseCases
3736
import com.opennotes.feature_node.domain.use_case.NoteUseCases
@@ -45,54 +44,44 @@ import javax.inject.Singleton
4544
@Module
4645
@InstallIn(SingletonComponent::class)
4746
object AppModule {
48-
4947
@Provides
5048
@Singleton
51-
fun provideNoteDataBase(app: Application): NoteDatabase {
52-
return Room.databaseBuilder(
53-
app,
54-
NoteDatabase::class.java,
55-
NoteDatabase.DATABASE_NAME
56-
).build()
57-
}
49+
fun provideNoteDataBase(app: Application): NoteDatabase =
50+
Room
51+
.databaseBuilder(
52+
app,
53+
NoteDatabase::class.java,
54+
NoteDatabase.DATABASE_NAME,
55+
).build()
5856

5957
@Provides
6058
@Singleton
61-
fun provideNoteRepository(db: NoteDatabase): NoteRepository {
62-
return NoteRepositoryImpl(db.noteDao)
63-
}
59+
fun provideNoteRepository(db: NoteDatabase): NoteRepository = NoteRepositoryImpl(db.noteDao)
6460

6561
// NEW: Provides the FileHandler implementation
6662
@Provides
6763
@Singleton
68-
fun provideFileHandler(app: Application): FileHandler {
69-
return AndroidFileHandler(app)
70-
}
64+
fun provideFileHandler(app: Application): FileHandler = AndroidFileHandler(app)
7165

7266
// CORRECTED: Provides the concrete GsonJsonHandler implementation
7367
@Provides
7468
@Singleton
75-
fun provideJsonHandler(): JsonHandler {
76-
return GsonJsonHandler()
77-
}
78-
69+
fun provideJsonHandler(): JsonHandler = GsonJsonHandler()
7970

8071
@Provides
8172
@Singleton
8273
fun provideNoteUseCaseId(
8374
repository: NoteRepository,
8475
jsonHandler: JsonHandler,
85-
fileHandler: FileHandler
86-
): NoteUseCases {
87-
return NoteUseCases(
88-
76+
fileHandler: FileHandler,
77+
): NoteUseCases =
78+
NoteUseCases(
8979
deleteNote = DeleteNote(repository),
9080
addNote = AddNote(repository),
9181
getNote = GetNote(repository),
9282
getNotes = GetNotes(repository),
9383
searchNotes = SearchNotesUseCase(repository),
94-
importNotes = ImportUseCases(repository, fileHandler,jsonHandler),
95-
exportNotes = ExportUseCases(repository, fileHandler,jsonHandler)
84+
importNotes = ImportUseCases(repository, fileHandler, jsonHandler),
85+
exportNotes = ExportUseCases(repository, fileHandler, jsonHandler),
9686
)
97-
}
98-
}
87+
}

app/src/main/java/com/opennotes/di/DataModule.kt

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,15 @@ private val Context.dataStore: DataStore<Preferences> by preferencesDataStore(na
3535
@Module
3636
@InstallIn(SingletonComponent::class)
3737
object DataModule {
38-
3938
@Provides
4039
@Singleton
41-
fun provideDataStore(@ApplicationContext context: Context): DataStore<Preferences> {
42-
return context.dataStore
43-
}
40+
fun provideDataStore(
41+
@ApplicationContext context: Context,
42+
): DataStore<Preferences> = context.dataStore
4443

4544
@Provides
4645
@Singleton
4746
fun provideDataStoreRepository(
48-
dataStore: DataStore<Preferences> // Changed this line
47+
dataStore: DataStore<Preferences>, // Changed this line
4948
): DataStoreRepository = DataStoreRepository(dataStore) // And this line
50-
}
49+
}

app/src/main/java/com/opennotes/feature_node/data/data_source/NoteDao.kt

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ import kotlinx.coroutines.flow.Flow
2929
@Dao
3030
interface NoteDao {
3131
@Query(value = "SELECT * FROM note")
32-
fun getNotes():Flow<List<Note>>
32+
fun getNotes(): Flow<List<Note>>
3333

3434
@Query(value = "SELECT * FROM note WHERE id=:id")
35-
suspend fun getNoteById(id:Int): Note?
35+
suspend fun getNoteById(id: Int): Note?
3636

37-
@Insert(onConflict=OnConflictStrategy.REPLACE)
37+
@Insert(onConflict = OnConflictStrategy.REPLACE)
3838
suspend fun insertNote(note: Note)
3939

4040
@Delete
@@ -43,9 +43,6 @@ interface NoteDao {
4343
@Query("SELECT * FROM note WHERE title LIKE '%' || :query || '%' OR content LIKE '%' || :query || '%'")
4444
fun searchNotes(query: String): Flow<List<Note>>
4545

46-
47-
@Insert(onConflict=OnConflictStrategy.REPLACE)
48-
suspend fun insertAll(notes:List<Note>)
49-
50-
51-
}
46+
@Insert(onConflict = OnConflictStrategy.REPLACE)
47+
suspend fun insertAll(notes: List<Note>)
48+
}

app/src/main/java/com/opennotes/feature_node/data/data_source/NoteDatabase.kt

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,14 @@ import androidx.room.Database
2222
import androidx.room.RoomDatabase
2323
import com.opennotes.feature_node.domain.model.Note
2424

25-
2625
@Database(
27-
entities=[Note::class],
28-
version=2
26+
entities = [Note::class],
27+
version = 2,
2928
)
30-
abstract class NoteDatabase :RoomDatabase(){
31-
abstract val noteDao: NoteDao
29+
abstract class NoteDatabase : RoomDatabase() {
30+
abstract val noteDao: NoteDao
3231

33-
companion object{
34-
const val DATABASE_NAME="notes_db"
35-
}
36-
}
32+
companion object {
33+
const val DATABASE_NAME = "notes_db"
34+
}
35+
}

0 commit comments

Comments
 (0)