Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added version 10.x support #368

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 49 additions & 50 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>fr.cnes.sonar</groupId>
<artifactId>cnesreport</artifactId>
<version>4.2.0</version>
<version>4.2.1</version>
<packaging>sonar-plugin</packaging>

<name>SonarQube CNES Report</name>
Expand Down Expand Up @@ -34,10 +33,10 @@
<maven.compiler.target>11</maven.compiler.target>
<junit.version>5.9.2</junit.version>
<jacoco.version>0.8.8</jacoco.version>
<sonar.apiVersion>9.8.0.203</sonar.apiVersion>
<sonar.testingHarnessVersion>9.5.0.56709</sonar.testingHarnessVersion>
<sonar.Version>9.9.0.65466</sonar.Version>
<sonar-packaging-maven-plugin.version>1.21.0.505</sonar-packaging-maven-plugin.version>
<sonar.apiVersion>10.0.0.695</sonar.apiVersion>
<sonar.testingHarnessVersion>10.0.0.68432</sonar.testingHarnessVersion>
<sonar.Version>10.0.0.68432</sonar.Version>
<sonar-packaging-maven-plugin.version>1.23.0.740</sonar-packaging-maven-plugin.version>
<sonar.pluginKey>cnesreport</sonar.pluginKey>
<sonar.pluginUrl>https://github.com/cnescatlab/sonar-cnes-report</sonar.pluginUrl>
<sonar.pluginOrganizationName>CNES</sonar.pluginOrganizationName>
Expand Down Expand Up @@ -201,10 +200,10 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<version>${junit.version}</version>
</dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<version>${junit.version}</version>
</dependency>
<dependency>
<groupId>com.github.stefanbirkner</groupId>
<artifactId>system-rules</artifactId>
Expand Down Expand Up @@ -287,18 +286,18 @@
</plugin>

<plugin>
<!-- UTF-8 bundles are not supported by Java, so they must be converted during build -->
<groupId>org.codehaus.mojo</groupId>
<artifactId>native2ascii-maven-plugin</artifactId>
<version>2.0.1</version>
<executions>
<execution>
<goals>
<goal>resources</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- UTF-8 bundles are not supported by Java, so they must be converted during build -->
<groupId>org.codehaus.mojo</groupId>
<artifactId>native2ascii-maven-plugin</artifactId>
<version>2.0.1</version>
<executions>
<execution>
<goals>
<goal>resources</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down Expand Up @@ -354,33 +353,33 @@
<artifactId>frontend-maven-plugin</artifactId>
<version>1.9.1</version>
<executions>
<execution>
<phase>generate-resources</phase>
<id>install node and yarn</id>
<goals>
<goal>install-node-and-yarn</goal>
</goals>
<configuration>
<nodeVersion>v16.14.0</nodeVersion>
<yarnVersion>v1.22.5</yarnVersion>
</configuration>
</execution>
<execution>
<id>yarn install</id>
<goals>
<goal>yarn</goal>
</goals>
</execution>
<execution>
<phase>generate-resources</phase>
<id>yarn run script</id>
<goals>
<goal>yarn</goal>
</goals>
<configuration>
<arguments>run build</arguments>
</configuration>
</execution>
<execution>
<phase>generate-resources</phase>
<id>install node and yarn</id>
<goals>
<goal>install-node-and-yarn</goal>
</goals>
<configuration>
<nodeVersion>v16.14.0</nodeVersion>
<yarnVersion>v1.22.5</yarnVersion>
</configuration>
</execution>
<execution>
<id>yarn install</id>
<goals>
<goal>yarn</goal>
</goals>
</execution>
<execution>
<phase>generate-resources</phase>
<id>yarn run script</id>
<goals>
<goal>yarn</goal>
</goals>
<configuration>
<arguments>run build</arguments>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ public abstract class AbstractDataProvider {
* Field to search in json to get a key
*/
protected static final String KEY = "key";
/**
* Field to search in json to get a name
*/
protected static final String NAME = "name";

/**
* Logger for the class
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,11 @@ protected QualityGate getProjectQualityGateAbstract()
QualityGate tmp;
boolean find = false;
final String key = jsonObject.getAsJsonObject(QUALITY_GATE).get(KEY).getAsString();
final String name = jsonObject.getAsJsonObject(QUALITY_GATE).get(NAME).getAsString();

while (iterator.hasNext() && !find) {
tmp = iterator.next();
if (tmp.getId().equals(key)) {
if (tmp.getName().equals(name) || tmp.getId().equals(key)) {
res = tmp;
find = true;
}
Expand Down
38 changes: 19 additions & 19 deletions src/main/js/common/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { getJSON, postJSON, post } from "sonar-request";

// Function used to get current SonarQube Server version
export function isCompatible() {
const COMPATIBILITY_PATTERN = /[8-9]\.9(\.[0-9])*/;
const COMPATIBILITY_PATTERN = /(?:[8-9]|10)\.\d+(\.\d+)*/;

return getJSON("/api/system/status").then(response => {
return response.version.match(COMPATIBILITY_PATTERN) != null;
Expand All @@ -16,19 +16,19 @@ export function isCompatible() {
//Functions used to get all user projects
//The maximum number of projects with this API (api/components/search) is 500.
//Thus, the objective is to display an infinite number of projects
export function getProjectsList(){
export function getProjectsList() {
const elementByPage = 500;
let allPromises = [];
//Get the number of projects and compute the number of pages required
return getJSON("/api/components/search", {"qualifiers": "TRK", "ps":elementByPage}).then(response => {
return getJSON("/api/components/search", { "qualifiers": "TRK", "ps": elementByPage }).then(response => {
const nbProjects = response.paging.total;
let nbPages = Math.ceil(nbProjects/elementByPage);
let nbPages = Math.ceil(nbProjects / elementByPage);
//Store the first page
allPromises.push(response.components);
//Fill the array of promises with next pages if there are ones
if (nbPages >= 2) {
for(let i = 2; i <= nbPages; i++){
allPromises.push(getJSON("/api/components/search", {"qualifiers": "TRK", "ps":elementByPage, "p":i}).then(response => {
for (let i = 2; i <= nbPages; i++) {
allPromises.push(getJSON("/api/components/search", { "qualifiers": "TRK", "ps": elementByPage, "p": i }).then(response => {
return response.components;
}));
}
Expand All @@ -37,23 +37,23 @@ export function getProjectsList(){
return Promise.all(allPromises);
}).then((results) => {
//Concatenate an array : x * 500 (x = number of pages)
let projects = [];
results.forEach((result) => {
projects = projects.concat(result);
})
//Sort the projects list for a user-friendlier display
//The name is displayed in the user interface, so we sort the projects by name
projects.sort(GetSortOrder("name"));
return projects;
});
let projects = [];
results.forEach((result) => {
projects = projects.concat(result);
})
//Sort the projects list for a user-friendlier display
//The name is displayed in the user interface, so we sort the projects by name
projects.sort(GetSortOrder("name"));
return projects;
});
}

//Comparator function in order to compare each specific key of the json array
function GetSortOrder(key){
return function(a, b){
if(a[key] > b[key]){
function GetSortOrder(key) {
return function (a, b) {
if (a[key] > b[key]) {
return 1;
} else if (a[key] < b[key]){
} else if (a[key] < b[key]) {
return -1;
}
return 0;
Expand Down
Loading