reek-3.8.2/0000755000175000017500000000000012646022100011041 5ustar aleealeereek-3.8.2/features/0000755000175000017500000000000012646022100012657 5ustar aleealeereek-3.8.2/features/step_definitions/0000755000175000017500000000000012646022100016225 5ustar aleealeereek-3.8.2/features/step_definitions/sample_file_steps.rb0000644000175000017500000001072212646022100022252 0ustar aleealeeGiven(/^the smelly file 'smelly.rb'$/) do contents = <<-EOS.strip_heredoc class Smelly def x; end end EOS write_file('smelly.rb', contents) end Given(/^the clean file 'clean.rb'$/) do contents = <<-EOS.strip_heredoc # Explanatory comment class Clean def foo; end end EOS write_file('clean.rb', contents) end Given(/^the smelly file 'demo.rb' from the example in the README$/) do contents = <<-EOS.strip_heredoc class Dirty # This method smells of :reek:NestedIterators but ignores them def awful(x, y, offset = 0, log = false) puts @screen.title @screen = widgets.map {|w| w.each {|key| key += 3 * x}} puts @screen.contents end end EOS write_file('demo.rb', contents) end Given(/^a smelly file with inline masking called 'inline.rb'$/) do write_file 'inline.rb', <<-EOS.strip_heredoc # smells of :reek:NestedIterators but ignores them class Dirty def a puts @s.title @s = foo.map {|x| x.each {|key| key += 3}} puts @s.title end end EOS end Given(/^the "(.*?)" sample file exists$/) do |file_name| full_path = Pathname.new("#{__dir__}/../../spec/samples/#{file_name}") cd('.') { FileUtils.cp full_path, file_name } end Given(/^a directory called 'clean_files' containing some clean files$/) do contents = <<-EOS.strip_heredoc # clean class for testing purposes class Clean def assign puts @sub.title @sub.map {|para| para.name } end end EOS write_file 'clean_files/clean_one.rb', contents write_file 'clean_files/clean_two.rb', contents write_file 'clean_files/clean_three.rb', contents end Given(/^a directory called 'smelly' containing two smelly files$/) do write_file('smelly/dirty_one.rb', <<-EOS.strip_heredoc) class Dirty def a; end end EOS write_file('smelly/dirty_two.rb', <<-EOS.strip_heredoc) class Dirty def a; end def b; end end EOS end Given(/^a smelly file called 'smelly.rb'( in a subdirectory)?$/) do |in_subdir| file_name = in_subdir ? 'subdir/smelly.rb' : 'smelly.rb' write_file file_name, <<-EOS.strip_heredoc # smelly class for testing purposes class Smelly def m puts @foo.bar puts @foo.bar end end EOS end Given(/^an empty configuration file called 'empty.reek'$/) do write_file('empty.reek', '') end Given(/^a corrupt configuration file called 'corrupt.reek'$/) do write_file('corrupt.reek', 'This is not a configuration file') end Given(/^a masking configuration file called 'config.reek'$/) do write_file('config.reek', <<-EOS.strip_heredoc) --- DuplicateMethodCall: enabled: false UncommunicativeMethodName: enabled: false EOS end Given(/^a configuration file masking some duplication smells called 'config.reek'$/) do write_file('config.reek', <<-EOS.strip_heredoc) --- DuplicateMethodCall: allow_calls: - puts\\(@foo.bar\\) EOS end When(/^I run "reek (.*?)" in the subdirectory$/) do |args| cd 'subdir' reek(args) end Given(/^a masking configuration file in the HOME directory$/) do set_environment_variable 'HOME', Pathname.new("#{expand_path('.')}/home") write_file('home/config.reek', <<-EOS.strip_heredoc) --- DuplicateMethodCall: enabled: false UncommunicativeMethodName: enabled: false EOS end Given(/^an enabling configuration file in the subdirectory$/) do write_file('subdir/config.reek', <<-EOS.strip_heredoc) --- IrresponsibleModule: enabled: true UncommunicativeModuleName: enabled: true UncommunicativeMethodName: enabled: true EOS end Given(/^a smelly file called 'smelly.rb' with private, protected and public UtilityFunction methods$/) do write_file 'smelly.rb', <<-EOS.strip_heredoc # smelly class for testing purposes class Klass def public_method(arg) arg.to_s; end protected def protected_method(arg) arg.to_s; end private def private_method(arg) arg.to_s; end end EOS end Given(/^a configuration file disabling UtilityFunction for non-public methods called 'config.reek'$/) do write_file('config.reek', <<-EOS.strip_heredoc) --- UtilityFunction: public_methods_only: true # Not necessary for the feature per se but for removing distracting output. UnusedPrivateMethod: enabled: false EOS end Then(/^it does not report private or protected methods$/) do # Pseudo step for feature clarity. end reek-3.8.2/features/step_definitions/.rubocop.yml0000644000175000017500000000016412646022100020500 0ustar aleealeeinherit_from: ../../.rubocop.yml # Allow common When syntax Lint/AmbiguousRegexpLiteral: Enabled: false reek-3.8.2/features/step_definitions/reek_steps.rb0000644000175000017500000000473512646022100020727 0ustar aleealeeWhen /^I run reek (.*)$/ do |args| reek(args) end When /^I pass "([^\"]*)" to reek *(.*)$/ do |stdin, args| reek_with_pipe(stdin, args) end When /^I run rake (\w*) with:$/ do |name, task_def| rake(name, task_def) end Then /^it reports nothing$/ do expect(last_command_started).to have_output_on_stdout('') end Then /^there is no output on stdout$/ do expect(last_command_started).to have_output_on_stdout('') end Then /^stdout includes "(.*)"$/ do |text| expect(last_command_started).to have_output_on_stdout(/#{Regexp.escape(text)}/) end Then /^it succeeds$/ do success = Reek::CLI::Options::DEFAULT_SUCCESS_EXIT_CODE expect(last_command_started).to have_exit_status(success) end Then /^the exit status indicates an error$/ do error = Reek::CLI::Options::DEFAULT_ERROR_EXIT_CODE expect(last_command_started).to have_exit_status(error) end Then /^the exit status indicates smells$/ do smells = Reek::CLI::Options::DEFAULT_FAILURE_EXIT_CODE expect(last_command_started).to have_exit_status(smells) end Then(/^the exit status is (\d+)$/) do |status| expect(last_command_started).to have_exit_status(status.to_i) end Then /^it reports:$/ do |report| expect(last_command_started).to have_output_on_stdout(report.gsub('\n', "\n")) end Then /^it reports this yaml:$/ do |expected_yaml| expected_warnings = YAML.load(expected_yaml.chomp) actual_warnings = YAML.load(last_command_started.stdout) expect(actual_warnings).to eq expected_warnings end Then /^it reports this JSON:$/ do |expected_json| expected_warnings = JSON.parse(expected_json.chomp) actual_warnings = JSON.parse(last_command_started.stdout) expect(actual_warnings).to eq expected_warnings end Then /^stderr reports:$/ do |report| expect(last_command_started).to have_output_on_stderr(report.chomp) end Then /^it reports no errors$/ do expect(last_command_started).to have_output_on_stderr('') end Then /^it reports an error$/ do expect(last_command_started.stderr).to_not be_empty end Then /^it reports the error ['"](.*)['"]$/ do |string| expect(last_command_started).to have_output_on_stderr(/#{Regexp.escape(string)}/) end Then /^it reports a parsing error$/ do expect(last_command_started).to have_output_on_stderr(/Parser::SyntaxError/) end Then /^it should indicate the line numbers of those smells$/ do expect(last_command_started).to have_output(/\[.*\]:/) end Then /^it reports the current version$/ do expect(last_command_started).to have_output("reek #{Reek::Version::STRING}") end reek-3.8.2/features/reports/0000755000175000017500000000000012646022100014355 5ustar aleealeereek-3.8.2/features/reports/reports.feature0000644000175000017500000002500712646022100017434 0ustar aleealeeFeature: Correctly formatted reports In order to get the most out of Reek As a developer I want to be able to parse Reek's output simply and consistently Scenario Outline: two reports run together with indented smells Given a directory called 'smelly' containing two smelly files When I run reek Then the exit status indicates smells And it reports: """ smelly/dirty_one.rb -- 2 warnings: [1]:IrresponsibleModule: Dirty has no descriptive comment [https://github.com/troessner/reek/blob/master/docs/Irresponsible-Module.md] [2]:UncommunicativeMethodName: Dirty#a has the name 'a' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md] smelly/dirty_two.rb -- 3 warnings: [1]:IrresponsibleModule: Dirty has no descriptive comment [https://github.com/troessner/reek/blob/master/docs/Irresponsible-Module.md] [2]:UncommunicativeMethodName: Dirty#a has the name 'a' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md] [3]:UncommunicativeMethodName: Dirty#b has the name 'b' [https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Method-Name.md] 5 total warnings """ Examples: | args | | smelly/dirty_one.rb smelly/dirty_two.rb | | smelly | Scenario Outline: No sorting (which means report each file as it is read in) Given a directory called 'smelly' containing two smelly files When I run reek