Skip to content

Commit

Permalink
Merge pull request #509 from codacy/fix-clover-parser
Browse files Browse the repository at this point in the history
Make the count property optional on line node for clover parser
  • Loading branch information
hjrocha authored Jul 23, 2024
2 parents 9642dc1 + af29ed5 commit 48f0bec
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
4 changes: 3 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: 2.1

orbs:
codacy: codacy/base@10.10.1
codacy: codacy/base@12.1.2

references:
circleci_job: &circleci_job
Expand Down Expand Up @@ -251,10 +251,12 @@ workflows:
mv target/native-image/codacy-coverage-reporter ~/workdir/tmp-artifacts/codacy-coverage-reporter-linux
mv target/codacy-coverage-reporter-assembly-$(cat .version).jar ~/workdir/tmp-artifacts/codacy-coverage-reporter-assembly.jar
persist_to_workspace: true
save_cache: true
requires:
- compile_and_test
- codacy/sbt_osx:
name: create_artifacts_for_osx
openjdk_version: '11'
cmd: |
sbt nativeImage
mkdir -p ~/workdir/tmp-artifacts
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ object CloverParser extends CoverageParser with XmlReportParser {
fileLineTags.foldLeft[Either[String, Map[Int, Int]]](Right(Map.empty[Int, Int])) {
case (left: Left[_, _], _) => left

case (Right(lines), line) if (line \@ "type") == "stmt" || (line \@ "type") == "cond" =>
case (Right(lines), line)
if ((line \@ "type") == "stmt" || (line \@ "type") == "cond") && (line \@ "count").nonEmpty =>
val lineCoverage = for {
lineNumber <- getFirstNonEmptyValueAsInt(Seq(line), "num")
countOfExecutions <- getFirstNonEmptyValueAsInt(Seq(line), "count")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<metrics statements="1164" coveredstatements="0" conditionals="20" coveredconditionals="0" methods="20" coveredmethods="0"/>
<file name="file.js" path="/Users/username/workspace/repository/src/app/file.js">
<metrics statements="9" coveredstatements="1" conditionals="1" coveredconditionals="0" methods="1" coveredmethods="0"/>
<line num="1" count="0" type="cond" truecount="0" falsecount="1"/>
<line num="1" type="cond" truecount="0" falsecount="1"/>
<line num="2" count="0" type="stmt"/>
<line num="3" count="0" type="stmt"/>
<line num="4" count="0" type="stmt"/>
Expand Down
9 changes: 4 additions & 5 deletions get.sh
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ checksum() {
elif [ "$major_version" -ge 13 ]; then
log "$i" "Checking checksum..."
download_file "$checksum_url"

if command -v sha512sum > /dev/null 2>&1; then
sha_check_command="sha512sum"
elif command -v shasum > /dev/null 2>&1; then
Expand Down Expand Up @@ -130,15 +129,15 @@ download() {

download_file "$url"
checksum "$file_name" "$checksum_url"
if [ "$os_name_arch" = "Linux x86_64" ] || [ "$os_name_arch" = "Darwin x86_64" ]; then
if [ "$os_name_arch" = "Linux x86_64" ] || [ "$os_name_arch" = "Darwin arm64" ]; then
mv "$file_name" "$output_filename"
fi

cd "$original_folder"
}

download_reporter() {
if [ "$os_name_arch" = "Linux x86_64" ] || [ "$os_name_arch" = "Darwin x86_64" ]; then
if [ "$os_name_arch" = "Linux x86_64" ] || [ "$os_name_arch" = "Darwin arm64" ]; then
# OS name lower case
suffix=$(echo "$os_name" | tr '[:upper:]' '[:lower:]')
else
Expand Down Expand Up @@ -204,7 +203,7 @@ if [ -z "$CODACY_REPORTER_TMP_FOLDER" ]; then
fi

# Set binary name
if [ "$os_name_arch" = "Linux x86_64" ] || [ "$os_name_arch" = "Darwin x86_64" ]; then
if [ "$os_name_arch" = "Linux x86_64" ] || [ "$os_name_arch" = "Darwin arm64" ]; then
reporter_filename="codacy-coverage-reporter"
else
reporter_filename="codacy-coverage-reporter-assembly.jar"
Expand All @@ -221,7 +220,7 @@ reporter_path="$reporter_folder"/"$reporter_filename"

download_reporter "$reporter_path" "$reporter_folder" "$reporter_filename"

if [ "$os_name_arch" = "Linux x86_64" ] || [ "$os_name_arch" = "Darwin x86_64" ]; then
if [ "$os_name_arch" = "Linux x86_64" ] || [ "$os_name_arch" = "Darwin arm64" ]; then
chmod +x "$reporter_path"
run_command="$reporter_path"
else
Expand Down

0 comments on commit 48f0bec

Please sign in to comment.