Ticket #19053: 19053.3.patch
File 19053.3.patch, 7.9 KB (added by , 5 years ago) |
---|
-
src/org/openstreetmap/josm/data/validation/OsmValidator.java
234 234 } catch (SecurityException e) { 235 235 Logging.log(Logging.LEVEL_ERROR, "Unable to load ignored errors", e); 236 236 } 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 239 253 } 240 254 } 241 255 … … 426 440 } 427 441 if (tr("Ignore list").equals(description)) 428 442 description = ""; 429 if (!key.matches("^[0-9]+( _.*|$)")) {443 if (!key.matches("^[0-9]+(:.*|$)")) { 430 444 description = key; 431 445 key = ""; 432 446 } … … 439 453 } else if (item.matches("^(r|w|n)_.*")) { 440 454 // single element 441 455 entry = key + ":" + item; 442 } else if (item.matches("^[0-9]+( _.*|)$")) {456 } else if (item.matches("^[0-9]+(:.*|)$")) { 443 457 // no element ids 444 458 entry = item; 445 459 } -
src/org/openstreetmap/josm/data/validation/TestError.java
21 21 import org.openstreetmap.josm.data.osm.Relation; 22 22 import org.openstreetmap.josm.data.osm.Way; 23 23 import org.openstreetmap.josm.data.osm.WaySegment; 24 import org.openstreetmap.josm.data.validation.tests.MapCSSTagChecker; 24 25 import org.openstreetmap.josm.data.validation.util.MultipleNameVisitor; 25 26 import org.openstreetmap.josm.tools.AlphanumComparator; 26 27 import org.openstreetmap.josm.tools.CheckParameterUtil; … … 351 352 * @see TestError#getIgnoreSubGroup() 352 353 */ 353 354 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 } 354 359 return Integer.toString(code); 355 360 } 356 361 -
src/org/openstreetmap/josm/data/validation/tests/MapCSSTagChecker.java
76 76 * @since 6506 77 77 */ 78 78 public 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 79 82 private MapCSSStyleIndex indexData; 80 83 private final Map<MapCSSRule, MapCSSTagCheckerAndRule> ruleToCheckMap = new HashMap<>(); 81 84 private static final Map<IPrimitive, Area> mpAreaCache = new HashMap<>(); … … 551 554 final String description = getDescriptionForMatchingSelector(p, matchingSelector); 552 555 final String description1 = group == null ? description : group; 553 556 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); 557 559 if (fix != null) { 558 560 errorBuilder.fix(() -> fix); 559 561 } … … 562 564 } else if (env.children != null) { 563 565 for (IPrimitive c : env.children) { 564 566 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); 567 569 if (fix != null) { 568 570 errorBuilder.fix(() -> fix); 569 571 } -
src/org/openstreetmap/josm/gui/dialogs/ValidatorDialog.java
53 53 import org.openstreetmap.josm.data.validation.Severity; 54 54 import org.openstreetmap.josm.data.validation.TestError; 55 55 import org.openstreetmap.josm.data.validation.ValidatorVisitor; 56 import org.openstreetmap.josm.data.validation.tests.MapCSSTagChecker; 56 57 import org.openstreetmap.josm.gui.MainApplication; 57 58 import org.openstreetmap.josm.gui.PleaseWaitRunnable; 58 59 import org.openstreetmap.josm.gui.PopupMenuHandler; … … 412 413 if (node != null) { 413 414 final Set<String> codes = new HashSet<>(); 414 415 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 } 416 420 error.setSelected(true); 417 421 418 422 hasFixes.set(hasFixes.get() || error.isFixable()); -
test/unit/org/openstreetmap/josm/data/validation/tests/MapCSSTagCheckerTest.java
144 144 final Collection<TestError> errors = test.getErrorsForPrimitive(p, false); 145 145 assertEquals(1, errors.size()); 146 146 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()); 148 148 } 149 149 150 150 /** … … 159 159 final Collection<TestError> errors = test.getErrorsForPrimitive(p, false); 160 160 assertEquals(1, errors.size()); 161 161 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()); 163 163 } 164 164 165 165 /**