From 236002b68ed435007c7b037aca23bb291e06245b Mon Sep 17 00:00:00 2001 From: Cody Cutrer Date: Fri, 8 Sep 2023 14:00:09 -0600 Subject: [PATCH] switch to rubocop-inst's base set of rubocop rules it already contains most of my personal preferences, so that then our rubocop config can be even smaller Signed-off-by: Cody Cutrer --- .rubocop.yml | 37 +++---------------- Gemfile.lock | 6 ++- lib/openhab/core/actions/audio.rb | 7 +++- lib/openhab/core/items/semantics.rb | 4 +- lib/openhab/core/things/proxy.rb | 3 +- lib/openhab/core/value_cache.rb | 9 +++-- lib/openhab/core_ext/java/local_time.rb | 14 ++++--- lib/openhab/core_ext/java/month_day.rb | 3 +- lib/openhab/dsl/items/builder.rb | 4 +- lib/openhab/dsl/rules/builder.rb | 20 ++++++---- .../dsl/rules/triggers/conditions/generic.rb | 2 +- lib/openhab/dsl/things/builder.rb | 6 ++- lib/openhab/rspec/karaf.rb | 7 +++- lib/openhab/rspec/openhab/core/actions.rb | 3 -- openhab-scripting.gemspec | 3 +- rakelib/openhab.rake | 4 +- spec/openhab/core/items/group_item_spec.rb | 11 ++++-- spec/openhab/core/items/semantics_spec.rb | 8 +++- spec/openhab/core/timer_spec.rb | 2 +- spec/openhab/dsl/rules/builder_spec.rb | 9 +++-- spec/openhab/dsl_spec.rb | 4 +- spec/openhab/log_spec.rb | 4 +- spec/openhab/rspec/helpers_spec.rb | 6 ++- spec/openhab/rspec/item_spec.rb | 2 +- spec/openhab/rspec/rule_spec.rb | 2 +- templates/default/module/setup.rb | 27 ++++++++++---- 26 files changed, 114 insertions(+), 93 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index a0cf009026..f37ec8a794 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,5 +1,9 @@ +inherit_gem: + rubocop-inst: + - rubocop.yml + - rubocop-rspec.yml + require: - - rubocop-performance - rubocop-rake - rubocop-rspec @@ -23,9 +27,6 @@ Bundler/GemFilename: Exclude: - lib/openhab/dsl/gems.rb -Gemspec/DevelopmentDependencies: - EnforcedStyle: gemspec - Layout/LineLength: AllowedPatterns: - "# @example" # YARD example titles can't be broken up onto multiple lines. @@ -38,18 +39,8 @@ Lint/BinaryOperatorWithIdenticalOperands: Exclude: - spec/openhab/core/types/*_spec.rb -Metrics: - Enabled: false - -Performance/Casecmp: - AutoCorrect: false - RSpec/DescribeClass: Enabled: false -RSpec/ExampleLength: - Enabled: false -RSpec/ExampleWording: - DisallowedExamples: [] RSpec/ExpectActual: Exclude: - spec/openhab/core/types/*_spec.rb @@ -63,8 +54,6 @@ RSpec/IdenticalEqualityAssertion: - spec/openhab/core/types/*_spec.rb RSpec/IndexedLet: Enabled: false -RSpec/MatchArray: - Enabled: false RSpec/MessageSpies: Enabled: false RSpec/MultipleExpectations: @@ -76,8 +65,6 @@ RSpec/NestedGroups: RSpec/NoExpectationExample: Enabled: false -Style/Alias: - EnforcedStyle: prefer_alias_method Style/CaseEquality: Exclude: # we're explicitly testing this operator - spec/openhab/core/types/*_spec.rb @@ -97,22 +84,8 @@ Style/GlobalVars: - $scriptExtension - $sharedCache - $things -Style/HashSyntax: - EnforcedStyle: ruby19_no_mixed_keys -Style/PercentQLiterals: - EnforcedStyle: upper_case_q -Style/PerlBackrefs: - Enabled: false -Style/RescueStandardError: - EnforcedStyle: implicit Style/SpecialGlobalVars: Enabled: false -Style/StringLiterals: - EnforcedStyle: double_quotes -Style/StringLiteralsInInterpolation: - EnforcedStyle: double_quotes -Style/TernaryParentheses: - EnforcedStyle: require_parentheses_when_complex Style/YodaCondition: Exclude: - spec/openhab/core/types/*_spec.rb diff --git a/Gemfile.lock b/Gemfile.lock index cdef753c45..c47637b42f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -236,6 +236,9 @@ GEM parser (>= 3.2.1.0) rubocop-capybara (2.18.0) rubocop (~> 1.41) + rubocop-inst (1.0.2) + rubocop (~> 1.50) + rubocop-performance (~> 1.17) rubocop-performance (1.17.1) rubocop (>= 1.7.0, < 2.0) rubocop-ast (>= 0.4.0) @@ -299,8 +302,7 @@ DEPENDENCIES process_exists (~> 0.2) rake (~> 13.0) rspec (~> 3.11) - rubocop (~> 1.8) - rubocop-performance (~> 1.11) + rubocop-inst rubocop-rake (~> 0.6) rubocop-rspec (~> 2.11) thin (~> 1.8.1) diff --git a/lib/openhab/core/actions/audio.rb b/lib/openhab/core/actions/audio.rb index 5a60492b8f..e681ccde76 100644 --- a/lib/openhab/core/actions/audio.rb +++ b/lib/openhab/core/actions/audio.rb @@ -23,8 +23,11 @@ class << self # def play_sound(filename, sink: nil, volume: nil) volume = PercentType.new(volume) unless volume.is_a?(PercentType) || volume.nil? - java_send :playSound, [java.lang.String, java.lang.String, PercentType.java_class], - sink, filename.to_s, volume + java_send :playSound, + [java.lang.String, java.lang.String, PercentType.java_class], + sink, + filename.to_s, + volume end # diff --git a/lib/openhab/core/items/semantics.rb b/lib/openhab/core/items/semantics.rb index 77182126fc..cf9da16a2a 100644 --- a/lib/openhab/core/items/semantics.rb +++ b/lib/openhab/core/items/semantics.rb @@ -317,7 +317,9 @@ def add(label: nil, synonyms: "", description: "", **tags) next if lookup(name) next unless parent - new_tag = org.openhab.core.semantics.SemanticTagImpl.new("#{parent.uid}_#{name}", label, description, + new_tag = org.openhab.core.semantics.SemanticTagImpl.new("#{parent.uid}_#{name}", + label, + description, synonyms) Provider.instance.add(new_tag) lookup(name) diff --git a/lib/openhab/core/things/proxy.rb b/lib/openhab/core/things/proxy.rb index 15ebf1fb4d..0a37c67a91 100644 --- a/lib/openhab/core/things/proxy.rb +++ b/lib/openhab/core/things/proxy.rb @@ -13,7 +13,8 @@ class Proxy < Delegator def_delegators :__getobj__, :class, :is_a?, :kind_of? # @!visibility private - EVENTS = [Events::ThingAddedEvent::TYPE, Events::ThingUpdatedEvent::TYPE, + EVENTS = [Events::ThingAddedEvent::TYPE, + Events::ThingUpdatedEvent::TYPE, Events::ThingRemovedEvent::TYPE].freeze # @!visibility private UID_METHOD = :uid diff --git a/lib/openhab/core/value_cache.rb b/lib/openhab/core/value_cache.rb index 2e26d79c43..b91455bae1 100644 --- a/lib/openhab/core/value_cache.rb +++ b/lib/openhab/core/value_cache.rb @@ -107,10 +107,11 @@ def fetch(key, *default_value) # @see https://docs.ruby-lang.org/en/master/Hash.html#method-i-assoc Hash#assoc def assoc(key) - [key, fetch(key) do - # return nil directly, without storing a value to the cache - return nil - end] + [key, + fetch(key) do + # return nil directly, without storing a value to the cache + return nil + end] end # @see https://docs.ruby-lang.org/en/master/Hash.html#method-i-dig Hash#dig diff --git a/lib/openhab/core_ext/java/local_time.rb b/lib/openhab/core_ext/java/local_time.rb index 8ffba2190c..33667252fd 100644 --- a/lib/openhab/core_ext/java/local_time.rb +++ b/lib/openhab/core_ext/java/local_time.rb @@ -56,12 +56,14 @@ def parse(string, formatter = nil) return raw_parse(string, formatter) if formatter format = /(am|pm)$/i.match?(string) ? "h[:mm[:ss][.S]][ ]a" : "H[:mm[:ss][.S]]" - java_send(:parse, [java.lang.CharSequence, java.time.format.DateTimeFormatter], - string, java.time.format.DateTimeFormatterBuilder.new - .parse_case_insensitive - .parse_lenient - .append_pattern(format) - .to_formatter(java.util.Locale::ENGLISH)) + java_send(:parse, + [java.lang.CharSequence, java.time.format.DateTimeFormatter], + string, + java.time.format.DateTimeFormatterBuilder.new + .parse_case_insensitive + .parse_lenient + .append_pattern(format) + .to_formatter(java.util.Locale::ENGLISH)) end end diff --git a/lib/openhab/core_ext/java/month_day.rb b/lib/openhab/core_ext/java/month_day.rb index d1424f5454..8c4885ab4a 100644 --- a/lib/openhab/core_ext/java/month_day.rb +++ b/lib/openhab/core_ext/java/month_day.rb @@ -21,7 +21,8 @@ class << self # def parse(string) logger.trace("#{self.class}.parse #{string} (#{string.class})") - java_send(:parse, [java.lang.CharSequence, java.time.format.DateTimeFormatter], + java_send(:parse, + [java.lang.CharSequence, java.time.format.DateTimeFormatter], string.to_s, java.time.format.DateTimeFormatter.ofPattern("[--]M-d")) end diff --git a/lib/openhab/dsl/items/builder.rb b/lib/openhab/dsl/items/builder.rb index da4b008516..60774d61e2 100644 --- a/lib/openhab/dsl/items/builder.rb +++ b/lib/openhab/dsl/items/builder.rb @@ -270,7 +270,9 @@ def normalize_tags(*tags) # Homekit metadata (see {ItemBuilder#homekit}) # @param metadata [Hash] Generic metadata (see {ItemBuilder#metadata}) # @param state [State] Initial state - def initialize(type, name = nil, label = nil, + def initialize(type, + name = nil, + label = nil, provider:, dimension: nil, unit: nil, diff --git a/lib/openhab/dsl/rules/builder.rb b/lib/openhab/dsl/rules/builder.rb index eff7c2b96d..b91b4f832f 100644 --- a/lib/openhab/dsl/rules/builder.rb +++ b/lib/openhab/dsl/rules/builder.rb @@ -70,7 +70,8 @@ def rule(name = nil, id: nil, script: nil, binding: nil, &block) builder = BuilderDSL.new(binding || block.binding) builder.uid(id) builder.instance_exec(builder, &block) - builder.guard = Guard.new(run_context: builder.caller, only_if: builder.only_if, + builder.guard = Guard.new(run_context: builder.caller, + only_if: builder.only_if, not_if: builder.not_if) name ||= NameInference.infer_rule_name(builder) @@ -1559,8 +1560,12 @@ def event(topic, source: nil, types: nil, attach: nil) # @deprecated OH3.4 - OH3 config uses eventXXX vs OH4 uses `topic`, `source`, and `types` # See https://github.com/openhab/openhab-core/pull/3299 trigger("core.GenericEventTrigger", - eventTopic: topic, eventSource: source, eventTypes: types, # @deprecated OH3.4 - topic: topic, source: source, types: types, + eventTopic: topic, + eventSource: source, + eventTypes: types, # @deprecated OH3.4 + topic: topic, + source: source, + types: types, attach: attach) end @@ -1831,10 +1836,11 @@ def watch(path, glob: "*", for: %i[created deleted modified], attach: nil) types = [binding.local_variable_get(:for)].flatten WatchHandler::WatchTriggerHandlerFactory.instance # ensure it's registered - trigger(WatchHandler::WATCH_TRIGGER_MODULE_ID, path: path.to_s, - types: types.map(&:to_s), - glob: glob.to_s, - attach: attach) + trigger(WatchHandler::WATCH_TRIGGER_MODULE_ID, + path: path.to_s, + types: types.map(&:to_s), + glob: glob.to_s, + attach: attach) end # @!endgroup diff --git a/lib/openhab/dsl/rules/triggers/conditions/generic.rb b/lib/openhab/dsl/rules/triggers/conditions/generic.rb index de970fb746..92a43ab926 100644 --- a/lib/openhab/dsl/rules/triggers/conditions/generic.rb +++ b/lib/openhab/dsl/rules/triggers/conditions/generic.rb @@ -29,7 +29,7 @@ def initialize(from: nil, to: nil, command: nil) # @param [Hash] inputs inputs from trigger # @return [true, false] if the conditions passed (and therefore the block was run) # - def process(mod:, inputs:) # rubocop:disable Lint/UnusedMethodArgument - mod is unused here but required + def process(mod:, inputs:) logger.trace("Checking #{inputs} against condition trigger #{self}") unless check_value(Conditions.old_state_from(inputs), @from) && check_value(Conditions.new_state_from(inputs), @to) && diff --git a/lib/openhab/dsl/things/builder.rb b/lib/openhab/dsl/things/builder.rb index 935d1f2460..27abe6dae3 100644 --- a/lib/openhab/dsl/things/builder.rb +++ b/lib/openhab/dsl/things/builder.rb @@ -187,7 +187,8 @@ def build configuration = Core::Configuration.new(config) if thing_type self.class.thing_factory_helper.apply_default_configuration( - configuration, thing_type, + configuration, + thing_type, self.class.config_description_registry ) end @@ -200,7 +201,8 @@ def build if thing_type # can't use with_channels, or it will wipe out custom channels from above - self.class.thing_factory_helper.create_channels(thing_type, uid, + self.class.thing_factory_helper.create_channels(thing_type, + uid, self.class.config_description_registry).each do |channel| builder.with_channel(channel) end diff --git a/lib/openhab/rspec/karaf.rb b/lib/openhab/rspec/karaf.rb index d93847b18b..b1c38ce7e0 100644 --- a/lib/openhab/rspec/karaf.rb +++ b/lib/openhab/rspec/karaf.rb @@ -154,7 +154,9 @@ def launch_karaf klass.field_accessor :classLoader, :activatorManager klass.field_writer :framework klass.field_reader :LOG - org.apache.karaf.main.ConfigProperties.field_reader :props, :defaultBundleStartlevel, :karafEtc, + org.apache.karaf.main.ConfigProperties.field_reader :props, + :defaultBundleStartlevel, + :karafEtc, :defaultStartLevel klass.class_eval do def send_private(method_name, *args) @@ -472,7 +474,8 @@ def set_up_bundle_listener thf = Mocks::ThingHandlerFactory.instance bundle = org.osgi.framework.FrameworkUtil.get_bundle(org.openhab.core.thing.Thing.java_class) Mocks::BundleResolver.instance.register_class(thf.class, bundle) - bundle.bundle_context.register_service(org.openhab.core.thing.binding.ThingHandlerFactory.java_class, thf, + bundle.bundle_context.register_service(org.openhab.core.thing.binding.ThingHandlerFactory.java_class, + thf, nil) end end diff --git a/lib/openhab/rspec/openhab/core/actions.rb b/lib/openhab/rspec/openhab/core/actions.rb index 30b651f284..a7d1190479 100644 --- a/lib/openhab/rspec/openhab/core/actions.rb +++ b/lib/openhab/rspec/openhab/core/actions.rb @@ -3,7 +3,6 @@ module OpenHAB module Core module Actions - # rubocop:disable Lint/UnusedMethodArgument # redefine these to do nothing so that rules won't fail module_function @@ -31,8 +30,6 @@ def play_stream(url, sink: nil) end end end - - # rubocop:enable Lint/UnusedMethodArgument end end end diff --git a/openhab-scripting.gemspec b/openhab-scripting.gemspec index 4c20431ed8..6cc1b41e50 100644 --- a/openhab-scripting.gemspec +++ b/openhab-scripting.gemspec @@ -41,8 +41,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency "process_exists", "~> 0.2" spec.add_development_dependency "rake", "~> 13.0" spec.add_development_dependency "rspec", "~> 3.11" - spec.add_development_dependency "rubocop", "~> 1.8" - spec.add_development_dependency "rubocop-performance", "~> 1.11" + spec.add_development_dependency "rubocop-inst" spec.add_development_dependency "rubocop-rake", "~> 0.6" spec.add_development_dependency "rubocop-rspec", "~> 2.11" spec.add_development_dependency "timecop", "~> 0.9" diff --git a/rakelib/openhab.rake b/rakelib/openhab.rake index a5921671f5..78761f9eaf 100644 --- a/rakelib/openhab.rake +++ b/rakelib/openhab.rake @@ -181,10 +181,10 @@ namespace :openhab do state(task.name) do mkdir_p gem_home mkdir_p ruby_lib_dir - services_config = ERB.new <<~SERVICES + services_config = ERB.new <<~TEXT org.openhab.automation.jrubyscripting:gem_home=<%= gem_home %> org.openhab.automation.jrubyscripting:rubylib=<%= ruby_lib_dir %> - SERVICES + TEXT File.write(@services_config_file, services_config.result) end end diff --git a/spec/openhab/core/items/group_item_spec.rb b/spec/openhab/core/items/group_item_spec.rb index 32be6ea4ca..725c4bd1e8 100644 --- a/spec/openhab/core/items/group_item_spec.rb +++ b/spec/openhab/core/items/group_item_spec.rb @@ -42,7 +42,8 @@ describe "#members" do it "is enumerable" do expect(Temperatures.members.count).to be 3 - expect(Temperatures.members.map(&:label)).to match_array ["Bedroom Temperature", "Den Temperature", + expect(Temperatures.members.map(&:label)).to match_array ["Bedroom Temperature", + "Den Temperature", "Living Room Temperature"] end @@ -57,14 +58,18 @@ number_item "Kitchen_Temp", group: Temperatures number_item "Basement_Temp" end - expect(Temperatures.members.map(&:name)).to match_array %w[Bedroom_Temp Den_Temp Kitchen_Temp + expect(Temperatures.members.map(&:name)).to match_array %w[Bedroom_Temp + Den_Temp + Kitchen_Temp LivingRoom_Temp] end it "can be added to an array" do expect([Temperatures] + LivingRoom.members).to match_array [Temperatures, LivingRoom_Temp] expect(LivingRoom.members + [Temperatures]).to match_array [Temperatures, LivingRoom_Temp] - expect(LivingRoom.members + GroundFloor.members).to match_array [LivingRoom_Temp, Bedroom_Temp, Den_Temp, + expect(LivingRoom.members + GroundFloor.members).to match_array [LivingRoom_Temp, + Bedroom_Temp, + Den_Temp, LivingRoom] end end diff --git a/spec/openhab/core/items/semantics_spec.rb b/spec/openhab/core/items/semantics_spec.rb index 785f901dce..2ab422420d 100644 --- a/spec/openhab/core/items/semantics_spec.rb +++ b/spec/openhab/core/items/semantics_spec.rb @@ -328,7 +328,9 @@ def points(*args) end it "returns the created tags as an array" do - created = Semantics.add(ArrayTag1: :Equipment, ArrayTag2: :Location, ArrayTag3: :Point, + created = Semantics.add(ArrayTag1: :Equipment, + ArrayTag2: :Location, + ArrayTag3: :Point, LivingRoom: Semantics::Room) expect(created).to match_array([Semantics::ArrayTag1, Semantics::ArrayTag2, Semantics::ArrayTag3]) @@ -337,7 +339,9 @@ def points(*args) end it "supports specifying label, synonyms, and description for the tag" do - Semantics.add(Detailed: Semantics::Equipment, label: "Label 1", synonyms: "Synonym 2", + Semantics.add(Detailed: Semantics::Equipment, + label: "Label 1", + synonyms: "Synonym 2", description: "Description 3") expect(Semantics::Detailed.label).to eq "Label 1" expect(Semantics.lookup("Synonym 2")).to eql Semantics::Detailed diff --git a/spec/openhab/core/timer_spec.rb b/spec/openhab/core/timer_spec.rb index 8d585eae07..f0938a4e24 100644 --- a/spec/openhab/core/timer_spec.rb +++ b/spec/openhab/core/timer_spec.rb @@ -8,7 +8,7 @@ fired = false t = after(0.1.seconds) do |timer| fired = true - expect(timer).to be t # rubocop:disable RSpec/ExpectInHook + expect(timer).to be t end expect(t).not_to be_a(OpenHAB::RSpec::Mocks::Timer) unless self.class.mock_timers? expect(fired).to be false diff --git a/spec/openhab/dsl/rules/builder_spec.rb b/spec/openhab/dsl/rules/builder_spec.rb index 3dc2256648..3d6a629671 100644 --- a/spec/openhab/dsl/rules/builder_spec.rb +++ b/spec/openhab/dsl/rules/builder_spec.rb @@ -1080,7 +1080,9 @@ def self.generate(name, cron_expression, *every_args, attach: nil, **kwargs) generate("uses cron for :seconds", "* * * ? * ? *", :second) generate("passes through attachment", "* * * ? * ? *", :second, attach: 1) generate("can use durations", "*/5 * * ? * ? *", 5.seconds) - generate("can use MonthDay and LocalTime", "0 0 12 17 11 ? *", MonthDay.parse("11-17"), + generate("can use MonthDay and LocalTime", + "0 0 12 17 11 ? *", + MonthDay.parse("11-17"), at: LocalTime.parse("12:00")) generate("can use MonthDay as a string", "0 0 12 17 11 ? *", "11-17", at: LocalTime.parse("12:00")) generate("can use LocalTime a string", "0 0 12 17 11 ? *", MonthDay.parse("11-17"), at: "12:00") @@ -1328,8 +1330,9 @@ def test_it(filename, watch_args:, expected: true, check: nil) end it "doesn't monitor changes inside subdirectories" do - test_it(config_folder / "tmp" / test_file, expected: false, - watch_args: [config_folder, { glob: test_file, for: :created }]) + test_it(config_folder / "tmp" / test_file, + expected: false, + watch_args: [config_folder, { glob: test_file, for: :created }]) end end diff --git a/spec/openhab/dsl_spec.rb b/spec/openhab/dsl_spec.rb index 9771b4e80b..2b4c92432a 100644 --- a/spec/openhab/dsl_spec.rb +++ b/spec/openhab/dsl_spec.rb @@ -252,8 +252,8 @@ unit("°C") do expect(f - (20 | "°C") < 2).to be true - expect((f - 2).format("%.1f %unit%")).to eq "19.1 °C" # rubocop:disable Style/FormatStringToken - expect((c + f).format("%.1f %unit%")).to eq "44.1 °C" # rubocop:disable Style/FormatStringToken + expect((f - 2).format("%.1f %unit%")).to eq "19.1 °C" + expect((c + f).format("%.1f %unit%")).to eq "44.1 °C" expect(f - 2 < 20).to be true expect(2 + c == 25).to be true expect(2 * c == 46).to be true diff --git a/spec/openhab/log_spec.rb b/spec/openhab/log_spec.rb index 5b2b60226e..c85a60830c 100644 --- a/spec/openhab/log_spec.rb +++ b/spec/openhab/log_spec.rb @@ -62,7 +62,7 @@ def logger_name run do after(1.second) do executed = true - expect(logger.name).to match(/^org\.openhab\.automation\.jrubyscripting\.rule\.log_spec\.rb:(?:\d+)$/) # rubocop:disable RSpec/ExpectInHook + expect(logger.name).to match(/^org\.openhab\.automation\.jrubyscripting\.rule\.log_spec\.rb:(?:\d+)$/) end end end @@ -108,7 +108,7 @@ def logger_name executed = false after(1.second) do executed = true - expect(logger.name).to eql file_logger_name # rubocop:disable RSpec/ExpectInHook + expect(logger.name).to eql file_logger_name end time_travel_and_execute_timers(5.seconds) diff --git a/spec/openhab/rspec/helpers_spec.rb b/spec/openhab/rspec/helpers_spec.rb index 529bb36858..4e2605c66a 100644 --- a/spec/openhab/rspec/helpers_spec.rb +++ b/spec/openhab/rspec/helpers_spec.rb @@ -5,8 +5,10 @@ describe "load_rules" do it "respects start levels" do allow(RSpec.configuration).to receive(:openhab_automation_search_paths).and_return(["automation"]) - allow(Dir).to receive(:[]).and_return(%w[automation/filea.rb automation/sl30/filec.rb - automation/filea.sl20.rb automation/sl30/fileb.rb]) + allow(Dir).to receive(:[]).and_return(%w[automation/filea.rb + automation/sl30/filec.rb + automation/filea.sl20.rb + automation/sl30/fileb.rb]) # rubocop:disable RSpec/SubjectStub expect(subject).to receive(:load).with("automation/filea.sl20.rb").ordered diff --git a/spec/openhab/rspec/item_spec.rb b/spec/openhab/rspec/item_spec.rb index aa659b6f8c..e9a11eb24c 100644 --- a/spec/openhab/rspec/item_spec.rb +++ b/spec/openhab/rspec/item_spec.rb @@ -5,7 +5,7 @@ # Has to be in after(:all) so that the top-level after hook has run; # this example group explicitly has a single spec after(:all) do # rubocop:disable RSpec/BeforeAfterAll - expect(items["MyItem"]).to be_nil # rubocop:disable RSpec/ExpectInHook + expect(items["MyItem"]).to be_nil end it "cleans up all items created in a spec" do diff --git a/spec/openhab/rspec/rule_spec.rb b/spec/openhab/rspec/rule_spec.rb index 7947d4acd5..aea1cbc1dd 100644 --- a/spec/openhab/rspec/rule_spec.rb +++ b/spec/openhab/rspec/rule_spec.rb @@ -4,7 +4,7 @@ context "with in-spec created rules" do # Has to be in before/after(:all) so that the top-level after hook has run; # this example group explicitly has a single spec - # rubocop:disable RSpec/BeforeAfterAll, RSpec/ExpectInHook + # rubocop:disable RSpec/BeforeAfterAll before(:all) do rule id: "out-of-spec-rule" do every :day diff --git a/templates/default/module/setup.rb b/templates/default/module/setup.rb index cd00f72eea..f867abfbe1 100644 --- a/templates/default/module/setup.rb +++ b/templates/default/module/setup.rb @@ -1,13 +1,26 @@ # frozen_string_literal: true def init - sections :header, :box_info, :pre_docstring, T("docstring"), :children, - :constant_summary, [T("docstring")], :inherited_constants, - :attribute_summary, [:item_summary], :inherited_attributes, - :method_summary, [T("docstring"), :item_summary], :inherited_methods, - :methodmissing, [T("method_details")], - :attribute_details, [T("method_details")], - :method_details_list, [T("method_details")] + sections :header, + :box_info, + :pre_docstring, + T("docstring"), + :children, + :constant_summary, + [T("docstring")], + :inherited_constants, + :attribute_summary, + [:item_summary], + :inherited_attributes, + :method_summary, + [T("docstring"), :item_summary], + :inherited_methods, + :methodmissing, + [T("method_details")], + :attribute_details, + [T("method_details")], + :method_details_list, + [T("method_details")] end def groups(list, type = "Method")