Skip to content

Commit 9649908

Browse files
committed
2880: static fixes
1 parent b86cf57 commit 9649908

18 files changed

+82
-129
lines changed

.github/workflows/gradle.yml

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,12 +111,35 @@ jobs:
111111
run: chmod +x gradlew
112112
- id: file_changes
113113
uses: trilom/[email protected]
114+
- name: Filter Java Files
115+
id: filter_java_files
116+
run: |
117+
# Get modified and added files
118+
MODIFIED_FILES=${{ steps.file_changes.outputs.files_modified }}
119+
ADDED_FILES=${{ steps.file_changes.outputs.files_added }}
120+
121+
echo "Modified files: $MODIFIED_FILES"
122+
echo "Added files: $ADDED_FILES"
123+
124+
# Combine and filter for .java files
125+
# Make sure we handle empty arrays properly
126+
if [ "$MODIFIED_FILES" == "[]" ]; then
127+
MODIFIED_FILES="[]"
128+
fi
129+
if [ "$ADDED_FILES" == "[]" ]; then
130+
ADDED_FILES="[]"
131+
fi
132+
133+
# Combine arrays and filter for .java files
134+
COMBINED_FILES=$(echo "$MODIFIED_FILES $ADDED_FILES" | jq -s 'add | map(select(endswith(".java")))')
135+
echo "JAVA_FILES=$COMBINED_FILES" >> $GITHUB_ENV
136+
echo "Filtered Java Files: $COMBINED_FILES"
114137
- name: Run Code Style Check
115138
run: ./gradlew checkstyleCI --no-daemon
116139
env:
117-
MODIFIED_FILES: ${{ steps.file_changes.outputs.files}}
140+
MODIFIED_FILES: ${{ env.JAVA_FILES }}
118141
ACTIONS_STEP_DEBUG: true
119142
- name: Run PMD Quality Check
120143
run: ./gradlew pmdCI --no-daemon
121144
env:
122-
MODIFIED_FILES: ${{ steps.file_changes.outputs.files}}
145+
MODIFIED_FILES: ${{ env.JAVA_FILES }}

build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ tasks.withType(Pmd::class).configureEach {
208208
// Specify all files that should be checked
209209
classpath = files()
210210
setSource("${project.rootDir}")
211+
maxHeapSize = "12g"
211212
}
212213

213214
// Execute PMD on all files

