bpmnlint 10.0.0 → 10.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/config/all.js +3 -2
- package/config/recommended.js +2 -1
- package/package.json +1 -1
- package/rules/superfluous-termination.js +63 -0
package/config/all.js
CHANGED
|
@@ -9,8 +9,8 @@ const allRules = [
|
|
|
9
9
|
'no-disconnected',
|
|
10
10
|
'no-duplicate-sequence-flows',
|
|
11
11
|
'no-gateway-join-fork',
|
|
12
|
-
'no-implicit-split',
|
|
13
12
|
'no-implicit-end',
|
|
13
|
+
'no-implicit-split',
|
|
14
14
|
'no-implicit-start',
|
|
15
15
|
'no-inclusive-gateway',
|
|
16
16
|
'no-overlapping-elements',
|
|
@@ -18,7 +18,8 @@ const allRules = [
|
|
|
18
18
|
'single-event-definition',
|
|
19
19
|
'start-event-required',
|
|
20
20
|
'sub-process-blank-start-event',
|
|
21
|
-
'superfluous-gateway'
|
|
21
|
+
'superfluous-gateway',
|
|
22
|
+
'superfluous-termination'
|
|
22
23
|
];
|
|
23
24
|
|
|
24
25
|
|
package/config/recommended.js
CHANGED
package/package.json
CHANGED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
const {
|
|
2
|
+
is, isAny
|
|
3
|
+
} = require('bpmnlint-utils');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* A rule that checks, whether a gateway has only one source and target.
|
|
7
|
+
*
|
|
8
|
+
* Those gateways are superfluous since they don't do anything.
|
|
9
|
+
*/
|
|
10
|
+
module.exports = function() {
|
|
11
|
+
|
|
12
|
+
function check(node, reporter) {
|
|
13
|
+
|
|
14
|
+
if (!isAny(node, [ 'bpmn:Process', 'bpmn:SubProcess' ])) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const flowElements = node.flowElements || [];
|
|
19
|
+
|
|
20
|
+
const ends = flowElements.filter(
|
|
21
|
+
element => is(element, 'bpmn:FlowNode') && (element.outgoing || []).length === 0
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
const terminateEnds = ends.filter(isTerminateEnd);
|
|
25
|
+
|
|
26
|
+
if (terminateEnds.length !== 1) {
|
|
27
|
+
|
|
28
|
+
// TODO(nikku): only detect basic cases, do not
|
|
29
|
+
// do any kinds of elaborate flow analysis
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const superfluous = ends.every(
|
|
34
|
+
(end) => isInterruptingEventSub(end) || isTerminateEnd(end)
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
if (superfluous) {
|
|
38
|
+
|
|
39
|
+
for (const node of terminateEnds) {
|
|
40
|
+
reporter.report(node.id, 'Termination is superfluous.');
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return {
|
|
46
|
+
check
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
function isTerminateEnd(element) {
|
|
52
|
+
return is(element, 'bpmn:EndEvent') && (element.eventDefinitions || []).some(
|
|
53
|
+
eventDefinition => is(eventDefinition, 'bpmn:TerminateEventDefinition')
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function isInterruptingEventSub(element) {
|
|
58
|
+
const isEventSub = is(element, 'bpmn:SubProcess') && element.triggeredByEvent;
|
|
59
|
+
|
|
60
|
+
return isEventSub && (element.flowElements || []).some(
|
|
61
|
+
element => is(element, 'bpmn:StartEvent') && element.isInterrupting
|
|
62
|
+
);
|
|
63
|
+
}
|