GDScript: Ignore unused arguments/local vars that start with _
Makes it simple to ignore particular arguments without adding special comments, especially in engine-defined functions.
This commit is contained in:
parent
4d2b9a4b35
commit
94d662ad55
1 changed files with 7 additions and 5 deletions
|
@ -7397,7 +7397,7 @@ void GDScriptParser::_check_function_types(FunctionNode *p_function) {
|
|||
}
|
||||
}
|
||||
#ifdef DEBUG_ENABLED
|
||||
if (p_function->arguments_usage[i] == 0) {
|
||||
if (p_function->arguments_usage[i] == 0 && !p_function->arguments[i].operator String().begins_with("_")) {
|
||||
_add_warning(GDScriptWarning::UNUSED_ARGUMENT, p_function->line, p_function->name, p_function->arguments[i].operator String());
|
||||
}
|
||||
#endif // DEBUG_ENABLED
|
||||
|
@ -7855,10 +7855,12 @@ void GDScriptParser::_check_block_types(BlockNode *p_block) {
|
|||
// Warnings check
|
||||
for (Map<StringName, LocalVarNode *>::Element *E = p_block->variables.front(); E; E = E->next()) {
|
||||
LocalVarNode *lv = E->get();
|
||||
if (lv->usages == 0) {
|
||||
_add_warning(GDScriptWarning::UNUSED_VARIABLE, lv->line, lv->name);
|
||||
} else if (lv->assignments == 0) {
|
||||
_add_warning(GDScriptWarning::UNASSIGNED_VARIABLE, lv->line, lv->name);
|
||||
if (!lv->name.operator String().begins_with("_")) {
|
||||
if (lv->usages == 0) {
|
||||
_add_warning(GDScriptWarning::UNUSED_VARIABLE, lv->line, lv->name);
|
||||
} else if (lv->assignments == 0) {
|
||||
_add_warning(GDScriptWarning::UNASSIGNED_VARIABLE, lv->line, lv->name);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // DEBUG_ENABLED
|
||||
|
|
Loading…
Reference in a new issue