Skip to content

Commit

Permalink
Lint
Browse files Browse the repository at this point in the history
  • Loading branch information
fdaugan committed Aug 8, 2023
1 parent ccb8f6e commit c473293
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
@Getter
@Setter
@JsonIgnoreProperties(ignoreUnknown = true)
public class SonarMesure implements Serializable {
public class SonarMeasure implements Serializable {

/**
* SID
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import jakarta.ws.rs.*;
import jakarta.ws.rs.core.MediaType;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -88,7 +89,7 @@ public void link(final int subscription) throws Exception {

/**
* Validate the project connectivity.
*
*
* @param parameters the project parameters.
* @return project details.
* @throws IOException When JSON parsing failed.
Expand All @@ -108,7 +109,7 @@ protected SonarProject validateProject(final Map<String, String> parameters) thr

/**
* Validate the basic REST connectivity to SonarQube.
*
*
* @param parameters the server parameters.
* @return the detected SonarQube version.
* @throws IOException When JSON parsing failed.
Expand All @@ -117,8 +118,7 @@ protected String validateAdminAccess(final Map<String, String> parameters) throw
final var url = StringUtils.appendIfMissing(parameters.get(PARAMETER_URL), "/") + "sessions/new";
CurlProcessor.validateAndClose(url, PARAMETER_URL, "sonar-connection");

// Check the user can logins to SonarQube with the preempted authentication
// processor
// Check the user can logins to SonarQube with the preempted authentication processor
if (!StringUtils.trimToEmpty(getResource(parameters, "api/authentication/validate?format=json"))
.contains("true")) {
throw new ValidationJsonException(PARAMETER_USER, "sonar-login");
Expand All @@ -134,7 +134,7 @@ protected String validateAdminAccess(final Map<String, String> parameters) throw
/**
* Return a SonarQube's resource. Return <code>null</code> when the resource is
* not found.
*
*
* @param parameters The subscription parameters.
* @param resource The SonarQube resource URL to query.
* @return The JSON data.
Expand All @@ -146,7 +146,7 @@ protected String getResource(final Map<String, String> parameters, final String
/**
* Return a SonarQube's resource. Return <code>null</code> when the resource is
* not found.
*
*
* @param processor The CURL processor.
* @param url The base URL.
* @param resource The SonarQube resource URL to query.
Expand All @@ -166,7 +166,7 @@ public String getVersion(final Map<String, String> parameters) throws IOExceptio

/**
* Return all SonarQube project without limit.
*
*
* @param parameters The subscription parameters.
* @return The gathered SonarQube projects data.
* @throws IOException When JSON parsing failed.
Expand All @@ -180,7 +180,7 @@ protected List<SonarProject> getProjects(final Map<String, String> parameters) t

/**
* Return SonarQube project from its identifier.
*
*
* @param parameters The subscription parameters.
* @param id The SonarQube project identifier.
* @return The gathered SonarQube data.
Expand All @@ -199,15 +199,15 @@ protected SonarProject getProject(final Map<String, String> parameters, final in

// Map nicely the measures
project.setMeasures(
project.getRawMesures().stream().collect(Collectors.toMap(SonarMesure::getKey, SonarMesure::getValue)));
project.setRawMesures(null);
project.getRawMeasures().stream().collect(Collectors.toMap(SonarMeasure::getKey, SonarMeasure::getValue)));
project.setRawMeasures(null);
return project;
}

/**
* Search the SonarQube's projects matching to the given criteria. Name, display
* name and description are considered.
*
*
* @param node the node to be tested with given parameters.
* @param criteria the search criteria.
* @return project names matching the criteria.
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/ligoj/app/plugin/qa/sonar/SonarProject.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ public class SonarProject extends NamedBean<Integer> implements IDescribableBean
* SonarQube raw structure.
*/
@JsonProperty("msr")
private List<SonarMesure> rawMesures;
private List<SonarMeasure> rawMeasures;

/**
* Mapped values for easiest traversals.
*/
private Map<String, Integer> measures;

/**
* Human readable key
* Human-readable key
*/
private String key;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,12 @@ void prepareData() throws IOException {
persistEntities("csv",
new Class[] { Node.class, Parameter.class, Project.class, Subscription.class, ParameterValue.class, },
StandardCharsets.UTF_8);
}

@Test
void getKey() {
// Coverage only
resource.getKey();
Assertions.assertEquals("",resource.getKey());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,12 @@ void prepareData() throws IOException {
persistEntities("csv", new Class[]{Node.class, Parameter.class, Project.class, Subscription.class, ParameterValue.class},
StandardCharsets.UTF_8);
this.subscription = getSubscription("gStack");
}

@Test
void getKey() {
// Coverage only
resource.getKey();
Assertions.assertEquals("",resource.getKey());
}

/**
Expand Down

0 comments on commit c473293

Please sign in to comment.