Code style update: convert enums to CamelCase
This change updates enum names from UPPER_SNAKE_CASE to CamelCase to
align with best practices in code styling.
Change-Id: Ie30e8531cebabcdfb8594ea273b173dea1b59225
Signed-off-by: Patrizio <patrizio.gelosi@amarulasolutions.com>
diff --git a/src/main/java/com/googlesource/gerrit/plugins/chatgpt/PatchSetReviewer.java b/src/main/java/com/googlesource/gerrit/plugins/chatgpt/PatchSetReviewer.java
index 53d1d32..28b7040 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/chatgpt/PatchSetReviewer.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/chatgpt/PatchSetReviewer.java
@@ -66,7 +66,7 @@
commentProperties = gerritClient.getClientData(change).getCommentProperties();
gerritCommentRange = new GerritCommentRange(gerritClient, change);
String patchSet = gerritClient.getPatchSet(change);
- if (patchSet.isEmpty() && config.getGptMode() == Settings.MODES.stateless) {
+ if (patchSet.isEmpty() && config.getGptMode() == Settings.Modes.stateless) {
log.info("No file to review has been found in the PatchSet");
return;
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/chatgpt/config/Configuration.java b/src/main/java/com/googlesource/gerrit/plugins/chatgpt/config/Configuration.java
index 46b0921..dddced3 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/chatgpt/config/Configuration.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/chatgpt/config/Configuration.java
@@ -12,7 +12,7 @@
import java.util.*;
import java.util.regex.Pattern;
-import static com.googlesource.gerrit.plugins.chatgpt.settings.Settings.MODES;
+import static com.googlesource.gerrit.plugins.chatgpt.settings.Settings.Modes;
@Slf4j
public class Configuration {
@@ -173,10 +173,10 @@
return getBoolean(KEY_REVIEW_PATCH_SET, DEFAULT_REVIEW_PATCH_SET);
}
- public MODES getGptMode() {
+ public Modes getGptMode() {
String mode = getString(KEY_GPT_MODE, DEFAULT_GPT_MODE);
try {
- return Enum.valueOf(MODES.class, mode);
+ return Enum.valueOf(Modes.class, mode);
} catch (IllegalArgumentException e) {
throw new RuntimeException("Illegal mode: " + mode, e);
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/chatgpt/mode/common/client/commands/ClientCommands.java b/src/main/java/com/googlesource/gerrit/plugins/chatgpt/mode/common/client/commands/ClientCommands.java
index 7e8ce7c..38619d6 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/chatgpt/mode/common/client/commands/ClientCommands.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/chatgpt/mode/common/client/commands/ClientCommands.java
@@ -20,39 +20,39 @@
@Slf4j
@Getter
public class ClientCommands extends ClientBase {
- private enum COMMAND_SET {
+ private enum CommandSet {
REVIEW,
REVIEW_LAST,
DIRECTIVE,
CONFIGURE
}
- private enum REVIEW_OPTION_SET {
+ private enum ReviewOptionSet {
FILTER,
DEBUG
}
- private enum CONFIGURE_OPTION_SET {
+ private enum ConfigureOptionSet {
RESET
}
- private static final Map<String, COMMAND_SET> COMMAND_MAP = Map.of(
- "review", COMMAND_SET.REVIEW,
- "review_last", COMMAND_SET.REVIEW_LAST,
- "directive", COMMAND_SET.DIRECTIVE,
- "configure", COMMAND_SET.CONFIGURE
+ private static final Map<String, CommandSet> COMMAND_MAP = Map.of(
+ "review", CommandSet.REVIEW,
+ "review_last", CommandSet.REVIEW_LAST,
+ "directive", CommandSet.DIRECTIVE,
+ "configure", CommandSet.CONFIGURE
);
- private static final Map<String, REVIEW_OPTION_SET> REVIEW_OPTION_MAP = Map.of(
- "filter", REVIEW_OPTION_SET.FILTER,
- "debug", REVIEW_OPTION_SET.DEBUG
+ private static final Map<String, ReviewOptionSet> REVIEW_OPTION_MAP = Map.of(
+ "filter", ReviewOptionSet.FILTER,
+ "debug", ReviewOptionSet.DEBUG
);
- private static final List<COMMAND_SET> REVIEW_COMMANDS = new ArrayList<>(List.of(
- COMMAND_SET.REVIEW,
- COMMAND_SET.REVIEW_LAST
+ private static final List<CommandSet> REVIEW_COMMANDS = new ArrayList<>(List.of(
+ CommandSet.REVIEW,
+ CommandSet.REVIEW_LAST
));
- private static final List<COMMAND_SET> HISTORY_COMMANDS = new ArrayList<>(List.of(
- COMMAND_SET.DIRECTIVE
+ private static final List<CommandSet> HISTORY_COMMANDS = new ArrayList<>(List.of(
+ CommandSet.DIRECTIVE
));
- private static final Map<String, CONFIGURE_OPTION_SET> CONFIGURE_OPTION_MAP = Map.of(
- "reset", CONFIGURE_OPTION_SET.RESET
+ private static final Map<String, ConfigureOptionSet> CONFIGURE_OPTION_MAP = Map.of(
+ "reset", ConfigureOptionSet.RESET
);
// Option values can be either a sequence of chars enclosed in double quotes or a sequence of non-space chars.
private static final String OPTION_VALUES = "\"[^\"\\\\]*(?:\\\\.[^\"\\\\]*)*\"|\\S+";
@@ -92,7 +92,7 @@
boolean commandFound = false;
Matcher reviewCommandMatcher = COMMAND_PATTERN.matcher(comment);
while (reviewCommandMatcher.find()) {
- COMMAND_SET command = COMMAND_MAP.get(reviewCommandMatcher.group(1));
+ CommandSet command = COMMAND_MAP.get(reviewCommandMatcher.group(1));
parseOptions(command, reviewCommandMatcher, isNotHistory);
parseCommand(command, comment, isNotHistory);
commandFound = true;
@@ -112,11 +112,11 @@
return reviewCommandMatcher.replaceAll("");
}
- private void parseCommand(COMMAND_SET command, String comment, boolean isNotHistory) {
+ private void parseCommand(CommandSet command, String comment, boolean isNotHistory) {
if (isNotHistory) {
if (REVIEW_COMMANDS.contains(command)) {
changeSetData.setForcedReview(true);
- if (command == COMMAND_SET.REVIEW_LAST) {
+ if (command == CommandSet.REVIEW_LAST) {
log.info("Forced review command applied to the last Patch Set");
changeSetData.setForcedReviewLastPatchSet(true);
}
@@ -124,7 +124,7 @@
log.info("Forced review command applied to the entire Change Set");
}
}
- else if (command == COMMAND_SET.CONFIGURE) {
+ else if (command == CommandSet.CONFIGURE) {
if (config.getEnableMessageDebugging()) {
changeSetData.setHideChatGptReview(true);
dynamicConfiguration.updateConfiguration(modifiedDynamicConfig, shouldResetDynamicConfig);
@@ -140,13 +140,13 @@
}
if (HISTORY_COMMANDS.contains(command)) {
containingHistoryCommand = true;
- if (command == COMMAND_SET.DIRECTIVE) {
+ if (command == CommandSet.DIRECTIVE) {
directives.addDirective(removeCommands(comment));
}
}
}
- private void parseOptions(COMMAND_SET command, Matcher reviewCommandMatcher, boolean isNotHistory) {
+ private void parseOptions(CommandSet command, Matcher reviewCommandMatcher, boolean isNotHistory) {
// Command options need to be parsed only when processing the current message, not the message history
if (reviewCommandMatcher.group(2) == null || !isNotHistory) return;
Matcher reviewOptionsMatcher = OPTIONS_PATTERN.matcher(reviewCommandMatcher.group(2));
@@ -155,7 +155,7 @@
}
}
- private void parseSingleOption(COMMAND_SET command, Matcher reviewOptionsMatcher) {
+ private void parseSingleOption(CommandSet command, Matcher reviewOptionsMatcher) {
String optionKey = reviewOptionsMatcher.group(1);
String optionValue = Optional.ofNullable(reviewOptionsMatcher.group(2))
.map(val -> val.replaceAll("^\"(.*)\"$", "$1"))
@@ -181,8 +181,8 @@
}
break;
}
- } else if (command == COMMAND_SET.CONFIGURE && config.getEnableMessageDebugging()) {
- if (CONFIGURE_OPTION_MAP.get(optionKey) == CONFIGURE_OPTION_SET.RESET) {
+ } else if (command == CommandSet.CONFIGURE && config.getEnableMessageDebugging()) {
+ if (CONFIGURE_OPTION_MAP.get(optionKey) == ConfigureOptionSet.RESET) {
shouldResetDynamicConfig = true;
log.debug("Resetting configuration settings");
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/chatgpt/mode/common/client/prompt/ChatGptUserPromptFactory.java b/src/main/java/com/googlesource/gerrit/plugins/chatgpt/mode/common/client/prompt/ChatGptUserPromptFactory.java
index 8743250..7303412 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/chatgpt/mode/common/client/prompt/ChatGptUserPromptFactory.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/chatgpt/mode/common/client/prompt/ChatGptUserPromptFactory.java
@@ -22,7 +22,7 @@
Localizer localizer
) {
if (change.getIsCommentEvent()) {
- if ((config.getGptMode() == Settings.MODES.stateless)) {
+ if ((config.getGptMode() == Settings.Modes.stateless)) {
log.info("ChatGptUserPromptFactory: Returned ChatGptUserPromptRequestsStateless");
return new ChatGptUserPromptRequestsStateless(config, changeSetData, gerritClientData, localizer);
} else {
diff --git a/src/main/java/com/googlesource/gerrit/plugins/chatgpt/settings/Settings.java b/src/main/java/com/googlesource/gerrit/plugins/chatgpt/settings/Settings.java
index 091355c..90c91fe 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/chatgpt/settings/Settings.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/chatgpt/settings/Settings.java
@@ -19,7 +19,7 @@
public static final String CHAT_GPT_ROLE_USER = "user";
public static final String CHAT_GPT_ROLE_ASSISTANT = "assistant";
- public enum MODES {
+ public enum Modes {
stateless,
stateful
}
diff --git a/src/test/java/com/googlesource/gerrit/plugins/chatgpt/ChatGptReviewStatefulTest.java b/src/test/java/com/googlesource/gerrit/plugins/chatgpt/ChatGptReviewStatefulTest.java
index 995e16d..239f84b 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/chatgpt/ChatGptReviewStatefulTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/chatgpt/ChatGptReviewStatefulTest.java
@@ -13,7 +13,7 @@
import com.googlesource.gerrit.plugins.chatgpt.mode.stateful.client.api.UriResourceLocatorStateful;
import com.googlesource.gerrit.plugins.chatgpt.mode.stateful.client.prompt.ChatGptPromptStateful;
import com.googlesource.gerrit.plugins.chatgpt.mode.stateful.model.api.chatgpt.ChatGptListResponse;
-import com.googlesource.gerrit.plugins.chatgpt.settings.Settings.MODES;
+import com.googlesource.gerrit.plugins.chatgpt.settings.Settings.Modes;
import com.googlesource.gerrit.plugins.chatgpt.utils.ThreadUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.http.entity.ContentType;
@@ -62,7 +62,7 @@
// Mock the Global Config values that differ from the ones provided by Default
when(globalConfig.getString(Mockito.eq("gptMode"), Mockito.anyString()))
- .thenReturn(MODES.stateful.name());
+ .thenReturn(Modes.stateful.name());
setupPluginData();
PluginDataHandlerProvider provider = new PluginDataHandlerProvider(mockPluginDataPath, getGerritChange());