Skip to content

Commit

Permalink
Fixed various Lints (ChuckerTeam#268)
Browse files Browse the repository at this point in the history
* fixed typos
* fixed KDocs
  • Loading branch information
hitanshu-dhawan authored Mar 9, 2020
1 parent 726412a commit 4b43559
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import com.chuckerteam.chucker.internal.support.NotificationHelper
* @param context An Android Context
* @param showNotification Control whether a notification is shown while HTTP activity
* is recorded.
* @param retentionManager Set the retention period for HTTP transaction data captured
* @param retentionPeriod Set the retention period for HTTP transaction data captured
* by this collector. The default is one week.
*/
class ChuckerCollector @JvmOverloads constructor(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.chuckerteam.chucker.api
import android.content.Context
import com.chuckerteam.chucker.internal.data.entity.HttpTransaction
import com.chuckerteam.chucker.internal.support.IOUtils
import com.chuckerteam.chucker.internal.support.contentLenght
import com.chuckerteam.chucker.internal.support.contentLength
import com.chuckerteam.chucker.internal.support.contentType
import com.chuckerteam.chucker.internal.support.isGzipped
import java.io.IOException
Expand Down Expand Up @@ -129,7 +129,7 @@ class ChuckerInterceptor @JvmOverloads constructor(
}

responseContentType = response.contentType
responseContentLength = response.contentLenght
responseContentLength = response.contentLength

tookMs = (response.receivedResponseAtMillis() - response.sentRequestAtMillis())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,38 +12,38 @@ internal class HttpTransactionDatabaseRepository(private val database: ChuckerDa

private val executor: Executor = Executors.newSingleThreadExecutor()

private val transcationDao get() = database.transactionDao()
private val transactionDao get() = database.transactionDao()

override fun getFilteredTransactionTuples(code: String, path: String): LiveData<List<HttpTransactionTuple>> {
val pathQuery = if (path.isNotEmpty()) "%$path%" else "%"
return transcationDao.getFilteredTuples("$code%", pathQuery)
return transactionDao.getFilteredTuples("$code%", pathQuery)
}

override fun getTransaction(transactionId: Long): LiveData<HttpTransaction?> {
return transcationDao.getById(transactionId)
return transactionDao.getById(transactionId)
.distinctUntilChanged { old, new -> old?.hasTheSameContent(new) != false }
}

override fun getSortedTransactionTuples(): LiveData<List<HttpTransactionTuple>> {
return transcationDao.getSortedTuples()
return transactionDao.getSortedTuples()
}

override fun deleteAllTransactions() {
executor.execute { transcationDao.deleteAll() }
executor.execute { transactionDao.deleteAll() }
}

override fun insertTransaction(transaction: HttpTransaction) {
executor.execute {
val id = transcationDao.insert(transaction)
val id = transactionDao.insert(transaction)
transaction.id = id ?: 0
}
}

override fun updateTransaction(transaction: HttpTransaction): Int {
return transcationDao.update(transaction)
return transactionDao.update(transaction)
}

override fun deleteOldTransactions(threshold: Long) {
executor.execute { transcationDao.deleteBefore(threshold) }
executor.execute { transactionDao.deleteBefore(threshold) }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import com.chuckerteam.chucker.internal.data.entity.RecordedThrowableTuple

/**
* Repository Interface representing all the operations that are needed to let Chucker work
* with [RecordedThrowable] and [RecordedThrowableTuple]. Please use [ChuckerDatabaseRepository]
* with [RecordedThrowable] and [RecordedThrowableTuple]. Please use [RecordedThrowableDatabaseRepository]
* that uses Room and SqLite to run those operations.
*/
internal interface RecordedThrowableRepository {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import com.chuckerteam.chucker.internal.data.repository.RepositoryProvider.initi
import com.chuckerteam.chucker.internal.data.room.ChuckerDatabase

/**
* A singleton to hold the [ChuckerRepository] instance. Make sure you call [initialize] before
* accessing the stored instance.
* A singleton to hold the [HttpTransactionRepository] and [RecordedThrowableRepository] instances.
* Make sure you call [initialize] before accessing the stored instance.
*/
internal object RepositoryProvider {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import okhttp3.Headers
import okhttp3.Request
import okhttp3.Response

internal val Response.contentLenght: Long
internal val Response.contentLength: Long
get() {
return this.header("Content-Length")?.toLongOrNull() ?: -1
}
Expand Down
2 changes: 1 addition & 1 deletion library/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:tools="http://schemas.android.com/tools">
<resources>

<style name="Chucker.BaseTheme" parent="Theme.MaterialComponents.DayNight.NoActionBar">
<item name="colorPrimary">@color/chucker_color_primary</item>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class ChuckerInterceptorTest {
private val mockContext = mockk<Context> {
every { getString(any()) } returns ""
}
private val mockCollector = mockk<ChuckerCollector>() {
private val mockCollector = mockk<ChuckerCollector> {
every { onRequestSent(any()) } returns Unit
every { onResponseReceived(any()) } answers {
transaction = args[0] as HttpTransaction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,23 @@ class OkHttpUtilsTest {
val mockResponse = mockk<Response>()
every { mockResponse.header("Content-Length") } returns null

assertThat(mockResponse.contentLenght).isEqualTo(-1)
assertThat(mockResponse.contentLength).isEqualTo(-1)
}

@Test
fun contentLength_withZeroLenght_returnsZero() {
fun contentLength_withZeroLength_returnsZero() {
val mockResponse = mockk<Response>()
every { mockResponse.header("Content-Length") } returns "0"

assertThat(mockResponse.contentLenght).isEqualTo(0L)
assertThat(mockResponse.contentLength).isEqualTo(0L)
}

@Test
fun contentLength_withRealLenght_returnsValue() {
fun contentLength_withRealLength_returnsValue() {
val mockResponse = mockk<Response>()
every { mockResponse.header("Content-Length") } returns "42"

assertThat(mockResponse.contentLenght).isEqualTo(42L)
assertThat(mockResponse.contentLength).isEqualTo(42L)
}

@Test
Expand Down

0 comments on commit 4b43559

Please sign in to comment.