Skip to content
Permalink
Browse files

Issue #38: detekt is configured to only run on 'fretboard' module

Closes #38: detekt is configured to only run on 'fretboard' module
  • Loading branch information...
fercarcedo committed Jun 21, 2018
1 parent 0c4ce5d commit d5ebdda10e04d5429adcb0952d2838e38b7d8f89
@@ -40,7 +40,7 @@ plugins {
detekt {
version = "1.0.0.RC7"
defaultProfile {
input = "$projectDir/fretboard"
input = "$projectDir"
config = "$projectDir/config/detekt.yml"
filters = ".*test.*,.*/resources/.*,.*/tmp/.*"
output = "$projectDir/build/reports/detekt"
@@ -22,7 +22,7 @@ internal class HttpURLConnectionHttpClient : HttpClient {
headers?.forEach { urlConnection.setRequestProperty(it.key, it.value) }

val responseCode = urlConnection.responseCode
if (responseCode !in 200..299)
if (responseCode !in HTTP_OK_START..HTTP_OK_END)
throw ExperimentDownloadException("Status code: $responseCode")

return urlConnection.inputStream.bufferedReader().use { it.readText() }
@@ -32,4 +32,9 @@ internal class HttpURLConnectionHttpClient : HttpClient {
urlConnection?.disconnect()
}
}
}

companion object {
private const val HTTP_OK_START = 200
private const val HTTP_OK_END = 299
}
}
@@ -43,4 +43,4 @@ internal class KintoClient(
}

private fun recordsUrl() = "$baseUrl/buckets/$bucketName/collections/$collectionName/records"
}
}
@@ -76,10 +76,8 @@ class KintoExperimentSource(
var maxLastModified: Long = -1
for (experiment in experiments) {
val lastModified = experiment.lastModified
if (lastModified != null) {
if (lastModified > maxLastModified) {
maxLastModified = lastModified
}
if (lastModified != null && lastModified > maxLastModified) {
maxLastModified = lastModified
}
}
return if (maxLastModified > 0) maxLastModified else null
@@ -90,4 +88,4 @@ class KintoExperimentSource(
private const val DATA_KEY = "data"
private const val DELETED_KEY = "deleted"
}
}
}
@@ -38,4 +38,4 @@ class JobSchedulerSyncScheduler(context: Context) {
.build()
jobScheduler.schedule(jobInfo)
}
}
}
@@ -37,4 +37,4 @@ abstract class SyncJob : JobService() {
* @return current Fretboard instance
*/
abstract fun getFretboard(): Fretboard
}
}
@@ -33,6 +33,11 @@ class AtomicFileExperimentStorageTest {
AtomicFileExperimentStorage(atomicFile).save(experiments)
assertTrue(atomicFile.baseFile.exists())
val experimentsJson = JSONObject(String(atomicFile.readFully()))
checkSavedExperimentsJson(experimentsJson)
atomicFile.delete()
}

private fun checkSavedExperimentsJson(experimentsJson: JSONObject) {
assertEquals(1, experimentsJson.length())
val experimentsJsonArray = experimentsJson.getJSONArray("experiments")
assertEquals(1, experimentsJsonArray.length())
@@ -50,7 +55,6 @@ class AtomicFileExperimentStorageTest {
assertEquals("sample-description", experimentJson.getString("description"))
assertEquals("sample-id", experimentJson.getString("id"))
assertEquals(1526991669, experimentJson.getLong("last_modified"))
atomicFile.delete()
}

@Test
@@ -78,4 +82,4 @@ class AtomicFileExperimentStorageTest {
val experiments = AtomicFileExperimentStorage(AtomicFile(file)).retrieve()
assertEquals(0, experiments.size)
}
}
}
@@ -25,4 +25,4 @@ class AtomicFileExperimentStorage(private val atomicFile: AtomicFile) : Experime
it.append(experimentsJson)
}
}
}
}
@@ -51,4 +51,4 @@ internal class ExperimentsSerializer {
companion object {
private const val EXPERIMENTS_KEY = "experiments"
}
}
}

0 comments on commit d5ebdda

Please sign in to comment.
You can’t perform that action at this time.