Skip to content

Commit

Permalink
thanks Idean#236
Browse files Browse the repository at this point in the history
  • Loading branch information
bcolvin committed Aug 22, 2019
1 parent 794c8f4 commit 42fa5ce
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
language: java
jdk:
- oraclejdk8
- openjdk11
31 changes: 18 additions & 13 deletions sonar-swift-plugin/src/main/shell/run-sonar-swift.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 42fa5ce

Please sign in to comment.