Skip to content
Closed
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# main [(unreleased)](https://github.com/whitesmith/rubycritic/compare/v4.9.2...main)

* [CHANGE] Bump aruba, byebug, cucumber, fakefs, rake, reek dependencies (by [@faisal][])
* [CHANGE] Update CI checkout action to v4 (by [@faisal][])

# v4.9.2 / 2025-04-08 [(commits)](https://github.com/whitesmith/rubycritic/compare/v4.9.1...v4.9.2)
Expand Down
12 changes: 6 additions & 6 deletions rubycritic.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -35,30 +35,30 @@ Gem::Specification.new do |spec|
spec.add_dependency 'launchy', '>= 2.5.2'
spec.add_dependency 'parser', '>= 3.3.0.5'
spec.add_dependency 'rainbow', '~> 3.1.1'
spec.add_dependency 'reek', '~> 6.4.0', '< 7.0'
spec.add_dependency 'reek', '~> 6.5.0', '< 7.0'
spec.add_dependency 'rexml'
spec.add_dependency 'ruby_parser', '~> 3.21'
spec.add_dependency 'simplecov', '>= 0.22.0'
spec.add_dependency 'tty-which', '~> 0.5.0'
spec.add_dependency 'virtus', '~> 2.0'

spec.add_development_dependency 'aruba', '~> 2.3.0'
spec.add_development_dependency 'aruba', '~> 2.3.1', '>= 2.3.1'
spec.add_development_dependency 'bundler', '>= 2.0.0'
if RUBY_PLATFORM == 'java'
spec.add_development_dependency 'pry-debugger-jruby'
else
spec.add_development_dependency 'byebug', '~> 11.0', '>= 10.0'
spec.add_development_dependency 'byebug', '~> 12.0', '>= 10.0'
end
spec.add_development_dependency 'cucumber', '~> 9.2.1', '!= 9.0.0'
spec.add_development_dependency 'cucumber', '~> 10.0.0', '!= 9.0.0'
spec.add_development_dependency 'diff-lcs', '~> 1.3'
spec.add_development_dependency 'fakefs', '~> 2.6.0'
spec.add_development_dependency 'fakefs', '~> 3.0.0'
spec.add_development_dependency 'irb'
spec.add_development_dependency 'mdl', '~> 0.13.0', '>= 0.12.0'
spec.add_development_dependency 'minitest', '~> 5.25.2', '>= 5.3.0'
spec.add_development_dependency 'minitest-around', '~> 0.5.0', '>= 0.4.0'
spec.add_development_dependency 'mocha', '~> 2.7.1'
spec.add_development_dependency 'ostruct'
spec.add_development_dependency 'rake', '~> 13.2.0', '>= 11.0.0'
spec.add_development_dependency 'rake', '~> 13.3.0', '>= 11.0.0'
spec.add_development_dependency 'rdoc'
spec.add_development_dependency 'rexml', '>= 3.2.0'
spec.add_development_dependency 'rubocop', '>= 1.72.0', '< 2.0'
Expand Down
3 changes: 3 additions & 0 deletions test/lib/rubycritic/analysers/helpers/methods_counter_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,23 @@
context 'when a file contains Ruby code' do
it 'calculates the number of methods' do
analysed_module = AnalysedModuleDouble.new(path: 'test/samples/methods_count.rb')

_(RubyCritic::MethodsCounter.new(analysed_module).count).must_equal 2
end
end

context 'when a file is empty' do
it 'returns 0 as the number of methods' do
analysed_module = AnalysedModuleDouble.new(path: 'test/samples/empty.rb')

_(RubyCritic::MethodsCounter.new(analysed_module).count).must_equal 0
end
end

context 'when a file has no method' do
it 'does not blow up and returns 0 as the number of methods' do
analysed_module = AnalysedModuleDouble.new(path: 'test/samples/no_methods.rb')

