Code Monkey home page Code Monkey logo

sonar-swift's Introduction

Branch Status
master Build Status
develop Build Status

SonarQube Plugin for Swift

This is an open source initiative for Apple Swift language support in SonarQube. The structure of the plugin is based on the sonar-objective-c plugin.

Example iOS SonarQube dashboard

In SonarQube under Quality Profiles the used Linter can be specified by selecting either the SwiftLint Profile or the Tailor Profile as Default profile for Swift Projects:

Set preferred profile (SwiftLint or Tailor) to default in SonarQube.

Features

Feature Supported MacOS Unix
Complexity YES Uses Lizard Uses Lizard
Design NO
Documentation YES
Duplications YES
Issues YES Uses SwiftLint and/or Tailor for Swift. OCLint and Faux Pas for Objective-C Uses Tailor
Size YES
Tests YES Uses xcodebuild + xcpretty xcpretty Not Supported
Code coverage YES Uses slather Not Supported

Faux Pas support

Faux Pas is a wonderful tool to analyse iOS or Mac applications Objective-C source code, however it is not free. A 30 trial version is available here.

The plugin runs fine even if Faux Pas is not installed (Faux Pas analysis will be skipped).

Download

Checkout the Releases page.

The full release history is also available in CHANGELOG.md.

Launching an analysis

If you use fastlane, please read our fastlane integration doc. Otherwise, run the run-sonar-swift.sh script from your Xcode project root folder

Prerequisites

  • a Mac with Xcode 7 or +
  • SonarQube and SonarQube Scanner
  • xcpretty (see instructions below)
  • SwiftLint (HomeBrew installed and brew install swiftlint). Version 0.3.0 or above.
  • Tailor (HomeBrew installed and brew install tailor). Version 0.11.1 or above.
  • slather (gem install slather). Version 2.1.0 or above (2.4 since Xcode 8.3).
  • lizard (PIP installed and sudo pip install lizard)
  • OCLint installed. Version 0.11.0 recommended (0.13.0 since Xcode 9).
  • Faux Pas command line tools installed (optional)

Installation of xcpretty with JUnit reports fix

At the time, xcpretty needs to be fixed to work with SonarQube.

To install the fixed version, follow those steps :

git clone https://github.com/Backelite/xcpretty.git
cd xcpretty
git checkout fix/duration_of_failed_tests_workaround
gem build xcpretty.gemspec
sudo gem install --both xcpretty-0.2.2.gem

Installation (once for all your Swift projects)

  • Download the plugin binary into the $SONARQUBE_HOME/extensions/plugins directory
  • Copy run-sonar-swift.sh somewhere in your PATH
  • Restart the SonarQube server.

Configuration (once per project)

  • Copy sonar-project.properties in your Xcode project root folder (along your .xcodeproj file)
  • Edit the sonar-project.properties file to match your Xcode iOS/MacOS project

The good news is that you don't have to modify your Xcode project to enable SonarQube!. Ok, there might be one needed modification if you don't have a specific scheme for your test target, but that's all.

Update (once per plugin update)

  • Install the lastest plugin version
  • Copy run-sonar-swift.sh somewhere in your PATH

If you still have run-sonar-swift.sh file in each of your project (not recommended), you will need to update all those files.

Contributing

Thank you for your interest in the project! Contributions are welcome and appreciated.

Make sure to read these guides before getting started:

License

SonarQube Plugin for Swift is released under the GNU LGPL v3 license. See the LICENSE file for more info.

sonar-swift's People

Contributors

zippy1978 avatar gaelfoppolo avatar alex009 avatar bcolvin avatar tzwickl avatar meltenc avatar akshaysyaduvanshi avatar davidy4ng avatar delannoyk avatar iwang-atlassian avatar branlute avatar ch-one avatar xiaowenvc avatar pbernery avatar hugal31 avatar benjohnde avatar zewaren avatar gretzki avatar kasparskurms avatar milch avatar marcusdroy avatar mammuth avatar viteinfinite avatar egr-ext avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.