-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: support execution listeners #168
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
const { | ||
findExtensionElement, | ||
hasDuplicatedPropertiesValues | ||
} = require('../utils/element'); | ||
|
||
const { reportErrors } = require('../utils/reporter'); | ||
|
||
const { skipInNonExecutableProcess } = require('../utils/rule'); | ||
|
||
module.exports = skipInNonExecutableProcess(function() { | ||
function check(node, reporter) { | ||
const executionListeners = findExtensionElement(node, 'zeebe:ExecutionListeners'); | ||
|
||
if (!executionListeners) { | ||
return; | ||
} | ||
|
||
const errors = hasDuplicatedExecutionListeners(executionListeners, node); | ||
|
||
if (errors && errors.length) { | ||
reportErrors(node, reporter, errors); | ||
} | ||
} | ||
|
||
return { | ||
check | ||
}; | ||
}); | ||
|
||
// helpers ////////// | ||
function hasDuplicatedExecutionListeners(executionListeners, parentNode = null) { | ||
return hasDuplicatedPropertiesValues(executionListeners, 'listeners', [ 'eventType', 'type' ], parentNode); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
const { | ||
findExtensionElement, | ||
hasProperties | ||
} = require('../utils/element'); | ||
|
||
const { reportErrors } = require('../utils/reporter'); | ||
|
||
const { skipInNonExecutableProcess } = require('../utils/rule'); | ||
|
||
|
||
module.exports = skipInNonExecutableProcess(function() { | ||
function check(node, reporter) { | ||
const executionListeners = findExtensionElement(node, 'zeebe:ExecutionListeners'); | ||
|
||
if (!executionListeners) { | ||
return; | ||
} | ||
|
||
const listeners = executionListeners.get('listeners'); | ||
const errors = listeners.flatMap(listener => hasProperties(listener, { | ||
type: { | ||
required: true | ||
} | ||
}, node)); | ||
|
||
if (errors.length) { | ||
reportErrors(node, reporter, errors); | ||
} | ||
} | ||
|
||
return { | ||
check | ||
}; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
const { reportErrors } = require('../utils/reporter'); | ||
|
||
const { skipInNonExecutableProcess } = require('../utils/rule'); | ||
|
||
const { hasNoExtensionElement } = require('../utils/element'); | ||
|
||
const ALLOWED_VERSION = '8.6'; | ||
|
||
module.exports = skipInNonExecutableProcess(function() { | ||
function check(node, reporter) { | ||
const errors = hasNoExtensionElement(node, 'zeebe:ExecutionListeners', node, ALLOWED_VERSION); | ||
|
||
if (errors && errors.length) { | ||
reportErrors(node, reporter, errors); | ||
} | ||
} | ||
|
||
return { | ||
check | ||
}; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have we considered using the existing helper used by a similar rule (https://github.com/camunda/bpmnlint-plugin-camunda-compat/blob/main/rules/camunda-cloud/duplicate-task-headers.js#L28)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess it's because duplication requires two duplicate properties instead of just one. We could still adjust the helper to allow multiple properties.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have considered this and decided against it due to the adjustment needed. If we have more cases like this, we may abstract it away, but right now I'd consider it YAGNI.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not a huge fan of using
ERROR_TYPES.PROPERTY_VALUE_DUPLICATED
and thenduplicatedProperty: 'type'
since it doesn't mention the event type at all. We should probably have a separate typePROPERTY_VALUES_DUPLICATED
and include all the data necessary to create a custom error message.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd just add a
hasDuplicatedPropertiesValues
helper that encapsulates the logic so the rule simply callshasDuplicatedPropertiesValues(taskHeaders, 'listeners', [ 'eventType', 'type' ], node)
. 🤔There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll try that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@philippfromme please have a look now.