From 46a8f4640d8c635139fc32d5181d41797fc01493 Mon Sep 17 00:00:00 2001 From: tzugen Date: Mon, 20 Jun 2022 10:12:45 +0200 Subject: [PATCH 1/2] Fix #759 , a crash when the artist name was empty. --- .../org/moire/ultrasonic/adapters/ArtistRowBinder.kt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/ultrasonic/src/main/kotlin/org/moire/ultrasonic/adapters/ArtistRowBinder.kt b/ultrasonic/src/main/kotlin/org/moire/ultrasonic/adapters/ArtistRowBinder.kt index d83385ab..df9d8cc8 100644 --- a/ultrasonic/src/main/kotlin/org/moire/ultrasonic/adapters/ArtistRowBinder.kt +++ b/ultrasonic/src/main/kotlin/org/moire/ultrasonic/adapters/ArtistRowBinder.kt @@ -102,8 +102,9 @@ class ArtistRowBinder( } private fun getSectionFromName(name: String): String { - var section = name.first().uppercaseChar() - if (!section.isLetter()) section = '#' + if (name.isEmpty()) return SECTION_KEY_DEFAULT + val section = name.first().uppercaseChar() + if (!section.isLetter()) return SECTION_KEY_DEFAULT return section.toString() } @@ -123,4 +124,8 @@ class ArtistRowBinder( override fun onCreateViewHolder(inflater: LayoutInflater, parent: ViewGroup): ViewHolder { return ViewHolder(inflater.inflate(layout, parent, false)) } + + companion object { + const val SECTION_KEY_DEFAULT = "#" + } } From 8a90e98989bc5a5b1adebfd161d4a3e09b244b87 Mon Sep 17 00:00:00 2001 From: tzugen <67737443+tzugen@users.noreply.github.com> Date: Mon, 20 Jun 2022 19:35:46 +0200 Subject: [PATCH 2/2] Update CONTRIBUTING.md --- CONTRIBUTING.md | 48 ++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 38 insertions(+), 10 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d52377f1..963f73f1 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -18,18 +18,46 @@ By default Pull Request should be opened against **develop** branch, PR against ### Here are a few guidelines you should follow before submitting: 1. **License Acceptance:** All contributions must be licensed as [GNU GPLv3](LICENSE) to be accepted. -Use `git commit --signoff` to acknowledge this. -2. **App is migrating to [Kotlin](https://kotlinlang.org/) programming language:** new Pull Requests -should be written in this programming language. -3. **No Breakage:** New features or changes to existing ones must not degrade the user experience. -4. **Coding standards:** best-practices should be followed, comment generously, and avoid "clever" algorithms. +Use `git commit --signoff` to acknowledge this. +2. **No Breakage:** New features or changes to existing ones must not degrade the user experience. +3. **Coding standards:** best-practices should be followed, comment generously, and avoid "clever" algorithms. Refactoring existing messes is great, but watch out for breakage. -5. **No large PR:** Try to limit the scope of PR only to the related issue, so it will be easier to review +4. **No large PR:** Try to limit the scope of PR only to the related issue, so it will be easier to review and test. ### Pull Request Process +On each Pull Request Github runs a number of checks to make sure there are no problems. + +#### Signed commits +Commits must be signed. [See here how to set it up](https://docs.github.com/en/authentication/managing-commit-signature-verification/signing-commits) + +#### KtLint +This programm checks if the source code is formatted correctly. +You can run it yourself locally with + +`./gradlew -Pqc ktlintFormat` + +Running this command will fix common problems and will notify you of problems it couldn't fix automatically. + +#### Detekt + +Detekt is a static analyser. It helps to find potential bugs in our code. + +You can run it yourself locally with + +`./gradlew -Pqc detekt` + +There is a "baseline" file, in which errors which have been in the code base before are noted. +Sometimes it is necessary to regenerate this file by running: + +`./gradlew -Pqc detektBaseline` + +#### Lint +Lint looks for general problems in the code or unused resources etc. +You can run it with + +`./gradlew -Pqc lintRelease` + +If there is a need to regenerate the baseline, remove `ultrasonic/lint-baseline.xml` and rerun the command. + -1. Ensure [all commits are signed-off](https://docs.github.com/en/free-pro-team@latest/github/authenticating-to-github/about-commit-signature-verification). -2. Check tests for the new code are added. -3. Check code style is passing. -4. Check code static analysis is passing.