Skip to content

Commit

Permalink
Fix: skip oclint analysis on source directories without objc
Browse files Browse the repository at this point in the history
  • Loading branch information
David Yang committed Jul 16, 2019
1 parent 42831ea commit 6881889
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions sonar-swift-plugin/src/main/shell/run-sonar-swift.sh
Original file line number Diff line number Diff line change
Expand Up @@ -418,15 +418,18 @@ 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 ' ')
if [ $numberOfObjcFiles -gt 0 ]; then
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
else
echo "$word has no Objective-C, skipping..."
fi
done < tmpFileRunSonarSh
rm -rf tmpFileRunSonarSh

Expand Down

0 comments on commit 6881889

Please sign in to comment.