From bf812264c13069d6c8a5afb2b8725714a91c0e7f Mon Sep 17 00:00:00 2001 From: Thomas Thomassen Date: Wed, 3 Jan 2024 13:37:57 +0100 Subject: [PATCH] Address RuboCop warnings. --- .rubocop.yml | 14 ++++++++++++++ src/testup.rb | 2 +- src/testup/console.rb | 2 +- src/testup/debug_reporter.rb | 2 +- src/testup/sketchup_test_utilities.rb | 2 ++ src/testup/ui.rb | 2 +- src/testup/ui/adapters/htmldialog.rb | 2 +- src/testup/ui/window.rb | 2 +- 8 files changed, 22 insertions(+), 6 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 2c4a6d1..806bf6a 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -7,6 +7,7 @@ require: AllCops: DisabledByDefault: true # TODO: Reenable DisplayStyleGuide: true + SuggestExtensions: false SketchUp: SourcePath: src TargetSketchUpVersion: 2014 @@ -55,6 +56,19 @@ SketchupSuggestions: SketchupBugs: Enabled: true +# TestUp relies on Minitest gem and need to install it. +SketchupRequirements/GemInstall: + Enabled: false + +# Need to modify the load path for Minitest to work within SketchUp. +SketchupRequirements/LoadPath: + Exclude: + - src/testup/minitest_setup.rb + +# Lots of monkey patching of Minitest required in order for it to operate within SketchUp. +SketchupRequirements/RubyStdLibNamespace: + Enabled: false + SketchupSuggestions/FileEncoding: Enabled: false diff --git a/src/testup.rb b/src/testup.rb index 4f7f7c8..d0dfbf7 100644 --- a/src/testup.rb +++ b/src/testup.rb @@ -8,7 +8,7 @@ if defined?(Sketchup) require 'sketchup.rb' require 'extensions.rb' -elsif defined?(Layout) +elsif defined?(Layout) # rubocop:disable SketchupSuggestions/Compatibility require 'layout.rb' end diff --git a/src/testup/console.rb b/src/testup/console.rb index 343410b..9d03865 100644 --- a/src/testup/console.rb +++ b/src/testup/console.rb @@ -15,7 +15,7 @@ module TestUp # TODO(thomthom): Add LayOut console class. if defined?(Sketchup) APP_CONSOLE = SKETCHUP_CONSOLE - elsif defined?(Layout) + elsif defined?(Layout) # rubocop:disable SketchupSuggestions/Compatibility APP_CONSOLE = LAYOUT_CONSOLE # TODO(thomthom): Correct? end diff --git a/src/testup/debug_reporter.rb b/src/testup/debug_reporter.rb index a05d3c0..8b4201b 100644 --- a/src/testup/debug_reporter.rb +++ b/src/testup/debug_reporter.rb @@ -17,7 +17,7 @@ module Minitest class Runnable - class << self + class << self # rubocop:disable Style/MultilineIfModifier puts "Alias old_run_one_method..." alias_method :old_run_one_method, :run_one_method end unless respond_to?(:old_run_one_method) diff --git a/src/testup/sketchup_test_utilities.rb b/src/testup/sketchup_test_utilities.rb index 426d09d..c24d2bc 100644 --- a/src/testup/sketchup_test_utilities.rb +++ b/src/testup/sketchup_test_utilities.rb @@ -58,6 +58,7 @@ module SketchUpTestUtilities SKETCHUP_RANGE_MAX = -1.0e30 SKETCHUP_RANGE_MIN = 1.0e30 + # rubocop:disable SketchupSuggestions/ModelEntities def start_with_empty_model model = Sketchup.active_model model.abort_operation # Incase any operation is left hanging open. @@ -87,6 +88,7 @@ def start_with_empty_model model.commit_operation model end + # rubocop:enable SketchupSuggestions/ModelEntities def open_new_model model = Sketchup.active_model diff --git a/src/testup/ui.rb b/src/testup/ui.rb index 55951d6..f6b9c7f 100644 --- a/src/testup/ui.rb +++ b/src/testup/ui.rb @@ -202,7 +202,7 @@ module SystemUI def self.select_directory(options) if defined?(UI) && UI.respond_to?(:select_directory) - result = UI.select_directory(options) + result = UI.select_directory(options) # rubocop:disable SketchupSuggestions/Compatibility return nil if result.nil? if options && options[:select_multiple] result.map! { |path| File.expand_path(path) } diff --git a/src/testup/ui/adapters/htmldialog.rb b/src/testup/ui/adapters/htmldialog.rb index 85de350..3704168 100644 --- a/src/testup/ui/adapters/htmldialog.rb +++ b/src/testup/ui/adapters/htmldialog.rb @@ -18,5 +18,5 @@ def register_callback(callback_name, &block) add_action_callback(callback_name, &block) end - end if defined?(UI::HtmlDialog) + end if defined?(UI::HtmlDialog) # rubocop:disable SketchupSuggestions/Compatibility end # module diff --git a/src/testup/ui/window.rb b/src/testup/ui/window.rb index 6376870..f9e83ce 100644 --- a/src/testup/ui/window.rb +++ b/src/testup/ui/window.rb @@ -6,7 +6,7 @@ #------------------------------------------------------------------------------- require 'testup/ui/adapters/webdialog' -require 'testup/ui/adapters/htmldialog' if defined?(UI::HtmlDialog) +require 'testup/ui/adapters/htmldialog' if defined?(UI::HtmlDialog) # rubocop:disable SketchupSuggestions/Compatibility require 'testup/config' require 'testup/log'