Searching in Code Review
In this topic: |
Searching in Code Review
In Code Review, you can perform full-text or keyword searches for revisions, actions and comments on your feed page. Any matches to your search criteria are returned with the most recent date at the top of the list. A search will retrieve information only from revisions that have been loaded (either with the--revision option of kwscm, or on demand).
You can use keywords, full-text search, or a combination. Full-text searches are applied to file names, revision commit messages, comments and actions. Basic supported search patterns are described with examples below.
See the section below called Using keywords to filter search results for information about using simple and complex keywords to search a code review.
Items you want to exclude (-)
Preceding your search criteria (either keyword or text) with a minus sign indicates that you want to exclude items from your specified criteria, for example:
message:"needs research" -file:foo.c
returns any comments, actions and commit messages that match "needs research" in files other than foo.c.
Klocwork does not support using the minus sign with the text keyword.
Phrase search ("")
Use double quotes to indicate a phrase or expression that contains spaces or punctuation.
For example:
message:"needs more research"
Wildcard (*)
The wildcard is implictly applied to all string searches. For example, a search for the pattern:
message:"test5"
message:"test*5"
will return all patterns such as "testserver5", or "test server 5".
Exact match (+)
Use the plus-sign to indicate an exact match is required for your keyword or full-text search.
For example:
file:+moo.c
Returns only files that exactly match "moo.c"
On the other hand, if you specify (without the plus-sign):
file:moo.c
Then any file or path that contained "moo.c" would be returned, such as "smoo.c".
You can precede a keyword with a minus sign, but not a plus-sign. Example: -file:foo.c is permitted, but +file:foo.c is not.
The OR operator
The default search behavior is to consider all keywords or text and list those issues that match all criteria. Use OR or "|" to override this behavior.
For example:
PPR2777 OR PR2778
The above query will return matches to revision commit messages, actions or comments that contain "PR2777" or "PR2778".
This can also be expressed as:
PR2777 | PR2778
The OR operator can also be used to group search results. For example, if you want to search for everything one particular user is responsible for, do the following:
actions:open responsible:+'John Doe' OR commits:any reviews:pending reviewer:+'John Doe'
This search will show all the tasks that John Doe is currently responsible for.
Opening a revision from an external tool
http(s)://<host>:<port>/codereview/CodeReview.htm#search_goto:q=<url encoded search>,openCommit=true
where <url encoded search> is the URL encoded search query, for example:
revision%25253A%25252B%252522107841%252522%252520project%25253A%25252B%252522win_all_sources%252522
Specifying openCommit=true; takes the user directly to the revision specified in the query. If multiple results are returned, the user is presented with a list of all search results.
Using keywords to filter search results
You can use keywords and matching key values to narrow your search focus.
For example:
<keyword>:<string>
- Do not insert a space after the colon.
- Keyword searches are not case sensitive, however the search pattern is case sensitive when preceded by the '+' symbol. For example, the query:
COMMITTER:+JDOE
will not return any results if the user's actual userid is jdoe. - Multiple values for a keyword should be separated by commas, whereas multiple keywords should be separated by spaces. For example:
comment:"needs more research" file:cruise.java,outsinks.c user:jleeIf you enter:
file:foo.c moo.c noo.cthe search engine will look for files that match "foo.c" and then do a full-text search for "moo.c" and "noo.c" in revision commit messages, actions or comments.
Searching by simple keyword
You can use the following simple keywords to return information from code reviews and existing revisions.
Supported keywords | Search parameters | Format | Example |
---|---|---|---|
revision | revision number or code review ID This keyword returns revisions and/or pre-commits with the specified ID. If you want to narrow down your results, you can specify 'commit_type' as 'pre' or 'post'. |
revision:<revision_number>, <revision_number>... |
revision:4,6 |
message | revision commit message, comments and actions that contain the specified text |
message:<"message">,<"message">... Use quotes for expressions that contain spaces or punctuation. |
message:"check with bob", windows |
text | text search for specific comments, messages, tags, authors or file names | text:<"comment">,<"message">,<tag>, <author>, <filename>... | text:"please revise", jlee |
file | revisions, actions or comments that contain the specified file(s) | file:<filename>,<filename>... | file.htmparser |
project | revisions, actions and comments for the specified project(s) |
project:<project_name>,<project_name>... Use quotes for expressions that contain spaces or punctuation. |
project:my_project |
user | user who committed the revision, made a comment, created an action or had actions assigned to them. See Searching by user role below for a list of valid roles. | user:<user_name>,<user_name>... | user:jlee |
tags | tags that are applied to specific code reviews | tag:<tag>,<tag>... | tag:myTag |
You can negate search phrases in your query to filter data out of your search results.
For example, to return all comments and actions except those by user JDoe, prefix your search keyword with a hyphen:
type:actions,comments -author:JDoe
type:actions,comments -author:JDoe
You can negate any keyword. The following example returns all activity for the current week, with the exception of approved commits:
changed:'this week' -commits:approved
Searching using entities and states (complex keywords)
commits:pending file:/branches/BR_9_6where commits is an entity and pending is a state.
Supported keywords | Search parameters | Format | Example |
---|---|---|---|
type | comments, actions or commits for the specified type(s). Valid types are:
|
type:<type>,<type>... | type:actions,comments author:JDoe |
commit(s) | commits, in any state, where allowed states are:
Where it's not entirely clear, states are defined using the following criteria:
|
commit:<state>,<state>... commits:<state>,<state>... |
commits:any to:JDoe |
review(s) | reviews in a given state, where allowed states are:
|
review: <state>,<state>... reviews: <state>,<state>... |
reviews:pending from:JDoe |
commit_type | commit type for revisions or pre-checkin code reviews, using one of the following states:
|
commit_type:<state>,<state>... | reviews:pending from:JDoe commit_type:post |
commit_state | commit state for revisions or pre-checkin code reviews, using one of the following states:
|
commit_state:<state>,<state>... | commit_state:fixed commit_type:pre commits:rejected |
comment(s) | comments given a state, where allowed states are:
|
comment:<state>,<state>... comments:<state>,<state>... |
comments:unread to:JDoe |
action(s) | actions given a state, where allowed states are:
|
action:<state>,<state>... actions:<state>,<state>... |
actions:open reviews:pending |
Searching by user role
You can filter your search results given one or more user roles, where a user role represents the activity performed by a user. For example, author or submitter.
Supported keywords | Search parameters | Format | Example |
---|---|---|---|
responsible | The reviewer for a pre-checkin code review, or the user responsible for the action. | responsible:<user>,<user>... where user is the user name of a valid user. |
commits:unreviewed responsible:JDoe |
author | the author of the comment, action, or the committer (or precomitter). | author:<user>,<user>... where user is the user name of a valid user. |
comments:unread author:JDoe |
by | same as above | by:<user>,<user>... where user is the user name of a valid user. |
comments:read by:JDoe |
committer | The commtter or pre-committer. | committer:<user>,<user>... where user is the user name of a valid user. |
committer:JDoe date:this_week |
reviewer | The reviewer for a commit or pre-commit. | reviewer:<user>,<user>... where user is the user name of a valid user. |
date:'this week' reviewer:JDoe |
to | The person addressed by a comment, the reviewer for a commit or pre-commit, or the person responsible for an action. | to:<user>,<user>... where user is the user name of a valid user. |
date:'this month' to:JDoe by:JBlow |
Filtering by date
You can filter your searches by date allowing you to return results according to individual dates or ranges of dates. To filter results by a single date, simply specify the date keyword along with a valid <datespec> value:
type:commit reviews:pending created:'January 1, 1970'
All date values must be surrounded by either single or double quotes. To return results for a range of dates, specify a hyphen between two valid <datespec> values.
type:commit reviews:pending created:'January 1, 1970'-'last month'
Supported keywords | Search parameters | Format | Example |
---|---|---|---|
date | one or two <datespec> values, using a standard date format such as: '03-07-2013', or ' January 1, 1970' or by using one of the following supported literals:
You can also specify the literal value without the underscore by using quotes such as 'this week', 'this year', etc. |
date:<datespec>[-<datespec>] | date:'January 1, 1970'
The following example specifies a range of dates: created:'January 1, 1970'-'last month' You can also use the year value to return all data for a given year. For example: date:'2013' |
created | a valid <datespec> value representing the creation date. | created:<datespec> | actions:any author:JDoe created:yesterday |
updated | a valid <datespec> value representing the date of last update. | updated:<datespec> | actions:any updated:last_month |
modified | a valid <datespec> value representing the date of last modification. | modified:<datespec> | author:JDoe modified:'January 1, 1970'-'last month' |
changed | a valid <datespec> value representing the date of last change. | changed:<datespec> | review:pending author:JDoe changed:yesterday |
"yyyy", "MM yyyy", "MM, yyyy", "MMM yyyy", "MMM, yyyy", "MM/dd/yy", "MM/dd/yyyy", "yy-MM-dd", "yyyy-MM-dd", "dd MMM yyyy", "dd MMMMM yyyy", "EEE, dd MMM yyyy HH:mm:ss Z", "dd MMM yyyy HH:mm:ss Z", "dd MMM yyyy HH:mm", "dd MMM yyyy hh:mma", "dd MMM yyyy hh:mm a", "EEE, MMM dd, yyy", "MMM dd yyyy", "MMM dd, yyyy", "MMM dd'st', yyyy", "MMM dd'nd', yyyy", "MMM dd'rd', yyyy", "MMM dd'th', yyyy", "yyyy dd MMM", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd hh:mm:ss a", "yyyy-MM-dd hh:mma", "MMM dd, yyyy hh:mm a z", "MMM dd, yyyy HH:mm:ss Z",
For the Japanese locale:
"y年M月d日(EEE) H:mm:ss", "y年M月d日 H:mm:ss", "yyyy年MM月dd日(EEE)", "yyyy年MM月dd日"
If the search engine does not recognize the keyword, then the specified value (after ":") is treated as a text search.