mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-15 05:30:35 +02:00
Avoid anonymous functions as validators
Givnig them names makes it easier to understand in the profiler
This commit is contained in:
@@ -13,7 +13,7 @@ export function coreValidator(context) {
|
||||
var _rules = {};
|
||||
var _disabledRules = {};
|
||||
var _entityRules = [];
|
||||
var _changesRules = [];
|
||||
// var _changesRules = []; // skip for now
|
||||
|
||||
var _issues = [];
|
||||
var _issuesByEntityID = {};
|
||||
@@ -29,7 +29,7 @@ export function coreValidator(context) {
|
||||
_rules[key] = fn;
|
||||
|
||||
if (fn.inputType === 'changes') { // 'many_deletions' is the only one like this
|
||||
_changesRules.push(key);
|
||||
// _changesRules.push(key); // skip for now
|
||||
} else {
|
||||
_entityRules.push(key);
|
||||
}
|
||||
@@ -39,8 +39,8 @@ export function coreValidator(context) {
|
||||
|
||||
validator.reset = function() {
|
||||
// clear caches
|
||||
var _issues = [];
|
||||
var _issuesByEntityID = {};
|
||||
_issues = [];
|
||||
_issuesByEntityID = {};
|
||||
for (var key in _rules) {
|
||||
if (typeof _rules[key].reset === 'function') {
|
||||
_rules[key].reset(); // 'crossing_ways' is the only one like this
|
||||
|
||||
@@ -118,15 +118,15 @@ export function validationAlmostJunction() {
|
||||
}
|
||||
|
||||
|
||||
var validation = function(endHighway, context) {
|
||||
if (!isHighway(endHighway)) return [];
|
||||
if (endHighway.isDegenerate()) return [];
|
||||
var validation = function checkAlmostJunction(entity, context) {
|
||||
if (!isHighway(entity)) return [];
|
||||
if (entity.isDegenerate()) return [];
|
||||
|
||||
var graph = context.graph();
|
||||
var tree = context.history().tree();
|
||||
var issues = [];
|
||||
|
||||
var extendableNodeInfos = findConnectableEndNodesByExtension(endHighway, graph, tree);
|
||||
var extendableNodeInfos = findConnectableEndNodesByExtension(entity, graph, tree);
|
||||
extendableNodeInfos.forEach(function(extendableNodeInfo) {
|
||||
var node = extendableNodeInfo.node;
|
||||
var edgeHighway = graph.entity(extendableNodeInfo.wid);
|
||||
@@ -177,11 +177,11 @@ export function validationAlmostJunction() {
|
||||
type: type,
|
||||
severity: 'warning',
|
||||
message: t('issues.almost_junction.message', {
|
||||
feature: utilDisplayLabel(endHighway, context),
|
||||
feature: utilDisplayLabel(entity, context),
|
||||
feature2: utilDisplayLabel(edgeHighway, context)
|
||||
}),
|
||||
tooltip: t('issues.almost_junction.highway-highway.tip'),
|
||||
entities: [endHighway, node, edgeHighway],
|
||||
entities: [entity, node, edgeHighway],
|
||||
loc: extendableNodeInfo.node.loc,
|
||||
info: {
|
||||
edge: extendableNodeInfo.edge,
|
||||
|
||||
@@ -344,7 +344,8 @@ export function validationCrossingWays() {
|
||||
return [];
|
||||
}
|
||||
|
||||
var validation = function(entity, context) {
|
||||
|
||||
var validation = function checkCrossingWays(entity, context) {
|
||||
var graph = context.graph();
|
||||
var tree = context.history().tree();
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ export function validationDisconnectedWay() {
|
||||
return highways[entity.tags.highway];
|
||||
}
|
||||
|
||||
|
||||
function vertexIsDisconnected(way, vertex, graph, relation) {
|
||||
var parents = graph.parentWays(vertex);
|
||||
|
||||
@@ -45,10 +46,9 @@ export function validationDisconnectedWay() {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function isDisconnectedWay(entity, graph) {
|
||||
|
||||
if (entity.type !== 'way') return false;
|
||||
|
||||
return graph.childNodes(entity).every(function(vertex) {
|
||||
return vertexIsDisconnected(entity, vertex, graph);
|
||||
});
|
||||
@@ -71,11 +71,9 @@ export function validationDisconnectedWay() {
|
||||
}
|
||||
|
||||
|
||||
var validation = function(entity, context) {
|
||||
var validation = function checkDisconnectedWay(entity, context) {
|
||||
var graph = context.graph();
|
||||
|
||||
if (!isTaggedAsHighway(entity)) return [];
|
||||
|
||||
if (!isDisconnectedWay(entity, graph) && !isDisconnectedMultipolygon(entity, graph)) return [];
|
||||
|
||||
var entityLabel = utilDisplayLabel(entity, context);
|
||||
|
||||
@@ -49,7 +49,7 @@ export function validationGenericName() {
|
||||
}
|
||||
|
||||
|
||||
var validation = function(entity, context) {
|
||||
var validation = function checkGenericName(entity, context) {
|
||||
var generic = isGenericName(entity);
|
||||
if (!generic) return [];
|
||||
|
||||
|
||||
@@ -8,7 +8,8 @@ export function validationManyDeletions() {
|
||||
|
||||
var type = 'many_deletions';
|
||||
|
||||
var validation = function(changes, context) {
|
||||
|
||||
var validation = function checkManyDeletions(changes, context) {
|
||||
var points = 0, lines = 0, areas = 0, relations = 0;
|
||||
var base = context.history().base();
|
||||
var geometry;
|
||||
|
||||
@@ -5,7 +5,7 @@ export function validationMaprules() {
|
||||
var type = 'maprules';
|
||||
|
||||
|
||||
var validation = function(entity, context) {
|
||||
var validation = function checkMaprules(entity, context) {
|
||||
if (!services.maprules) return [];
|
||||
|
||||
var graph = context.graph();
|
||||
|
||||
@@ -7,8 +7,7 @@ import { validationIssue, validationIssueFix } from '../core/validator';
|
||||
export function validationMissingRole() {
|
||||
var type = 'missing_role';
|
||||
|
||||
var validation = function(entity, context) {
|
||||
|
||||
var validation = function checkMissingRole(entity, context) {
|
||||
var issues = [];
|
||||
if (entity.type === 'way') {
|
||||
context.graph().parentRelations(entity).forEach(function(relation) {
|
||||
|
||||
@@ -26,7 +26,7 @@ export function validationMissingTag() {
|
||||
}
|
||||
|
||||
|
||||
var validation = function(entity, context) {
|
||||
var validation = function checkMissingTag(entity, context) {
|
||||
var graph = context.graph();
|
||||
|
||||
// ignore vertex features and relation members
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { t } from '../util/locale';
|
||||
|
||||
import { actionChangeTags } from '../actions';
|
||||
import { osmIsOldMultipolygonOuterMember, osmOldMultipolygonOuterMemberOfRelation } from '../osm';
|
||||
import { utilDisplayLabel } from '../util';
|
||||
@@ -10,7 +9,7 @@ export function validationOldMultipolygon() {
|
||||
var type = 'old_multipolygon';
|
||||
|
||||
|
||||
var validation = function(entity, context) {
|
||||
var validation = function checkOldMultipolygon(entity, context) {
|
||||
var graph = context.graph();
|
||||
|
||||
var multipolygon, outerWay;
|
||||
|
||||
@@ -22,7 +22,7 @@ export function validationOutdatedTags() {
|
||||
}
|
||||
|
||||
|
||||
var validation = function(entity, context) {
|
||||
var validation = function checkOutdatedTags(entity, context) {
|
||||
var replacementPresetID = context.presets().match(entity, context.graph()).replacement;
|
||||
var deprecatedTagsArray = entity.deprecatedTags();
|
||||
var missingTags = missingRecommendedTags(entity, context, context.graph());
|
||||
|
||||
@@ -50,10 +50,8 @@ export function validationPrivateData() {
|
||||
return privateKeys;
|
||||
}
|
||||
|
||||
var validation = function(entity, context) {
|
||||
|
||||
var validation = function checkPrivateData(entity, context) {
|
||||
var privateKeys = privateDataKeys(entity);
|
||||
|
||||
if (privateKeys.length === 0) return [];
|
||||
|
||||
var fixID = privateKeys.length === 1 ? 'remove_tag' : 'remove_tags';
|
||||
|
||||
@@ -9,7 +9,7 @@ export function validationTagSuggestsArea() {
|
||||
var type = 'tag_suggests_area';
|
||||
|
||||
|
||||
var validation = function(entity, context) {
|
||||
var validation = function checkTagSuggestsArea(entity, context) {
|
||||
if (entity.type !== 'way' || entity.isClosed()) return [];
|
||||
|
||||
var tagSuggestingArea = entity.tagSuggestingArea();
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
import { operationDelete } from '../operations/index';
|
||||
import { t } from '../util/locale';
|
||||
import { utilDisplayLabel } from '../util';
|
||||
@@ -8,8 +7,7 @@ import { validationIssue, validationIssueFix } from '../core/validator';
|
||||
export function validationUnknownRoad() {
|
||||
var type = 'unknown_road';
|
||||
|
||||
var validation = function(entity, context) {
|
||||
|
||||
var validation = function checkUnknownRoad(entity, context) {
|
||||
if (entity.type !== 'way' || entity.tags.highway !== 'road') return [];
|
||||
|
||||
var fixes = [
|
||||
|
||||
Reference in New Issue
Block a user