Ignore:
Timestamp:
2023-10-16T19:03:11+02:00 (14 months ago)
Author:
taylor.smock
Message:

See #23218: Use newer error_prone versions when compiling on Java 11+

error_prone 2.11 dropped support for compiling with Java 8, although it still
supports compiling for Java 8. The "major" new check for us is NotJavadoc since
we used /** in quite a few places which were not javadoc.

Other "new" checks that are of interest:

  • AlreadyChecked: if (foo) { doFoo(); } else if (!foo) { doBar(); }
  • UnnecessaryStringBuilder: Avoid StringBuilder (Java converts + to StringBuilder behind-the-scenes, but may also do something else if it performs better)
  • NonApiType: Avoid specific interface types in function definitions
  • NamedLikeContextualKeyword: Avoid using restricted names for classes and methods
  • UnusedMethod: Unused private methods should be removed

This fixes most of the new error_prone issues and some SonarLint issues.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/preferences/ToolbarPreferences.java

    r18801 r18871  
    2424import java.util.Collection;
    2525import java.util.Collections;
     26import java.util.HashMap;
    2627import java.util.LinkedList;
    2728import java.util.List;
     
    299300                return null;
    300301
    301             ActionDefinition result = new ActionDefinition(action);
     302            ActionDefinition actionDefinition = new ActionDefinition(action);
    302303
    303304            if (action instanceof ParameterizedAction) {
     
    305306
    306307                ParameterizedAction parametrizedAction = (ParameterizedAction) action;
    307                 Map<String, ActionParameter<?>> actionParams = new ConcurrentHashMap<>();
     308                Map<String, ActionParameter<?>> actionParams = new HashMap<>();
    308309                for (ActionParameter<?> param: parametrizedAction.getActionParameters()) {
    309310                    actionParams.put(param.getName(), param);
     
    317318                        ActionParameter<?> actionParam = actionParams.get(paramName);
    318319                        if (actionParam != null) {
    319                             result.getParameters().put(paramName, actionParam.readFromString(paramValue));
     320                            actionDefinition.getParameters().put(paramName, actionParam.readFromString(paramValue));
    320321                        }
    321322                    }
     
    332333                    String paramValue = readTillChar(',', '}');
    333334                    if ("icon".equals(paramName) && !paramValue.isEmpty()) {
    334                         result.setIcon(paramValue);
     335                        actionDefinition.setIcon(paramValue);
    335336                    } else if ("name".equals(paramName) && !paramValue.isEmpty()) {
    336                         result.setName(paramValue);
     337                        actionDefinition.setName(paramValue);
    337338                    }
    338339                    skip(',');
     
    341342            }
    342343
    343             return result;
     344            return actionDefinition;
    344345        }
    345346
     
    798799        private JButton createButton(String name) {
    799800            JButton b = new JButton();
    800             if ("up".equals(name)) {
    801                 b.setIcon(ImageProvider.get("dialogs", "up", ImageSizes.LARGEICON));
    802                 b.setToolTipText(tr("Move the currently selected members up"));
    803             } else if ("down".equals(name)) {
    804                 b.setIcon(ImageProvider.get("dialogs", "down", ImageSizes.LARGEICON));
    805                 b.setToolTipText(tr("Move the currently selected members down"));
    806             } else if ("<".equals(name)) {
    807                 b.setIcon(ImageProvider.get("dialogs/conflict", "copybeforecurrentright", ImageSizes.LARGEICON));
    808                 b.setToolTipText(tr("Add all objects selected in the current dataset before the first selected member"));
    809             } else if (">".equals(name)) {
    810                 b.setIcon(ImageProvider.get("dialogs", "delete", ImageSizes.LARGEICON));
    811                 b.setToolTipText(tr("Remove"));
     801            switch (name) {
     802                case "up":
     803                    b.setIcon(ImageProvider.get("dialogs", "up", ImageSizes.LARGEICON));
     804                    b.setToolTipText(tr("Move the currently selected members up"));
     805                    break;
     806                case "down":
     807                    b.setIcon(ImageProvider.get("dialogs", "down", ImageSizes.LARGEICON));
     808                    b.setToolTipText(tr("Move the currently selected members down"));
     809                    break;
     810                case "<":
     811                    b.setIcon(ImageProvider.get("dialogs/conflict", "copybeforecurrentright", ImageSizes.LARGEICON));
     812                    b.setToolTipText(tr("Add all objects selected in the current dataset before the first selected member"));
     813                    break;
     814                case ">":
     815                    b.setIcon(ImageProvider.get("dialogs", "delete", ImageSizes.LARGEICON));
     816                    b.setToolTipText(tr("Remove"));
     817                    break;
     818                default:
     819                    // do nothing
    812820            }
    813821            b.addActionListener(moveAction);
     
    10441052                        continue;
    10451053                    } else if (!(tb instanceof String)) {
    1046                         if (!(tb instanceof Boolean) || (Boolean) tb) {
     1054                        if (!(tb instanceof Boolean) || Boolean.TRUE.equals(tb)) {
    10471055                            Logging.info(tr("Strange toolbar value: {0}",
    10481056                            action.getClass().getName()));
     
    11621170    /**
    11631171     * Parse the toolbar preference setting and construct the toolbar GUI control.
    1164      *
     1172     * <p>
    11651173     * Call this, if anything has changed in the toolbar settings and you want to refresh
    11661174     * the toolbar content (e.g. after registering actions in a plugin)
Note: See TracChangeset for help on using the changeset viewer.