-
Notifications
You must be signed in to change notification settings - Fork 456
Addition of Saving and Loading of Filter Presets #4755
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
95740d0
8ca0a56
d304eca
251a336
424d306
92c6635
5a3a5ca
3ef93d6
afc62e0
5f2e79e
e2f8db5
0132c0c
1400422
003fad6
462d44e
53cd471
cbf1265
2f98c8d
cda9d3e
799513f
bc6698d
3149eda
a530f6f
bf8606b
0d4f536
1b36295
dda5933
c79e691
08900d2
27291c9
288e2e7
6ff79f7
e29092d
74e81fe
009748f
0edf927
c3e5fb9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -406,6 +406,12 @@ struct ReportFilter { | |
| 24: optional bool fullReportPathInComponent, | ||
| } | ||
|
|
||
| struct FilterPreset { | ||
| 1: i64 id, // Unique ID of "FilterPreset". | ||
| 2: string name, // Human readable name of preset. | ||
| 3: ReportFilter reportFilter // Uniquely configured ReportFilter. | ||
| } | ||
|
|
||
| struct RunReportCount { | ||
| 1: i64 runId, // Unique ID of the run. | ||
| 2: string name, // Human readable name of the run. | ||
|
|
@@ -583,6 +589,40 @@ service codeCheckerDBAccess { | |
| 4: optional RunSortMode sortMode) | ||
| throws (1: codechecker_api_shared.RequestFailed requestError), | ||
|
|
||
| //============================================ | ||
| // Filter grouping api calls. | ||
| //============================================ | ||
|
|
||
| // Stores the given FilterPreset with the given id | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I got a few questions / remarks regarding this part:
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed. |
||
| // If the preset exists with the given id, it overwrites the name, and all preset values | ||
| // If the preset does not exist yet, throws and error | ||
| // If the id is -1 a new preset filter is created and the id of the new preset is returned. | ||
| // If a preset with that name already existed, it throws an error. Thus the "FilterPreset" name must be unique. | ||
| // The encoding of the name must be unicode. (whitespaces allowed) | ||
| // Maximum "FilterPreset" name 50 | ||
| // Returns: the id of the modified or created preset | ||
| // PERMISSION: PRODUCT_ADMIN | ||
| i64 storeFilterPreset(1: FilterPreset preset) | ||
| throws (1: codechecker_api_shared.RequestFailed requestError); | ||
|
|
||
| // Returns the "FilterPreset" identified by id | ||
| // Throws and error in case there is no preset with the given id | ||
| // PERMISSION: PRODUCT_VIEW | ||
| FilterPreset getFilterPreset(1: i64 id) | ||
| throws (1: codechecker_api_shared.RequestFailed requestError); | ||
|
|
||
| // Removes the FilterPreset with the given id | ||
| // Returns the id of the "FilterPreset" removed | ||
| // Throws an error if the preset with the given id does not exist. | ||
| // PERMISSION: PRODUCT_ADMIN | ||
| i64 deleteFilterPreset(1: i64 id) | ||
| throws (1: codechecker_api_shared.RequestFailed requestError); | ||
|
|
||
| // Returns all "FilterPreset"s stored for the product repository | ||
| // PERMISSION: PRODUCT_VIEW | ||
| list <FilterPreset> listFilterPreset() | ||
| throws (1: codechecker_api_shared.RequestFailed requestError); | ||
|
|
||
| // Returns the number of available runs based on the run filter parameter. | ||
| // PERMISSION: PRODUCT_VIEW | ||
| i64 getRunCount(1: RunFilter runFilter) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,18 +25,13 @@ | |
| product_client, \ | ||
| source_component_client, \ | ||
| task_client, \ | ||
| token_client | ||
| token_client, \ | ||
| filter_preset_client | ||
| from codechecker_client.filter_defaults import DEFAULT_FILTER_VALUES | ||
|
|
||
| from codechecker_common import arg, logger, util | ||
| from codechecker_common.output import USER_FORMATS | ||
|
|
||
| DEFAULT_FILTER_VALUES = { | ||
| 'review_status': ['unreviewed', 'confirmed'], | ||
| 'detection_status': ['new', 'reopened', 'unresolved'], | ||
| 'uniqueing': 'off', | ||
| 'anywhere_on_report_path': False, | ||
| 'single_origin_report': False | ||
| } | ||
|
|
||
| DEFAULT_OUTPUT_FORMATS = ["plaintext"] + USER_FORMATS | ||
|
|
||
|
|
@@ -448,6 +443,32 @@ def init_default(dest): | |
| "entirely in the files specified by the " | ||
| "given --component.") | ||
|
|
||
| f_group.add_argument('--report-status', | ||
| nargs='*', | ||
| dest="report_status", | ||
| metavar='REPORT_STATUS', | ||
| default=init_default('report_status'), | ||
| help="R|Filter results by report statuses.\n" | ||
| "Reports can be assigned a report status of the " | ||
| "following values:\n" | ||
| "- Outstanding: Currently detected and still unresolved reports.\n" | ||
| "- Closed: Reports marked as fixed, false positive, or otherwise resolved.\n" + | ||
| warn_diff_mode) | ||
|
|
||
|
|
||
| def __add_filter_preset_argument(parser): | ||
| """Add the --filter-preset argument to the given parser.""" | ||
| parser.add_argument('--filter-preset', | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This option shouldn't be available for
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed, now this option only appears for |
||
| type=str, | ||
| dest='filter_preset_name', | ||
| metavar='PRESET_NAME', | ||
| required=False, | ||
| default=argparse.SUPPRESS, | ||
| help="Use a pre-configured filter preset. The preset " | ||
| "is loaded from the server and applied to the " | ||
| "results. Use 'CodeChecker cmd filter-preset " | ||
| "list' to see available presets.") | ||
|
|
||
|
|
||
| def __register_results(parser): | ||
| """ | ||
|
|
@@ -478,6 +499,7 @@ def __register_results(parser): | |
| "events, bug report points etc.") | ||
|
|
||
| __add_filtering_arguments(parser, DEFAULT_FILTER_VALUES) | ||
| __add_filter_preset_argument(parser) | ||
|
|
||
|
|
||
| def __register_diff(parser): | ||
|
|
@@ -543,6 +565,7 @@ def __register_diff(parser): | |
| "the reported defect.") | ||
|
|
||
| __add_filtering_arguments(parser, DEFAULT_FILTER_VALUES, True) | ||
| __add_filter_preset_argument(parser) | ||
|
|
||
| group = parser.add_argument_group( | ||
| "comparison modes", | ||
|
|
@@ -623,6 +646,7 @@ def __register_sum(parser): | |
| default_filter_values = DEFAULT_FILTER_VALUES | ||
| default_filter_values['uniqueing'] = 'on' | ||
| __add_filtering_arguments(parser, default_filter_values) | ||
| __add_filter_preset_argument(parser) | ||
|
|
||
|
|
||
| def __register_delete(parser): | ||
|
|
@@ -1530,6 +1554,62 @@ def __register_del(parser): | |
| __add_common_arguments(del_t, needs_product_url=False) | ||
|
|
||
|
|
||
| def __register_filter_presets(parser): | ||
| """ | ||
| Add argparse subcommand parser for the "filter preset management" action. | ||
| """ | ||
|
|
||
| def __register_new(parser): | ||
| parser.add_argument('--name', | ||
| type=str, | ||
| dest='preset_name', | ||
| required=True, | ||
| metavar='PRESET_NAME', | ||
| help="Name of the filter preset to create.") | ||
| __add_filtering_arguments(parser) | ||
|
|
||
| def __register_delete(parser): | ||
| """ | ||
| Add argparse subcommand parser for the "delete preset" action. | ||
| """ | ||
| parser.add_argument('--id', | ||
| type=int, | ||
| dest='preset_id', | ||
| required=True, | ||
| metavar='PRESET_ID', | ||
| help="ID of the filter preset to delete.") | ||
|
|
||
| subcommands = parser.add_subparsers(title='available actions') | ||
|
|
||
| # Create handlers for individual subcommands. | ||
| list_presets = subcommands.add_parser( | ||
| 'list', | ||
| formatter_class=argparse.ArgumentDefaultsHelpFormatter, | ||
| description="List all filter presets available on the server.", | ||
| help="List all filter presets.") | ||
| list_presets.set_defaults(func=filter_preset_client.handle_list_presets) | ||
| __add_common_arguments(list_presets, | ||
| output_formats=DEFAULT_OUTPUT_FORMATS) | ||
|
|
||
| new_preset = subcommands.add_parser( | ||
| 'new', | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe this should be
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed, now only creates new. |
||
| formatter_class=arg.RawDescriptionDefaultHelpFormatter, | ||
| description="Create a new filter preset.", | ||
| help="Create a new filter preset.") | ||
| __register_new(new_preset) | ||
| new_preset.set_defaults(func=filter_preset_client.handle_new_preset) | ||
| __add_common_arguments(new_preset) | ||
|
|
||
| delete_preset = subcommands.add_parser( | ||
| 'delete', | ||
| formatter_class=argparse.ArgumentDefaultsHelpFormatter, | ||
| description="Delete a filter preset from the server.", | ||
| help="Delete a filter preset.") | ||
| __register_delete(delete_preset) | ||
| delete_preset.set_defaults(func=filter_preset_client.handle_delete_preset) | ||
| __add_common_arguments(delete_preset) | ||
|
|
||
|
|
||
| def add_arguments_to_parser(parser): | ||
| """ | ||
| Add the subcommand's arguments to the given argparse.ArgumentParser. | ||
|
|
@@ -1820,5 +1900,18 @@ def add_arguments_to_parser(parser): | |
| tasks.set_defaults(func=task_client.handle_tasks) | ||
| __add_common_arguments(tasks, needs_product_url=False) | ||
|
|
||
| filter_preset = subcommands.add_parser( | ||
| 'filter-preset', | ||
| formatter_class=argparse.ArgumentDefaultsHelpFormatter, | ||
| description="Manage filter presets of a CodeChecker server. " | ||
| "Filter presets are named collections of filter " | ||
| "configurations that can be applied to the analysis " | ||
| "results of a run. Please see the individual " | ||
| "subcommands for details.", | ||
| help="Access subcommands related to configuring filter presets of a " | ||
| "CodeChecker server.") | ||
| __register_filter_presets(filter_preset) | ||
| __add_common_arguments(filter_preset) | ||
|
|
||
| # 'cmd' does not have a main() method in itself, as individual subcommands are | ||
| # handled later on separately. | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a sentence about how to get an ID, for example with a link to the previous section.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.