From a0c4863becf9e7b35d850764196ccf30007dec41 Mon Sep 17 00:00:00 2001 From: "Daniel (dB.) Doubrovkine" Date: Sun, 12 Apr 2026 10:36:38 -0400 Subject: [PATCH 1/3] Add summary output to find command Previously, `fui find` produced no output when all imports were in use, leaving users wondering if the command ran at all. Now prints: - "Found N unused header(s)." when unused headers are found - "No unused imports found." when everything is in use Fixes #38. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- CHANGELOG.md | 1 + bin/fui | 4 +++- spec/fui/fui_spec.rb | 9 +++++---- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b44839f..e841c1d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ * [#45](https://github.com/dblock/fui/pull/45): Migrated from Travis CI to GitHub Actions with danger-pr-comment workflow - [@dblock](https://github.com/dblock). * [#37](https://github.com/dblock/fui/issues/37): Fixed `ArgumentError: invalid byte sequence in UTF-8` when processing files with non-UTF-8 encoding - [@dblock](https://github.com/dblock). * [#42](https://github.com/dblock/fui/issues/42): Fixed `NameError: undefined local variable or method 'project_path'` in verbose mode - [@dblock](https://github.com/dblock). +* [#38](https://github.com/dblock/fui/issues/38): Added summary output to `find` command: prints `Found N unused header(s).` or `No unused imports found.` - [@dblock](https://github.com/dblock). * Your contribution here. ### 0.5.0 (2018/12/19) diff --git a/bin/fui b/bin/fui index ef72752..d621db5 100755 --- a/bin/fui +++ b/bin/fui @@ -37,7 +37,9 @@ command :find do |c| puts relative_path end end - exit_now! nil, $fui.unused_references.count + count = $fui.unused_references.count + puts count > 0 ? "Found #{count} unused header(s)." : 'No unused imports found.' + exit_now! nil, count end end diff --git a/spec/fui/fui_spec.rb b/spec/fui/fui_spec.rb index c0b932b..b3af3c4 100644 --- a/spec/fui/fui_spec.rb +++ b/spec/fui/fui_spec.rb @@ -15,11 +15,11 @@ describe '#find' do it 'is the default action' do files = `"#{@binary}" --path "#{@fixtures}"` - expect(files.split("\n")).to eq ['unused_class.h'] + expect(files.split("\n")).to eq ['unused_class.h', 'Found 1 unused header(s).'] end it 'finds all unreferences headers' do files = `"#{@binary}" --path "#{@fixtures}" find` - expect(files.split("\n")).to eq ['unused_class.h'] + expect(files.split("\n")).to eq ['unused_class.h', 'Found 1 unused header(s).'] end it 'defaults to the current directory' do files = `"#{@binary}"` @@ -27,14 +27,15 @@ end it 'defaults to the current directory and returns unreferenced headers relative to it' do files = `cd #{@fixtures} ; "#{@binary}"` - expect(files.split("\n")).to eq ['unused_class.h'] + expect(files.split("\n")).to eq ['unused_class.h', 'Found 1 unused header(s).'] end it 'returns a non-zero error code when files are found' do `cd #{@fixtures} ; "#{@binary}"` expect($CHILD_STATUS.exitstatus).to eq 1 end it 'returns a zero error code when no files are found' do - _files = `cd #{File.expand_path(File.join(__FILE__, '../../../bin/'))} ; "#{@binary}"` + files = `cd #{File.expand_path(File.join(__FILE__, '../../../bin/'))} ; "#{@binary}"` + expect(files.split("\n")).to eq ['No unused imports found.'] expect($CHILD_STATUS.exitstatus).to eq 0 end end From c1a519a48fb6435d7a16871b9bba6db476221e80 Mon Sep 17 00:00:00 2001 From: "Daniel (dB.) Doubrovkine" Date: Sun, 12 Apr 2026 10:38:54 -0400 Subject: [PATCH 2/3] Use proper pluralization in find summary output "Found 1 unused header." and "Found 2 unused headers." instead of "Found N unused header(s)." Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- bin/fui | 2 +- spec/fui/fui_spec.rb | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/bin/fui b/bin/fui index d621db5..24eee44 100755 --- a/bin/fui +++ b/bin/fui @@ -38,7 +38,7 @@ command :find do |c| end end count = $fui.unused_references.count - puts count > 0 ? "Found #{count} unused header(s)." : 'No unused imports found.' + puts count > 0 ? "Found #{count} unused #{count == 1 ? 'header' : 'headers'}." : 'No unused imports found.' exit_now! nil, count end end diff --git a/spec/fui/fui_spec.rb b/spec/fui/fui_spec.rb index b3af3c4..1b2af68 100644 --- a/spec/fui/fui_spec.rb +++ b/spec/fui/fui_spec.rb @@ -15,11 +15,11 @@ describe '#find' do it 'is the default action' do files = `"#{@binary}" --path "#{@fixtures}"` - expect(files.split("\n")).to eq ['unused_class.h', 'Found 1 unused header(s).'] + expect(files.split("\n")).to eq ['unused_class.h', 'Found 1 unused header.'] end it 'finds all unreferences headers' do files = `"#{@binary}" --path "#{@fixtures}" find` - expect(files.split("\n")).to eq ['unused_class.h', 'Found 1 unused header(s).'] + expect(files.split("\n")).to eq ['unused_class.h', 'Found 1 unused header.'] end it 'defaults to the current directory' do files = `"#{@binary}"` @@ -27,7 +27,7 @@ end it 'defaults to the current directory and returns unreferenced headers relative to it' do files = `cd #{@fixtures} ; "#{@binary}"` - expect(files.split("\n")).to eq ['unused_class.h', 'Found 1 unused header(s).'] + expect(files.split("\n")).to eq ['unused_class.h', 'Found 1 unused header.'] end it 'returns a non-zero error code when files are found' do `cd #{@fixtures} ; "#{@binary}"` @@ -38,6 +38,11 @@ expect(files.split("\n")).to eq ['No unused imports found.'] expect($CHILD_STATUS.exitstatus).to eq 0 end + it 'pluralizes the summary for multiple unused headers' do + h_fixtures = File.expand_path(File.join(__FILE__, '../../fixtures/h')) + files = `"#{@binary}" --path "#{h_fixtures}" find` + expect(files.split("\n").last).to eq 'Found 2 unused headers.' + end end describe '#verbose' do it 'displays verbose output' do From 77dde7539417ce841d8b4eb97af1970ccfa3bb60 Mon Sep 17 00:00:00 2001 From: "Daniel (dB.) Doubrovkine" Date: Sun, 12 Apr 2026 10:41:31 -0400 Subject: [PATCH 3/3] Update RuboCop to 1.86.1, run rubocop --auto-gen-config and rubocop -a Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .rubocop.yml | 2 +- .rubocop_todo.yml | 37 ++++++++++++++++++++++++++++++++++--- Gemfile | 2 +- bin/fui | 6 +++++- 4 files changed, 41 insertions(+), 6 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index ca5da2c..db5a444 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -11,7 +11,7 @@ Style/Documentation: Metrics: Enabled: false -Metrics/LineLength: +Layout/LineLength: Max: 256 inherit_from: .rubocop_todo.yml diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 89a2f8f..5e66510 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,24 +1,42 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2018-12-16 18:13:33 -0500 using RuboCop version 0.61.1. +# on 2026-04-12 14:40:37 UTC using RuboCop version 1.86.1. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. # Offense count: 1 -# Configuration parameters: Include. -# Include: **/*.gemspec Gemspec/RequiredRubyVersion: Exclude: - 'fui.gemspec' +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +Layout/SpaceAroundMethodCallOperator: + Exclude: + - 'spec/fui/finder_spec.rb' + +# Offense count: 1 +# This cop supports unsafe autocorrection (--autocorrect-all). +Style/GlobalStdStream: + Exclude: + - 'bin/fui' + # Offense count: 6 # Configuration parameters: AllowedVariables. Style/GlobalVars: Exclude: - 'bin/fui' +# Offense count: 2 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: AllowedReceivers. +# AllowedReceivers: Thread.current +Style/HashEachMethods: + Exclude: + - 'bin/fui' + # Offense count: 1 Style/MixinUsage: Exclude: @@ -28,3 +46,16 @@ Style/MixinUsage: Style/MultilineBlockChain: Exclude: - 'bin/fui' + +# Offense count: 2 +# This cop supports safe autocorrection (--autocorrect). +Style/RedundantRegexpEscape: + Exclude: + - 'lib/fui/project.rb' + +# Offense count: 1 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: Mode. +Style/StringConcatenation: + Exclude: + - 'lib/fui/finder.rb' diff --git a/Gemfile b/Gemfile index add6f9d..23f16df 100644 --- a/Gemfile +++ b/Gemfile @@ -8,4 +8,4 @@ gem 'danger-pr-comment', '0.1.0' gem 'danger-toc' gem 'rake' gem 'rspec', '~> 3.4.0' -gem 'rubocop', '0.61.1' +gem 'rubocop', '1.86.1' diff --git a/bin/fui b/bin/fui index 24eee44..69af1cf 100755 --- a/bin/fui +++ b/bin/fui @@ -38,7 +38,11 @@ command :find do |c| end end count = $fui.unused_references.count - puts count > 0 ? "Found #{count} unused #{count == 1 ? 'header' : 'headers'}." : 'No unused imports found.' + if count > 0 + puts "Found #{count} unused #{count == 1 ? 'header' : 'headers'}." + else + puts 'No unused imports found.' + end exit_now! nil, count end end