Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions assemblies/rules-development-guide/assembly_creating-rule.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
:_newdoc-version: 2.18.3
:_template-generated: 2025-05-28

ifdef::context[:parent-context-of-creating-rule: {context}]

:_mod-docs-content-type: ASSEMBLY

ifndef::context[]
[id="creating-rule"]
endif::[]
ifdef::context[]
[id="creating-rule_{context}"]
endif::[]
= Creating custom rules

:context: creating-rule

[role="_abstract"]
You can refer to example rules that describe how to create a YAML rule. This assumes that you already have MTA installed. See the MTA CLI Guide for installation instructions.

//This section describes how to create a {ProductShortName} YAML rule. This assumes that you already have {ProductShortName} installed. See the {ProductShortName} {ProductDocUserGuideURL}[_{UserCLIBookName}_] for installation instructions.//

include::topics/rules-development/create-basic-yaml-rule-template.adoc[leveloffset=+1]

include::topics/rules-development/create-first-yaml-rule.adoc[leveloffset=+1]

include::topics/rules-development/create-go-custom-rule.adoc[leveloffset=+1]


ifdef::parent-context-of-creating-rule[:context: {parent-context-of-creating-rule}]
ifndef::parent-context-of-creating-rule[:!context:]

:!creating-rule:
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
:_newdoc-version: 2.18.3
:_template-generated: 2025-05-28

ifdef::context[:parent-context-of-java-conditions-capabilities: {context}]

:_mod-docs-content-type: ASSEMBLY

ifndef::context[]
[id="java-conditions-capabilities"]
endif::[]
ifdef::context[]
[id="java-conditions-capabilities_{context}"]
endif::[]
= Java condition and capabilities

:context: java-conditions-capabilities

[role="_abstract"]
The `java.referenced` capability in the when condition for Java rules can define search queries for the following fields in the source code:

* Locations - such as the classes, methods, packages and so on
* Annotations
* Patterns

You can refer to this section for a detailed explanation on the Locations, Annotations, and Patterns.


include::topics/rules-development/yaml-java-provider.adoc[leveloffset=+1]

include::topics/rules-development/yaml-java-locations.adoc[leveloffset=+1]

include::topics/rules-development/yaml-annotation-inspection.adoc[leveloffset=+1]

include::topics/rules-development/yaml-condition-patterns.adoc[leveloffset=+1]

ifdef::parent-context-of-rule-java-conditions-capabilities[:context: {parent-context-of-rule-java-conditions-capabilities}]
ifndef::parent-context-of-rule-java-conditions-capabilities[:!context:]

:!java-conditions-capabilities:
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
:_newdoc-version: 2.18.3
:_template-generated: 2025-05-28

ifdef::context[:parent-context-of-logical-chaining-custom-variables: {context}]

:_mod-docs-content-type: ASSEMBLY

ifndef::context[]
[id="logical-chaining-custom-variables"]
endif::[]
ifdef::context[]
[id="logical-chaining-custom-variables_{context}"]
endif::[]
= Logical conditions, condition chaining, and custom variables

:context: logical-chaining-custom-variables

[role="_abstract"]
You can create complex conditions in rules by using the following:

* Logical conditions inform the provider how to handle more than one condition in a when block. You can aggregate or filter conditions using logical operations.
* Condition chaining uses the output of one condition as the input in another condition of the when block. Assign the output to a variable in one condition and reuse it in other conditions in the when block.
* Nested conditions to create conditions that depend on the evaluation of other conditions.
* Custom variables to capture specific information from the code that is evaluated by a rule. You can use the custom variable in the message displayed for the code if it contains a violation defined by the rule.

include::topics/rules-development/yaml-logical-conditions.adoc[leveloffset=+1]

include::topics/rules-development/yaml-and-condition.adoc[leveloffset=+1]

include::topics/rules-development/yaml-or-condition.adoc[leveloffset=+1]

include::topics/rules-development/yaml-chaining-condition-variables.adoc[leveloffset=+1]

include::topics/rules-development/yaml-chaining-java-provider.adoc[leveloffset=+1]

include::topics/rules-development/yaml-nested-condition.adoc[leveloffset=+1]

include::topics/rules-development/yaml-custom-variables.adoc[leveloffset=+1]

ifdef::parent-context-of-rule-logical-chaining-custom-variables[:context: {parent-context-of-rule-logical-chaining-custom-variables}]
ifndef::parent-context-of-rule-logical-chaining-custom-variables[:!context:]

:!logical-chaining-custom-variables:
30 changes: 30 additions & 0 deletions assemblies/rules-development-guide/assembly_rule-rulesets.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
:_newdoc-version: 2.18.3
:_template-generated: 2025-05-28

ifdef::context[:parent-context-of-rule-rulesets: {context}]

:_mod-docs-content-type: ASSEMBLY

ifndef::context[]
[id="rule-rulesets"]
endif::[]
ifdef::context[]
[id="rule-rulesets_{context}"]
endif::[]
= Rulesets

:context: rule-rulesets

[role="_abstract"]
Rulesets.

include::topics/rules-development/yaml-rulesets.adoc[leveloffset=+1]

include::topics/rules-development/create-basic-yaml-ruleset-template.adoc[leveloffset=+1]

include::topics/rules-development/running-analysis-using-custom-yaml-rule.adoc[leveloffset=+1]

ifdef::parent-context-of-rule-rulesets[:context: {parent-context-of-rule-rulesets}]
ifndef::parent-context-of-rule-rulesets[:!context:]

:!rule-rulesets:
30 changes: 30 additions & 0 deletions assemblies/rules-development-guide/assembly_rule-yaml-actions.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
:_newdoc-version: 2.18.3
:_template-generated: 2025-05-28

