Skip to content

feat: update incomplete-signature-doc to also error on non-global functions#975

Open
dquixote-jr wants to merge 3 commits intoEmmyLuaLs:mainfrom
dquixote-jr:dqjr/incomplete-sig-doc
Open

feat: update incomplete-signature-doc to also error on non-global functions#975
dquixote-jr wants to merge 3 commits intoEmmyLuaLs:mainfrom
dquixote-jr:dqjr/incomplete-sig-doc

Conversation

@dquixote-jr
Copy link

@dquixote-jr dquixote-jr commented Mar 4, 2026

relates - #964

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, 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 enhances the code analysis capabilities by extending the incomplete-signature-doc diagnostic to cover all functions, not just global ones. This change aims to improve code quality and maintainability by ensuring that all functions have appropriate documentation, providing more precise feedback to developers.

Highlights

  • Extended Diagnostic Scope: The incomplete-signature-doc diagnostic now applies to both global and non-global functions, ensuring broader documentation coverage.
  • Differentiated Diagnostic Codes: Introduced DiagnosticCode::IncompleteSignatureDoc for non-global functions missing documentation, while DiagnosticCode::MissingGlobalDoc is retained for global functions.
  • Contextual Error Messages: Error messages for missing function documentation are now tailored to specify whether the function is global or non-global.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • crates/emmylua_code_analysis/src/diagnostic/checker/incomplete_signature_doc.rs
    • Modified the check_doc function to apply the missing documentation check to non-global functions.
    • Introduced a conditional DiagnosticCode assignment based on whether the function is global or not.
    • Adjusted the diagnostic message to be specific to global or non-global functions.
  • crates/emmylua_code_analysis/src/diagnostic/test/incomplete_signature_doc_test.rs
    • Updated existing test cases to reflect the new diagnostic behavior for non-global functions.
    • Added new test cases to specifically verify the IncompleteSignatureDoc diagnostic for non-global functions.
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 by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

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 pull request 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 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

  1. 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.

@dquixote-jr dquixote-jr changed the title feat: update incomplete-signature-doc to also error on non-global fun… feat: update incomplete-signature-doc to also error on non-global functions Mar 4, 2026
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a 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 extends the incomplete-signature-doc check to also report missing documentation for non-global functions. The implementation in incomplete_signature_doc.rs appears correct, and the refactoring to move the code variable definition is a good improvement. However, I've found a couple of issues in the accompanying tests. Some test cases seem to have inverted assertions, incorrectly asserting that a diagnostic is not found when it should be. Please see my detailed comments on the test file.

@CppCXY
Copy link
Member

CppCXY commented Mar 4, 2026

Please fix the check

@dquixote-jr
Copy link
Author

done

@xuhuanzy
Copy link
Member

xuhuanzy commented Mar 4, 2026

@CppCXY 需要考虑对闭包跟一些简单函数的影响,先别合

@xuhuanzy
Copy link
Member

xuhuanzy commented Mar 4, 2026

If we want to extend the diagnosis to be effective for non-global variables, then we need to handle some simple cases.

local function a() -- No function parameters should trigger a warning.

end

function b(a) -- issue warning

end

local c = function(a) -- A warning should be issued.

end

@dquixote-jr
Copy link
Author

dquixote-jr commented Mar 4, 2026

Added tests for the first 2, part 3 is broken right now as well, it doesn't work for global functions either, e.g. for the following:

c = function(a) -- A warning should be issued.
end

Type checker does not issue any warnings. So I'm not sure if fixing that is supposed to be part of this change. Should be a different PR.

ws.enable_full_diagnostic();

// TODO: closures are not detected as functions in the semantic model
// assert!(!ws.check_code_for(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you don't know how to handle it, you can ask AI for help.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it have to be this PR?
Closures are not detected for global functions either. So I'm not sure if fixing that needs to be done right now.
The functionality that I am adding is unrelated to fixing the function detection.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants