mirror of
https://github.com/element-hq/element-android
synced 2024-11-23 18:05:36 +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 {
|
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 == "") {
|
if (fieldName == null || fieldName == "") {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
@ -35,7 +36,11 @@ class FieldNameFormatter {
|
||||||
currentCodepoint = normalizedFieldName.codePointAt(offset)
|
currentCodepoint = normalizedFieldName.codePointAt(offset)
|
||||||
|
|
||||||
if (previousCodepoint != null) {
|
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
|
// Hungarian notation starting with: mX
|
||||||
result.delete(0, 1)
|
result.delete(0, 1)
|
||||||
result.appendCodePoint(currentCodepoint)
|
result.appendCodePoint(currentCodepoint)
|
||||||
|
@ -51,7 +56,9 @@ class FieldNameFormatter {
|
||||||
} else if (currentCodepoint === '-'.code as Int? || currentCodepoint === '_'.code as Int?) {
|
} else if (currentCodepoint === '-'.code as Int? || currentCodepoint === '_'.code as Int?) {
|
||||||
// Word-separator: x-x or x_x
|
// Word-separator: x-x or x_x
|
||||||
result.append("_")
|
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
|
// camelCase: xX
|
||||||
result.append("_")
|
result.append("_")
|
||||||
result.appendCodePoint(currentCodepoint)
|
result.appendCodePoint(currentCodepoint)
|
||||||
|
|
|
@ -62,7 +62,7 @@ class FileGenerator(private val filer: Filer) {
|
||||||
javaFile.writeTo(filer)
|
javaFile.writeTo(filer)
|
||||||
return true
|
return true
|
||||||
} catch (e: IOException) {
|
} catch (e: IOException) {
|
||||||
e.printStackTrace()
|
// e.printStackTrace()
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue