mirror of
https://github.com/Sheldan/abstracto.git
synced 2026-04-14 03:45:57 +00:00
addressed sonar code smells
This commit is contained in:
@@ -25,7 +25,7 @@ public class DecayAllWarnings extends AbstractConditionableCommand {
|
||||
@Override
|
||||
public CommandResult execute(CommandContext commandContext) {
|
||||
List<Object> parameters = commandContext.getParameters().getParameters();
|
||||
Boolean logWarnings = !parameters.isEmpty() ? (Boolean) parameters.get(0) : Boolean.FALSE;
|
||||
boolean logWarnings = !parameters.isEmpty() ? (Boolean) parameters.get(0) : Boolean.FALSE;
|
||||
warnService.decayAllWarningsForServer(commandContext.getUserInitiatedContext().getServer(), logWarnings);
|
||||
return CommandResult.fromSuccess();
|
||||
}
|
||||
|
||||
@@ -7,13 +7,10 @@ import dev.sheldan.abstracto.core.command.config.Parameter;
|
||||
import dev.sheldan.abstracto.core.command.execution.CommandContext;
|
||||
import dev.sheldan.abstracto.core.command.execution.CommandResult;
|
||||
import dev.sheldan.abstracto.core.config.FeatureEnum;
|
||||
import dev.sheldan.abstracto.core.models.database.AUserInAServer;
|
||||
import dev.sheldan.abstracto.core.service.management.UserInServerManagementService;
|
||||
import dev.sheldan.abstracto.moderation.config.ModerationModule;
|
||||
import dev.sheldan.abstracto.moderation.config.features.ModerationFeatures;
|
||||
import dev.sheldan.abstracto.moderation.service.management.UserNoteManagementService;
|
||||
import dev.sheldan.abstracto.templating.service.TemplateService;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ public class Warnings extends AbstractConditionableCommand {
|
||||
@Override
|
||||
public CommandResult execute(CommandContext commandContext) {
|
||||
List<Warning> warnsToDisplay;
|
||||
if(commandContext.getParameters().getParameters().size() > 0) {
|
||||
if(!commandContext.getParameters().getParameters().isEmpty()) {
|
||||
Member member = (Member) commandContext.getParameters().getParameters().get(0);
|
||||
warnsToDisplay = warnManagementService.getAllWarnsForUser(userInServerManagementService.loadUser(member));
|
||||
} else {
|
||||
|
||||
@@ -23,7 +23,6 @@ import java.util.HashMap;
|
||||
public class JoinLogger implements JoinListener {
|
||||
|
||||
private static final String USER_JOIN_TEMPLATE = "user_join";
|
||||
private static final String JOIN_LOG_TARGET = "joinLog";
|
||||
|
||||
@Autowired
|
||||
private TemplateService templateService;
|
||||
|
||||
@@ -19,7 +19,6 @@ import org.springframework.stereotype.Component;
|
||||
@Slf4j
|
||||
public class MessageDeleteLogListener implements MessageDeletedListener {
|
||||
|
||||
private static final String DELETE_LOG_TARGET = "deleteLog";
|
||||
private static final String MESSAGE_DELETED_TEMPLATE = "message_deleted";
|
||||
private static final String MESSAGE_DELETED_ATTACHMENT_TEMPLATE = "message_deleted_attachment";
|
||||
|
||||
|
||||
@@ -80,7 +80,6 @@ public class MuteServiceBean implements MuteService {
|
||||
|
||||
private static final String MUTE_LOG_TEMPLATE = "mute_log";
|
||||
private static final String UNMUTE_LOG_TEMPLATE = "unmute_log";
|
||||
private static final String MUTE_LOG_TARGET = "muteLog";
|
||||
private static final String MUTE_NOTIFICATION_TEMPLATE = "mute_notification";
|
||||
|
||||
@Override
|
||||
@@ -225,7 +224,7 @@ public class MuteServiceBean implements MuteService {
|
||||
// but if the person gets unmuted immediately, via command, this might still execute of the instant unmute
|
||||
// so we need to load the mute, and check if the mute was unmuted already, because the mute object we have at
|
||||
// hand was loaded earlier, and does not reflect the true state
|
||||
if(updatedMute.getMuteEnded()) {
|
||||
if(Boolean.TRUE.equals(updatedMute.getMuteEnded())) {
|
||||
log.info("Mute {} has ended already, {} does not need to be unmuted anymore.", mute.getId(), mute.getMutedUser().getUserReference().getId());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -148,7 +148,7 @@ public class WarnServiceBean implements WarnService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void decayAllWarningsForServer(AServer server, Boolean logWarnings) {
|
||||
public void decayAllWarningsForServer(AServer server, boolean logWarnings) {
|
||||
List<Warning> warningsToDecay = warnManagementService.getActiveWarningsInServerOlderThan(server, Instant.now());
|
||||
decayWarnings(warningsToDecay);
|
||||
if(logWarnings) {
|
||||
|
||||
@@ -15,5 +15,5 @@ public interface WarnService {
|
||||
Warning warnUser(FullUser warnedUser, FullUser warningUser, String reason, TextChannel feedbackChannel);
|
||||
void warnUserWithLog(Member warnedMember, Member warningMember, String reason, WarnLog warnLog, TextChannel feedbackChannel);
|
||||
void decayWarningsForServer(AServer server);
|
||||
void decayAllWarningsForServer(AServer server, Boolean logWarnings);
|
||||
void decayAllWarningsForServer(AServer server, boolean logWarnings);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user