From e62f0c1ed3376557ca3be1bf61ad6436679979f0 Mon Sep 17 00:00:00 2001 From: Rodrigo Zambrana Date: Mon, 16 Dec 2024 13:53:11 -0300 Subject: [PATCH] Sonar cloud fixes -Define a constant instead of duplicating this literal -Remove this empty statement. --- .../ui/admin/election/ElectionsListPanel.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/elections-admin-web/src/main/java/net/lacnic/elections/adminweb/ui/admin/election/ElectionsListPanel.java b/elections-admin-web/src/main/java/net/lacnic/elections/adminweb/ui/admin/election/ElectionsListPanel.java index 9627478..5dee357 100644 --- a/elections-admin-web/src/main/java/net/lacnic/elections/adminweb/ui/admin/election/ElectionsListPanel.java +++ b/elections-admin-web/src/main/java/net/lacnic/elections/adminweb/ui/admin/election/ElectionsListPanel.java @@ -29,7 +29,6 @@ import net.lacnic.elections.adminweb.wicket.util.UtilsParameters; import net.lacnic.elections.domain.Election; - public class ElectionsListPanel extends Panel { private static final long serialVersionUID = -7217245542954325281L; @@ -38,7 +37,6 @@ public class ElectionsListPanel extends Panel { private long userAdminId; - public ElectionsListPanel(String id, PageParameters pars) { super(id); List electionsList = new ArrayList<>(); @@ -89,22 +87,25 @@ protected void populateItem(ListItem item) { BookmarkablePageLink census = new BookmarkablePageLink<>("manageCensus", ElectionCensusDashboard.class, UtilsParameters.getId(currentElection.getElectionId())); census.setMarkupId("electionCensus" + currentElection.getElectionId()); census.setEnabled(!currentElection.isClosed()); + String atribute = "class"; + String btnClass = "btn-circle btn-primary btn-sm"; + if (currentElection.isElectorsSet()) - census.add(new AttributeModifier("class", "btn-circle btn-primary btn-sm")); + census.add(new AttributeModifier(atribute, btnClass)); item.add(census); BookmarkablePageLink candidates = new BookmarkablePageLink<>("candidates", ElectionCandidatesDashboard.class, UtilsParameters.getId(currentElection.getElectionId())); candidates.setMarkupId("electionCandidates" + currentElection.getElectionId()); candidates.setEnabled(!currentElection.isClosed()); if (currentElection.isCandidatesSet()) - candidates.add(new AttributeModifier("class", "btn-circle btn-primary btn-sm")); + candidates.add(new AttributeModifier(atribute, btnClass)); item.add(candidates); BookmarkablePageLink auditors = new BookmarkablePageLink<>("auditors", ElectionAuditorsDashboard.class, UtilsParameters.getId(currentElection.getElectionId())); auditors.setMarkupId("electionAuditors" + currentElection.getElectionId()); auditors.setEnabled(!currentElection.isClosed()); if (currentElection.isAuditorsSet()) - auditors.add(new AttributeModifier("class", "btn-circle btn-primary btn-sm")); + auditors.add(new AttributeModifier(atribute, btnClass)); item.add(auditors); ButtonDeleteWithConfirmation buttonDeleteWithConfirmation = new ButtonDeleteWithConfirmation("removeElection", currentElection.getElectionId()) { @@ -121,7 +122,7 @@ public void onConfirm() { } else { isNew = false; isJoint = AppContext.getInstance().getManagerBeanRemote().isJointElection(currentElection.getElectionId()); - }; + } if ((!isNew) && (isJoint)) { SecurityUtils.error(getString("deleteElectionErrorJoint")); @@ -147,7 +148,7 @@ public void onConfirm() { BookmarkablePageLink manageEmailsLink = new BookmarkablePageLink<>("manageEmails", EmailTemplatesDashboard.class, UtilsParameters.getId(currentElection.getElectionId())); manageEmailsLink.setMarkupId("manageEmails" + currentElection.getElectionId()); manageEmailsLink.setVisible(!currentElection.isClosed()); - item.add(manageEmailsLink); + item.add(manageEmailsLink); BookmarkablePageLink statsLink = new BookmarkablePageLink<>("seeStats", StatsDashboard.class, UtilsParameters.getId(currentElection.getElectionId())); statsLink.setMarkupId("seeStats" + currentElection.getElectionId());