diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..1e4ee95 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..6a0e676 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/reviewer.iml b/.idea/reviewer.iml new file mode 100644 index 0000000..cab2e47 --- /dev/null +++ b/.idea/reviewer.iml @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.rubocop.yml b/.rubocop.yml index a54db8f..ac100d9 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -10,10 +10,6 @@ AllCops: Layout/LineLength: Enabled: false -# One case statement in a single method isn't complex. -Metrics/CyclomaticComplexity: - IgnoredMethods: ['case'] - # 10 is a good goal but a little draconian Metrics/MethodLength: CountAsOne: ['array', 'hash', 'heredoc'] diff --git a/Gemfile b/Gemfile index 9fe038b..f72f5cb 100644 --- a/Gemfile +++ b/Gemfile @@ -6,3 +6,20 @@ source 'https://rubygems.org' gemspec gem 'rake', '~> 13.0' + +group :development do + gem 'bundler-audit' + gem 'codecov' + gem 'flay' + gem 'flog' + gem 'inch' + gem 'minitest' + gem 'minitest-heat' + gem 'psych' + gem 'reek' + gem 'rubocop' + gem 'rubocop-minitest' + gem 'rubocop-rake' + gem 'simplecov' + gem 'yard' +end diff --git a/lib/reviewer/command/string/env.rb b/lib/reviewer/command/string/env.rb index 07f21e4..93495ac 100644 --- a/lib/reviewer/command/string/env.rb +++ b/lib/reviewer/command/string/env.rb @@ -30,7 +30,7 @@ def to_a def env(key, value) return nil if key.to_s.strip.empty? || value.to_s.strip.empty? - value = needs_quotes?(value) ? "'#{value}'" : value + value = "'#{value}'" if needs_quotes?(value) "#{key.to_s.strip.upcase}=#{value.to_s.strip}" end diff --git a/lib/reviewer/command/string/flags.rb b/lib/reviewer/command/string/flags.rb index a2ca3a5..325c483 100644 --- a/lib/reviewer/command/string/flags.rb +++ b/lib/reviewer/command/string/flags.rb @@ -37,7 +37,7 @@ def to_a def flag(key, value) dash = key.to_s.size == 1 ? '-' : '--' - value = needs_quotes?(value) ? "'#{value}'" : value + value = "'#{value}'" if needs_quotes?(value) "#{dash}#{key} #{value}".strip end diff --git a/lib/reviewer/output.rb b/lib/reviewer/output.rb index 895f452..b41b13a 100644 --- a/lib/reviewer/output.rb +++ b/lib/reviewer/output.rb @@ -10,7 +10,7 @@ module Reviewer # Friendly API for printing nicely-formatted output to the console class Output DEFAULT_CONSOLE_WIDTH = 120 - DIVIDER = 'ยท' + DIVIDER = '.' attr_reader :printer diff --git a/lib/reviewer/runner/strategies/captured.rb b/lib/reviewer/runner/strategies/captured.rb index 3d91419..e216262 100644 --- a/lib/reviewer/runner/strategies/captured.rb +++ b/lib/reviewer/runner/strategies/captured.rb @@ -80,7 +80,11 @@ def display_progress(command, &block) # rubocop:disable Metrics/AbcSize # # @return [Boolean] true if either stdout or stderr contain printable content def usable_output_captured? - [runner.stdout, runner.stderr].reject { |value| value.nil? || value.strip.empty? }.any? + [runner.stdout, runner.stderr].reject do |value| + value.nil? || value.strip.empty? + end.any? + rescue Encoding::CompatibilityError + false end # Prints "Success" and the resulting timing details before moving on to the next tool diff --git a/reviewer.gemspec b/reviewer.gemspec index 73fae6d..a849162 100644 --- a/reviewer.gemspec +++ b/reviewer.gemspec @@ -33,19 +33,4 @@ Gem::Specification.new do |spec| spec.add_dependency 'rainbow' spec.add_dependency 'slop' - - spec.add_development_dependency 'bundler-audit' - spec.add_development_dependency 'codecov' - spec.add_development_dependency 'flay' - spec.add_development_dependency 'flog' - spec.add_development_dependency 'inch' - spec.add_development_dependency 'minitest' - spec.add_development_dependency 'minitest-heat' - spec.add_development_dependency 'psych' - spec.add_development_dependency 'reek' - spec.add_development_dependency 'rubocop' - spec.add_development_dependency 'rubocop-minitest' - spec.add_development_dependency 'rubocop-rake' - spec.add_development_dependency 'simplecov' - spec.add_development_dependency 'yard' end diff --git a/test/reviewer/arguments/files_test.rb b/test/reviewer/arguments/files_test.rb index a032ce3..dca62f3 100644 --- a/test/reviewer/arguments/files_test.rb +++ b/test/reviewer/arguments/files_test.rb @@ -4,7 +4,7 @@ module Reviewer class Arguments - class FilesTest < MiniTest::Test + class FilesTest < Minitest::Test def test_array_casting assert_equal [], Files.new.to_a assert_equal ['*.css', '*.rb'], Files.new(provided: ['*.rb', '*.css'], keywords: []).to_a diff --git a/test/reviewer/arguments/keywords_test.rb b/test/reviewer/arguments/keywords_test.rb index a54c612..1bf91cb 100644 --- a/test/reviewer/arguments/keywords_test.rb +++ b/test/reviewer/arguments/keywords_test.rb @@ -4,7 +4,7 @@ module Reviewer class Arguments - class KeywordsTest < MiniTest::Test + class KeywordsTest < Minitest::Test def test_initializes_from_multiple_argument_formats keywords = Keywords.new('one') assert_equal ['one'], keywords.provided diff --git a/test/reviewer/arguments/tags_test.rb b/test/reviewer/arguments/tags_test.rb index 3b4bd3e..10331f6 100644 --- a/test/reviewer/arguments/tags_test.rb +++ b/test/reviewer/arguments/tags_test.rb @@ -4,7 +4,7 @@ module Reviewer class Arguments - class TagsTest < MiniTest::Test + class TagsTest < Minitest::Test def test_array_casting assert_equal [], Tags.new.to_a assert_equal %w[css html ruby], Tags.new(provided: %w[css], keywords: %w[ruby html]).to_a diff --git a/test/reviewer/arguments_test.rb b/test/reviewer/arguments_test.rb index 56946f4..b2d273d 100644 --- a/test/reviewer/arguments_test.rb +++ b/test/reviewer/arguments_test.rb @@ -3,7 +3,7 @@ require 'test_helper' module Reviewer - class ArgumentsTest < MiniTest::Test + class ArgumentsTest < Minitest::Test def test_has_an_empty_array_of_tags_by_default args = %w[] arguments = Arguments.new(args) diff --git a/test/reviewer/batch_test.rb b/test/reviewer/batch_test.rb index 1eba899..e6f29e1 100644 --- a/test/reviewer/batch_test.rb +++ b/test/reviewer/batch_test.rb @@ -3,7 +3,7 @@ require 'test_helper' module Reviewer - class BatchTest < MiniTest::Test + class BatchTest < Minitest::Test def setup @result = nil end diff --git a/test/reviewer/command/string/env_test.rb b/test/reviewer/command/string/env_test.rb index 0f94493..785efbf 100644 --- a/test/reviewer/command/string/env_test.rb +++ b/test/reviewer/command/string/env_test.rb @@ -5,7 +5,7 @@ module Reviewer module Commands class String - class EnvTest < MiniTest::Test + class EnvTest < Minitest::Test def setup @env_pairs = { environment: 'production', diff --git a/test/reviewer/command/string/flags_test.rb b/test/reviewer/command/string/flags_test.rb index cf3d45e..3333dca 100644 --- a/test/reviewer/command/string/flags_test.rb +++ b/test/reviewer/command/string/flags_test.rb @@ -5,7 +5,7 @@ module Reviewer class Command class String - class FlagsTest < MiniTest::Test + class FlagsTest < Minitest::Test def setup @flag_pairs = { f: true, diff --git a/test/reviewer/command/string_test.rb b/test/reviewer/command/string_test.rb index 15a5d93..dbf9894 100644 --- a/test/reviewer/command/string_test.rb +++ b/test/reviewer/command/string_test.rb @@ -4,7 +4,7 @@ module Reviewer class Command - class StringTest < MiniTest::Test + class StringTest < Minitest::Test def setup @settings = ::Reviewer::Tool::Settings.new(:enabled_tool) end diff --git a/test/reviewer/command_test.rb b/test/reviewer/command_test.rb index eb0ac91..165c65d 100644 --- a/test/reviewer/command_test.rb +++ b/test/reviewer/command_test.rb @@ -3,7 +3,7 @@ require 'test_helper' module Reviewer - class CommandTest < MiniTest::Test + class CommandTest < Minitest::Test def setup @command = Reviewer::Command.new(:enabled_tool, :review) end diff --git a/test/reviewer/conversions_test.rb b/test/reviewer/conversions_test.rb index fbb263d..aa511af 100644 --- a/test/reviewer/conversions_test.rb +++ b/test/reviewer/conversions_test.rb @@ -3,7 +3,7 @@ require 'test_helper' module Reviewer - class ConversionsTest < MiniTest::Test + class ConversionsTest < Minitest::Test include Conversions def test_tool_from_tool_instance diff --git a/test/reviewer/guidance_test.rb b/test/reviewer/guidance_test.rb index fae3501..ad844a9 100644 --- a/test/reviewer/guidance_test.rb +++ b/test/reviewer/guidance_test.rb @@ -3,7 +3,7 @@ require 'test_helper' module Reviewer - class GuidanceTest < MiniTest::Test + class GuidanceTest < Minitest::Test def setup @output = Output.new end diff --git a/test/reviewer/history_test.rb b/test/reviewer/history_test.rb index 12575f8..2832e0b 100644 --- a/test/reviewer/history_test.rb +++ b/test/reviewer/history_test.rb @@ -3,7 +3,7 @@ require 'test_helper' module Reviewer - class HistoryTest < MiniTest::Test + class HistoryTest < Minitest::Test def setup @history = History.new end diff --git a/test/reviewer/keywords/git/staged_test.rb b/test/reviewer/keywords/git/staged_test.rb index 8aecf64..c049bc2 100644 --- a/test/reviewer/keywords/git/staged_test.rb +++ b/test/reviewer/keywords/git/staged_test.rb @@ -16,7 +16,7 @@ def exitstatus end end - class StagedTest < MiniTest::Test + class StagedTest < Minitest::Test def test_lists_staged_files_via_class_method assert_equal Staged.new.list, Staged.list end @@ -26,8 +26,10 @@ def test_lists_staged_files end def test_parses_empty_git_command_output + # rubocop:disable Style/EmptyHeredoc empty_staged_files_list = <<~EMPTY_GIT_OUTPUT EMPTY_GIT_OUTPUT + # rubocop:enable Style/EmptyHeredoc # Instead of staging files, stub the Open3 call. Open3.stub :capture3, [empty_staged_files_list, nil, ProcessStatus.new(true)] do diff --git a/test/reviewer/loader_test.rb b/test/reviewer/loader_test.rb index b47f50d..4238d12 100644 --- a/test/reviewer/loader_test.rb +++ b/test/reviewer/loader_test.rb @@ -3,7 +3,7 @@ require 'test_helper' module Reviewer - class LoaderTest < MiniTest::Test + class LoaderTest < Minitest::Test def test_reads_the_yaml_configuration_file loader = Loader.new assert loader.configuration.is_a? Hash diff --git a/test/reviewer/output/printer_test.rb b/test/reviewer/output/printer_test.rb index c2ba14d..d91d602 100644 --- a/test/reviewer/output/printer_test.rb +++ b/test/reviewer/output/printer_test.rb @@ -4,7 +4,7 @@ module Reviewer class Output - class PrinterTest < MiniTest::Test + class PrinterTest < Minitest::Test def setup @printer = Printer.new end diff --git a/test/reviewer/output/scrubber_test.rb b/test/reviewer/output/scrubber_test.rb index 6df3349..bec9342 100644 --- a/test/reviewer/output/scrubber_test.rb +++ b/test/reviewer/output/scrubber_test.rb @@ -4,7 +4,7 @@ module Reviewer class Output - class ScrubberTest < MiniTest::Test + class ScrubberTest < Minitest::Test def test_scrubs_rake_aborted_content raw_stderr = <<~STDERR some text before diff --git a/test/reviewer/output_test.rb b/test/reviewer/output_test.rb index 7652e7f..ac473ca 100644 --- a/test/reviewer/output_test.rb +++ b/test/reviewer/output_test.rb @@ -3,7 +3,7 @@ require 'test_helper' module Reviewer - class OutputTest < MiniTest::Test + class OutputTest < Minitest::Test def setup @output = Output.new end diff --git a/test/reviewer/runner/strategies/captured_test.rb b/test/reviewer/runner/strategies/captured_test.rb index c1e69ee..2737851 100644 --- a/test/reviewer/runner/strategies/captured_test.rb +++ b/test/reviewer/runner/strategies/captured_test.rb @@ -5,7 +5,7 @@ module Reviewer class Runner module Strategies - class CapturedTest < MiniTest::Test + class CapturedTest < Minitest::Test def setup @strategy = Runner::Strategies::Captured end diff --git a/test/reviewer/runner/strategies/passthrough_test.rb b/test/reviewer/runner/strategies/passthrough_test.rb index 76547a3..4a54421 100644 --- a/test/reviewer/runner/strategies/passthrough_test.rb +++ b/test/reviewer/runner/strategies/passthrough_test.rb @@ -5,7 +5,7 @@ module Reviewer class Runner module Strategies - class PassthroughTest < MiniTest::Test + class PassthroughTest < Minitest::Test def setup @strategy = Runner::Strategies::Passthrough end diff --git a/test/reviewer/runner_test.rb b/test/reviewer/runner_test.rb index e68235a..67b4356 100644 --- a/test/reviewer/runner_test.rb +++ b/test/reviewer/runner_test.rb @@ -3,7 +3,7 @@ require 'test_helper' module Reviewer - class RunnerTest < MiniTest::Test + class RunnerTest < Minitest::Test def test_determines_success_based_on_configured_max_exit_status_for_review runner = Runner.new(:enabled_tool, :review) max_exit_status = 3 diff --git a/test/reviewer/shell/result_test.rb b/test/reviewer/shell/result_test.rb index c38b8d2..68ba766 100644 --- a/test/reviewer/shell/result_test.rb +++ b/test/reviewer/shell/result_test.rb @@ -4,7 +4,7 @@ module Reviewer class Shell - class ResultTest < MiniTest::Test + class ResultTest < Minitest::Test def setup @process_status = MockProcessStatus.new(exitstatus: 0, pid: 123) end diff --git a/test/reviewer/shell/timer_test.rb b/test/reviewer/shell/timer_test.rb index ea600aa..9caed86 100644 --- a/test/reviewer/shell/timer_test.rb +++ b/test/reviewer/shell/timer_test.rb @@ -4,7 +4,7 @@ module Reviewer class Shell - class TimerTest < MiniTest::Test + class TimerTest < Minitest::Test def test_records_prep_time timer = Timer.new assert timer.prep.nil? diff --git a/test/reviewer/shell_test.rb b/test/reviewer/shell_test.rb index 6a14b21..83aeb1d 100644 --- a/test/reviewer/shell_test.rb +++ b/test/reviewer/shell_test.rb @@ -3,7 +3,7 @@ require 'test_helper' module Reviewer - class ShellTest < MiniTest::Test + class ShellTest < Minitest::Test def setup @shell = Shell.new end diff --git a/test/reviewer/tool/settings_test.rb b/test/reviewer/tool/settings_test.rb index 084cf54..fbad866 100644 --- a/test/reviewer/tool/settings_test.rb +++ b/test/reviewer/tool/settings_test.rb @@ -4,7 +4,7 @@ module Reviewer class Tool - class SettingsTest < MiniTest::Test + class SettingsTest < Minitest::Test def setup @tool = :example @config = { diff --git a/test/reviewer/tool_test.rb b/test/reviewer/tool_test.rb index d13b66f..3cbecad 100644 --- a/test/reviewer/tool_test.rb +++ b/test/reviewer/tool_test.rb @@ -3,7 +3,7 @@ require 'test_helper' module Reviewer - class ToolTest < MiniTest::Test + class ToolTest < Minitest::Test def setup @tool = Tool.new(:enabled_tool) @mvt = Tool.new(:minimum_viable_tool)