It has your back … by riding your back
This article contains my notes on Static Analysis of code.
SonarQube (abbreviated to Sonar here) improves code quality by scanning source code to identify issues from meaures it calculates. The functionality it performs is SonarQube performs “static analysis” of programming code.
Static Analysis vs Lint
The value proposition for using static analysis tools versus simpler lint programs is the time and frustration that developers save analyzing false positives, which leads to less usage and thus more lingering defects (“technical debt”).
A summary of what SonarQube finds estimates Technical Debt, which SonarQube tracks over time.
Sonar scans different facets (such as security).
Sonar analyzes various languages using plug-ins.
### Sonar for Scala #
http://www.scalastyle.org/ provides a list of ways to use Scalastyle at https://github.com/scalastyle
by 3 people:
- Matthew Farwell (http://www.farwell.co.uk/ of Switzerland)
is based on a fork of https://github.com/NCR-CoDE/sonar-scalastyle
SQALE Summary Ratings
Sonar calculates a SQALE Rating based on the open-source SQALE (Software Quality Assessment based on Lifecycle Expectations) methodology defined by industry group http://www.sqale.org/. The caluculation is based on inclusion of rules set in the Common SonarQube repository:
- Duplicated blocks
- Failed unit tests
- Insufficient branch coverage by unit tests
- Insufficient comment density
- Insufficient line coverage by unit tests
- Skipped unit tests
Change SQUALE calculations in the plug-in http://www.sonarsource.com/products/plugins/governance/sqale/
SonarQube Analyzers scan code organized into projects.
Coding standards include:
MISRA (Motor Industry Software Reliability Association) was first published in April 2013 to support C99 and C90 versions of the C language, used mostly for embedded software development.
Customizable Tags provide a way to categorize and filter rules.
Install Enviornment to Run SonarQube
Since SonarQube runs as a server, it’s best to have it run within a VM.
Install Enviornment to Run SonarQube
Install SonarQube using Homebrew:
brew install scalastyle
This page was written after downloading file SonarQube 5.1.2 created Jul. 27, 2015 from http://www.sonarqube.org/
Most developers prefer to have Sonar look at code before commit into a team repository. Such preview mode runs do not store results in the Sonar run database.
Plugins enable Sonar to be invoked several ways:
From inside IDE (IntelliJ, Eclipse, etc.) as part of code unit development and testing.
From a build server (Maven, Ant, MSBuild, etc.) as part of continuous integration/build.
The server uses Oracle or OpenSDK, which requires much more work https://github.com/hgomez/obuildfactory/wiki/Building-and-Packaging-OpenJDK7-for-OSX So please stay with Oracle for now.
MySQL is supported.
Docker and Puppet scripts to build the server ???
- Read the documentation
- Unzip and start
- Analyze projects
- Ready to improve quality
Connection to Jenkins: http://docs.sonarqube.org/display/PLUG/SonarQube+Scanner+for+Jenkins
http://www.sonarlint.org/visualstudio/ SonarLint for Visual Studio is based on and benefits from the .NET Compiler Platform (“Roslyn”) and its code analysis API to provide a fully-integrated user experience in Visual Studio 2015. SonarLint is free, open source, and available in the Visual Studio Gallery.
This article on July 2016 reported that researchers from NYU found that static scans found only 2% of defects injected by their PDF about their LAVA (Large-Scale Automated Vulnerability Addition).
More on DevOps
This is one of a series on DevOps:
- ci-cd (Continuous Integration and Continuous Delivery)
- Git and GitHub vs File Archival
- Git Commands and Statuses
- Git Commit, Tag, Push
- Git Utilities
- Data Security GitHub
- GitHub API
- Choices for DevOps Technologies
- Java DevOps Workflow
- AWS DevOps (CodeCommit, CodePipeline, CodeDeploy)
- Cloud regions
- AWS Virtual Private Cloud
- Azure Cloud Onramp
- Azure Cloud
- Azure Cloud Powershell
- Digital Ocean
- Packer automation to build Vagrant images
Terraform multi-cloud provisioning automation
- Powershell Ecosystem
- Powershell on MacOS
- Jenkins Server Setup
- Jenkins Plug-ins
- Jenkins Freestyle jobs
- Dockerize apps
- Docker Setup
- API Management Microsoft
- Scenarios for load