Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Style/Documentation:
Metrics:
Enabled: false

Metrics/LineLength:
Layout/LineLength:
Max: 256

inherit_from: .rubocop_todo.yml
37 changes: 34 additions & 3 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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'
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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'
8 changes: 7 additions & 1 deletion bin/fui
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,13 @@ command :find do |c|
puts relative_path
end
end
exit_now! nil, $fui.unused_references.count
count = $fui.unused_references.count
if count > 0
puts "Found #{count} unused #{count == 1 ? 'header' : 'headers'}."
else
puts 'No unused imports found.'
end
exit_now! nil, count
end
end

Expand Down
14 changes: 10 additions & 4 deletions spec/fui/fui_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,34 @@
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.']
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.']
end
it 'defaults to the current directory' do
files = `"#{@binary}"`
expect(files.split("\n")).to include 'spec/fixtures/h/header.h'
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.']
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
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
Expand Down
Loading