Check if the issues contains text, values in its title, labels, body and milestone.

contains(x, ...)

# S3 method for class 'IssueTB'
contains(
  x,
  values,
  fields = c("body", "title", "labels", "milestone"),
  values_logic_gate = c("AND", "OR"),
  fields_logic_gate = c("OR", "AND"),
  negate = FALSE,
  ...
)

# S3 method for class 'IssuesTB'
contains(x, values, ...)

# Default S3 method
contains(x, ...)

Arguments

x

a IssueTB or IssuesTB object.

...

Arguments passed on to vgrepl and therefore to grepl

values

a vector string. Patterns to look for in the outcome.

fields

a vector string. The different fields of the issue in which to search for the pattern (among "title", "body", "labels" and "milestone").

values_logic_gate

the logic operator which will aggregate the different assertion related to values: "OR" or "AND" (by default).

fields_logic_gate

the logic operator which will aggregate the different assertion related to fields: "OR" (by default) or "AND".

negate

a boolean indicate the negation of the assertion.

Value

a boolean (of length equals 1 if the class of x is IssueTB and length superior to 1 if x if of class IssuesTB) specifying if the pattern is contained in the field field of the issue.

Details

The contains function in R is designed to check if specific fields of GitHub issues contain certain values, offering a flexible mechanism for constructing complex assertions. The function operates with two main logical gates: fields_logic_gate and values_logic_gate.

The fields_logic_gate determines how conditions on multiple fields are combined (either "OR" or "AND"). This means that the call contains(x = issue_1, fields = c("body", "title"), values = "README", fields_logic_gate = "OR") will say whether the issue issue_1 contains the string "README" in its title OR in its body.

The values_logic_gate specifies how conditions on multiple values are combined within each field (either "OR" or "AND"). For example the call


contains(x = issue_1,
         fields = "body",
         values = c("README", "package"),
         values_logic_gate = "OR")

will say whether the issue issue_1 contains the string "README" OR "package" in its body. Whereas the call


contains(x = issue_1,
         fields = "title",
         values = c("README", "package"),
         values_logic_gate = "AND")

will say whether the issue issue_1 contains the string "README" AND "package" in its body.

The function can also negate the condition using the negate argument, effectively allowing users to negate an assertion.

The following example:


contains(
    x = all_issues,
    fields = "labels",
    values = c("unknown", "medium"),
    values_logic_gate = "OR",
    negate = TRUE,
    fields_logic_gate = "AND"
)

designates issues that contain neither "unknown" nor "medium" in their label.

Note that in the last example, the fields_logic_gate argument has no importance and is not taken into account because there is only one field on which to filter. In the same way, if the values argument contains only one element, the values_logic_gate argument has no importance and is not taken into account.

This function is not case-sensitive.

How assertions with multiple values and multiple fields are built

For the order of logical assertions, as it is easy to add assertions linked by an AND (by piping a new filter_issues), it has been decided that assertions containing AND gates will be distributed and assertions containing OR gates will be factorised. The assertions used by filter_issues will therefore have the following format: \((P1 AND Q1) OR (P2 AND Q2)\)

Thus the following call to filter_issue:


filter_issues(
    ...,
    values = c("v1", "v2"), fields = c("f1", "f2"),
    values_logic_gate = "AND", fields_logic_gate = "OR",
    ...
)

will be represented by the following logical proposition: \((v1 in f1 AND v2 in f1) OR (v1 in f2 AND v2 in f2)\).

This makes it possible to create more complex logical forms by combining AND gates and OR gates.

Short names

  • fields = "b" for "body";

  • fields = "t" for "title";

  • fields = "l" for "labels";

  • fields = "m" for "milestone".

Examples


# \donttest{
all_issues <- get_issues(source = "online", verbose = FALSE)
issue_1 <- all_issues[[1L]]
# This will return TRUE if the issue contains either "README" or "package"
# in its body.
contains(x = issue_1,
         fields = "body",
         values = c("README", "package"),
         values_logic_gate = "OR")
#> [1] FALSE
# This will return TRUE if the issue contains "README" in its body AND its
# title.
contains(x = issue_1,
         values = "README",
         fields = c("body", "title"),
         fields_logic_gate = "AND")
#> [1] FALSE
# }