-
-
Notifications
You must be signed in to change notification settings - Fork 6
Fix global vars in lua scripts #114
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?
Conversation
Deploying ftextra with
|
Latest commit: |
0f0b54f
|
Status: | ✅ Deploy successful! |
Preview URL: | https://d7d75a3a.ftextra.pages.dev |
Branch Preview URL: | https://fix-global-vars.ftextra.pages.dev |
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.
Hello @atusy, 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
Hello! Gemini here, providing a summary of this pull request titled "Fix global vars in lua scripts" by @atusy.
This pull request primarily focuses on improving the code quality and preventing potential issues by converting global variables used within several Lua scripts into local variables. This practice helps avoid polluting the global namespace and reduces the risk of unintended side effects or conflicts when these scripts are used in larger contexts or alongside other code.
The changes involve modifying the variable declarations in three different Lua files (blocks-to-inlines.lua
, cite.lua
, and math.lua
) to use the local
keyword. Additionally, the math.lua
script groups several related variables and functions within a local table for better organization and scoping. The inline-code.lua
file also received some minor formatting adjustments.
Highlights
- Variable Scoping: Converted global variables to local variables in
blocks-to-inlines.lua
andcite.lua
to prevent global namespace pollution. - Code Organization: In
math.lua
, several variables and helper functions were grouped within a local tableL
to improve scoping and organization. - Formatting: Minor formatting adjustments (like indentation and spacing) were applied across the changed Lua files, including
inline-code.lua
.
Changelog
- inst/lua/blocks-to-inlines.lua
- Made the
sep
variable local.
- Made the
- inst/lua/cite.lua
- Made the
cite
variable local.
- Made the
- inst/lua/inline-code.lua
- Applied formatting changes (indentation and spacing).
- inst/lua/math.lua
- Made the
is_pandoc_2_10
variable local. - Grouped several variables (
cmd
,temporary_directory
) and helper functions (math2html
,with_temporary_directory
) into a local tableL
.
- Made the
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.
Global scope is wide,
Local keeps things safe inside,
Clean code, no surprise.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request effectively addresses the issue of global variables in the Lua scripts by introducing local
declarations and encapsulating related functions and variables within local tables where appropriate. This is a significant improvement for code maintainability and prevents potential namespace conflicts. The changes are well-implemented and consistent across the modified files.
Summary of Findings
- Reduction of Global State: The primary and most valuable change is the conversion of implicitly global variables (
sep
,cite
,is_pandoc_2_10
,cmd
,temporary_directory
) and functions (math2html
,with_temporary_directory
) to local scope using thelocal
keyword or by placing them within a local table (L
inmath.lua
). This is a best practice in Lua programming to avoid polluting the global environment and improve modularity. - Stylistic Changes (Not Commented): The pull request also includes consistent stylistic changes across the Lua files, such as changing indentation from 2 spaces to tabs and reformatting table literals. These are considered
low
severity issues and were not commented on directly as per the review settings.
Merge Readiness
The changes in this pull request improve the code quality by reducing reliance on global state. No medium
, high
, or critical
severity issues were found during the review. The code appears correct and well-formatted according to the changes made. Based on this review, the pull request seems ready to be merged. Please note that I am unable to directly approve the pull request; other reviewers should provide the final approval.
No description provided.