Skip to content

Commit ab60004

Browse files
committed
Fix PMD
1 parent 9ba7180 commit ab60004

File tree

3 files changed

+5
-35
lines changed

3 files changed

+5
-35
lines changed

net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/dialogs/NewPropertyDialog.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ public NewPropertyDialog(Shell parent, PropertySource theSource, ValueChangeList
8484
* @deprecated use {@link #NewPropertyDialog(Shell, PropertySource, ValueChangeListener)} instead.
8585
*/
8686
@Deprecated // for removal
87+
@SuppressWarnings("PMD.UnusedFormalParameter")
8788
public NewPropertyDialog(Shell parent, Map<Class<?>, EditorFactory<?>> theEditorFactoriesByValueType,
8889
PropertySource theSource, ValueChangeListener theChangeListener) {
8990
this(parent, theSource, theChangeListener);

net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/preferences/internal/PropertyEditorFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import net.sourceforge.pmd.properties.PropertyFactory;
2121
import net.sourceforge.pmd.properties.PropertySource;
2222

23-
public class PropertyEditorFactory extends AbstractEditorFactory {
23+
public final class PropertyEditorFactory extends AbstractEditorFactory {
2424

2525
public static final PropertyEditorFactory INSTANCE = new PropertyEditorFactory();
2626

net.sourceforge.pmd.eclipse.plugin/src/main/java/net/sourceforge/pmd/eclipse/ui/preferences/panelmanagers/FormArranger.java

Lines changed: 3 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import java.util.Comparator;
1111
import java.util.HashMap;
1212
import java.util.List;
13-
import java.util.Locale;
1413
import java.util.Map;
1514
import java.util.Objects;
1615

@@ -22,8 +21,6 @@
2221
import org.eclipse.swt.widgets.Button;
2322
import org.eclipse.swt.widgets.Composite;
2423
import org.eclipse.swt.widgets.Control;
25-
import org.slf4j.Logger;
26-
import org.slf4j.LoggerFactory;
2724

2825
import net.sourceforge.pmd.eclipse.ui.PMDUiConstants;
2926
import net.sourceforge.pmd.eclipse.ui.dialogs.NewPropertyDialog;
@@ -48,8 +45,6 @@
4845
* @author Brian Remedios
4946
*/
5047
public class FormArranger implements ValueChangeListener {
51-
private static final Logger LOG = LoggerFactory.getLogger(FormArranger.class);
52-
5348
private final Composite parent;
5449
private final ValueChangeListener changeListener;
5550
private final SizeChangeListener sizeChangeListener;
@@ -70,6 +65,7 @@ public FormArranger(Composite theParent, ValueChangeListener listener, SizeChang
7065
* @deprecated Use {@link #FormArranger(Composite, ValueChangeListener, SizeChangeListener)} instead.
7166
*/
7267
@Deprecated // for removal
68+
@SuppressWarnings("PMD.UnusedFormalParameter")
7369
public FormArranger(Composite theParent, Map<Class<?>, EditorFactory<?>> factories, ValueChangeListener listener,
7470
SizeChangeListener sizeListener) {
7571
this(theParent, listener, sizeListener);
@@ -103,10 +99,6 @@ protected void register(PropertyDescriptor<?> property, Control[] controls) {
10399
controlsByProperty.put(property, controls);
104100
}
105101

106-
private EditorFactory<?> factoryFor(PropertyDescriptor<?> desc) {
107-
return PropertyEditorFactory.INSTANCE;
108-
}
109-
110102
public void clearChildren() {
111103
Control[] kids = parent.getChildren();
112104
for (Control kid : kids) {
@@ -150,20 +142,7 @@ private int rearrangeFor(PropertySource theSource) {
150142
PropertyDescriptor<?>[] orderedDescs = valuesByDescriptor.keySet().toArray(new PropertyDescriptor[0]);
151143
Arrays.sort(orderedDescs, Comparator.comparing(PropertyDescriptor::name));
152144

153-
int rowCount = 0; // count up the actual rows with widgets needed, not all have editors yet
154-
for (PropertyDescriptor<?> desc : orderedDescs) {
155-
EditorFactory<?> factory = factoryFor(desc);
156-
if (factory == null) {
157-
if (isPropertyDeprecated(desc)) {
158-
LOG.info("No property editor for deprecated property defined in rule {}: {}",
159-
theSource.getName(), desc);
160-
} else {
161-
LOG.error("No property editor defined for rule {}: {}", theSource.getName(), desc);
162-
}
163-
continue;
164-
}
165-
rowCount++;
166-
}
145+
int rowCount = orderedDescs.length; // count up the actual rows with widgets needed, not all have editors yet
167146

168147
boolean isXPathRule = RuleUtil.isXPathRule(propertySource);
169148
int columnCount = isXPathRule ? 3 : 2; // xpath descriptors have a column of delete buttons
@@ -178,7 +157,7 @@ private int rearrangeFor(PropertySource theSource) {
178157
int rowsAdded = 0;
179158

180159
for (PropertyDescriptor<?> desc : orderedDescs) {
181-
if (addRowWidgets(factoryFor(desc), rowsAdded, desc, isXPathRule)) {
160+
if (addRowWidgets(PropertyEditorFactory.INSTANCE, rowsAdded, desc, isXPathRule)) {
182161
rowsAdded++;
183162
}
184163
}
@@ -197,16 +176,6 @@ private int rearrangeFor(PropertySource theSource) {
197176
return rowsAdded;
198177
}
199178

200-
private boolean isPropertyDeprecated(PropertyDescriptor<?> desc) {
201-
String description = desc.description();
202-
if (description != null) {
203-
description = description.toLowerCase(Locale.ROOT).trim();
204-
} else {
205-
description = "";
206-
}
207-
return description.startsWith("deprecated");
208-
}
209-
210179
private void addAddButton() {
211180
Button button = new Button(parent, SWT.PUSH);
212181
button.setText("Add new...");

0 commit comments

Comments
 (0)