c3c icon indicating copy to clipboard operation
c3c copied to clipboard

add option to emit warnings for unused functions/macros/variables/types

Open Book-reader opened this issue 6 months ago • 4 comments

my current project has a lot of utility functions and macros that have since been phased out due to refactoring, but because I have taken multiple month long breaks from my project & all my old and new function declarations are mixed together it is difficult for me to easily tell what functions I am currently using and which ones I can remove. This is is absolutely my fault, but it would be nice to have a compiler flag that I could use to print all unused functions and macros

there is "warnings": ["no-unused"] in the default project.json and a corresponding PROJECT_VIEW_TYPE_WARNINGS_USED option, but that doesn't look like it's used anywhere

Book-reader avatar May 30 '25 10:05 Book-reader

Do we want this, or do we want to use the setting for different levels of checking? I was thinking that maybe it's better to have three levels of warnings instead of specific warnings like this.

lerno avatar Jun 06 '25 21:06 lerno

so something along the lines of --validation=lenient for no unused warnings, --validation=strict for unused warnings, and --validation=obnoxious for unused errors? or did you mean something like a --unused flag with for example none for no unused warnings, some for unused variables & functions, and all for all unused things, and then the --validation level could affect whether --unused emits warnings or errors?

I do agree though that there probably shouldn't be an option to individually turn specific unused warnings on or off.

Book-reader avatar Jun 07 '25 02:06 Book-reader

Something along those lines yes.

lerno avatar Jun 07 '25 12:06 lerno

sometimes the code is just copied from previous code with changed parameters, and it is easily forgot to use the newly variable to replace the old parameters in the copied code. Adding this warnings can be helpful to find these bugs.

xnhp0320 avatar Oct 05 '25 07:10 xnhp0320