src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/AbstractDialog.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,18 @@ public AbstractDialog() {
7474
* so this method is kept for compatibility.
7575
*
7676
* @param dialog AbstractDialog
77+
* @deprecated This method is no longer needed as DialogWrapper handles centering automatically.
78+
* It is kept for backward compatibility with existing code.
7779
*/
80+
@Deprecated
81+
@SuppressWarnings({
82+
"PMD.UncommentedEmptyMethod",
83+
"PMD.EmptyMethodInAbstractClassShouldBeAbstract"
84+
})
7885
protected void centerDialog(final AbstractDialog dialog) {
7986
// DialogWrapper handles centering automatically
87+
// This method is intentionally left with minimal implementation
88+
// as it's deprecated and only kept for backward compatibility
8089
}
8190

8291
/**
@@ -87,9 +96,7 @@ protected void centerDialog(final AbstractDialog dialog) {
8796
*/
8897
@Nullable
8998
@Override
90-
protected JComponent createCenterPanel() {
91-
return null; // Subclasses must override this method
92-
}
99+
protected abstract JComponent createCenterPanel();
93100

94101
/**
95102
* Default on cancel action.
@@ -157,8 +164,8 @@ public void doCancelAction() {
157164
"PMD.CognitiveComplexity"
158165
})
159166
protected boolean validateFormFields() {
160-
boolean dialogHasErrors;
161-
isValidationErrorShown = dialogHasErrors = false;
167+
boolean dialogHasErrors = false;
168+
isValidationErrorShown = false;
162169
clearValidationHighlighting();
163170

164171
for (final FieldValidationData fieldValidationData : getFieldsToValidate()) {

src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/InjectAViewModelDialog.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import com.magento.idea.magento2plugin.magento.packages.XsiTypes;
2626
import com.magento.idea.magento2plugin.util.FirstLetterToLowercaseUtil;
2727
import com.magento.idea.magento2plugin.util.magento.GetModuleNameByDirectoryUtil;
28-
import java.awt.event.ActionEvent;
2928
import java.awt.event.KeyEvent;
3029
import java.awt.event.WindowAdapter;
3130
import java.awt.event.WindowEvent;

src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/NewBlockDialog.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,27 +19,19 @@
1919
import com.magento.idea.magento2plugin.magento.packages.File;
2020
import com.magento.idea.magento2plugin.magento.packages.Package;
2121
import com.magento.idea.magento2plugin.util.magento.GetModuleNameByDirectoryUtil;
22-
import java.awt.event.ActionEvent;
23-
import java.awt.event.KeyEvent;
24-
import java.awt.event.WindowAdapter;
25-
import java.awt.event.WindowEvent;
26-
import javax.swing.JButton;
2722
import javax.swing.JComponent;
2823
import javax.swing.JLabel;
2924
import javax.swing.JPanel;
3025
import javax.swing.JRadioButton;
3126
import javax.swing.JTextField;
3227
import javax.swing.JTextPane;
33-
import javax.swing.KeyStroke;
3428
import org.jetbrains.annotations.Nullable;
3529

3630
public class NewBlockDialog extends AbstractDialog {
3731

3832
private final PsiDirectory baseDir;
3933
private final String moduleName;
4034
private JPanel contentPanel;
41-
private JButton buttonOK;
42-
private JButton buttonCancel;
4335
private final Project project;
4436
private JTextPane warning;//NOPMD
4537
private JRadioButton adminhtmlRadioButton;//NOPMD

src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/NewCronGroupDialog.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,35 +16,29 @@
1616
import com.magento.idea.magento2plugin.actions.generation.generator.ModuleCronGroupXmlGenerator;
1717
import com.magento.idea.magento2plugin.ui.FilteredComboBox;
1818
import com.magento.idea.magento2plugin.util.magento.GetModuleNameByDirectoryUtil;
19-
import java.awt.event.KeyEvent;
20-
import java.awt.event.WindowAdapter;
21-
import java.awt.event.WindowEvent;
2219
import java.util.ArrayList;
2320
import java.util.Arrays;
2421
import java.util.List;
25-
import javax.swing.JButton;
2622
import javax.swing.JCheckBox;
2723
import javax.swing.JComponent;
2824
import javax.swing.JLabel;
2925
import javax.swing.JPanel;
3026
import javax.swing.JSpinner;
3127
import javax.swing.JTextField;
32-
import javax.swing.KeyStroke;
3328
import javax.swing.SpinnerNumberModel;
3429
import org.jetbrains.annotations.Nullable;
3530

3631
@SuppressWarnings({
3732
"PMD.TooManyFields",
3833
"PMD.TooManyMethods",
39-
"PMD.ExcessiveImports,"
34+
"PMD.ExcessiveImports",
35+
"PMD.ImmutableField"
4036
})
4137
public class NewCronGroupDialog extends AbstractDialog {
4238

4339
private final String moduleName;
4440
private final Project project;
4541
private JPanel contentPanel;
46-
private JButton buttonOK;
47-
private JButton buttonCancel;
4842
private static final String NAME = "name";
4943

5044
@FieldValidation(rule = RuleRegistry.NOT_EMPTY, message = {NotEmptyRule.MESSAGE, NAME})

src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/NewCronjobDialog.java

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,8 @@
2626
import com.magento.idea.magento2plugin.ui.FilteredComboBox;
2727
import com.magento.idea.magento2plugin.util.CamelCaseToSnakeCase;
2828
import com.magento.idea.magento2plugin.util.magento.GetModuleNameByDirectoryUtil;
29-
import java.awt.event.ActionEvent;
3029
import java.awt.event.FocusEvent;
3130
import java.awt.event.FocusListener;
32-
import java.awt.event.KeyEvent;
33-
import java.awt.event.WindowAdapter;
34-
import java.awt.event.WindowEvent;
3531
import java.util.List;
3632
import javax.swing.JButton;
3733
import javax.swing.JComponent;
@@ -40,7 +36,6 @@
4036
import javax.swing.JPanel;
4137
import javax.swing.JRadioButton;
4238
import javax.swing.JTextField;
43-
import javax.swing.KeyStroke;
4439
import org.jetbrains.annotations.NotNull;
4540
import org.jetbrains.annotations.Nullable;
4641

@@ -63,8 +58,8 @@ public class NewCronjobDialog extends AbstractDialog {
6358
private final CamelCaseToSnakeCase camelCaseToSnakeCase;
6459

6560
private JPanel contentPane;
66-
private JButton buttonOK;
67-
private JButton buttonCancel;
61+
private JButton buttonOK;//NOPMD
62+
private JButton buttonCancel;//NOPMD
6863
private JRadioButton fixedScheduleRadioButton;
6964
private JRadioButton configurableScheduleRadioButton;
7065
private JRadioButton everyMinuteRadioButton;
@@ -265,16 +260,15 @@ private String suggestCronjobName(final String cronjobClassname) {
265260
}
266261

267262
if (cronjobClassname == null || cronjobClassname.isEmpty()) {
268-
return moduleName.toLowerCase(new java.util.Locale("en","EN"));
263+
return moduleName.toLowerCase(java.util.Locale.ENGLISH);
269264
}
270265

271266
final String cronjobClassnameToSnakeCase = this.camelCaseToSnakeCase.convert(
272267
cronjobClassname
273268
);
274269

275-
return moduleName.toLowerCase(new java.util.Locale("en","EN"))
276-
+ "_"
277-
+ cronjobClassnameToSnakeCase;
270+
final String moduleNameLower = moduleName.toLowerCase(java.util.Locale.ENGLISH);
271+
return moduleNameLower + "_" + cronjobClassnameToSnakeCase;
278272
}
279273

280274
/**

src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/NewCustomerEavAttributeDialog.java

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@
5555
public class NewCustomerEavAttributeDialog extends AbstractDialog {
5656

5757
private static final String ENTITY_NAME = "Customer";
58-
private String moduleName;
59-
private Project project;
60-
private String actionName;
58+
private final String moduleName;
59+
private final Project project;
60+
private final String actionName;
6161
private TableGroupWrapper entityPropertiesTableGroupWrapper;
62-
private SourceModelData sourceModelData;
62+
private final SourceModelData sourceModelData;
6363

6464
private JPanel contentPanel;
6565
private JButton buttonOK;
@@ -179,9 +179,9 @@ protected void fillAttributeTypeComboBox() {
179179
}
180180

181181
for (final AttributeType typeValue : AttributeType.values()) {
182-
typeComboBox.addItem(
183-
new ComboBoxItemData(typeValue.getType(), typeValue.getType())
184-
);
182+
final String type = typeValue.getType();
183+
final ComboBoxItemData item = new ComboBoxItemData(type, type);
184+
typeComboBox.addItem(item);
185185
}
186186
}
187187

@@ -194,9 +194,9 @@ protected void fillAttributeInputComboBox() {
194194
}
195195

196196
for (final AttributeInput inputValue : AttributeInput.values()) {
197-
inputComboBox.addItem(
198-
new ComboBoxItemData(inputValue.getInput(), inputValue.getInput())
199-
);
197+
final String input = inputValue.getInput();
198+
final ComboBoxItemData item = new ComboBoxItemData(input, input);
199+
inputComboBox.addItem(item);
200200
}
201201
}
202202

@@ -532,6 +532,9 @@ protected void generateExtraFilesBeforeDataPatchGeneration() {
532532

533533
/**
534534
* Generate extra files after data patch generation.
535+
* This method is intentionally left empty as no extra files need to be generated
536+
* after the data patch for customer EAV attributes. Subclasses may override this
537+
* method to provide specific implementation if needed.
535538
*
536539
* @param eavEntityDataInterface EavEntityDataInterface
537540
*/

src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/NewDataModelDialog.java

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,6 @@
3131
import com.magento.idea.magento2plugin.ui.table.TableButton;
3232
import com.magento.idea.magento2plugin.util.RegExUtil;
3333
import com.magento.idea.magento2plugin.util.magento.GetModuleNameByDirectoryUtil;
34-
import java.awt.event.ActionEvent;
35-
import java.awt.event.KeyEvent;
36-
import java.awt.event.WindowAdapter;
37-
import java.awt.event.WindowEvent;
3834
import java.util.ArrayList;
3935
import java.util.List;
4036
import javax.swing.JButton;
@@ -45,15 +41,15 @@
4541
import javax.swing.JPanel;
4642
import javax.swing.JTable;
4743
import javax.swing.JTextField;
48-
import javax.swing.KeyStroke;
4944
import javax.swing.table.DefaultTableModel;
5045
import javax.swing.table.TableColumn;
5146
import org.jetbrains.annotations.NotNull;
5247
import org.jetbrains.annotations.Nullable;
5348

5449
@SuppressWarnings({
5550
"PMD.ExcessiveImports",
56-
"PMD.ConstructorCallsOverridableMethod"
51+
"PMD.ConstructorCallsOverridableMethod",
52+
"PMD.ImmutableField"
5753
})
5854
public class NewDataModelDialog extends AbstractDialog {
5955

@@ -148,10 +144,9 @@ protected void onWriteActionOK() {
148144

149145
@Override
150146
protected boolean validateFormFields() {
151-
boolean valid = false;
147+
boolean valid = super.validateFormFields();
152148

153-
if (super.validateFormFields()) {
154-
valid = true;
149+
if (valid) {
155150
final String errorTitle = commonBundle.message("common.error");
156151
final int column = 0;
157152

src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/NewDbSchemaDialog.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,6 @@
2525
import com.magento.idea.magento2plugin.magento.packages.database.TableResources;
2626
import com.magento.idea.magento2plugin.ui.table.TableGroupWrapper;
2727
import com.magento.idea.magento2plugin.util.magento.GetModuleNameByDirectoryUtil;
28-
import java.awt.event.KeyEvent;
29-
import java.awt.event.WindowAdapter;
30-
import java.awt.event.WindowEvent;
3128
import java.util.Arrays;
3229
import java.util.HashMap;
3330
import java.util.LinkedList;
@@ -41,7 +38,6 @@
4138
import javax.swing.JScrollPane;
4239
import javax.swing.JTable;
4340
import javax.swing.JTextField;
44-
import javax.swing.KeyStroke;
4541
import org.jetbrains.annotations.NotNull;
4642
import org.jetbrains.annotations.Nullable;
4743

@@ -54,10 +50,6 @@ public class NewDbSchemaDialog extends AbstractDialog {
5450
private final String moduleName;
5551
private JPanel contentPanel;
5652

57-
// Buttons
58-
private JButton buttonOK;
59-
private JButton buttonCancel;
60-
6153
// Fields
6254
@FieldValidation(rule = RuleRegistry.NOT_EMPTY, message = {NotEmptyRule.MESSAGE, TABLE_NAME})
6355
@FieldValidation(rule = RuleRegistry.LOWERCASE, message = {Lowercase.MESSAGE, TABLE_NAME})

src/main/java/com/magento/idea/magento2plugin/actions/generation/dialog/NewGraphQlResolverDialog.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,11 @@
1919
import com.magento.idea.magento2plugin.magento.packages.File;
2020
import com.magento.idea.magento2plugin.magento.packages.Package;
2121
import com.magento.idea.magento2plugin.util.magento.GetModuleNameByDirectoryUtil;
22-
import java.awt.event.ActionEvent;
23-
import java.awt.event.KeyEvent;
24-
import java.awt.event.WindowAdapter;
25-
import java.awt.event.WindowEvent;
2622
import javax.swing.JButton;
2723
import javax.swing.JComponent;
2824
import javax.swing.JLabel;
2925
import javax.swing.JPanel;
3026
import javax.swing.JTextField;
31-
import javax.swing.KeyStroke;
3227
import org.jetbrains.annotations.NotNull;
3328
import org.jetbrains.annotations.Nullable;
3429

@@ -37,8 +32,6 @@ public class NewGraphQlResolverDialog extends AbstractDialog {
3732
private final PsiDirectory baseDir;
3833
private final String moduleName;
3934
private JPanel contentPanel;
40-
private JButton buttonOK;
41-
private JButton buttonCancel;
4235
private final Project project;
4336
private static final String CLASS_NAME = "class name";
4437
private static final String PARENT_DIRECTORY = "directory";

0 commit comments

Comments
 (0)