First Commit
This commit is contained in:
Executable
+56
@@ -0,0 +1,56 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Copyright (c) 2025 Element Creations Ltd.
|
||||
# Copyright 2023-2024 New Vector Ltd.
|
||||
#
|
||||
# SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial.
|
||||
# Please see LICENSE files in the repository root for full details.
|
||||
|
||||
#######################################################################################################################
|
||||
# Search forbidden pattern
|
||||
#######################################################################################################################
|
||||
|
||||
searchForbiddenStringsScript=./tmp/search_forbidden_strings.pl
|
||||
|
||||
if [[ -f ${searchForbiddenStringsScript} ]]; then
|
||||
echo "${searchForbiddenStringsScript} already there"
|
||||
else
|
||||
mkdir tmp
|
||||
echo "Get the script"
|
||||
wget https://raw.githubusercontent.com/matrix-org/matrix-dev-tools/develop/bin/search_forbidden_strings.pl -O ${searchForbiddenStringsScript}
|
||||
fi
|
||||
|
||||
if [[ -x ${searchForbiddenStringsScript} ]]; then
|
||||
echo "${searchForbiddenStringsScript} is already executable"
|
||||
else
|
||||
echo "Make the script executable"
|
||||
chmod u+x ${searchForbiddenStringsScript}
|
||||
fi
|
||||
|
||||
echo
|
||||
echo "Search for forbidden patterns in Kotlin source files..."
|
||||
|
||||
# list all Kotlin folders of the project.
|
||||
allKotlinDirs=$(find . -type d |grep -v build |grep -v \.git |grep -v \.gradle |grep kotlin$)
|
||||
|
||||
${searchForbiddenStringsScript} ./tools/check/forbidden_strings_in_code.txt "$allKotlinDirs"
|
||||
|
||||
resultForbiddenStringInCode=$?
|
||||
|
||||
echo
|
||||
echo "Search for forbidden patterns in XML resource files..."
|
||||
|
||||
# list all res folders of the project.
|
||||
allResDirs=$(find . -type d |grep -v build |grep -v \.git |grep -v \.gradle |grep /res$)
|
||||
|
||||
${searchForbiddenStringsScript} ./tools/check/forbidden_strings_in_xml.txt "$allResDirs"
|
||||
|
||||
resultForbiddenStringInXml=$?
|
||||
|
||||
if [[ ${resultForbiddenStringInCode} -eq 0 ]] \
|
||||
&& [[ ${resultForbiddenStringInXml} -eq 0 ]]; then
|
||||
echo "OK"
|
||||
else
|
||||
echo "❌ ERROR, please check the logs above."
|
||||
exit 1
|
||||
fi
|
||||
Executable
+128
@@ -0,0 +1,128 @@
|
||||
# Copyright (c) 2025 Element Creations Ltd.
|
||||
# Copyright 2023-2024 New Vector Ltd.
|
||||
#
|
||||
# SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial.
|
||||
# Please see LICENSE files in the repository root for full details.
|
||||
|
||||
# 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:kt
|
||||
|
||||
### No import static: use full class name
|
||||
import static
|
||||
|
||||
### Rubbish from merge. Please delete those lines (sometimes in comment)
|
||||
<<<<<<<
|
||||
>>>>>>>
|
||||
|
||||
### carry return before "}". Please remove empty lines.
|
||||
\n\s*\n\s*\}
|
||||
|
||||
### typo detected.
|
||||
formated
|
||||
abtract
|
||||
Succes[^s]
|
||||
succes[^s]
|
||||
|
||||
### Use int instead of Integer
|
||||
protected Integer
|
||||
|
||||
### Use the interface declaration. Example: use type "Map" instead of type "HashMap" to declare variable or parameter. For Kotlin, use mapOf, setOf, ...
|
||||
(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
|
||||
#[^─]{161}
|
||||
|
||||
### "DO NOT COMMIT" has been committed
|
||||
DO NOT COMMIT
|
||||
|
||||
### invalid formatting
|
||||
\s{8}/\*\n \*
|
||||
# Now checked by ktlint
|
||||
# [^\w]if\(
|
||||
# while\(
|
||||
# for\(
|
||||
|
||||
# Add space after //
|
||||
# DISABLED To re-enable when code will be formatted globally
|
||||
#^\s*//[^\s]
|
||||
|
||||
### invalid formatting (too many space char)
|
||||
^ /\*
|
||||
|
||||
### unnecessary parenthesis around numbers, example: " (0)"
|
||||
\(\d+\)[^"]
|
||||
|
||||
### 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\(
|
||||
|
||||
### In Kotlin, Void has to be null safe, i.e. use 'Void?' instead of 'Void'
|
||||
\: Void\)
|
||||
|
||||
### Kotlin conversion tools introduce this, but is can be replace by trim()
|
||||
trim \{ it \<\= \' \' \}
|
||||
|
||||
### Put the operator at the beginning of next line
|
||||
==$
|
||||
|
||||
### Use JsonUtils.getBasicGson()
|
||||
new Gson\(\)
|
||||
|
||||
### Use TextUtils.formatFileSize
|
||||
Formatter\.formatFileSize===1
|
||||
|
||||
### Use TextUtils.formatFileSize with short format param to true
|
||||
Formatter\.formatShortFileSize===1
|
||||
|
||||
### Use `Context#getSystemService` extension function provided by `core-ktx`
|
||||
getSystemService\(Context
|
||||
|
||||
### Use DefaultSharedPreferences.getInstance() instead for better performance
|
||||
PreferenceManager\.getDefaultSharedPreferences==2
|
||||
|
||||
### Use the Clock interface, or use `measureTimeMillis`
|
||||
System\.currentTimeMillis\(\)===1
|
||||
|
||||
### Remove extra space between the name and the description
|
||||
\* @\w+ \w+ +
|
||||
|
||||
### 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.
|
||||
Timber.*\$[a-zA-Z_]\w*\??\.[a-zA-Z_]
|
||||
|
||||
### Use `import io.element.android.libraries.ui.strings.CommonStrings` then `CommonStrings.<stringKey>` instead
|
||||
import io\.element\.android\.libraries\.ui\.strings\.R
|
||||
|
||||
# Accessibility
|
||||
### Use string resource for `contentDescription`, or null instead of empty string
|
||||
contentDescription = "
|
||||
Executable
+28
@@ -0,0 +1,28 @@
|
||||
# Copyright (c) 2025 Element Creations Ltd.
|
||||
# Copyright 2023-2024 New Vector Ltd.
|
||||
#
|
||||
# SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial.
|
||||
# Please see LICENSE files in the repository root for full details.
|
||||
|
||||
# This file list String which are not allowed in resource.
|
||||
# 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:xml
|
||||
|
||||
### Empty tag detected. Empty translation or plurals?
|
||||
"></
|
||||
">""</
|
||||
|
||||
### Rubbish from merge. Please delete those lines (sometimes in comment)
|
||||
<<<<<<<
|
||||
>>>>>>>
|
||||
|
||||
### "DO NOT COMMIT" has been committed
|
||||
DO NOT COMMIT
|
||||
|
||||
### Tab char is forbidden. Use only spaces
|
||||
\t
|
||||
Reference in New Issue
Block a user