From 02fa68e5bedb92757e60e2972be607358c569af5 Mon Sep 17 00:00:00 2001 From: Adam Garrett-Harris Date: Mon, 31 Oct 2022 15:16:18 -0600 Subject: [PATCH] Ignore lines with `ignore_unused` --- unused.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/unused.rb b/unused.rb index 579f2c2..2f0383e 100755 --- a/unused.rb +++ b/unused.rb @@ -175,6 +175,7 @@ def find_usages_in_files(files, xibs, items_in) def grab_items(file) lines = File.readlines(file).map {|line| line.gsub(/^\s*\/\/.*/, "") } + lines = lines.select { |line| Regexp.new(/ignore_unused/).match(line).nil? } items = lines.each_with_index.select { |line, i| line[/(func|let|var|class|enum|struct|protocol)\s+\w+/] }.map { |line, i| Item.new(file, line, i)} end @@ -213,4 +214,4 @@ def reverse_color; "\e[7m#{self}\e[27m" end end -Unused.new.find \ No newline at end of file +Unused.new.find