You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/topics/yaml-rule-structure-syntax.adoc
+44-15Lines changed: 44 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -353,7 +353,7 @@ when:
353
353
<1> When more than one tag is given, a logical AND is implied.
354
354
355
355
[id="yaml-java-provider_{context}"]
356
-
=== `java` provider
356
+
== `java` provider
357
357
358
358
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.
359
359
@@ -364,8 +364,8 @@ This provider has the following capabilities:
364
364
365
365
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)`.
366
366
367
-
368
-
.`referenced`
367
+
[id="yaml-java-referenced_{context}"]
368
+
=== `referenced`
369
369
370
370
The `referenced` capability enables the provider to find references in the source code. This capability takes three input parameters: `pattern`, `location`, and `annotated`.
371
371
@@ -380,7 +380,15 @@ when:
380
380
<1> A regular expression pattern to match, for example, `org.kubernetes*`.
381
381
<2> Specifies the exact location where the pattern needs to be matched, for example, `IMPORT`.
382
382
<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
+
----
384
392
385
393
.Examples
386
394
@@ -434,8 +442,25 @@ java.referenced:
434
442
pattern: java.util.List
435
443
----
436
444
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
+
437
462
[id="yaml-java-locations_{context}"]
438
-
==== `java` locations
463
+
=== `java` locations
439
464
440
465
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:
441
466
@@ -466,7 +491,6 @@ If you want to match using an asterisk `*` wildcard for a wider range of results
466
491
467
492
** Do not use: `org.apache.lucene.search.*`
468
493
469
-
470
494
* *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:
471
495
+
472
496
[source,yaml]
@@ -515,15 +539,15 @@ In the current release of {ProductShortName}, fully qualified static method matc
515
539
* *INHERITANCE*: matches against a class inheriting from a given type.
516
540
* *ANNOTATION*: matches against annotations.
517
541
* *IMPLEMENTS_TYPE*: matches against any type implementing the given type.
518
-
* *ENUM_CONSTANT*: matches against `enum` constants.
542
+
* *ENUM_CONSTANT*: matches against enum constants.
519
543
* *RETURN_TYPE*: matches against a type being returned by a method.
520
544
* *VARIABLE_DECLARATION*: matches against a type being declared as a variable.
521
545
* *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.
522
546
* *METHOD*: matches against a given method declaration. It can be coupled with an annotation match.
523
547
* *CLASS* (declaration): matches against a given method declaration. It can be coupled with an annotation match.
524
548
525
-
526
-
===== `go` provider
549
+
[id="yaml-go-provider_{context}"]
550
+
== `go` provider
527
551
528
552
The `go` provider analyzes Go source code. This provider's capabilities are `referenced` and `dependency`.
529
553
@@ -553,7 +577,8 @@ when:
553
577
<2> Upper bound on the version of the dependency.
554
578
<3> Lower bound on the version of the dependency.
555
579
556
-
===== `dotnet` provider
580
+
[id="yaml-dotnet-provider_{context}"]
581
+
== `dotnet` provider
557
582
558
583
The `dotnet` is an external provider used to analyze .NET and C# source code. Currently, the provider supports the `referenced` capability.
559
584
@@ -571,7 +596,8 @@ when:
571
596
<1> `pattern`: A regex pattern to match the desired reference. For example, HttpNotFound.
572
597
<2> `namespace`: Specifies the namespace to search within. For example, System.Web.Mvc.
573
598
574
-
==== Custom variables
599
+
[id="yaml-custom-variables_{context}"]
600
+
== Custom variables
575
601
576
602
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:
577
603
@@ -592,12 +618,13 @@ Provider conditions can have associated custom variables. You can use custom var
592
618
<2> `name`: The name of the variable that can be used in templates.
593
619
<3> `message`: A template for a message using a custom variable.
594
620
595
-
596
-
=== Logical conditions
621
+
[id="yaml-logical-conditions_{context}"]
622
+
== Logical conditions
597
623
598
624
The analyzer provides two basic logical conditions, `and` and `or`, which enable you to aggregate results of other conditions and create more complex queries.
599
625
600
-
==== `and` condition
626
+
[id="yaml-logical-and_{context}"]
627
+
=== `and` condition
601
628
602
629
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.
603
630
@@ -640,7 +667,8 @@ when:
640
667
- go.referenced: "*CustomResourceDefinition*"
641
668
----
642
669
643
-
==== `or` condition
670
+
[id="yaml-logical-or_{context}"]
671
+
=== `or` condition
644
672
645
673
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.
646
674
@@ -667,6 +695,7 @@ when:
667
695
pattern: junit.junit
668
696
----
669
697
698
+
[id="yaml-rulesets_{context}"]
670
699
== Rulesets
671
700
672
701
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