The building of Jenkins environment, here is not repeat, below we write, how to access Oclint.
OCLint
is a powerful static code analysis tool that can be used to improve code quality, find potential bugs, and focus on static analysis of c,c++ and Objective-c. Features are very powerful. Project address: http://oclint.org/.
1. Installation of Oclint and Xcpretty
Recommended is to install with homebrew, fast and save energy, you can choose the source installation or release package to install, but need to configure the content of environment variables. With homebrew installation, you need to set up a brew third-party warehouse, then install, Xcpretty used to parse the Xcodebuild build log, and the parsed results are given to Oclint to use:
Installation of Oclint:
Brew tap oclint/Install oclint
Installation of Xcpretty:
Gem Install Xcpretty
2. Build and static code Scan 1), build and parse logs
We use Xcodebuild to build.
Xcodebuild the default build of the format release, you need to build debug or Adhoc package to add the relevant parameters to execute. After build, use Xcpretty to parse the compilation log.
Tee Xcodebuild.log | Xcpretty-r Json-compilation-database
-r json-compilation-database The output format of the data is in JSON format. The output data is Build/reports/compilation_db.json
2), analytic results using oclint to do scanning
When using Oclint, you need to rename the Build/reports/compilation_db.json to Compile_commands.json and move to the current directory.
Oclint-json-compilation-database---Report-type pmd-o oclint.xml
The output format of the results is in PMD format, and then the results can be displayed through the PMD plugin of Jenkins.
3), Oclint other parameters
-e Pods Remove the scan of dependent third-party libraries
---rc=long_line=200 Change the default function line number to 100
lint_disable_rules= "-disable-rule=longclass \
-disable-rule=longline \
-disable-rule=longmethod \
-disable-rule=longvariablename \
-disable-rule=shortvariablename \
-disable-rule=highncssmethod \
-disable-rule=deepnestedblock \
-disable-rule=toomanyfields \
-disable-rule=toomanymethods \
-disable-rule=toomanyparameters \
-disable-rule=ivarassignmentoutsideaccessorsorinit "
The command line is added at the end of the $LINT _disbale_rules can disable some unwanted rules
Jenkins uses Oclint to scan OC code