Skip to content

Commit 77c5620

Browse files
committed
2464: stati fixes
1 parent 1d812b4 commit 77c5620

File tree

2 files changed

+15
-20
lines changed

2 files changed

+15
-20
lines changed

src/main/java/com/magento/idea/magento2uct/execution/configurations/UctSettingsEditor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
import org.jetbrains.annotations.NotNull;
4444

4545
@SuppressWarnings({"PMD.TooManyFields", "PMD.ExcessiveImports"})
46-
public class UctSettingsEditor extends SettingsEditor<UctRunConfiguration> {
46+
public class UctSettingsEditor extends SettingsEditor<UctRunConfiguration> { //NOPMD - suppressed TooManyMethods
4747

4848
private static final String LEARN_MORE_URI =
4949
"https://docs.magento.com/user-guide/getting-started.html#product-editions";
@@ -398,7 +398,7 @@ private void validateComingVersionField(final ComboBoxItemData selectedItem) {
398398
* @return ComboBoxItemData
399399
*/
400400
private ComboBoxItemData getCorrectedSelectedItem(final Object selectedItem) {
401-
ComboBoxItemData selectedComingVersion;
401+
final ComboBoxItemData selectedComingVersion;
402402

403403
if (selectedItem instanceof ComboBoxItemData) {
404404
selectedComingVersion = (ComboBoxItemData) selectedItem;

src/main/java/com/magento/idea/magento2uct/packages/SupportedVersion.java

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public String getVersion() {
5757
public static List<String> getSupportedVersions() {
5858
try {
5959
return fetchSupportedVersions();
60-
} catch (Exception e) {
60+
} catch (Exception e) { //NOPMD - suppressed AvoidCatchingGenericException
6161
// Return an empty list or log the exception
6262
return List.of();
6363
}
@@ -71,9 +71,9 @@ public static List<String> getSupportedVersions() {
7171
* @return List[String] containing supported version strings
7272
* @throws Exception if an error occurs during HTTP connection or JSON parsing
7373
*/
74-
public static List<String> fetchSupportedVersions() throws Exception {
75-
String url = "https://repo.packagist.org/p2/magento/community-edition.json";
76-
List<String> versions = new ArrayList<>();
74+
public static List<String> fetchSupportedVersions() throws Exception { //NOPMD - suppressed SignatureDeclareThrowsException
75+
final String url = "https://repo.packagist.org/p2/magento/community-edition.json";
76+
final List<String> versions = new ArrayList<>();
7777

7878
HttpURLConnection connection = null;
7979
try {
@@ -82,8 +82,8 @@ public static List<String> fetchSupportedVersions() throws Exception {
8282
connection.setRequestMethod("GET");
8383
connection.setRequestProperty("Accept", "application/json");
8484

85-
if (connection.getResponseCode() != 200) {
86-
throw new Exception(
85+
if (connection.getResponseCode() != 200) { //NOPMD - suppressed AvoidLiteralsInIfCondition
86+
throw new Exception( //NOPMD - suppressed AvoidThrowingRawExceptionTypes
8787
"Failed to fetch data, HTTP response code: " + connection.getResponseCode()
8888
);
8989
}
@@ -92,35 +92,30 @@ public static List<String> fetchSupportedVersions() throws Exception {
9292
try (BufferedReader reader = new BufferedReader(
9393
new InputStreamReader(connection.getInputStream()))
9494
) {
95-
StringBuilder response = new StringBuilder();
95+
final StringBuilder response = new StringBuilder();
9696
String line;
97-
while ((line = reader.readLine()) != null) {
97+
while ((line = reader.readLine()) != null) { //NOPMD - suppressed AssignmentInOperand
9898
response.append(line);
9999
}
100100

101101
// Parse JSON for version data
102-
JSONObject jsonResponse = new JSONObject(response.toString());
103-
JSONArray packageObject = jsonResponse
102+
final JSONObject jsonResponse = new JSONObject(response.toString());
103+
final JSONArray packageObject = jsonResponse
104104
.getJSONObject("packages")
105105
.getJSONArray("magento/community-edition");
106106

107-
for (Object o : packageObject) {
108-
JSONObject version = (JSONObject) o;
107+
for (final Object o : packageObject) {
108+
final JSONObject version = (JSONObject) o;
109109
if (version == null) {
110110
continue;
111111
}
112-
String versionstring = version.getString("version");
112+
final String versionstring = version.getString("version");
113113
if (versionstring == null) {
114114
continue;
115115
}
116116
versions.add(versionstring);
117117
}
118118
}
119-
} catch (Exception e) {
120-
throw new Exception(
121-
"Error fetching or parsing supported versions: " + e.getMessage(),
122-
e
123-
);
124119
} finally {
125120
if (connection != null) {
126121
connection.disconnect();

0 commit comments

Comments
 (0)