Skip to content

Commit

Permalink
Linters (#2651)
Browse files Browse the repository at this point in the history
* Configure Lint properly

* Disable "ComposeViewModelInjection" for `:app` and add a baseline

* Add Detekt baseline

* Add `detektBaseline.sh` script

* Add Qodana

* Upload Qodana report

* Configure QODANA reports
  • Loading branch information
ILIYANGERMANOV committed Sep 19, 2023
1 parent f8d697d commit d0aa12e
Show file tree
Hide file tree
Showing 10 changed files with 4,786 additions and 734 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
- name: Fail if lint errors are found
run: |
# Check if the lint XML report contains any error issues
if grep -q 'severity="Error"' build/reports/lint-results.xml; then
if grep -q 'severity="Error"' build/reports/lint/lint.xml; then
echo "Lint errors found. Failing the build."
exit 1
fi
Expand Down
25 changes: 25 additions & 0 deletions .github/workflows/qodana.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Qodana
on:
workflow_dispatch:
pull_request:
push:
branches:
- main
- 'releases/*'

jobs:
qodana:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
checks: write
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }} # to check out the actual pull request commit, not the merge commit
fetch-depth: 0 # a full history is required for pull request analysis
- name: 'Qodana Scan'
uses: JetBrains/qodana-action@v2023.2
env:
QODANA_TOKEN: ${{ secrets.QODANA_TOKEN }}
7 changes: 3 additions & 4 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -114,16 +114,15 @@ android {
}

lint {
disable += "MissingTranslation"
disable += "ComposeViewModelInjection"
checkReleaseBuilds = true
checkDependencies = true
abortOnError = false
checkReleaseBuilds = false
htmlReport = true
htmlOutput = file("${project.rootDir}/build/reports/lint/lint.html")
xmlReport = true
xmlOutput = file("${project.rootDir}/build/reports/lint-results.xml")
baseline = file("${project.rootDir}/lint-baseline.xml")
xmlOutput = file("${project.rootDir}/build/reports/lint/lint.xml")
baseline = file("lint-baseline.xml")
}
}

Expand Down
4,750 changes: 4,705 additions & 45 deletions lint-baseline.xml → app/lint-baseline.xml

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions buildSrc/src/main/kotlin/ivy.compose.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,16 @@ android {
composeOptions {
kotlinCompilerExtensionVersion = catalog.version("compose-compiler")
}

lint {
disable += "MissingTranslation"
disable += "ComposeViewModelInjection"
abortOnError = false
}
}

dependencies {
implementation(libs.bundles.compose)

lintChecks(libs.slack.lint.compose)
}
682 changes: 2 additions & 680 deletions config/detekt/baseline.yml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.persistentListOf

@Composable
fun AttributionsScreenImpl() {
val viewModel: AttributionsViewModel = viewModel()
fun AttributionsScreenImpl(
viewModel: AttributionsViewModel = viewModel()
) {
val uiState = viewModel.uiState()

AttributionsUI(uiState = uiState)
Expand Down
19 changes: 19 additions & 0 deletions scripts/detektBaseline.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

# -------------------
# 0. ROOT DIRECTORY CHECK
# -------------------

# Check if the script is being run from the root directory of the repo
if [ ! -f "settings.gradle.kts" ]; then
echo "ERROR:"
echo "Please run this script from the root directory of the repo."
exit 1
fi


./gradlew detektBaseline || exit 0
git add config/detekt/baseline.yml || exit 0
git commit -m "Add Detekt baseline" || exit 0
echo "Detekt baseline added."
echo "WARNING: Commit made. You need to push it"
6 changes: 4 additions & 2 deletions scripts/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ fi
# chmod +x $GIT_HOOKS_DIR/pre-push || exit -1
# echo "pre-push hook is now executable."

chmod +x "$BASE_DIR"/scripts/detektFormat.sh || exit -1
chmod +x "$BASE_DIR"/scripts/create_module.sh || exit -1
chmod +x "$BASE_DIR"/scripts/detektFormat.sh || exit 1
chmod +x "$BASE_DIR"/scripts/create_module.sh || exit 1
chmod +x "$BASE_DIR"/scripts/lint.sh || exit 1
chmod +x "$BASE_DIR"/scripts/detektBaseline.sh || exit 1
echo "scripts in '/scripts' are now executable."

echo "Repository setup complete!"
16 changes: 16 additions & 0 deletions scripts/lint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

# -------------------
# 0. ROOT DIRECTORY CHECK
# -------------------

# Check if the script is being run from the root directory of the repo
if [ ! -f "settings.gradle.kts" ]; then
echo "ERROR:"
echo "Please run this script from the root directory of the repo."
exit 1
fi


./gradlew lintR
open build/reports/lint/lint.html

0 comments on commit d0aa12e

Please sign in to comment.