Ticket #19053: 19053.3.patch

File 19053.3.patch, 7.9 KB (added by GerdP, 5 years ago)
  • src/org/openstreetmap/josm/data/validation/OsmValidator.java

     
    234234            } catch (SecurityException e) {
    235235                Logging.log(Logging.LEVEL_ERROR, "Unable to load ignored errors", e);
    236236            }
    237             // see #19053: remove invalid entry
    238             ignoredErrors.remove("3000");
     237
     238            // see #19053: remove unusable entries created by older releases
     239            boolean removedEntries = false;
     240            Iterator<Entry<String, String>> iter = ignoredErrors.entrySet().iterator();
     241            while (iter.hasNext()) {
     242                Entry<String, String> entry = iter.next();
     243                if ("3000".equals(entry.getKey()) || entry.getKey().startsWith("3000_")) {
     244                    Logging.warn(tr("Cannot handle ignore list entry {0}"), entry);
     245                    iter.remove();
     246                    removedEntries = true;
     247                }
     248            }
     249            if (removedEntries) {
     250                saveIgnoredErrors();
     251            }
     252
    239253        }
    240254    }
    241255
     
    426440                }
    427441                if (tr("Ignore list").equals(description))
    428442                    description = "";
    429                 if (!key.matches("^[0-9]+(_.*|$)")) {
     443                if (!key.matches("^[0-9]+(:.*|$)")) {
    430444                    description = key;
    431445                    key = "";
    432446                }
     
    439453                } else if (item.matches("^(r|w|n)_.*")) {
    440454                    // single element
    441455                    entry = key + ":" + item;
    442                 } else if (item.matches("^[0-9]+(_.*|)$")) {
     456                } else if (item.matches("^[0-9]+(:.*|)$")) {
    443457                    // no element ids
    444458                    entry = item;
    445459                }
  • src/org/openstreetmap/josm/data/validation/TestError.java

     
    2121import org.openstreetmap.josm.data.osm.Relation;
    2222import org.openstreetmap.josm.data.osm.Way;
    2323import org.openstreetmap.josm.data.osm.WaySegment;
     24import org.openstreetmap.josm.data.validation.tests.MapCSSTagChecker;
    2425import org.openstreetmap.josm.data.validation.util.MultipleNameVisitor;
    2526import org.openstreetmap.josm.tools.AlphanumComparator;
    2627import org.openstreetmap.josm.tools.CheckParameterUtil;
     
    351352     * @see TestError#getIgnoreSubGroup()
    352353     */
    353354    public String getIgnoreGroup() {
     355        if (code == MapCSSTagChecker.MAPCSS_CODE) {
     356            // see #19053: add most descriptive text to key
     357            return MapCSSTagChecker.MAPCSS_CODE + ":" + (description == null ? message : description);
     358        }
    354359        return Integer.toString(code);
    355360    }
    356361
  • src/org/openstreetmap/josm/data/validation/tests/MapCSSTagChecker.java

     
    7676 * @since 6506
    7777 */
    7878public class MapCSSTagChecker extends Test.TagTest {
     79    /** Code used for all {@link TestError} instances created by MapCSS validator rules */
     80    public static final int MAPCSS_CODE = 3000;
     81
    7982    private MapCSSStyleIndex indexData;
    8083    private final Map<MapCSSRule, MapCSSTagCheckerAndRule> ruleToCheckMap = new HashMap<>();
    8184    private static final Map<IPrimitive, Area> mpAreaCache = new HashMap<>();
     
    551554                final String description = getDescriptionForMatchingSelector(p, matchingSelector);
    552555                final String description1 = group == null ? description : group;
    553556                final String description2 = group == null ? null : description;
    554                 final String selector = matchingSelector.toString();
    555                 TestError.Builder errorBuilder = TestError.builder(tester, getSeverity(), 3000)
    556                         .messageWithManuallyTranslatedDescription(description1, description2, selector);
     557                TestError.Builder errorBuilder = TestError.builder(tester, getSeverity(), MAPCSS_CODE)
     558                        .messageWithManuallyTranslatedDescription(description1, description2, null);
    557559                if (fix != null) {
    558560                    errorBuilder.fix(() -> fix);
    559561                }
     
    562564                } else if (env.children != null) {
    563565                    for (IPrimitive c : env.children) {
    564566                        if (c instanceof OsmPrimitive) {
    565                             errorBuilder = TestError.builder(tester, getSeverity(), 3000)
    566                                     .messageWithManuallyTranslatedDescription(description1, description2, selector);
     567                            errorBuilder = TestError.builder(tester, getSeverity(), MAPCSS_CODE)
     568                                    .messageWithManuallyTranslatedDescription(description1, description2, null);
    567569                            if (fix != null) {
    568570                                errorBuilder.fix(() -> fix);
    569571                            }
  • src/org/openstreetmap/josm/gui/dialogs/ValidatorDialog.java

     
    5353import org.openstreetmap.josm.data.validation.Severity;
    5454import org.openstreetmap.josm.data.validation.TestError;
    5555import org.openstreetmap.josm.data.validation.ValidatorVisitor;
     56import org.openstreetmap.josm.data.validation.tests.MapCSSTagChecker;
    5657import org.openstreetmap.josm.gui.MainApplication;
    5758import org.openstreetmap.josm.gui.PleaseWaitRunnable;
    5859import org.openstreetmap.josm.gui.PopupMenuHandler;
     
    412413        if (node != null) {
    413414            final Set<String> codes = new HashSet<>();
    414415            ValidatorTreePanel.visitTestErrors(node, error -> {
    415                 codes.add(error.getIgnoreSubGroup()); // see #19053
     416                if (error.getCode() == MapCSSTagChecker.MAPCSS_CODE) {
     417                    // see #19053
     418                    codes.add(error.getIgnoreSubGroup());
     419                }
    416420                error.setSelected(true);
    417421
    418422                hasFixes.set(hasFixes.get() || error.isFixable());
  • test/unit/org/openstreetmap/josm/data/validation/tests/MapCSSTagCheckerTest.java

     
    144144        final Collection<TestError> errors = test.getErrorsForPrimitive(p, false);
    145145        assertEquals(1, errors.size());
    146146        assertEquals("has alt_name but not name", errors.iterator().next().getMessage());
    147         assertEquals("3000_*[.+_name][!name]", errors.iterator().next().getIgnoreSubGroup());
     147        assertEquals("3000:has alt_name but not name", errors.iterator().next().getIgnoreSubGroup());
    148148    }
    149149
    150150    /**
     
    159159        final Collection<TestError> errors = test.getErrorsForPrimitive(p, false);
    160160        assertEquals(1, errors.size());
    161161        assertEquals("footway used with foot=no", errors.iterator().next().getMessage());
    162         assertEquals("3000_way[highway=footway][foot]", errors.iterator().next().getIgnoreSubGroup());
     162        assertEquals("3000:footway used with foot=no", errors.iterator().next().getIgnoreSubGroup());
    163163    }
    164164
    165165    /**