capture_output_streams do
_(RubyCritic::MethodsCounter.new(analysed_module).count).must_equal 0
end
Expand Down
3 changes: 3 additions & 0 deletions test/lib/rubycritic/analysers/helpers/modules_locator_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
pathname: Pathname.new('test/samples/module_names.rb'),
methods_count: 1
)

_(RubyCritic::ModulesLocator.new(analysed_module).names)
.must_equal ['Foo', 'Foo::Bar', 'Foo::Baz', 'Foo::Qux', 'Foo::Quux::Corge']
end
Expand All @@ -24,6 +25,7 @@
pathname: Pathname.new('test/samples/empty.rb'),
methods_count: 1
)

_(RubyCritic::ModulesLocator.new(analysed_module).names).must_equal ['Empty']
end
end
Expand All @@ -34,6 +36,7 @@
pathname: Pathname.new('test/samples/no_methods.rb'),
methods_count: 0
)

capture_output_streams do
_(RubyCritic::ModulesLocator.new(analysed_module).names).must_equal ['Foo::NoMethods']
end
Expand Down
3 changes: 3 additions & 0 deletions test/lib/rubycritic/analysers/smells/flay_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,19 @@

it 'creates smells with messages' do
smell = @analysed_modules.first.smells.first

_(smell.message).must_be_instance_of String
end

it 'creates smells with scores' do
smell = @analysed_modules.first.smells.first

_(smell.score).must_be_kind_of Numeric
end

it 'creates smells with more than one location' do
smell = @analysed_modules.first.smells.first

_(smell.multiple_locations?).must_equal true
end

Expand Down
2 changes: 2 additions & 0 deletions test/lib/rubycritic/analysers/smells/flog_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@

it 'creates smells with messages' do
smell = @analysed_module.smells.first

_(smell.message).must_be_instance_of String
end

it 'creates smells with scores' do
smell = @analysed_module.smells.first

_(smell.score).must_be :>, 0
end
end
Expand Down
3 changes: 3 additions & 0 deletions test/lib/rubycritic/analysers/smells/reek_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,17 @@

it 'respects the .reek file' do
messages = @analysed_module.smells.map(&:message)

_(messages).wont_include "has the parameter name 'a'"
end

it 'creates smells with messages' do
first_smell = @analysed_module.smells.first

_(first_smell.message).must_equal "has boolean parameter 'reek'"

last_smell = @analysed_module.smells.last

_(last_smell.message).must_equal 'has no descriptive comment'
end
end
Expand Down
1 change: 1 addition & 0 deletions test/lib/rubycritic/browser_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
describe '#open' do
it 'should be open report with launch browser' do
Launchy.stubs(:open).returns(true)

_(@browser.open).must_equal true
end
end
Expand Down
2 changes: 2 additions & 0 deletions test/lib/rubycritic/commands/compare_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ def abort(str); end
comparison.expects(:abort).once

status_reporter = comparison.execute

_(status_reporter.score).must_equal RubyCritic::Config.feature_branch_score
_(status_reporter.score).wont_equal RubyCritic::Config.base_branch_score
_(status_reporter.status_message).must_equal "Score: #{RubyCritic::Config.feature_branch_score}"
Expand All @@ -87,6 +88,7 @@ def abort(str); end
end
RubyCritic::SourceControlSystem::Git.stub(:switch_branch, copy_proc) do
status_reporter = RubyCritic::Command::Compare.new(options).execute

_(status_reporter.score).must_equal RubyCritic::Config.feature_branch_score
_(status_reporter.score).must_equal RubyCritic::Config.base_branch_score
_(status_reporter.status_message).must_equal "Score: #{RubyCritic::Config.feature_branch_score}"
Expand Down
6 changes: 6 additions & 0 deletions test/lib/rubycritic/commands/status_reporter_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,14 @@

it 'accept a score' do
@reporter.score = 50.0

_(@reporter.status).must_equal success_status
_(@reporter.status_message).must_equal 'Score: 50.0'
end

it 'should format the score' do
@reporter.score = 98.95258620689656

