Skip to content

Commit

Permalink
Fixed warning when next() is the only script
Browse files Browse the repository at this point in the history
  • Loading branch information
membro committed Oct 12, 2021
1 parent 80e8ac0 commit bfe5707
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 5 deletions.
4 changes: 2 additions & 2 deletions bpmnlint-plugin-custom/rules/script-task-warn.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ module.exports = function () {

function check(node, reporter) {
if (is(node, 'bpmn:ScriptTask') && (node.scriptFormat === 'js' || node.scriptFormat === 'javascript')) {
const regex = /\snext(\s?)\((.*)\)/;
const regex = new RegExp('\\snext(\\s?)\\((.*)\\)');

if (node.script && !node.script.match(regex)) {
if (node.script && !regex.test(` ${node.script} `)) {
reporter.report(node.id, 'next() functions does not exist');
}
}
Expand Down
4 changes: 2 additions & 2 deletions dist/client.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/client.js.map

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions test/rules/script-task-warn.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ RuleTester.verify('script-task-warn', rule, {
{
// next(null, var1)
moddleElement: readModdle(__dirname + '/script-task-warn/valid-next-function-with-parameters.bpmn')
},
{
moddleElement: readModdle(__dirname + '/script-task-warn/valid-when-next-is-the-only-script.bpmn')
}
],
invalid: [
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:modeler="http://camunda.org/schema/modeler/1.0" id="Definitions_13cv35p" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="4.10.0" modeler:executionPlatform="Camunda Platform" modeler:executionPlatformVersion="7.15.0">
<bpmn:process id="js" isExecutable="true">
<bpmn:startEvent id="StartEvent_1">
<bpmn:outgoing>Flow_1hn5qoa</bpmn:outgoing>
</bpmn:startEvent>
<bpmn:sequenceFlow id="Flow_1hn5qoa" sourceRef="StartEvent_1" targetRef="script_task" />
<bpmn:endEvent id="Event_1f8qgj7">
<bpmn:incoming>Flow_1bem8gr</bpmn:incoming>
</bpmn:endEvent>
<bpmn:sequenceFlow id="Flow_1bem8gr" sourceRef="script_task" targetRef="Event_1f8qgj7" />
<bpmn:scriptTask id="script_task" scriptFormat="js">
<bpmn:incoming>Flow_1hn5qoa</bpmn:incoming>
<bpmn:outgoing>Flow_1bem8gr</bpmn:outgoing>
<bpmn:script>next()</bpmn:script>
</bpmn:scriptTask>
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="js">
<bpmndi:BPMNEdge id="Flow_1bem8gr_di" bpmnElement="Flow_1bem8gr">
<di:waypoint x="370" y="117" />
<di:waypoint x="432" y="117" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_1hn5qoa_di" bpmnElement="Flow_1hn5qoa">
<di:waypoint x="215" y="117" />
<di:waypoint x="270" y="117" />
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
<dc:Bounds x="179" y="99" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Event_1f8qgj7_di" bpmnElement="Event_1f8qgj7">
<dc:Bounds x="432" y="99" width="36" height="36" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_0frc6re_di" bpmnElement="script_task">
<dc:Bounds x="270" y="77" width="100" height="80" />
</bpmndi:BPMNShape>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>

0 comments on commit bfe5707

Please sign in to comment.