Skip to content

Commit

Permalink
Added ktlint to gradle
Browse files Browse the repository at this point in the history
Formatted code

Added ktlint pipeline for PRs

Changed modifiers

Suppressed custom modifiers

Don't do ktlint in other job
  • Loading branch information
spacecowboy committed Jun 1, 2024
1 parent 1d306a7 commit 300f7ff
Show file tree
Hide file tree
Showing 64 changed files with 679 additions and 1,124 deletions.
3 changes: 2 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ ij_wrap_on_typing = false
max_line_length = 200
ktlint_code_style = ktlint_official
ktlint_function_naming_ignore_when_annotated_with=Composable
twitter_compose_allowed_composition_locals = LocalTypographySettings,LocalDimens,LocalWindowSize,LocalFoldableHinge
compose_allowed_composition_locals = LocalTypographySettings,LocalDI,LocalDimens,LocalWindowSize,LocalFoldableHinge
compose_allowed_forwarding = .*Screen

[{*.ant,*.fxml,*.jhm,*.jnlp,*.jrxml,*.opml,*.rng,*.tld,*.wsdl,*.xml,*.xsd,*.xsl,*.xslt,*.xul,rss_kuketz,rss_morningpaper}]
indent_size = 2
Expand Down
22 changes: 21 additions & 1 deletion .github/workflows/android_pr_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,24 @@ jobs:
- name: gradle build
uses: gradle/gradle-build-action@v2
with:
arguments: build packageDebugAndroidTest :app:lint check
arguments: assemble bundle packageDebugAndroidTest :app:lint test

# Lint
ktlint:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: perform the checkout
uses: actions/checkout@v3

- name: setup JDK
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'

- name: ktlint check
uses: gradle/gradle-build-action@v2
with:
arguments: ktlintCheck
16 changes: 0 additions & 16 deletions .gitlab/issue_templates/Bug.md

This file was deleted.

1 change: 0 additions & 1 deletion .gitlab/issue_templates/Feature.md

This file was deleted.

19 changes: 0 additions & 19 deletions .gitlab/merge_request_templates/patch.md

This file was deleted.

28 changes: 16 additions & 12 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ plugins {
alias(libs.plugins.kotlin.ksp)
alias(libs.plugins.kotlin.parcelize)
alias(libs.plugins.kotlin.serialization)
alias(libs.plugins.ktlint.gradle)
}

