From 393aec37e15526d2923b5a886f1a433c4f3b40c6 Mon Sep 17 00:00:00 2001 From: Matt Brown Date: Mon, 22 Apr 2024 17:13:25 -0400 Subject: [PATCH] Allow more unused methods to be covered by fixmes --- src/file_scanner_analyzer/unused_symbols.rs | 16 ++++++++-------- tests/unused/UnusedCode/coverByFixme/input.hack | 10 ++++++++++ 2 files changed, 18 insertions(+), 8 deletions(-) create mode 100644 tests/unused/UnusedCode/coverByFixme/input.hack diff --git a/src/file_scanner_analyzer/unused_symbols.rs b/src/file_scanner_analyzer/unused_symbols.rs index e4dac743..98e173eb 100644 --- a/src/file_scanner_analyzer/unused_symbols.rs +++ b/src/file_scanner_analyzer/unused_symbols.rs @@ -287,14 +287,6 @@ pub(crate) fn find_unused_definitions( let method_storage = functionlike_storage.method_info.as_ref().unwrap(); - if functionlike_storage - .suppressed_issues - .iter() - .any(|(i, _)| i == &IssueKind::UnusedPrivateMethod) - { - continue; - } - // allow one-liner private construct statements that prevent instantiation if *method_name_ptr == StrId::CONSTRUCT && matches!(method_storage.visibility, MemberVisibility::Private) @@ -358,6 +350,14 @@ pub(crate) fn find_unused_definitions( ) }; + if functionlike_storage + .suppressed_issues + .iter() + .any(|(i, _)| i == &issue.kind) + { + continue; + } + let file_path = interner.lookup(&pos.file_path.0); if !config.allow_issue_kind_in_file(&issue.kind, file_path) { diff --git a/tests/unused/UnusedCode/coverByFixme/input.hack b/tests/unused/UnusedCode/coverByFixme/input.hack new file mode 100644 index 00000000..4378af63 --- /dev/null +++ b/tests/unused/UnusedCode/coverByFixme/input.hack @@ -0,0 +1,10 @@ +class A { + /* HAKANA_FIXME[UnusedPublicOrProtectedMethod] */ + public function foo(): void { + } +} + +<<__EntryPoint>> +function main(): void { + new A(); +} \ No newline at end of file