-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* jscpd was failing on larger codebases, and the reporter wasn't packaged in HomeBrew * pmd was waiting in the wings anyway * renamed the csv2sarif utility to make it easier to call
- Loading branch information
1 parent
c493288
commit c6f394f
Showing
6 changed files
with
33 additions
and
34 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
File renamed without changes.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/bin/bash | ||
|
||
set -euo pipefail | ||
which pmd > /dev/null || exit 1 | ||
|
||
source=$1 | ||
pmd_version=$(pmd --version | grep PMD | awk '{print $2}') | ||
brew_prefix=$(brew --prefix) | ||
set -eo pipefail | ||
|
||
tmpdir=$(mktemp -d) | ||
|
||
|
||
for language in cpp cs java python ruby typescript; do | ||
pmd cpd --minimum-tokens=100 -l $language -d "$source" --no-fail-on-error --ignore-identifiers -f csv | \ | ||
grep -v "lines,tokens,occurrences" \ | ||
>> "${tmpdir}/output.csv" || true | ||
done | ||
|
||
awk -F ',' '{print $1, $4, $5}' "${tmpdir}/output.csv" | while read -r lines start_line file; do | ||
end_line=$(($start_line + $lines)) | ||
printf "duplication,note,code duplication found in source files,%s,%s,%s\n" "${file}" "${start_line}" "${end_line}" >> "${tmpdir}/findings.csv" | ||
done | ||
|
||
PATH="${brew_prefix}/opt/statica/libexec:.:$PATH" csv2sarif "pmd-cp" "${pmd_version}" "${tmpdir}/findings.csv" | ||
|
||
rm -rf "${tmpdir}" |