Skip to content

Commit 3d765c8

Browse files
committed
add
Signed-off-by: A.Arnold <[email protected]>
1 parent 1a447ca commit 3d765c8

File tree

1 file changed

+44
-15
lines changed

1 file changed

+44
-15
lines changed

docs/topics/yaml-rule-structure-syntax.adoc

Lines changed: 44 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ when:
353353
<1> When more than one tag is given, a logical AND is implied.
354354

355355
[id="yaml-java-provider_{context}"]
356-
=== `java` provider
356+
== `java` provider
357357

358358
The Language Server used by the Java provider is Eclipse’s JDT Language Server (JDTLS). Internally, the JDTLS uses the Eclipse Java Development Toolkit, which includes utilities for searching code in projects.
359359

@@ -364,8 +364,8 @@ This provider has the following capabilities:
364364

365365
In the `pattern` element of a `java.referenced` condition, you can search through application code by using these utilities. For more details, see link:https://help.eclipse.org/latest/index.jsp?topic=%2Forg.eclipse.jdt.doc.isv%2Freference%2Fapi%2Forg%2Feclipse%2Fjdt%2Fcore%2Fsearch%2FSearchPattern.html&anchor=createPattern[Class SearchPattern], which contains all the information for building these patterns for `createPattern(String, int, int, int)`.
366366

367-
368-
.`referenced`
367+
[id="yaml-java-referenced_{context}"]
368+
=== `referenced`
369369

370370
The `referenced` capability enables the provider to find references in the source code. This capability takes three input parameters: `pattern`, `location`, and `annotated`.
371371

@@ -380,7 +380,15 @@ when:
380380
<1> A regular expression pattern to match, for example, `org.kubernetes*`.
381381
<2> Specifies the exact location where the pattern needs to be matched, for example, `IMPORT`.
382382
<3> Checks for specific annotations and their elements, such as name and value in the Java code using a query. For example, the following query matches the Bean(url = “http://www.example.com”) annotation in the method.
383-
383+
+
384+
[source,terminal]
385+
----
386+
annotated:
387+
pattern: org.framework.Bean
388+
elements:
389+
- name: url
390+
value: "http://www.example.com"
391+
----
384392

385393
.Examples
386394

@@ -434,8 +442,25 @@ java.referenced:
434442
pattern: java.util.List
435443
----
436444

445+
[id="yaml-java-dependency_{context}"]
446+
=== `dependency`
447+
448+
The `dependency` capability enables the provider to find dependencies for a given application. {ProductShortName} generates a list of the application's dependencies, and you can use this capability to query the list and check whether a certain dependency exists for the application within a given range of the dependency's versions.
449+
450+
[source,terminal]
451+
----
452+
when:
453+
java.dependency:
454+
name: "<dependency_name>" <1>
455+
upperbound: "<version_string>" <2>
456+
lowerbound: "<version_string>" <3>
457+
----
458+
<1> Name of the dependency to search for.
459+
<2> Upper bound on the version of the dependency.
460+
<3> Lower bound on the version of the dependency.
461+
437462
[id="yaml-java-locations_{context}"]
438-
==== `java` locations
463+
=== `java` locations
439464

440465
The Java provider allows scoping down the search to certain source code locations. You can scope down Java searches from any one of the following search locations:
441466

@@ -466,7 +491,6 @@ If you want to match using an asterisk `*` wildcard for a wider range of results
466491

467492
** Do not use: `org.apache.lucene.search.*`
468493

469-
470494
* *PACKAGE*: PACKAGE allows for searches on any usage of a package, be it in an import or used as part of a FQDN in the code:
471495
+
472496
[source,yaml]
@@ -515,15 +539,15 @@ In the current release of {ProductShortName}, fully qualified static method matc
515539
* *INHERITANCE*: matches against a class inheriting from a given type.
516540
* *ANNOTATION*: matches against annotations.
517541
* *IMPLEMENTS_TYPE*: matches against any type implementing the given type.
518-
* *ENUM_CONSTANT*: matches against `enum` constants.
542+
* *ENUM_CONSTANT*: matches against enum constants.
519543
* *RETURN_TYPE*: matches against a type being returned by a method.
520544
* *VARIABLE_DECLARATION*: matches against a type being declared as a variable.
521545
* *FIELD* (declaration): matches against a type appearing in a field declaration. It can be coupled with an annotation match, this being an annotation happening on the field.
522546
* *METHOD*: matches against a given method declaration. It can be coupled with an annotation match.
523547
* *CLASS* (declaration): matches against a given method declaration. It can be coupled with an annotation match.
524548

525-
526-
===== `go` provider
549+
[id="yaml-go-provider_{context}"]
550+
== `go` provider
527551

528552
The `go` provider analyzes Go source code. This provider's capabilities are `referenced` and `dependency`.
529553

@@ -553,7 +577,8 @@ when:
553577
<2> Upper bound on the version of the dependency.
554578
<3> Lower bound on the version of the dependency.
555579

556-
===== `dotnet` provider
580+
[id="yaml-dotnet-provider_{context}"]
581+
== `dotnet` provider
557582

558583
The `dotnet` is an external provider used to analyze .NET and C# source code. Currently, the provider supports the `referenced` capability.
559584

@@ -571,7 +596,8 @@ when:
571596
<1> `pattern`: A regex pattern to match the desired reference. For example, HttpNotFound.
572597
<2> `namespace`: Specifies the namespace to search within. For example, System.Web.Mvc.
573598

574-
==== Custom variables
599+
[id="yaml-custom-variables_{context}"]
600+
== Custom variables
575601

576602
Provider conditions can have associated custom variables. You can use custom variables to capture relevant information from the matched line in the source code. The values of these variables are interpolated with data matched in the source code. These values can be used to generate detailed templated messages in a rule's action (see xref:yaml-rule-actions_{context}[Message actions]). They can be added to a rule in the `customVariables` field:
577603

@@ -592,12 +618,13 @@ Provider conditions can have associated custom variables. You can use custom var
592618
<2> `name`: The name of the variable that can be used in templates.
593619
<3> `message`: A template for a message using a custom variable.
594620

595-
596-
=== Logical conditions
621+
[id="yaml-logical-conditions_{context}"]
622+
== Logical conditions
597623

598624
The analyzer provides two basic logical conditions, `and` and `or`, which enable you to aggregate results of other conditions and create more complex queries.
599625

600-
==== `and` condition
626+
[id="yaml-logical-and_{context}"]
627+
=== `and` condition
601628

602629
The `and` condition performs a logical AND operation on the results of an array of conditions. An `and` condition matches when _all_ of its child conditions match.
603630

@@ -640,7 +667,8 @@ when:
640667
- go.referenced: "*CustomResourceDefinition*"
641668
----
642669

643-
==== `or` condition
670+
[id="yaml-logical-or_{context}"]
671+
=== `or` condition
644672

645673
The `or` condition performs a logical OR operation on the results of an array of conditions. An `or` condition matches when _any_ of its child conditions matches.
646674

@@ -667,6 +695,7 @@ when:
667695
pattern: junit.junit
668696
----
669697

698+
[id="yaml-rulesets_{context}"]
670699
== Rulesets
671700

672701
A set of rules forms a ruleset. {ProductShortName} does not require every rule file to belong to a ruleset, but you can use rulesets to group multiple rules that achieve a common goal and to pass the rules to the rules engine.

0 commit comments

Comments
 (0)