cd $WORKSPACE
xcodebuild -workspace xxx.xcworkspace -scheme xxx clean build | tee xcodebuild.log | xcpretty --report json-compilation-database
mv build/reports/compilation_db.json compile_commands.json
oclint-json-compilation-database -exclude Pods -- -report-type pmd -o oclint.xml -max-priority-1 99999 -max-priority-2 99999 -max-priority-3 99999 -rc LONG_LINE=140 -rc LONG_METHOD=80 -rc NCSS_METHOD=50 -rc SHORT_VARIABLE_NAME=1 -rc CYCLOMATIC_COMPLEXITY=13 -rc MINIMUM_CASES_IN_SWITCH=2 -rc NPATH_COMPLEXITY=1500
rm -rf sonar-reports
mkdir sonar-reports
cat oclint.xml | sed "s#Switch Statements Should Have Default Rule#switch statements should have default#g" \
| sed "s#missing hash method#must override hash with isEqual#g" \
| sed "s#prefer early exits and continue#use early exits and continue#g" \
| sed "s#use boxed expression#replace with boxed expression#g" \
| sed "s#use container literal#replace with container literal#g" \
| sed "s#use number literal#replace with number literal#g" \
| sed "s#use object subscripting#replace with object subscripting#g" \
| sed "s#missing default in switch statements#switch statements should have default#g" \
| sed "s#unnecessary default statement in covered switch statement#switch statements don't need default when fully covered#g" \
| sed "s#covered switch statements dont need default#switch statements don't need default when fully covered#g" > sonar-reports/oclint.xml
rm -f sonar-project.properties
cat > sonar-project.properties <<- EOF
sonar.projectKey=xxx-iOS
sonar.projectName=xxx-iOS
sonar.projectVersion=x.x.x
sonar.language=objectivec
sonar.sources=sources
sonar.sourceEncoding=UTF-8
sonar.objectivec.oclint.reportPath=sonar-reports/oclint.xml
EOF
/bin/sh sonar-scanner -X複製代碼
3 errors generated.
20 errors generated.
20 errors generated.
20 errors generated.
8 errors generated.
19 errors generated.
3 errors generated.
63 errors generated.複製代碼
The rule 'OCLint:use number literal' does not exist.
The rule 'OCLint:use object subscripting' does not exist.
The rule 'OCLint:ill-placed default label in switch statement' does not exist.
The rule 'OCLint:Switch Statements Misplaced Default Label' does not exist.複製代碼
sed "s#missing hash method#must override hash with isEqual#g"複製代碼
brew install Swiftlint
gem install slather
sudo pip install lizard複製代碼
cd $WORKSPACE
rm -rf kuai-swiftlint.txt
swiftlint lint --path Duobao > xxx-swiftlint.txt
rm -rf sonar-project.properties
cat > sonar-project.properties <<- EOF
sonar.projectKey=xxx-iOS-swift
sonar.projectName=xxx-iOS-swift
sonar.projectVersion=x.x.x
sonar.language=swift
sonar.projectDescription=xxx with Swift
sonar.sources=sources
sonar.swift.workspace=xxx.xcworkspace
sonar.swift.appScheme=xxx
sonar.sourceEncoding=UTF-8
sonar.swift.swiftlint.report=xxx-swiftlint.txt
EOF
/bin/sh sonar-scanner -X複製代碼
ObjectiveC_Swift目錄結構
--ObjectiveC:完整項目文件
--Swift:完整項目文件複製代碼
sonar.projectKey=objectivec_swift
sonar.projectName=objectivec_swift
sonar.projectVersion=1.9.0
sonar.sourceEncoding=UTF-8
#分模塊
sonar.modules=objective,swift
#構建objectivec
objective.sonar.projectName=objectivec
objective.sonar.language=objectivec
objective.sonar.projectBaseDir=objectivec
objective.sonar.sources=sources
objective.sonar.oclint.reportPath=sonar-reports/oclint.xml
#構建swift
swift.sonar.projectName=swift
swift.sonar.language=swift
swift.sonar.sources=sources
swift.sonar.projectBaseDir=swift
swift.sonar.swift.workspace=swift/xxx.xcworkspace
swift.sonar.swift.appScheme=Duobao
swift.sonar.sourceEncoding=UTF-8
swift.sonar.swift.swiftlint.report=swift/xxx-swiftlint.txt複製代碼
微信公衆號:樂少黑板報
git