ifdef::context[:parent-context-of-rule-yaml-actions: {context}]

:_mod-docs-content-type: ASSEMBLY

ifndef::context[]
[id="rule-yaml-actions"]
endif::[]
ifdef::context[]
[id="rule-yaml-actions_{context}"]
endif::[]
= Rule actions

:context: rule-yaml-actions

[role="_abstract"]
Rule actions.

include::topics/rules-development/yaml-rule-actions.adoc[leveloffset=+1]

include::topics/rules-development/yaml-tag-actions.adoc[leveloffset=+1]

include::topics/rules-development/yaml-message-actions.adoc[leveloffset=+1]

ifdef::parent-context-of-rule-yaml-actions[:context: {parent-context-of-rule-yaml-actions}]
ifndef::parent-context-of-rule-yaml-actions[:!context:]

:!rule-yaml-actions:
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
:_newdoc-version: 2.18.3
:_template-generated: 2025-05-28

ifdef::context[:parent-context-of-rule-provider-conditions: {context}]

:_mod-docs-content-type: ASSEMBLY

ifndef::context[]
[id="rule-provider-conditions"]
endif::[]
ifdef::context[]
[id="rule-provider-conditions_{context}"]
endif::[]
= Providers and rule conditions

:context: rule-provider-conditions

[role="_abstract"]
Each rule has a `when` block, which specifies a condition that needs to be met for {ProductShortName} to perform a certain action.

The `when` block contains one condition, but that condition can have multiple conditions nested under it.

[source,yaml]
----
when:
<condition>
<nested-condition>
----

{ProductShortName} supports the following providers:

* Builtin

Check failure on line 32 in assemblies/rules-development-guide/assembly_rule-yaml-conditions.adoc

View workflow job for this annotation

GitHub Actions / Linting with Vale

[vale] reported by reviewdog 🐶 [RedHat.TermsErrors] Use 'built-in' rather than 'Builtin'. Raw Output: {"message": "[RedHat.TermsErrors] Use 'built-in' rather than 'Builtin'.", "location": {"path": "assemblies/rules-development-guide/assembly_rule-yaml-conditions.adoc", "range": {"start": {"line": 32, "column": 3}}}, "severity": "ERROR"}
* Java
* Go
* External providers

include::topics/rules-development/yaml-provider-conditions.adoc[leveloffset=+1]

include::topics/rules-development/yaml-builin-provider.adoc[leveloffset=+1]

include::topics/rules-development/yaml-java-provider.adoc[leveloffset=+1]

include::topics/rules-development/yaml-go-provider.adoc[leveloffset=+1]

include::topics/rules-development/yaml-dotnet-provider.adoc[leveloffset=+1]

ifdef::parent-context-of-rule-provider-conditions[:context: {parent-context-of-rule-provider-conditions}]
ifndef::parent-context-of-rule-provider-conditions[:!context:]

:!rule-provider-conditions:
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
:_newdoc-version: 2.18.3
:_template-generated: 2025-05-28

ifdef::context[:parent-context-of-rule-yaml-metadata: {context}]

:_mod-docs-content-type: ASSEMBLY

ifndef::context[]
[id="rule-yaml-metadata"]
endif::[]
ifdef::context[]
[id="rule-yaml-metadata_{context}"]
endif::[]
= Rule metadata

:context: rule-yaml-metadata

[role="_abstract"]
The rule metadata contains information about the migration defined by the Architect. You can use rule metadata to:

* Estimate the total migration effort
* Prioritize issues that must be resolved based on the effort
* Evaluate if a resolution is mandatory through rule category before migrating the applications to the target technologies or platforms
* Define labels for which MTA filterfilters rules to trigger a violation.


include::topics/rules-development/yaml-rule-metadata.adoc[leveloffset=+1]

include::topics/rules-development/yaml-rule-hyperlinks.adoc[leveloffset=+1]

include::topics/rules-development/yaml-rule-labels.adoc[leveloffset=+1]

include::topics/rules-development/yaml-rule-categories.adoc[leveloffset=+1]

ifdef::parent-context-of-rule-yaml-metadata[:context: {parent-context-of-rule-yaml-metadata}]
ifndef::parent-context-of-rule-yaml-metadata[:!context:]

:!rule-yaml-metadata:
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
:_newdoc-version: 2.18.3
:_template-generated: 2025-05-28

ifdef::context[:parent-context-of-rules-introduction: {context}]

:_mod-docs-content-type: ASSEMBLY

ifndef::context[]
[id="rules-introduction"]
endif::[]
ifdef::context[]
[id="rules-introduction_{context}"]
endif::[]
= Introduction to rules

:context: rules-introduction

[role="_abstract"]
This guide is intended for software engineers who want to create custom YAML-based rules for {ProductName} ({ProductShortName}) tools.

See the link:{ProductDocIntroToMTAGuideURL}[_{IntroToMTABookName}_] for an overview and the link:{ProductDocUserGuideURL}[_{UserCLIBookName}_] for details.

// Use of <{ProductShortName}_HOME> in this Guide
include::topics/rules-development/mta-about-home-var.adoc[leveloffset=+1]

include::topics/rules-development/about-rules.adoc[leveloffset=+1]

include::topics/rules-development/yaml-rule-structure-syntax.adoc[leveloffset=+1]

ifdef::parent-context-of-getting-started[:context: {parent-context-of-rules-introduction}]
ifndef::parent-context-of-getting-started[:!context:]

:!rules-introduction:
1 change: 1 addition & 0 deletions assemblies/rules-development-guide/topics
1 change: 1 addition & 0 deletions docs/rules-development-guide/assemblies
Loading
Loading