2019-03-13 19:00:30 +03:00
#
# Copyright 2018 New Vector Ltd
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# This file list String which are not allowed in source code.
# Use Perl regex to write forbidden strings
# Note: line cannot start with a space. Use \s instead.
# It is possible to specify an authorized number of occurrence with === suffix. Default is 0
# Example:
# AuthorizedStringThreeTimes===3
# Extension:java
# Extension:kt
# Use new SecureLinearLayoutManager
# DISABLED
#new LinearLayoutManager
### No import static: use full class name
import static
### Rubbish from merge. Please delete those lines (sometimes in comment)
2022-01-04 18:15:25 +03:00
<<<<<<<
>>>>>>>
2019-03-13 19:00:30 +03:00
### carry return before "}". Please remove empty lines.
\n\s*\n\s*\}
### typo detected.
formated
abtract
Succes[^s]
succes[^s]
### Please insert line break. ex: .flatMap() not at new line
\}\)\.[\w]
### Use int instead of Integer
protected Integer
2019-07-09 16:40:49 +03:00
### Use the interface declaration. Example: use type "Map" instead of type "HashMap" to declare variable or parameter. For Kotlin, use mapOf, setOf, ...
2019-03-13 19:00:30 +03:00
(private|public|protected| ) (static )?(final )?(HashMap|HashSet|ArrayList)<
### Use int instead of short
Short\.parseShort
\(short\)
private short
final short
### Line length is limited to 160 chars. Please split long lines
2022-05-12 23:53:07 +03:00
#[^─]{161}
2019-03-13 19:00:30 +03:00
### "DO NOT COMMIT" has been committed
DO NOT COMMIT
### invalid formatting
\s{8}/\*\n \*
2020-02-25 11:57:12 +03:00
# Now checked by ktlint
# [^\w]if\(
# while\(
# for\(
2019-03-13 19:00:30 +03:00
# Add space after //
# DISABLED To re-enable when code will be formatted globally
#^\s*//[^\s]
# Not usable with unitary test. Use StringUtils
# DISABLED
#TextUtils\.isEmpty\(
### invalid formatting (too many space char)
^ /\*
# No ternary operator
# DISABLED
# \?
### unnecessary parenthesis around numbers, example: " (0)"
\(\d+\)
### Malformatted comment
^ \*
### import the package, do not use long class name with package
android\.os\.Build\.
### Tab char is forbidden. Use only spaces
\t
# Empty lines and trailing space
# DISABLED To re-enable when code will be formatted globally
#[ ]$
### Deprecated, use retrofit2.HttpException
import retrofit2\.adapter\.rxjava\.HttpException
### This is generally not necessary, no need to reset the padding if there is no drawable
setCompoundDrawablePadding\(0\)
# Change thread with Rx
# DISABLED
#runOnUiThread
### Bad formatting of chain (missing new line)
\w\.flatMap\(
### Bad formatting of Realm query chain. Insert new line
2020-06-03 19:54:03 +03:00
# DISABLED
# \)\.equalTo
2019-03-13 19:00:30 +03:00
# Use StandardCharsets.UTF_8.name()
# DISABLED (min API to low)
#\"UTF-
### Directly use getString() in a Fragment
getActivity\(\)\.getString\(
### In Kotlin, Void has to be null safe, i.e. use 'Void?' instead of 'Void'
\: Void\)
### Home menu click is managed in parent Activity, with one exception
android\.R\.id\.home===2
### Kotlin conversion tools introduce this, but is can be replace by trim()
trim \{ it \<\= \' \' \}
2021-06-09 12:51:04 +03:00
### Use MaterialAlertDialogBuilder
2019-03-13 19:00:30 +03:00
android\.app\.AlertDialog
2021-06-09 12:51:04 +03:00
androidx\.appcompat\.app\.AlertDialog===4
2019-03-13 19:00:30 +03:00
### Put the operator at the beginning of next line
==$
### Use JsonUtils.getBasicGson()
new Gson\(\)
2019-07-09 18:08:24 +03:00
### Use matrixOneTimeWorkRequestBuilder
2020-09-10 18:13:11 +03:00
import androidx.work.OneTimeWorkRequestBuilder===2
2019-09-26 11:41:52 +03:00
### Use TextUtils.formatFileSize
Formatter\.formatFileSize===1
### Use TextUtils.formatFileSize with short format param to true
Formatter\.formatShortFileSize===1
2019-10-22 18:41:59 +03:00
### Use kotlin stdlib to test or compare strings
2020-02-03 18:14:36 +03:00
# DISABLED
# android\.text\.TextUtils
2020-06-28 23:06:03 +03:00
2020-06-29 15:22:30 +03:00
### Do not import temporary legacy classes
2020-08-13 11:44:55 +03:00
import org.matrix.android.sdk.internal.legacy.riot===3
2020-06-29 15:22:30 +03:00
import org.matrix.androidsdk.crypto.data===2
2020-08-11 13:42:32 +03:00
### Use `Context#getSystemService` extension function provided by `core-ktx`
getSystemService\(Context
2020-09-09 13:10:46 +03:00
### Use DefaultSharedPreferences.getInstance() instead for better performance
PreferenceManager\.getDefaultSharedPreferences==2
2020-12-16 04:05:38 +03:00
### Use ViewBindings
2020-12-16 16:35:30 +03:00
# findViewById
2021-03-03 20:08:05 +03:00
### Do not use `template_` string. Please remove the prefix `template_` to use the generated resource instead.
2022-05-03 13:02:30 +03:00
R\.string\.template_
### Use the Clock interface, or use `measureTimeMillis`
2023-01-27 20:01:22 +03:00
System\.currentTimeMillis\(\)===3
2022-05-18 17:16:22 +03:00
### Remove extra space between the name and the description
\* @\w+ \w+ +
2022-07-01 18:05:32 +03:00
### Please use the MenuProvider interface now
onCreateOptionsMenu
onOptionsItemSelected
onPrepareOptionsMenu
2022-08-16 17:03:24 +03:00
### Suspicious String template. Please check that the string template will behave as expected, i.e. the class field and not the whole object will be used. For instance `Timber.d("$event.type")` is not correct, you should write `Timber.d("${event.type}")`. In the former the whole event content will be logged, since it's a data class. If this is expected (i.e. to fix false positive), please add explicit curly braces (`{` and `}`) around the variable, for instance `"elementLogs.${i}.txt"`
\$[a-zA-Z_]\w*\??\.[a-zA-Z_]