From 42fa5ce0b4c2f6a42d273eebaeb6ff236de2632a Mon Sep 17 00:00:00 2001 From: Brian Colvin Date: Thu, 22 Aug 2019 13:34:12 -0700 Subject: [PATCH] thanks https://github.com/Backelite/sonar-swift/pull/236 --- .travis.yml | 2 +- .../src/main/shell/run-sonar-swift.sh | 31 +++++++++++-------- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9bcf9994..94d2a223 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,3 @@ language: java jdk: - - oraclejdk8 + - openjdk11 diff --git a/sonar-swift-plugin/src/main/shell/run-sonar-swift.sh b/sonar-swift-plugin/src/main/shell/run-sonar-swift.sh index 9a06f933..54699db0 100755 --- a/sonar-swift-plugin/src/main/shell/run-sonar-swift.sh +++ b/sonar-swift-plugin/src/main/shell/run-sonar-swift.sh @@ -63,7 +63,7 @@ function readParameter() { parameter=$1 shift - eval $variable="\"$(sed '/^\#/d' sonar-project.properties | grep $parameter | tail -n 1 | cut -d '=' -f2- | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')\"" + eval $variable=$(printf %q "$(sed '/^\#/d' sonar-project.properties | grep $parameter | tail -n 1 | cut -d '=' -f2-)") } # Run a set of commands with logging and error handling @@ -277,13 +277,14 @@ rm -rf sonar-reports mkdir sonar-reports # Extracting project information needed later +buildCmd=($XCODEBUILD_CMD clean build) echo -n 'Extracting Xcode project information' if [[ "$workspaceFile" != "" ]] ; then - buildCmdPrefix="-workspace $workspaceFile" + buildCmd+=(-workspace "$workspaceFile") else - buildCmdPrefix="-project $projectFile" + buildCmd+=(-project "$projectFile") fi -buildCmd=($XCODEBUILD_CMD clean build $buildCmdPrefix -scheme "$appScheme") +buildCmd+=(-scheme $appScheme) if [[ ! -z "$destinationSimulator" ]]; then buildCmd+=(-destination "$destinationSimulator" -destination-timeout 360 COMPILER_INDEX_STORE_ENABLE=NO) fi @@ -418,15 +419,19 @@ if [ "$oclint" = "on" ] && [ "$hasObjC" = "yes" ]; then currentDirectory=${PWD##*/} echo "$srcDirs" | sed -n 1'p' | tr ',' '\n' > tmpFileRunSonarSh while read word; do - - includedCommandLineFlags=" --include .*/${currentDirectory}/${word}" - if [ "$vflag" = "on" ]; then - echo - echo -n "Path included in oclint analysis is:$includedCommandLineFlags" - fi - # Run OCLint with the right set of compiler options - runCommand no oclint-json-compilation-database -v $includedCommandLineFlags -- -rc LONG_LINE=$longLineThreshold -max-priority-1 $maxPriority -max-priority-2 $maxPriority -max-priority-3 $maxPriority -report-type pmd -o sonar-reports/$(echo $word | sed 's/\//_/g')-oclint.xml - + numberOfObjcFiles=$(find "${word}/" -name '*.m' | wc -l | tr -d ' ') + includedCommandLineFlags=" --include .*/${currentDirectory}/${word}" if [ $numberOfObjcFiles -gt 0 ]; then + if [ "$vflag" = "on" ]; then includedCommandLineFlags=" --include .*/${currentDirectory}/${word}" + echo if [ "$vflag" = "on" ]; then + echo -n "Path included in oclint analysis is:$includedCommandLineFlags" echo + fi echo -n "Path included in oclint analysis is:$includedCommandLineFlags" + # Run OCLint with the right set of compiler options fi + runCommand no oclint-json-compilation-database -v $includedCommandLineFlags -- -rc LONG_LINE=$longLineThreshold -max-priority-1 $maxPriority -max-priority-2 $maxPriority -max-priority-3 $maxPriority -report-type pmd -o sonar-reports/$(echo $word | sed 's/\//_/g')-oclint.xml # Run OCLint with the right set of compiler options + + runCommand no oclint-json-compilation-database -v $includedCommandLineFlags -- -rc LONG_LINE=$longLineThreshold -max-priority-1 $maxPriority -max-priority-2 $maxPriority -max-priority-3 $maxPriority -report-type pmd -o sonar-reports/$(echo $word | sed 's/\//_/g')-oclint.xml + else + echo "$word has no Objective-C, skipping..." + fi done < tmpFileRunSonarSh rm -rf tmpFileRunSonarSh