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

AI-generated Sonarqube issue remediation: remediation_branch-2024-08-23_18-01 -> master #6

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
762d7f8
Issue: ad141d06-76e2-4da9-909f-d03e496476e5. Description: Add "lang" …
ovkhasch Aug 23, 2024
5f62d77
Issue: d0079850-10a0-4f56-b41b-4e47cd6163f3. Description: Add a <titl…
ovkhasch Aug 23, 2024
0348e1a
Issue: 14e3d40a-1cd2-4c80-a613-691ee287c19e. Description: Insert a <!…
ovkhasch Aug 23, 2024
cfd75aa
Issue: 01bb1f7b-70e7-46c7-8440-e1386614f499. Description: Define and …
ovkhasch Aug 23, 2024
23ca9f6
Issue: 28b4ae57-859b-4ab5-9d53-af48d9a3a5ba. Description: Revoke and …
ovkhasch Aug 23, 2024
03d8093
Issue: 68aa06f1-0541-4af8-aaf1-10f47ac63914. Description: Make sure t…
ovkhasch Aug 23, 2024
290b1c0
Issue: 0cac7719-3465-4b86-b4a1-1cbcaee4de54. Description: Define a co…
ovkhasch Aug 23, 2024
2772168
Issue: 220411c0-db15-402e-8a60-e56b45a43caa. Description: Remove usel…
ovkhasch Aug 23, 2024
2df9f2c
Issue: 0d1b603d-6a01-4b9c-b417-5e1cc25c0d72. Description: Rename "own…
ovkhasch Aug 23, 2024
5430330
Issue: 55ca918b-262e-457a-bdc7-5fdcf8f3418e. Description: Add an "alt…
ovkhasch Aug 23, 2024
26aa938
Issue: bc2c55b5-d269-4154-b2d1-71b60ee7e623. Description: A form labe…
ovkhasch Aug 23, 2024
e5d5df5
Issue: 3412cbf4-60c1-4ef9-a050-2f641e7ad1d0. Description: Add "<th>" …
ovkhasch Aug 23, 2024
bfe771c
Issue: 0930e792-03b0-4acf-a7e9-132440a5dfb6. Description: Remove this…
ovkhasch Aug 23, 2024
c30f949
Issue: f67d8eaa-9bd9-463f-93b6-e69d6ed0bd28. Description: Remove this…
ovkhasch Aug 23, 2024
e7f7404
Issue: e9b1daa4-ba0c-4458-9173-96659cee4bf3. Description: Unexpected …
ovkhasch Aug 23, 2024
cbc6c44
Issue: e9c5f430-fc9c-4e3e-a633-de0fe96290a2. Description: Use another…
ovkhasch Aug 23, 2024
3d84192
Issue: 4182d123-061d-4e6b-93f3-da05b5b786be. Description: Rename fiel…
ovkhasch Aug 23, 2024
3c86427
Issue: c4939b8c-363f-480a-bf4c-ba4f21f9054a. Description: Add a priva…
ovkhasch Aug 23, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ class CacheConfiguration {

@Bean
public JCacheManagerCustomizer petclinicCacheConfigurationCustomizer() {
return cm -> {
cm.createCache("vets", cacheConfiguration());
};
return cm -> cm.createCache("vets", cacheConfiguration());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@
@XmlRootElement
public class Vets {

private List<Vet> vets;
private List<Vet> veterinarianList;

@XmlElement
public List<Vet> getVetList() {
if (vets == null) {
vets = new ArrayList<>();
if (veterinarianList == null) {
veterinarianList = new ArrayList<>();
}
return vets;
return veterinarianList;
}

}
2 changes: 0 additions & 2 deletions src/main/less/header.less
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@
font-family: "montserratregular", sans-serif;
text-shadow: none;
font-size: 14px;

/* line-height: 14px; */
padding: 28px 20px;
transition: all 0.15s;
-webkit-transition: all 0.15s;
Expand Down
2 changes: 0 additions & 2 deletions src/main/less/petclinic.less
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,6 @@ table td.action-column {
.deployment-status-deploying {
.label-info
}
.deployment-status-na {
}

.container-details-table th {
background-color: lighten(@spring-brown, 3%);
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/application-mysql.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
database=mysql
spring.datasource.url=jdbc:mysql://localhost/petclinic
spring.datasource.username=root
spring.datasource.password=petclinic
spring.datasource.password=${DB_PASSWORD}
# Uncomment this the first time the app runs
# spring.datasource.initialization-mode=always
9 changes: 6 additions & 3 deletions src/main/resources/templates/error.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
<!DOCTYPE html>

<html xmlns:th="https://www.thymeleaf.org" th:replace="~{fragments/layout :: layout (~{::body},'error')}">
<html lang="en" xmlns:th="https://www.thymeleaf.org" th:replace="~{fragments/layout :: layout (~{::body},'error')}">

<head>
<title>Error Page</title>
</head>
<body>
<img src="../static/resources/images/pets.png" th:src="@{/resources/images/pets.png}"/>
<img src="../static/resources/images/pets.png" th:src="@{/resources/images/pets.png}" alt="Pets Image"/>
<h2>Something happened...</h2>
<p th:text="${message}">Exception message</p>
</body>

</html>
</html>
13 changes: 8 additions & 5 deletions src/main/resources/templates/fragments/inputField.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@
<div th:with="valid=${!#fields.hasErrors(name)}"
th:class="${'form-group' + (valid ? '' : ' has-error')}"
class="form-group">
<label class="col-sm-2 control-label" th:text="${label}">Label</label>
<div class="col-sm-10">
<div th:switch="${type}">
<input th:case="'text'" class="form-control" type="text" th:field="*{__${name}__}" />
<input th:case="'date'" class="form-control" type="text" th:field="*{__${name}__}"
placeholder="YYYY-MM-DD" title="Enter a date in this format: YYYY-MM-DD"
pattern="(?:19|20)[0-9]{2}-(?:(?:0[1-9]|1[0-2])-(?:0[1-9]|1[0-9]|2[0-9])|(?:(?!02)(?:0[1-9]|1[0-2])-(?:30))|(?:(?:0[13578]|1[02])-31))"/>
<label class="col-sm-2 control-label" th:text="${label}">
<input th:case="'text'" class="form-control" type="text" th:field="*{__${name}__}" />
</label>
<label class="col-sm-2 control-label" th:text="${label}">
<input th:case="'date'" class="form-control" type="text" th:field="*{__${name}__}"
placeholder="YYYY-MM-DD" title="Enter a date in this format: YYYY-MM-DD"
pattern="(?:19|20)[0-9]{2}-(?:(?:0[1-9]|1[0-2])-(?:0[1-9]|1[0-9]|2[0-9])|(?:(?!02)(?:0[1-9]|1[0-2])-(?:30))|(?:(?:0[13578]|1[02])-31))"/>
</label>
</div>
<span th:if="${valid}"
class="glyphicon glyphicon-ok form-control-feedback"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<!DOCTYPE html>
<html xmlns:th="https://www.thymeleaf.org"
th:replace="~{fragments/layout :: layout (~{::body},'owners')}">

Expand Down
32 changes: 17 additions & 15 deletions src/main/resources/templates/owners/ownerDetails.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ <h2>Pets and Visits</h2>
<table class="table table-striped">

<tr th:each="pet : ${owner.pets}">
<td valign="top">
<td style="vertical-align: top;">
<dl class="dl-horizontal">
<dt>Name</dt>
<dd th:text="${pet.name}" /></dd>
Expand All @@ -56,22 +56,24 @@ <h2>Pets and Visits</h2>
<table class="table-condensed">
<thead>
<tr>
<th>Visit Date</th>
<th>Description</th>
<th scope="col">Visit Date</th>
<th scope="col">Description</th>
</tr>
</thead>
<tr th:each="visit : ${pet.visits}">
<td th:text="${#temporals.format(visit.date, 'yyyy-MM-dd')}"></td>
<td th:text="${visit?.description}"></td>
</tr>
<tr>
<td><a
th:href="@{{ownerId}/pets/{petId}/edit(ownerId=${owner.id},petId=${pet.id})}">Edit
Pet</a></td>
<td><a
th:href="@{{ownerId}/pets/{petId}/visits/new(ownerId=${owner.id},petId=${pet.id})}">Add
Visit</a></td>
</tr>
<tbody>
<tr th:each="visit : ${pet.visits}">
<td th:text="${#temporals.format(visit.date, 'yyyy-MM-dd')}"></td>
<td th:text="${visit?.description}"></td>
</tr>
<tr>
<td><a
th:href="@{{ownerId}/pets/{petId}/edit(ownerId=${owner.id},petId=${pet.id})}">Edit
Pet</a></td>
<td><a
th:href="@{{ownerId}/pets/{petId}/visits/new(ownerId=${owner.id},petId=${pet.id})}">Add
Visit</a></td>
</tr>
</tbody>
</table>
</td>
</tr>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class PetclinicIntegrationTests {
private VetRepository vets;

@Test
public void testFindAll() throws Exception {
public void testFindAll() throws PetclinicTestException {
vets.findAll();
vets.findAll(); // served from cache
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
public class PetControllerTests {

private static final int TEST_OWNER_ID = 1;
private static final String PETS_NEW_URL = "/owners/{ownerId}/pets/new";
private static final int TEST_PET_ID = 1;


Expand All @@ -80,15 +81,15 @@ public void setup() {

@Test
public void testInitCreationForm() throws Exception {
mockMvc.perform(get("/owners/{ownerId}/pets/new", TEST_OWNER_ID))
mockMvc.perform(get(PETS_NEW_URL, TEST_OWNER_ID))
.andExpect(status().isOk())
.andExpect(view().name("pets/createOrUpdatePetForm"))
.andExpect(model().attributeExists("pet"));
}

@Test
public void testProcessCreationFormSuccess() throws Exception {
mockMvc.perform(post("/owners/{ownerId}/pets/new", TEST_OWNER_ID)
mockMvc.perform(post(PETS_NEW_URL, TEST_OWNER_ID)
.param("name", "Betty")
.param("type", "hamster")
.param("birthDate", "2015-02-12")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,13 @@ public void shouldThrowParseException() throws ParseException {
*/
private List<PetType> makePetTypes() {
List<PetType> petTypes = new ArrayList<>();
petTypes.add(new PetType() {
{
setName("Dog");
}
});
petTypes.add(new PetType() {
{
setName("Bird");
}
});
PetType dog = new PetType();
dog.setName("Dog");
petTypes.add(dog);

PetType bird = new PetType();
bird.setName("Bird");
petTypes.add(bird);
return petTypes;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ public void shouldFindSingleOwnerWithPet() {
@Test
@Transactional
public void shouldInsertOwner() {
Collection<Owner> owners = this.owners.findByLastName("Schultz");
int found = owners.size();
Collection<Owner> foundOwners = this.owners.findByLastName("Schultz");
int found = foundOwners.size();

Owner owner = new Owner();
owner.setFirstName("Sam");
Expand All @@ -109,8 +109,8 @@ public void shouldInsertOwner() {
this.owners.save(owner);
assertThat(owner.getId().longValue()).isNotEqualTo(0);

owners = this.owners.findByLastName("Schultz");
assertThat(owners.size()).isEqualTo(found + 1);
foundOwners = this.owners.findByLastName("Schultz");
assertThat(foundOwners.size()).isEqualTo(found + 1);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,9 @@
*/
public abstract class EntityUtils {

/**
* Look up the entity of the given class with the given id in the given collection.
*
* @param entities the collection to search
* @param entityClass the entity class to look up
* @param entityId the entity id to look up
* @return the found entity
* @throws ObjectRetrievalFailureException if the entity was not found
*/
private EntityUtils() {
throw new IllegalStateException("Utility class");
}
public static <T extends BaseEntity> T getById(Collection<T> entities, Class<T> entityClass, int entityId)
throws ObjectRetrievalFailureException {
for (T entity : entities) {
Expand Down