Skip to content
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

Make CI disallow leftover debugging code #511

Open
niklasmohrin opened this issue Oct 9, 2021 · 5 comments
Open

Make CI disallow leftover debugging code #511

niklasmohrin opened this issue Oct 9, 2021 · 5 comments
Labels
• misc Related to other topics (e.g. CI).

Comments

@niklasmohrin
Copy link

See #483 (comment)

A CI job could ensure that there are no dbg! (or pr_info!, etc.) calls left in pushed code would be a nice addition to the test suite. I have three high level ideas for how to accomplish this, but I haven't checked the applicability of any of them:

  1. Use rust-analyzer to find all references of the disallowed methods
  2. I believe there are certain clippy lints similar to what we want (disallowed-methods or so, relatively new) that could potentially be used
  3. Just grep over all of the Rust code / all *.rs files

While the last option is probably simplest, it may not be the cleanest. (note that these are just my first ideas, anyone implementing this can of course diverge from them :D ).

@bjorn3
Copy link
Member

bjorn3 commented Oct 9, 2021

What about adding an option that will be enabled on CI replacing the definitions of these macros with compile_error!("some error message")?

@niklasmohrin
Copy link
Author

What about adding an option that will be enabled on CI replacing the definitions of these macros with compile_error!("some error message")?

Good idea! It could be gated by a feature or env variable

@ojeda ojeda added prio: normal • misc Related to other topics (e.g. CI). labels Oct 18, 2021
@riking
Copy link

riking commented Nov 18, 2022

How about a checkpatch.pl rule?

@bjorn3
Copy link
Member

bjorn3 commented Nov 18, 2022

That would trigger on the pr_log! call in the dbg! definition too, right? Even if dbg! isn't called.

@nbdd0121
Copy link
Member

nbdd0121 commented Nov 18, 2022

We just need to add #[rustc_diagnostic_item = "dbg_macro"] to our dbg macro and then enable clippy's dbg_macro lint.

(Alternatively I can add a similar lint to klint)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
• misc Related to other topics (e.g. CI).
Development

No branches or pull requests

5 participants