Skip to content

Commit

Permalink
refactor variable names as per sonar suggestion
Browse files Browse the repository at this point in the history
  • Loading branch information
ankitsmt211 committed Mar 6, 2024
1 parent 5595c19 commit 9f9f2d1
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,9 @@ RestAction<Message> constructChatGptAttempt(ThreadChannel threadChannel,
String answer = chatGPTAnswer.orElseThrow();
SelfUser selfUser = threadChannel.getJDA().getSelfUser();

int MESSAGE_CHARACTER_LIMIT = MessageEmbed.DESCRIPTION_MAX_LENGTH;
if (answer.length() > MESSAGE_CHARACTER_LIMIT) {
answer = answer.substring(0, MESSAGE_CHARACTER_LIMIT);
int responseCharLimit = MessageEmbed.DESCRIPTION_MAX_LENGTH;
if (answer.length() > responseCharLimit) {
answer = answer.substring(0, responseCharLimit);
}

MessageEmbed responseEmbed = generateGptResponseEmbed(answer, selfUser, originalQuestion);
Expand All @@ -162,11 +162,11 @@ RestAction<Message> constructChatGptAttempt(ThreadChannel threadChannel,
public MessageEmbed generateGptResponseEmbed(String answer, SelfUser selfUser, String title) {
String responseByGptFooter = "- AI generated response";

int TITLE_EMBED_LIMIT = MessageEmbed.TITLE_MAX_LENGTH;
int embedTitleLimit = MessageEmbed.TITLE_MAX_LENGTH;
String capitalizedTitle = Character.toUpperCase(title.charAt(0)) + title.substring(1);

String titleForEmbed = capitalizedTitle.length() > TITLE_EMBED_LIMIT
? capitalizedTitle.substring(0, TITLE_EMBED_LIMIT)
String titleForEmbed = capitalizedTitle.length() > embedTitleLimit
? capitalizedTitle.substring(0, embedTitleLimit)
: capitalizedTitle;

return new EmbedBuilder()
Expand Down

0 comments on commit 9f9f2d1

Please sign in to comment.