_(@reporter.status).must_equal success_status
_(@reporter.status_message).must_equal 'Score: 98.95'
end
Expand All @@ -49,12 +51,14 @@
let(:score) { 98.0 }
it 'should return the correct status' do
@reporter.score = score

_(@reporter.status).must_equal score_below_minimum
_(@reporter.status_message).must_equal 'Score (98.0) is below the minimum 99.0'
end

it 'should format the score' do
@reporter.score = 98.95258620689656

_(@reporter.status).must_equal score_below_minimum
_(@reporter.status_message).must_equal 'Score (98.95) is below the minimum 99.0'
end
Expand All @@ -64,6 +68,7 @@
let(:score) { 99.0 }
it 'should return the correct status' do
@reporter.score = score

_(@reporter.status).must_equal success_status
_(@reporter.status_message).must_equal 'Score: 99.0'
end
Expand All @@ -73,6 +78,7 @@
let(:score) { 100.0 }
it 'should return the correct status' do
@reporter.score = score

_(@reporter.status).must_equal success_status
_(@reporter.status_message).must_equal 'Score: 100.0'
end
Expand Down
2 changes: 2 additions & 0 deletions test/lib/rubycritic/configuration_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@

it 'can be set to a relative path' do
RubyCritic::Config.root = 'foo'

_(RubyCritic::Config.root).must_equal File.expand_path('foo')
end

it 'can be set to an absolute path' do
RubyCritic::Config.root = '/foo'

_(RubyCritic::Config.root).must_equal '/foo'
end

Expand Down
5 changes: 5 additions & 0 deletions test/lib/rubycritic/core/analysed_module_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
it 'returns the remediation cost of fixing the analysed_module' do
smells = [SmellDouble.new(cost: 1), SmellDouble.new(cost: 2)]
analysed_module = RubyCritic::AnalysedModule.new(smells: smells, complexity: 0)

_(analysed_module.cost).must_equal 3
end
end
Expand All @@ -58,13 +59,15 @@
context 'when the file has no methods' do
it 'returns a placeholder' do
analysed_module = RubyCritic::AnalysedModule.new(complexity: 0, methods_count: 0)

_(analysed_module.complexity_per_method).must_equal 'N/A'
end
end

context 'when the file has at least one method' do
it 'returns the average complexity per method' do
analysed_module = RubyCritic::AnalysedModule.new(complexity: 10, methods_count: 2)

_(analysed_module.complexity_per_method).must_equal 5
end
end
Expand All @@ -73,6 +76,7 @@
describe '#smells?' do
it 'returns true if the analysed_module has at least one smell' do
analysed_module = RubyCritic::AnalysedModule.new(smells: [SmellDouble.new])

_(analysed_module.smells?).must_equal true
end
end
Expand All @@ -82,6 +86,7 @@
location = RubyCritic::Location.new('./foo', '42')
smells = [RubyCritic::Smell.new(locations: [location])]
analysed_module = RubyCritic::AnalysedModule.new(smells: smells)

_(analysed_module.smells_at_location(location)).must_equal smells
end
end
Expand Down
2 changes: 2 additions & 0 deletions test/lib/rubycritic/core/analysed_modules_collection_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,10 @@

it 'registers one AnalysedModule element per existent file' do
analysed_modules_collection = RubyCritic::AnalysedModulesCollection.new(paths, analysed_modules)

_(analysed_modules_collection.count).must_equal 1
analysed_module = analysed_modules_collection.first

_(analysed_module.name).must_equal 'Name'
_(analysed_module.churn).must_equal 2
_(analysed_module.complexity).must_equal 2
Expand Down
2 changes: 2 additions & 0 deletions test/lib/rubycritic/core/location_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,15 @@
it 'is comparable' do
location1 = RubyCritic::Location.new('./foo', 42)
location2 = RubyCritic::Location.new('./foo', 42)

_(location1).must_equal location2
end

