Skip to content

Commit

Permalink
Tools must find their utilities when packaged
Browse files Browse the repository at this point in the history
  • Loading branch information
safejulian committed Oct 17, 2024
1 parent e628c29 commit 7f3e013
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
File renamed without changes.
9 changes: 8 additions & 1 deletion tools.d/churn
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ OUTPUT="${tmpdir}/churned"
CSV="${tmpdir}/findings.csv"
TOP_N_CHURNED_FILES=10

if [ -x "./csv2sarif.rb" ]; then
csv2sarif="./csv2sarif.rb"
else
csv2sarif="csv2sarif"
fi

git -C "${source}" log --format=format: --name-only --since=12.month \
| grep -Ev '^$' \
| sort \
Expand All @@ -18,7 +24,8 @@ git -C "${source}" log --format=format: --name-only --since=12.month \
while read -r filename _commits; do
printf "%s,%s,%s,%s,%s,%s\n" "top-file-churns" "note" "File has been committed to frequently. This may indicate design issues." "${filename}" 0 0 >> "$CSV"
done < "${OUTPUT}"
./2sarif.rb "churn" "$(git --version)" "$CSV"

$csv2sarif "churn" "$(git --version)" "$CSV"

# clean up
rm -rf "${tmpdir}"
7 changes: 6 additions & 1 deletion tools.d/lizard
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ which lizard > /dev/null || exit 1

source=$1
tmpdir=$(mktemp -d)
if [ -x "./csv2sarif.rb" ]; then
csv2sarif="./csv2sarif.rb"
else
csv2sarif="csv2sarif"
fi

choose() {
local input=$1
Expand All @@ -23,7 +28,7 @@ awk -F':' '{print $2,$3, $1}' "${result}"| while read -r startline severity file
"${filename}" "${startline}" 0 >> "${tmpdir}"/findings.csv
done

./2sarif.rb "lizard" "$(lizard --version)" "${tmpdir}/findings.csv"
$csv2sarif "lizard" "$(lizard --version)" "${tmpdir}/findings.csv"

# clean up
rm -rf "${tmpdir}"

0 comments on commit 7f3e013

Please sign in to comment.