Conversation
Introduces a new `get_api_key` function to simplify the retrieval of different API keys by name. This enhancement improves API key management and streamlines the configuration process by reducing redundant function definitions. Includes updates to documentation, exported functions, and import statements to support this feature.
Replaces empty configuration for `extra.suggests` and `pkg_ignore` with 'S7'. This ensures consistent handling of the additional package suggestion and ignore settings during development. No breaking changes.
…ct types Adds a robust set of validation functions for diverse object types, including R6 classes, Shiny applications, data frames, and API keys. The refactor introduces better error handling and extended documentation. Removes outdated checks and adopts a more modular structure for improved maintainability and usage. These enhancements aim to boost functionality and ensure accurate type validation in various contexts. No breaking changes.
There was a problem hiding this comment.
Hello @jimbrig, 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!
Summary of Changes
This pull request focuses on enhancing the input validation capabilities of the R package. It introduces a suite of new check functions, expanding the range of object types and properties that can be validated. The changes include adding checks for Shiny app components, R6 classes and objects, file paths, image files, and API keys. The pull request also updates existing check functions to return the original object invisibly if the check passes, and adds new helper functions and dependencies to support the new checks.
Highlights
- New Check Functions: The pull request introduces a variety of new check functions for validating different types of R objects, including Shiny app components (tags, tag lists, pages, HTML widgets), R6 classes and objects, expressions, loggers, and more.
- Enhanced File Validation: The pull request adds new check functions for validating file paths, including checks for specific file extensions and image files, enhancing the package's ability to validate file-based inputs.
- API Key Validation: The pull request includes new check functions for validating API keys, including OpenAI and Anthropic API keys, improving the package's ability to handle and validate API-related inputs.
- General Improvements to Check Functions: The pull request updates existing check functions to return the original object invisibly if the check passes, providing a more consistent and useful behavior for validation functions.
- Configuration and Dependencies: The pull request modifies the package's dependencies and configuration, including adding 'shiny' as an import, 'S7' as a suggested package, and updating the NAMESPACE file to export the new check functions.
Changelog
Click here to see the changelog
- DESCRIPTION
- Replaced
S7from Imports to Suggests. - Added
shinyto Imports. - Added
S7to Suggests.
- Replaced
- NAMESPACE
- Exported numerous new check functions, including those for Shiny components, R6 objects, file paths, and API keys.
- Exported
get_api_keyandcreate_data_checker. - Imported functions from
R6,S7,magick,shiny,tools, andutilsto support the new check functions.
- R/checks.R
- Introduced a comprehensive suite of new check functions for validating various R objects and properties.
- Added checks for Shiny app components, R6 classes and objects, file paths, image files, and API keys.
- Updated existing check functions to return the original object invisibly if the check passes.
- Added helper functions for checking inheritance and named arguments.
- R/config.R
- Added
get_api_keyfunction to retrieve API keys from the configuration file. - Documented the config functions.
- Added imports for
config,cli, andrlang.
- Added
- R/embed.R
- Imported
utils::tail.
- Imported
- R/gmaps.R
- Replaced hardcoded API key with
get_gmaps_api_key().
- Replaced hardcoded API key with
- dev/config_attachment.yaml
- Added
S7toextra.suggestsandpkg_ignore.
- Added
- man/checks.Rd
- Added documentation for all the new check functions.
- Added documentation for the return value of the check functions.
- man/config.Rd
- Added documentation for
get_api_key. - Documented the config functions.
- Added documentation for
Using Gemini Code Assist
The 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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist is currently in preview and 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 to provide feedback.
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.
A function's intent,
Checks ensure it's well-spent,
Validating all,
Before the fall,
A sturdy argument.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this comment.
Pull Request Overview
This PR adds new API key functions and updates the documentation and check functions to support additional API keys and validations. Key changes include:
- Addition of the get_api_key function and related documentation in R/config.R and man/config.Rd.
- Expansion of check functions in man/checks.Rd along with corresponding namespace and documentation updates.
- Minor updates in configuration files (dev/config_attachment.yaml and DESCRIPTION) and changes to Google Maps API key retrieval in R/gmaps.R.
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| man/config.Rd | Added new alias and documentation updates for API key functions. |
| man/checks.Rd | Added/updated numerous check_* aliases and functions. |
| dev/config_attachment.yaml | Modified dependency configuration values. |
| R/gmaps.R | Updated API key initialization to use get_gmaps_api_key(). |
| R/embed.R | Ensured use of utils::tail for clarity in capture_args(). |
| R/config.R | Introduced get_api_key function and extended documentation. |
| NAMESPACE | Exported new functions and added several import directives. |
| DESCRIPTION | Adjusted Imports/Suggests entries (swapping S7 with shiny). |
Comments suppressed due to low confidence (2)
R/config.R:461
- In the get_api_key function, the cli::cli_abort message references an undefined variable '{file}'. Consider passing the configuration file path as a parameter or removing that reference to avoid confusion.
get_api_key <- function(name, ...) {
DESCRIPTION:48
- Replacing 'S7' with 'shiny' in the Imports section may break functionality if S7 is used elsewhere. Please verify that the dependency change is intentional and that no functions require S7 at runtime.
shiny,
There was a problem hiding this comment.
Code Review
The pull request introduces a comprehensive set of check functions for various R objects, Shiny apps, databases, and API keys. The addition of these functions enhances the package's ability to validate data and configurations, contributing to more robust and reliable applications. The documentation is thorough and well-organized. However, there are a few areas where improvements can be made to enhance clarity and maintainability.
Summary of Findings
- Inconsistent return values: The check functions should consistently return the original object invisibly, rather than sometimes returning
NULL. This ensures that the functions can be used in a pipe-like fashion. - Missing documentation for arguments: Some functions lack documentation for their arguments, which can make it difficult for users to understand how to use them correctly. Ensure all arguments are properly documented.
- Duplicated code: There are instances of duplicated code, such as the API key checks, which could be refactored into a single, more generic function.
- Error message clarity: Some error messages could be more informative, providing specific guidance on how to resolve the issue.
Merge Readiness
The pull request is a valuable addition to the package, but there are several issues that should be addressed before merging. Specifically, the inconsistent return values, missing documentation, duplicated code, and error message clarity should be improved. Addressing these points will significantly enhance the quality and usability of the check functions. I am unable to directly approve this pull request, and recommend that others review and approve this code before merging. Due to the presence of medium and high severity issues, I recommend that this pull request not be merged until those are addressed.
Introduces a create_data_checker factory function to generate reusable validation functions for data frames or tibbles. This utility allows users to define required columns and column types for data structure validation.
Replaces `check_tibble` with `check_data_frame` to validate data structures more accurately. Adds a new function `xl_get_sheets` in the Excel module for improved sheet handling. This function includes file verification to ensure only supported Excel formats are processed.
No description provided.