-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## Context - Improving static analysis using [Detekt](https://detekt.github.io/) tool ## Code - Improving pre-commit install and management - Run detekt pre-commit/ci: - all files when any detekt configuration files change - for diff files otherwise ## Additional notes - Have screenshots? Attention points?
- Loading branch information
Showing
20 changed files
with
145 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -87,3 +87,6 @@ lint/tmp/ | |
#secrets | ||
*.keystore | ||
api.properties | ||
|
||
#tools | ||
.tools/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/bin/bash | ||
|
||
while getopts t:s: flag | ||
do | ||
case "${flag}" in | ||
t) TARGET_BRANCH=${OPTARG};; | ||
s) SOURCE_BRANCH=${OPTARG};; | ||
esac | ||
done | ||
|
||
git fetch origin $TARGET_BRANCH:$TARGET_BRANCH $SOURCE_BRANCH:$SOURCE_BRANCH --no-tags | ||
|
||
MODIFIED_DETEKT_FILES=$(git diff --diff-filter=ACMRd --name-only $TARGET_BRANCH...$SOURCE_BRANCH | grep 'detekt') | ||
|
||
if [[ $MODIFIED_DETEKT_FILES ]]; then | ||
echo "Configuration files have changed. All files need to be analyzed." | ||
quality/detekt/detekt-run.sh | ||
else | ||
FILES_TO_ANALYZE=$(git diff --diff-filter=ACMRd --name-only $TARGET_BRANCH...$SOURCE_BRANCH | grep '\.kt$') | ||
if [[ -z "$FILES_TO_ANALYZE" ]]; then | ||
echo "No files to analyze!" | ||
else | ||
quality/detekt/detekt-run.sh -i $FILES_TO_ANALYZE | ||
fi | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/bin/bash | ||
|
||
# Update detekt-run.sh on version update | ||
|
||
mkdir -p .tools | ||
|
||
echo "Downloading detekt cli" | ||
curl -sSL https://github.com/detekt/detekt/releases/download/v1.19.0-RC1/detekt-cli-1.19.0-RC1.zip -o .tools/detekt-cli.zip | ||
|
||
echo "Extracting..." | ||
unzip -q .tools/detekt-cli.zip -d .tools/ | ||
|
||
mv .tools/detekt-cli-1.19.0-RC1 .tools/detekt-cli | ||
rm .tools/detekt-cli.zip | ||
|
||
echo "Installation finished" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/bin/bash | ||
|
||
while getopts i:e: flag | ||
do | ||
case "${flag}" in | ||
i) INCLUDE_PATHS=${OPTARG};; | ||
e) EXCLUDE_PATHS=${OPTARG};; | ||
esac | ||
done | ||
|
||
# Install detekt cli if necessary | ||
DETEKT_VERSION=$(.tools/detekt-cli/bin/detekt-cli --version) | ||
if [[ $DETEKT_VERSION != "1.19.0-RC1" ]]; then | ||
./quality/detekt/detekt-install.sh | ||
fi | ||
|
||
CMD=".tools/detekt-cli/bin/detekt-cli --all-rules \ | ||
--excludes \"**/build/**,$EXCLUDE_PATHS\" " | ||
|
||
if [[ ! -z "$INCLUDE_PATHS" ]]; then | ||
CMD+=" --input $INCLUDE_PATHS" | ||
fi | ||
|
||
eval $CMD |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/bash | ||
|
||
ln -f quality/git-hooks/pre-commit .git/hooks/pre-commit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/bin/bash | ||
|
||
hook_dir="quality/git-hooks/pre-commit.d" | ||
|
||
echo $hook_dir | ||
|
||
if [[ -d $hook_dir ]]; then | ||
stdin=$(cat /dev/stdin) | ||
|
||
for hook in $hook_dir/*; do | ||
echo "$stdin" | $hook "$@" | ||
|
||
exit_code=$? | ||
|
||
if [ $exit_code != 0 ]; then | ||
exit $exit_code | ||
fi | ||
done | ||
fi | ||
|
||
exit 0 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/bin/bash | ||
|
||
echo "[Pre-commit] Detekt" | ||
|
||
MODIFIED_DETEKT_FILES=$(git diff --diff-filter=ACMRd --name-only --cached --relative | grep 'detekt') | ||
|
||
if [[ $MODIFIED_DETEKT_FILES ]]; then | ||
echo "Configuration files have changed. All files need to be analyzed." | ||
quality/detekt/detekt-run.sh | ||
else | ||
FILES_TO_ANALYZE=$(git diff --diff-filter=ACMRd --name-only --cached --relative | grep '\.kt$') | ||
if [[ -z "$FILES_TO_ANALYZE" ]]; then | ||
echo "No files to analyze!" | ||
else | ||
quality/detekt/detekt-run.sh -i $FILES_TO_ANALYZE | ||
fi | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters