Conversation
Adds Java sample for filter views. Based on the `sheets_filter_views` sample from Python.
Summary of ChangesHello @kencenerelli, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces a new Java sample for the Google Sheets API, focusing on the management of filter views. The sample provides practical examples for developers to understand and implement the creation, duplication, and modification of filter views within their applications, mirroring existing Python samples to ensure feature parity across client libraries. Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request adds a new Java sample for Sheets Filter Views. However, the new file contains critical syntax errors as it appears to be a direct translation from a Python sample, using Python-style comments and docstrings in a Java file. This will prevent the code from compiling. Additionally, there are some redundant code region tags and a lack of robust error handling for API responses, which could lead to runtime exceptions. My review includes suggestions to correct these issues to make the sample valid and robust.
| """ | ||
| Copyright 2022 Google LLC | ||
|
|
||
| Licensed under the Apache License, Version 2.0 (the "License"); | ||
| you may not use this file except in compliance with the License. | ||
| You may obtain a copy of the License at | ||
|
|
||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, software | ||
| distributed under the License is distributed on an "AS IS" BASIS, | ||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| See the License for the specific language governing permissions and | ||
| limitations under the License. | ||
| """ | ||
|
|
||
| # [START sheets_filter_views] |
There was a problem hiding this comment.
This file contains Python-style syntax that will cause compilation errors in Java. The file header (lines 1-15) uses a Python docstring ("""...""") instead of a Java block comment (/* ... */), and the region tag on line 17 uses a Python comment character (#) instead of //.
/*
Copyright 2022 Google LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// [START sheets_filter_views]| } | ||
| } | ||
|
|
||
| # [END sheets_filter_views] |
| // [START sheets_filter_views] | ||
| filterViews("1CM29gwKIzeXsAppeNwrc8lbYaVMmUclprLuLYuHog4k"); | ||
| // [END sheets_filter_views] |
There was a problem hiding this comment.
These [START ...] and [END ...] region tags appear to be redundant. The entire file content relevant to the sample is already wrapped in sheets_filter_views region tags (on lines 17 and 152, though they currently have incorrect syntax). Having nested tags for the same region can cause issues with sample processing tools. Please remove these inner tags.
filterViews("1CM29gwKIzeXsAppeNwrc8lbYaVMmUclprLuLYuHog4k");| int filterId = response1.getReplies().get(0) | ||
| .getAddFilterView().getFilter().getFilterViewId(); |
There was a problem hiding this comment.
The code directly accesses nested properties of the API responses (response1 on this line, and response2 on line 115) without any validation. If an API call doesn't return the expected structure (e.g., due to an error or an empty list of replies), this will cause a NullPointerException or IndexOutOfBoundsException at runtime. You should add checks to ensure the response objects and lists are not null or empty before accessing them.
kencenerelli
left a comment
There was a problem hiding this comment.
Fixed malformed commenting.
Adds Java sample for filter views. Based on the
sheets_filter_viewssample from Python.Description
This sample demonstrates how to:
AddFilterViewRequest.DuplicateFilterViewRequest.UpdateFilterViewRequest.Fixes # (issue)
Is it been tested?
Checklist