In Linux, sonar is mainly used to manage code quality, and two important parameters are the number of violations and the number of lines of code. This article will introduce the way that Linux uses sonar to get the number of violations and the number of lines of code.
demo follows:
public class SonarDemo {
static String host = & ldquo; http: //xxx: 9000 & rdquo ;;
static String username = “xxx”;
static String password = “xxx”;
static String resourceKey = “org.codehaus.sonar:sonar-ws-client”;
static String[] MEASURES_TO_GET = new String[] { “violations”, “lines” };
public static void main(String[] args) {
DecimalFormat Df = new DecimalFormat(“#.##”);
//Create Sonar
Sonar sonar = new Sonar(new HttpClient4Connector(new Host(host, username, password)) );
//Execute resource request
ResourceQuery query = ResourceQuery.createForMetrics(resourceKey, MEASURES_TO_GET);
query.setIncludeTrends(true);
Resource resource = sonar.find(query);
//Loop traversal gets “violations”, “lines”
List "Measure" allMeasures = resource.getMeasures();
for (Measure measure : allMeasures) {
System.out.println((measure.getMetricKey() + “: ” +
df.format(measure.getValue())));
}
}
} Previous 12 Next Total 2 Pages
As a computer system, its desktop design is very important. Although the Linux desk
UTF-8 is a variable-length character Unicode code for Linux systems that supports m
last is a built-in tracking tool for Linux system, can list the relevant information of the login us
A lot of linux users will give the system a network cable to connect to the interna
Linux method of cutting txt large files into small files through shell script
How to add custom fonts on Linux
How does the Linux system simulate the get or post request of Http?
Deep understanding of Linux text stream
Linux system how to configure multi-path
How to use the sync command on Linux
Linux can not delete users with urserdel?
Linux system switching root user skills
How to set Linux commands as keyboard shortcuts
What should I do if the GRUB boot error occurs when CentOS is booting?
Linux method for converting plain text documents into PDF files
Win10 system update TH2 often blue screen how to solve
How to solve the problem that Win7 notebook sound is too small?
Win7 Ultimate NVIDIA graphics driver control panel location description
Why did Microsoft directly push Win10 RS1 Preview version 14251?
Win10 system blue screen page display QR code reason and solution
Just 3 steps to get the win7 wireless network sharing settings easily
Win7 system play video suddenly appears watchdog.sys blue screen how to do?
What should I do if the Win8 system does not have permission to delete files?