diff --git a/rules/helper.js b/rules/helper.js index 5b46f46..54b9835 100644 --- a/rules/helper.js +++ b/rules/helper.js @@ -28,6 +28,8 @@ function disallowNodeType(type) { } +module.exports.disallowNodeType = disallowNodeType; + /** * Find a parent for the given element * @@ -56,5 +58,4 @@ function findParent(node, type) { return findParent(parent, type); } -module.exports.findParent = findParent; -module.exports.disallowNodeType = disallowNodeType; \ No newline at end of file +module.exports.findParent = findParent; \ No newline at end of file diff --git a/rules/no-implicit-end.js b/rules/no-implicit-end.js index 29af042..3f6d74d 100644 --- a/rules/no-implicit-end.js +++ b/rules/no-implicit-end.js @@ -28,15 +28,19 @@ module.exports = function() { ); } - function isConnectedToActivity(node) { + function hasCompensationActivity(node) { const parent = findParent(node, 'bpmn:Process'); + const artifacts = parent.artifacts || []; + return artifacts.some((element) => { - return ( - is(element, 'bpmn:Association') && - is(element.sourceRef, 'bpmn:BoundaryEvent') && - element.sourceRef.id === node.id - ); + if (!is(element, 'bpmn:Association')) { + return false; + } + + const source = element.sourceRef; + + return source.id === node.id; }); } @@ -59,10 +63,8 @@ module.exports = function() { return false; } - if (is(node, 'bpmn:BoundaryEvent')) { - if (isCompensationEvent(node) && isConnectedToActivity(node)) { - return false; - } + if (is(node, 'bpmn:BoundaryEvent') && isCompensationEvent(node) && hasCompensationActivity(node)) { + return false; } if (is(node, 'bpmn:Task') && isForCompensation(node)) {