2019-03-13 19:00:30 +03:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2024-09-24 13:09:02 +03:00
|
|
|
# Copyright 2019-2024 New Vector Ltd.
|
2019-03-13 19:00:30 +03:00
|
|
|
#
|
2024-09-24 13:09:02 +03:00
|
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
# Please see LICENSE in the repository root for full details.
|
2019-03-13 19:00:30 +03:00
|
|
|
|
|
|
|
#######################################################################################################################
|
|
|
|
# Check drawable quantity
|
|
|
|
#######################################################################################################################
|
|
|
|
|
|
|
|
echo "Check drawable quantity"
|
|
|
|
|
2019-03-19 16:38:15 +03:00
|
|
|
numberOfFiles1=`ls -1U ./vector/src/main/res/drawable-hdpi | wc -l | sed "s/ //g"`
|
|
|
|
numberOfFiles2=`ls -1U ./vector/src/main/res/drawable-mdpi | wc -l | sed "s/ //g"`
|
|
|
|
numberOfFiles3=`ls -1U ./vector/src/main/res/drawable-xhdpi | wc -l | sed "s/ //g"`
|
|
|
|
numberOfFiles4=`ls -1U ./vector/src/main/res/drawable-xxhdpi | wc -l | sed "s/ //g"`
|
|
|
|
numberOfFiles5=`ls -1U ./vector/src/main/res/drawable-xxxhdpi | wc -l | sed "s/ //g"`
|
2019-03-13 19:00:30 +03:00
|
|
|
|
|
|
|
if [[ ${numberOfFiles1} -eq ${numberOfFiles5} ]] && [[ ${numberOfFiles2} -eq ${numberOfFiles5} ]] && [[ ${numberOfFiles3} -eq ${numberOfFiles5} ]] && [[ ${numberOfFiles4} -eq ${numberOfFiles5} ]]; then
|
|
|
|
resultNbOfDrawable=0
|
|
|
|
echo "OK"
|
|
|
|
else
|
2019-03-29 20:25:44 +03:00
|
|
|
# Ignore for the moment
|
|
|
|
# resultNbOfDrawable=1
|
|
|
|
resultNbOfDrawable=0
|
2019-03-13 19:00:30 +03:00
|
|
|
echo "ERROR, missing drawable alternative."
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo
|
|
|
|
|
|
|
|
#######################################################################################################################
|
|
|
|
# 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 code..."
|
|
|
|
|
|
|
|
${searchForbiddenStringsScript} ./tools/check/forbidden_strings_in_code.txt \
|
2019-07-04 15:51:08 +03:00
|
|
|
./matrix-sdk-android/src/main/java \
|
2022-04-06 15:34:23 +03:00
|
|
|
./matrix-sdk-android-flow/src/main/java \
|
2022-02-17 23:21:30 +03:00
|
|
|
./library/core-utils/src/main/java \
|
2022-10-13 13:40:15 +03:00
|
|
|
./library/external/jsonviewer/src/main/java \
|
2022-02-17 23:21:30 +03:00
|
|
|
./library/ui-styles/src/main/java \
|
2019-07-04 15:51:08 +03:00
|
|
|
./vector/src/main/java \
|
2022-10-13 13:40:15 +03:00
|
|
|
./vector-app/src/debug/java \
|
|
|
|
./vector-app/src/fdroid/java \
|
2022-08-17 18:27:44 +03:00
|
|
|
./vector-app/src/gplay/java \
|
2022-10-13 13:40:15 +03:00
|
|
|
./vector-app/src/main/java \
|
|
|
|
./vector-app/src/release/java
|
2019-03-13 19:00:30 +03:00
|
|
|
|
|
|
|
resultForbiddenStringInCode=$?
|
|
|
|
|
2020-10-08 15:42:44 +03:00
|
|
|
echo
|
|
|
|
echo "Search for forbidden patterns specific for SDK code..."
|
|
|
|
|
|
|
|
${searchForbiddenStringsScript} ./tools/check/forbidden_strings_in_code_sdk.txt \
|
|
|
|
./matrix-sdk-android/src \
|
2022-04-06 15:34:23 +03:00
|
|
|
./matrix-sdk-android-flow/src
|
2020-10-08 15:42:44 +03:00
|
|
|
|
|
|
|
resultForbiddenStringInCodeSdk=$?
|
|
|
|
|
2022-04-11 12:54:16 +03:00
|
|
|
echo
|
|
|
|
echo "Search for forbidden patterns specific for App code..."
|
|
|
|
|
|
|
|
${searchForbiddenStringsScript} ./tools/check/forbidden_strings_in_code_app.txt \
|
2022-10-13 13:40:15 +03:00
|
|
|
./library/core-utils/src/main/java \
|
|
|
|
./library/external/jsonviewer/src/main/java \
|
|
|
|
./library/ui-styles/src/main/java \
|
2022-04-11 12:54:16 +03:00
|
|
|
./vector/src/main/java \
|
2022-10-13 13:40:15 +03:00
|
|
|
./vector-app/src/debug/java \
|
|
|
|
./vector-app/src/fdroid/java \
|
2022-08-17 18:27:44 +03:00
|
|
|
./vector-app/src/gplay/java \
|
2022-10-13 13:40:15 +03:00
|
|
|
./vector-app/src/main/java \
|
|
|
|
./vector-app/src/release/java
|
2022-04-11 12:54:16 +03:00
|
|
|
|
|
|
|
resultForbiddenStringInCodeApp=$?
|
|
|
|
|
2019-03-13 19:00:30 +03:00
|
|
|
echo
|
|
|
|
echo "Search for forbidden patterns in resources..."
|
|
|
|
|
|
|
|
${searchForbiddenStringsScript} ./tools/check/forbidden_strings_in_resources.txt \
|
2022-02-17 23:21:30 +03:00
|
|
|
./library/ui-styles/src/main/res/values \
|
2019-03-19 16:38:15 +03:00
|
|
|
./vector/src/main/res/color \
|
|
|
|
./vector/src/main/res/layout \
|
|
|
|
./vector/src/main/res/values \
|
2022-08-17 18:27:44 +03:00
|
|
|
./vector/src/main/res/xml \
|
|
|
|
./vector-app/src/main/res/values
|
2019-03-13 19:00:30 +03:00
|
|
|
|
|
|
|
resultForbiddenStringInResource=$?
|
|
|
|
|
2021-06-15 11:30:54 +03:00
|
|
|
echo
|
|
|
|
echo "Search for forbidden patterns in layouts..."
|
|
|
|
|
|
|
|
${searchForbiddenStringsScript} ./tools/check/forbidden_strings_in_layout.txt \
|
2022-10-13 13:40:15 +03:00
|
|
|
./vector/src/main/res/layout
|
2021-06-15 11:30:54 +03:00
|
|
|
|
|
|
|
resultForbiddenStringInLayout=$?
|
|
|
|
|
2019-03-13 19:00:30 +03:00
|
|
|
#######################################################################################################################
|
|
|
|
# Check files with long lines
|
|
|
|
#######################################################################################################################
|
|
|
|
|
|
|
|
checkLongFilesScript=./tmp/check_long_files.pl
|
|
|
|
|
|
|
|
if [[ -f ${checkLongFilesScript} ]]; then
|
|
|
|
echo "${checkLongFilesScript} already there"
|
|
|
|
else
|
|
|
|
mkdir tmp
|
|
|
|
echo "Get the script"
|
|
|
|
wget https://raw.githubusercontent.com/matrix-org/matrix-dev-tools/develop/bin/check_long_files.pl -O ${checkLongFilesScript}
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ -x ${checkLongFilesScript} ]]; then
|
|
|
|
echo "${checkLongFilesScript} is already executable"
|
|
|
|
else
|
|
|
|
echo "Make the script executable"
|
|
|
|
chmod u+x ${checkLongFilesScript}
|
|
|
|
fi
|
|
|
|
|
2022-02-22 10:58:15 +03:00
|
|
|
maxLines=2800
|
2020-06-30 01:50:17 +03:00
|
|
|
|
2019-03-13 19:00:30 +03:00
|
|
|
echo
|
2020-06-30 01:50:17 +03:00
|
|
|
echo "Search for kotlin files with more than ${maxLines} lines..."
|
2019-03-13 19:00:30 +03:00
|
|
|
|
2020-06-30 01:50:17 +03:00
|
|
|
${checkLongFilesScript} ${maxLines} \
|
|
|
|
./matrix-sdk-android/src/main/java \
|
2022-04-06 15:34:23 +03:00
|
|
|
./matrix-sdk-android-flow/src/main/java \
|
2022-10-13 13:40:15 +03:00
|
|
|
./library/core-utils/src/main/java \
|
|
|
|
./library/external/jsonviewer/src/main/java \
|
|
|
|
./library/ui-styles/src/main/java \
|
2020-06-30 01:50:17 +03:00
|
|
|
./vector/src/androidTest/java \
|
2019-03-19 16:38:15 +03:00
|
|
|
./vector/src/main/java \
|
2020-06-30 01:50:17 +03:00
|
|
|
./vector/src/sharedTest/java \
|
2022-08-17 18:27:44 +03:00
|
|
|
./vector/src/test/java \
|
2022-10-13 13:40:15 +03:00
|
|
|
./vector-app/src/androidTest/java \
|
|
|
|
./vector-app/src/debug/java \
|
|
|
|
./vector-app/src/fdroid/java \
|
|
|
|
./vector-app/src/gplay/java \
|
|
|
|
./vector-app/src/main/java \
|
|
|
|
./vector-app/src/release/java
|
2022-08-17 18:27:44 +03:00
|
|
|
|
2019-03-13 19:00:30 +03:00
|
|
|
|
|
|
|
resultLongFiles=$?
|
|
|
|
|
|
|
|
#######################################################################################################################
|
|
|
|
# search png in drawable folder
|
|
|
|
#######################################################################################################################
|
|
|
|
|
|
|
|
echo
|
|
|
|
echo "Search for png files in /drawable..."
|
|
|
|
|
2019-03-19 16:38:15 +03:00
|
|
|
ls -1U ./vector/src/main/res/drawable/*.png
|
2019-03-13 19:00:30 +03:00
|
|
|
resultTmp=$?
|
|
|
|
|
2022-10-13 13:40:15 +03:00
|
|
|
ls -1U ./vector-app/src/main/res/drawable/*.png
|
|
|
|
resultTmp2=$?
|
|
|
|
|
2019-03-13 19:00:30 +03:00
|
|
|
# Inverse the result, cause no file found is an error for ls but this is what we want!
|
2022-10-13 13:40:15 +03:00
|
|
|
if [[ ${resultTmp} -eq 0 ]] || [[ ${resultTmp2} -eq 0 ]]; then
|
2019-03-13 19:00:30 +03:00
|
|
|
echo "ERROR, png files detected in /drawable"
|
|
|
|
resultPngInDrawable=1
|
|
|
|
else
|
|
|
|
echo "OK"
|
|
|
|
resultPngInDrawable=0
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo
|
|
|
|
|
2021-06-15 11:30:54 +03:00
|
|
|
if [[ ${resultNbOfDrawable} -eq 0 ]] \
|
|
|
|
&& [[ ${resultForbiddenStringInCode} -eq 0 ]] \
|
|
|
|
&& [[ ${resultForbiddenStringInCodeSdk} -eq 0 ]] \
|
2022-04-11 12:54:16 +03:00
|
|
|
&& [[ ${resultForbiddenStringInCodeApp} -eq 0 ]] \
|
2021-06-15 11:30:54 +03:00
|
|
|
&& [[ ${resultForbiddenStringInResource} -eq 0 ]] \
|
|
|
|
&& [[ ${resultForbiddenStringInLayout} -eq 0 ]] \
|
|
|
|
&& [[ ${resultLongFiles} -eq 0 ]] \
|
|
|
|
&& [[ ${resultPngInDrawable} -eq 0 ]]; then
|
2019-03-13 19:00:30 +03:00
|
|
|
echo "MAIN OK"
|
|
|
|
else
|
|
|
|
echo "❌ MAIN ERROR"
|
|
|
|
exit 1
|
|
|
|
fi
|