android {
Expand Down Expand Up @@ -45,16 +46,16 @@ android {
}
if (project.hasProperty("STORE_FILE")) {
create("release") {
@Suppress("LocalVariableName")
@Suppress("LocalVariableName", "ktlint:standard:property-naming")
val STORE_FILE: String by project.properties

@Suppress("LocalVariableName")
@Suppress("LocalVariableName", "ktlint:standard:property-naming")
val STORE_PASSWORD: String by project.properties

@Suppress("LocalVariableName")
@Suppress("LocalVariableName", "ktlint:standard:property-naming")
val KEY_ALIAS: String by project.properties

@Suppress("LocalVariableName")
@Suppress("LocalVariableName", "ktlint:standard:property-naming")
val KEY_PASSWORD: String by project.properties
storeFile = file(STORE_FILE)
storePassword = STORE_PASSWORD
Expand Down Expand Up @@ -183,14 +184,16 @@ android {
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile::class.java) {
kotlinOptions {
if (project.findProperty("myapp.enableComposeCompilerReports") == "true") {
freeCompilerArgs += listOf(
"-P",
"plugin:androidx.compose.compiler.plugins.kotlin:reportsDestination=${project.buildDir.resolve("compose_metrics").canonicalPath}"
)
freeCompilerArgs += listOf(
"-P",
"plugin:androidx.compose.compiler.plugins.kotlin:metricsDestination=${project.buildDir.resolve("compose_metrics").canonicalPath}"
)
freeCompilerArgs +=
listOf(
"-P",
"plugin:androidx.compose.compiler.plugins.kotlin:reportsDestination=${project.buildDir.resolve("compose_metrics").canonicalPath}",
)
freeCompilerArgs +=
listOf(
"-P",
"plugin:androidx.compose.compiler.plugins.kotlin:metricsDestination=${project.buildDir.resolve("compose_metrics").canonicalPath}",
)
}
}
}
Expand All @@ -202,6 +205,7 @@ configurations.all {
}

dependencies {
ktlintRuleset(libs.ktlint.compose)
ksp(libs.room)
// For java time
coreLibraryDesugaring(libs.desugar)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class Feeds {
* All items are genuine - except the first which is taken from the feed at 2021-10-06T21:06:00
*/
@Language("xml")
const val rssWithDuplicateGuids = """
const val RSS_WITH_DUPLICATE_GUIDS = """
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
<channel>
<title>Weather Warnings for Victoria. Issued by the Australian Bureau of Meteorology</title>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ import com.nononsenseapps.feeder.db.room.ReadStatusSyncedDao
import com.nononsenseapps.feeder.db.room.RemoteReadMarkDao
import com.nononsenseapps.feeder.db.room.SyncRemoteDao
import com.nononsenseapps.feeder.di.networkModule
import com.nononsenseapps.feeder.model.Feeds.Companion.RSS_WITH_DUPLICATE_GUIDS
import com.nononsenseapps.feeder.model.Feeds.Companion.cowboyAtom
import com.nononsenseapps.feeder.model.Feeds.Companion.cowboyJson
import com.nononsenseapps.feeder.model.Feeds.Companion.nixosRss
import com.nononsenseapps.feeder.model.Feeds.Companion.rssWithDuplicateGuids
import com.nononsenseapps.feeder.ui.TestDatabaseRule
import com.nononsenseapps.feeder.util.DoNotUseInProd
import com.nononsenseapps.feeder.util.FilePathProvider
Expand Down Expand Up @@ -210,7 +210,7 @@ class RssLocalSyncKtTest : DIAware {
insertFeed(
"aussieWeather",
server.url("/IDZ00059.warnings_vic.xml").toUrl(),
rssWithDuplicateGuids,
RSS_WITH_DUPLICATE_GUIDS,
isJson = false,
useAlternateId = true,
)
Expand Down Expand Up @@ -686,27 +686,26 @@ class RssLocalSyncKtTest : DIAware {
}

private fun fooRss(itemsCount: Int = 1): String {
val items =
(1..itemsCount).joinToString("\n") {
"""
<item>
<title>Foo Item $it</title>
<link>https://foo.bar/$it</link>
<description>Woop woop $it</description>
</item>
""".trimIndent()
}

return """
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
<channel>
<title>Foo Feed</title>
<link>https://foo.bar</link>
${
(1..itemsCount).map {
"""
<item>
<title>Foo Item $it</title>
<link>https://foo.bar/$it</link>
<description>Woop woop $it</description>
</item>
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
<channel>
<title>Foo Feed</title>
<link>https://foo.bar</link>
$items
</channel>
</rss>
""".trimIndent()
}.fold("") { acc, s ->
"$acc\n$s"
}
}
</channel>
</rss>
""".trimIndent()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class RssNotificationsKtTest {

@Test
fun queryParameterDoesntGetGarbled() {
@Suppress("ktlint:standard:max-line-length")
val magnetLink = "magnet:?xt=urn:btih:82B1726F2D1B22F383A2B2CD6977B00F908FB315&dn=Crazy+Ex+Girlfriend+S04E10+720p+HDTV+x264+LucidTV&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A6969%2Fannounce&tr=udp%3A%2F%2Ftracker.leechers-paradise.org%3A6969%2Fannounce&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337%2Fannounce&tr=http%3A%2F%2Ftracker.trackerfix.com%3A80%2Fannounce"

val enclosureIntent = getOpenInDefaultActivityIntent(getInstrumentation().context, 5, link = magnetLink)
Expand Down

This file was deleted.

Loading

0 comments on commit 300f7ff

Please sign in to comment.