Jenkins uses Oclint to scan OC code

Source: Internet
Author: User

The building of Jenkins environment, here is not repeat, below we write, how to access Oclint.

OCLintis 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.