bpmnlint 11.13.0 → 11.14.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 +1 -0
- package/config/recommended.js +1 -0
- package/package.json +1 -1
- package/rules/superfluous-label.js +74 -0
package/config/all.js
CHANGED
package/config/recommended.js
CHANGED
package/package.json
CHANGED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
const {
|
|
2
|
+
is
|
|
3
|
+
} = require('bpmnlint-utils');
|
|
4
|
+
|
|
5
|
+
const {
|
|
6
|
+
annotateRule
|
|
7
|
+
} = require('./helper');
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* A rule that checks that unconditional sequence flows do not
|
|
12
|
+
* have a label.
|
|
13
|
+
*
|
|
14
|
+
* Labels are only meaningful on sequence flows forking out of
|
|
15
|
+
* XOR/OR gateways, on conditional flows, and on default flows.
|
|
16
|
+
* Anywhere else they duplicate information already conveyed by
|
|
17
|
+
* the diagram.
|
|
18
|
+
*
|
|
19
|
+
* @type { import('../lib/types.js').RuleFactory }
|
|
20
|
+
*/
|
|
21
|
+
module.exports = function() {
|
|
22
|
+
|
|
23
|
+
function check(node, reporter) {
|
|
24
|
+
|
|
25
|
+
if (!is(node, 'bpmn:SequenceFlow')) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const name = (node.name || '').trim();
|
|
30
|
+
|
|
31
|
+
if (!name) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (hasCondition(node) || isDefaultFlow(node) || isGatewayFork(node)) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
reporter.report(node.id, 'Sequence flow has superfluous label', [ 'name' ]);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return annotateRule('superfluous-label', {
|
|
43
|
+
check
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
// helpers /////////////////////////////
|
|
50
|
+
|
|
51
|
+
function hasCondition(flow) {
|
|
52
|
+
return !!flow.conditionExpression;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function isDefaultFlow(flow) {
|
|
56
|
+
const source = flow.sourceRef;
|
|
57
|
+
|
|
58
|
+
return source && source['default'] === flow;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function isGatewayFork(flow) {
|
|
62
|
+
const source = flow.sourceRef;
|
|
63
|
+
|
|
64
|
+
if (!source) {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const isDecisionGateway = (
|
|
69
|
+
is(source, 'bpmn:ExclusiveGateway') ||
|
|
70
|
+
is(source, 'bpmn:InclusiveGateway')
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
return isDecisionGateway && (source.outgoing || []).length > 1;
|
|
74
|
+
}
|