mirror of
https://github.com/element-hq/element-android
synced 2024-11-23 09:55:40 +03:00
Fix detekt issue
This commit is contained in:
parent
ea424f29fb
commit
2c57453efd
3 changed files with 11 additions and 4 deletions
|
@ -8,7 +8,8 @@ import java.util.Locale
|
|||
*/
|
||||
class FieldNameFormatter {
|
||||
|
||||
@JvmOverloads fun format(fieldName: String?, locale: Locale = Locale.US): String {
|
||||
@JvmOverloads
|
||||
fun format(fieldName: String?, locale: Locale = Locale.US): String {
|
||||
if (fieldName == null || fieldName == "") {
|
||||
return ""
|
||||
}
|
||||
|
@ -35,7 +36,11 @@ class FieldNameFormatter {
|
|||
currentCodepoint = normalizedFieldName.codePointAt(offset)
|
||||
|
||||
if (previousCodepoint != null) {
|
||||
if (Character.isUpperCase(currentCodepoint) && !Character.isUpperCase(previousCodepoint) && previousCodepoint === 'm'.code as Int? && result.length == 1) {
|
||||
if (Character.isUpperCase(currentCodepoint) &&
|
||||
!Character.isUpperCase(previousCodepoint) &&
|
||||
previousCodepoint === 'm'.code as Int? &&
|
||||
result.length == 1
|
||||
) {
|
||||
// Hungarian notation starting with: mX
|
||||
result.delete(0, 1)
|
||||
result.appendCodePoint(currentCodepoint)
|
||||
|
@ -51,7 +56,9 @@ class FieldNameFormatter {
|
|||
} else if (currentCodepoint === '-'.code as Int? || currentCodepoint === '_'.code as Int?) {
|
||||
// Word-separator: x-x or x_x
|
||||
result.append("_")
|
||||
} else if (Character.isUpperCase(currentCodepoint) && !Character.isUpperCase(previousCodepoint) && Character.isLetterOrDigit(previousCodepoint)) {
|
||||
} else if (Character.isUpperCase(currentCodepoint) && !Character.isUpperCase(previousCodepoint) && Character.isLetterOrDigit(
|
||||
previousCodepoint
|
||||
)) {
|
||||
// camelCase: xX
|
||||
result.append("_")
|
||||
result.appendCodePoint(currentCodepoint)
|
||||
|
|
|
@ -62,7 +62,7 @@ class FileGenerator(private val filer: Filer) {
|
|||
javaFile.writeTo(filer)
|
||||
return true
|
||||
} catch (e: IOException) {
|
||||
e.printStackTrace()
|
||||
// e.printStackTrace()
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue