Skip to content
This repository was archived by the owner on Sep 6, 2023. It is now read-only.

Latest commit

 

History

History
93 lines (75 loc) · 4.46 KB

File metadata and controls

93 lines (75 loc) · 4.46 KB
title Process Variables Name Convention Checker
parent Available Checkers

Process Variables Name Convention Checker

Elements in business processes are regularly subject to naming conventions. This checker validates the names of process variables with a configurable regular expression.

  • Variable name against internal convention
  • Variable name against external convention

Assumptions

  • The BPMN-models have to be in the classpath

Configuration

The rule should be configured as follows:

<rule>
    <name>ProcessVariablesNameConventionChecker</name>
    <state>true</state>
    <elementConventions>
      <elementConvention>
        <name>internal</name>
        <!-- field types for process variables -->
        <elementFieldTypes excluded="true">
          <elementFieldType>Class</elementFieldType>
          <elementFieldType>ExternalScript</elementFieldType>
          <elementFieldType>DMN</elementFieldType>
          <elementFieldType>DelegateExpression</elementFieldType>
        </elementFieldTypes>
        <description>Variable has to start with "int_"</description>
        <pattern>int_[a-zA-Z]+</pattern>
      </elementConvention>
      <elementConvention>
        <name>external</name>
        <!-- field types for process variables -->
        <elementFieldTypes>
          <elementFieldType>Class</elementFieldType>
          <elementFieldType>ExternalScript</elementFieldType>
          <elementFieldType>DMN</elementFieldType>
          <elementFieldType>DelegateExpression</elementFieldType>
        </elementFieldTypes>
        <description>Variable has to start with "ext_"</description>
        <pattern>ext_[a-zA-Z]+</pattern>
      </elementConvention>
    </elementConventions>
  </rule>

Via <state>true/false</state> the check can be enabled or disabled

For internal and external naming conventions, elementConventions must be defined.
An element convention consists of:

  • a name
  • an elementFieldType to be analyzed
  • a regular expression for the naming convention (pattern)
  • a description to describe the convention (optional)

The attribute excluded = "true" means that all element field types, except those that are stored, should be checked.

ElementFieldType can take the following values:
Class, FormField, Expression, DelegateExpression, ResultVariable, CalledElement, CaseRef, CollectionElement, ElementVariable, LoopCardinality, CompletionCondition, InlineScript, ExternalScript, Assignee, CandidateUsers, CandidateGroups, DueDate, FollowUpDate, DMN, CamundaIn and CamundaOut.

Error messages

process variable is against the naming convention '%conventionName%' (compare %Chapter%, %ElementFieldType%)

The message indicates that a process variable violates a specific naming convention.
%ConventionName% contains the name of the convention that has been defined within the rule.
%Chapter% and %ElementFieldType% contain information on where the process variable can be found in the Camunda Modeler for the specific BPMN element.

Solution: the variable has to be adapted to the convention.

Examples

process variable is against the naming convention 'external' (compare Details, Class)
Java class definition

Delegate with variables against convention
process variable is against the naming convention 'internal' (compare Details, Expression)
internal variable against convention
process variable is against the naming convention 'external' (compare ExecutionListener, External Script)
script definition
scriptWithVariableAgainstConvention.groovy:
script with variable against convention