it 'is sortable' do
location1 = RubyCritic::Location.new('./foo', 42)
location2 = RubyCritic::Location.new('./bar', 23)
location3 = RubyCritic::Location.new('./bar', 16)

_([location1, location2, location3].sort).must_equal [location3, location2, location1]
end
end
5 changes: 5 additions & 0 deletions test/lib/rubycritic/core/smell_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
it 'returns true if the smell has a location that matches the location passed as argument' do
location = RubyCritic::Location.new('./foo', '42')
smell = RubyCritic::Smell.new(locations: [location])

_(smell.at_location?(location)).must_equal true
end
end
Expand All @@ -54,6 +55,7 @@
location1 = RubyCritic::Location.new('./foo', '42')
location2 = RubyCritic::Location.new('./foo', '23')
smell = RubyCritic::Smell.new(locations: [location1, location2])

_(smell.multiple_locations?).must_equal true
end
end
Expand All @@ -68,6 +70,7 @@
}
smell1 = RubyCritic::Smell.new(attributes)
smell2 = RubyCritic::Smell.new(attributes)

_(smell1).must_equal smell2
end
end
Expand Down Expand Up @@ -106,11 +109,13 @@
describe 'default attributes' do
it 'has :new for status' do
smell = RubyCritic::Smell.new

_(smell.status).must_equal(:new)
end

it 'is has an empty array for locations' do
smell = RubyCritic::Smell.new

_(smell.locations).must_equal([])
end
end
Expand Down
3 changes: 3 additions & 0 deletions test/lib/rubycritic/core/smells_array_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,23 @@
smell1 = RubyCritic::Smell.new(locations: [location1])
smell2 = RubyCritic::Smell.new(locations: [location2])
smell3 = RubyCritic::Smell.new(locations: [location3])

_([smell1, smell2, smell3].sort).must_equal [smell3, smell2, smell1]
end

it 'implements set intersection' do
smell1 = RubyCritic::Smell.new(context: '#bar')
smell2 = RubyCritic::Smell.new(context: '#bar')
smell3 = RubyCritic::Smell.new(context: '#foo')

_([smell1, smell3] & [smell2]).must_equal [smell1]
end

it 'implements set union' do
smell1 = RubyCritic::Smell.new(context: '#bar')
smell2 = RubyCritic::Smell.new(context: '#bar')
smell3 = RubyCritic::Smell.new(context: '#foo')

_([smell1, smell3] | [smell2]).must_equal [smell1, smell3]
end
end
1 change: 1 addition & 0 deletions test/lib/rubycritic/generators/turbulence_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
files = [AnalysedModuleDouble.new(name: 'Foo', churn: 1, complexity: 2)]
turbulence_data = RubyCritic::Turbulence.data(files)
instance_parsed_json = JSON.parse(turbulence_data).first

_(instance_parsed_json['name']).must_equal 'Foo'
_(instance_parsed_json['x']).must_equal 1
_(instance_parsed_json['y']).must_equal 2
Expand Down
2 changes: 2 additions & 0 deletions test/lib/rubycritic/smells_status_setter_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@

it 'marks old smells' do
RubyCritic::SmellsStatusSetter.set(@smells, @smells)

_(@smell.status).must_equal :old
end

it 'marks new smells' do
RubyCritic::SmellsStatusSetter.set([], @smells)

_(@smell.status).must_equal :new
end
end
Expand Down
2 changes: 2 additions & 0 deletions test/lib/rubycritic/source_control_systems/base_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
it 'creates an instance of that source control system' do
RubyCritic::SourceControlSystem::Git.stubs(:supported?).returns(true)
system = RubyCritic::SourceControlSystem::Base.create

_(system).must_be_instance_of RubyCritic::SourceControlSystem::Git
end
end
Expand All @@ -23,6 +24,7 @@
it 'creates a source control system double' do
capture_output_streams do
system = RubyCritic::SourceControlSystem::Base.create

_(system).must_be_instance_of RubyCritic::SourceControlSystem::Double
end
end
Expand Down
Loading
Loading