fix code smells
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
Beatrice Dellacà 2025-03-09 11:52:26 +01:00
parent 44add27d5e
commit a5d647e6ba
2 changed files with 7 additions and 9 deletions

View File

@ -81,11 +81,9 @@ public class ClearChat
// set how many messages to delete for this iteration (usually <limit> unless there's a remainder) // set how many messages to delete for this iteration (usually <limit> unless there's a remainder)
int iterationSize = limit; int iterationSize = limit;
// if we are at the last iteration... // if we are at the last iteration... check if we have <limit> or fewer messages to delete
if(iteration+1 == iterations) if(iteration+1 == iterations && remainder != 0) {
{ iterationSize = remainder;
// check if we have <limit> or fewer messages to delete
if(remainder != 0) iterationSize = remainder;
} }
if(iterationSize == 1) if(iterationSize == 1)
@ -112,19 +110,19 @@ public class ClearChat
outOfBounds = true; outOfBounds = true;
} else { } else {
// before deleting, we need to grab the <previous to the oldest> message's id for next iteration. // before deleting, we need to grab the <previous to the oldest> message's id for next iteration.
action = channel.getHistoryBefore(messages.get(messages.size() - 1).getIdLong(), 1); action = channel.getHistoryBefore(messages.getLast().getIdLong(), 1);
List<Message> previousMessage = action.complete().getRetrievedHistory(); List<Message> previousMessage = action.complete().getRetrievedHistory();
// if that message exists (we are not out of bounds)... store it // if that message exists (we are not out of bounds)... store it
if(!previousMessage.isEmpty()) messageId = previousMessage.get(0).getIdLong(); if(!previousMessage.isEmpty()) messageId = previousMessage.getFirst().getIdLong();
else outOfBounds = true; else outOfBounds = true;
} }
// queue messages for deletion // queue messages for deletion
if(messages.size() == 1) if(messages.size() == 1)
{ {
messages.get(0).delete().queue(); messages.getFirst().delete().queue();
} }
else if(!messages.isEmpty()) else if(!messages.isEmpty())
{ {

View File

@ -11,7 +11,7 @@ public class Logger<T>
{ {
// objects that we need to have for a properly formatted message // objects that we need to have for a properly formatted message
private String className; private final String className;
private final String format = "[%date% %time%] [%class%] %message%"; private final String format = "[%date% %time%] [%class%] %message%";
private final DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); private final DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
private final DateTimeFormatter timeFormatter = DateTimeFormatter.ofPattern("HH:mm:ss"); private final DateTimeFormatter timeFormatter = DateTimeFormatter.ofPattern("HH:mm:ss");