Skip to content
Merged
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
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ jobs:
ci:
uses: LegionIO/.github/.github/workflows/ci.yml@main

lint:
uses: LegionIO/.github/.github/workflows/lint-patterns.yml@main
excluded-files:
uses: LegionIO/.github/.github/workflows/excluded-files.yml@main

security:
uses: LegionIO/.github/.github/workflows/security-scan.yml@main
Expand All @@ -27,7 +27,7 @@ jobs:
uses: LegionIO/.github/.github/workflows/stale.yml@main

release:
needs: [ci, lint]
needs: [ci, excluded-files]
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: LegionIO/.github/.github/workflows/release.yml@main
secrets:
Expand Down
58 changes: 2 additions & 56 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,56 +1,2 @@
AllCops:
TargetRubyVersion: 3.4
NewCops: enable
SuggestExtensions: false

Layout/LineLength:
Max: 160
Layout/SpaceAroundEqualsInParameterDefault:
EnforcedStyle: space
Layout/HashAlignment:
EnforcedHashRocketStyle: table
EnforcedColonStyle: table

Metrics/MethodLength:
Max: 50
Metrics/ClassLength:
Max: 1500
Metrics/ModuleLength:
Max: 1500
Metrics/BlockLength:
Max: 40
Exclude:
- 'spec/**/*'
Metrics/AbcSize:
Max: 60
Metrics/CyclomaticComplexity:
Max: 15
Metrics/PerceivedComplexity:
Max: 17
Metrics/ParameterLists:
Enabled: false

Style/Documentation:
Enabled: false
Style/SymbolArray:
Enabled: true
Style/FrozenStringLiteralComment:
Enabled: true
EnforcedStyle: always

Naming/FileName:
Enabled: false
Naming/PredicateMethod:
Enabled: false
Naming/PredicatePrefix:
Enabled: false
Naming/AccessorMethodName:
Enabled: false
Naming/MemoizedInstanceVariableName:
Enabled: false

Lint/EmptyClass:
Enabled: false

Gemspec/DevelopmentDependencies:
Enabled: false
inherit_gem:
rubocop-legion: config/lex.yml
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## [0.1.3] - 2026-03-30

### Changed
- update to rubocop-legion 0.1.7, resolve all offenses

## [0.1.2] - 2026-03-29

### Changed
Expand Down
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ gemspec
gem 'rake'
gem 'rspec'
gem 'rubocop'
gem 'rubocop-legion', '~> 0.1', require: false
gem 'rubocop-rspec'
12 changes: 6 additions & 6 deletions lib/legion/extensions/react.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
module Legion
module Extensions
module React
extend Legion::Extensions::Core if Legion::Extensions.const_defined?(:Core)
extend Legion::Extensions::Core if Legion::Extensions.const_defined?(:Core, false)

class << self
include Legion::Extensions::Helpers::Lex if defined?(Legion::Extensions::Helpers::Lex)
Expand All @@ -27,7 +27,7 @@ def remote_invocable?
def subscribe!
return unless defined?(Legion::Events)

@subscription ||= Legion::Events.on('*') do |event|
@subscribe ||= Legion::Events.on('*') do |event| # rubocop:disable ThreadSafety/ClassInstanceVariable
next if event[:event].to_s.start_with?('react.')

Runners::React.handle_event(event: event)
Expand All @@ -37,10 +37,10 @@ def subscribe!
end

def unsubscribe!
return unless @subscription && defined?(Legion::Events)
return unless @subscribe && defined?(Legion::Events) # rubocop:disable ThreadSafety/ClassInstanceVariable

Legion::Events.off('*', @subscription)
@subscription = nil
Legion::Events.off('*', @subscribe) # rubocop:disable ThreadSafety/ClassInstanceVariable
@subscribe = nil # rubocop:disable ThreadSafety/ClassInstanceVariable
end

unless method_defined?(:log)
Expand All @@ -50,7 +50,7 @@ def log
end
end

require_relative 'react/actors/event_subscriber' if defined?(Legion::Extensions::Actors::Once)
require_relative 'react/actors/event_subscriber'
end
end
end
4 changes: 2 additions & 2 deletions lib/legion/extensions/react/helpers/event_matcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def match?(pattern, event_name)
.gsub('__DS__', '\..*')
regex_str = "\\A#{regex_str}\\z"
Regexp.new(regex_str).match?(event_name)
rescue RegexpError
rescue RegexpError => _e
false
end

Expand All @@ -36,7 +36,7 @@ def evaluate_condition(condition, event)
else
false
end
rescue StandardError
rescue StandardError => _e
false
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/legion/extensions/react/rule_engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def self.from_settings
{}
end
new(rules_hash)
rescue StandardError
rescue StandardError => _e
new({})
end

Expand Down
8 changes: 4 additions & 4 deletions lib/legion/extensions/react/runners/react.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module Extensions
module React
module Runners
module React
module_function
extend self

def handle_event(event:)
engine = rule_engine
Expand Down Expand Up @@ -45,6 +45,8 @@ def reset!
@reaction_dispatcher = nil
end

private

def rule_engine
@rule_engine ||= RuleEngine.from_settings
end
Expand All @@ -68,11 +70,9 @@ def react_settings
return {} unless defined?(Legion::Settings) && !Legion::Settings[:react].nil?

Legion::Settings[:react] || {}
rescue StandardError
rescue StandardError => _e
{}
end

private_class_method :rule_engine, :loop_breaker, :reaction_dispatcher, :react_settings
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/legion/extensions/react/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module Legion
module Extensions
module React
VERSION = '0.1.2'
VERSION = '0.1.3'
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
describe 'Legion::Extensions::React.subscribe!' do
before do
Legion::Events.clear
Legion::Extensions::React.instance_variable_set(:@subscription, nil)
Legion::Extensions::React.instance_variable_set(:@subscribe, nil)
Legion::Settings.set_test_data({
react: {
rules: {
Expand Down
13 changes: 7 additions & 6 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,16 @@ module Extensions
module Core; end

module Actors
class Every; end
class Subscription; end
class Every; end # rubocop:disable Lint/EmptyClass
class Subscription; end # rubocop:disable Lint/EmptyClass
class Once; end # rubocop:disable Lint/EmptyClass
end
end

module Transport
class Exchange; end
class Queue; end
class Message; end
class Exchange; end # rubocop:disable Lint/EmptyClass
class Queue; end # rubocop:disable Lint/EmptyClass
class Message; end # rubocop:disable Lint/EmptyClass
end

module Settings
Expand All @@ -30,7 +31,7 @@ def self.dig(*keys)
keys.reduce(@data) { |h, k| h.is_a?(Hash) ? h[k] : nil }
end

def self.set_test_data(data)
def self.set_test_data(data) # rubocop:disable Naming/AccessorMethodName
@data = data
end
end
Expand Down
Loading