Skip to content

Commit 2f5386d

Browse files
authored
DEV: Fix linting (#353)
Moves linting to a separate CI step and removes rubocop from the Rakefile (at least until we drop Ruby 2.6)
1 parent 3274a26 commit 2f5386d

File tree

10 files changed

+47
-31
lines changed

10 files changed

+47
-31
lines changed

.github/workflows/ci.yml

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,34 @@ on:
77
pull_request:
88

99
jobs:
10-
build:
10+
lint:
11+
runs-on: ubuntu-latest
12+
timeout-minutes: 5
13+
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- uses: ruby/setup-ruby@v1
18+
with:
19+
ruby-version: "3.3"
20+
bundler-cache: true
21+
22+
- name: Set up Node.js
23+
uses: actions/setup-node@v4
24+
with:
25+
node-version: 20
26+
cache: npm
27+
28+
- name: Setup npm
29+
run: npm install
30+
31+
- name: Rubocop
32+
run: bundle exec rubocop
33+
34+
- name: ESLint
35+
run: npx eslint .
36+
37+
test:
1138
runs-on: ubuntu-latest
1239
name: Ruby ${{ matrix.ruby }} (redis ${{ matrix.redis }})
1340
timeout-minutes: 10
@@ -20,7 +47,7 @@ jobs:
2047
strategy:
2148
fail-fast: false
2249
matrix:
23-
ruby: [2.6, 2.7, '3.0', 3.1]
50+
ruby: [2.6, 2.7, "3.0", 3.1]
2451
redis: [5, 6]
2552

2653
services:
@@ -50,27 +77,14 @@ jobs:
5077
ruby-version: ${{ matrix.ruby }}
5178
bundler-cache: true
5279

53-
- name: Set up Node.js
54-
uses: actions/setup-node@v3
55-
with:
56-
node-version: 18
57-
cache: npm
58-
59-
- name: Setup npm
60-
run: npm install
61-
6280
- name: Tests
6381
env:
6482
TESTOPTS: --verbose
6583
run: bundle exec rake
66-
timeout-minutes: 3
67-
68-
- name: Linting
69-
run: npx eslint .
7084

7185
publish:
7286
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
73-
needs: build
87+
needs: [lint, test]
7488
runs-on: ubuntu-latest
7589

7690
steps:

.rubocop.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
inherit_gem:
2-
rubocop-discourse: .rubocop.yml
2+
rubocop-discourse: stree-compat.yml
33
inherit_mode:
44
merge:
55
- Exclude
6+
67
AllCops:
78
Exclude:
8-
- 'examples/**/*'
9+
- "examples/**/*"
10+
11+
Discourse/Plugins:
12+
Enabled: false
913

1014
RSpec:
1115
Enabled: false

Rakefile

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,10 @@ require 'rake/testtask'
44
require 'bundler'
55
require 'bundler/gem_tasks'
66
require 'bundler/setup'
7-
require 'rubocop/rake_task'
87
require 'yard'
98

109
Bundler.require(:default, :test)
1110

12-
RuboCop::RakeTask.new
1311
YARD::Rake::YardocTask.new
1412

1513
BACKENDS = Dir["lib/message_bus/backends/*.rb"].map { |file| file.match(%r{backends/(?<backend>.*).rb})[:backend] } - ["base"]
@@ -99,5 +97,5 @@ task :performance do
9997
end
10098
end
10199

102-
desc "Run all tests, link checks and confirms documentation compiles without error"
103-
task default: [:spec, :rubocop, :test_doc]
100+
desc "Run all tests and confirm the documentation compiles without error"
101+
task default: [:spec, :test_doc]

lib/message_bus.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# frozen_string_literal: true
22

33
require "monitor"
4-
require "set"
54

65
require_relative "message_bus/version"
76
require_relative "message_bus/message"
@@ -772,7 +771,7 @@ def global_subscribe_thread
772771
globals, locals, local_globals, global_globals = nil
773772

774773
@mutex.synchronize do
775-
return if @destroyed
774+
return if @destroyed # rubocop:disable Lint/NonLocalExitFromIterator
776775
next unless @subscriptions
777776

778777
globals = @subscriptions[nil]

lib/message_bus/backends/base.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ module Backends
4848
#
4949
# @abstract
5050
class Base
51-
# rubocop:disable Lint/UnusedMethodArgument
5251

5352
# Raised to indicate that the concrete backend implementation does not implement part of the API
5453
ConcreteClassMustImplementError = Class.new(StandardError)

lib/message_bus/backends/postgres.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ def global_subscribe(last_id = nil)
406406
on.message do |_c, m|
407407
if m == UNSUB_MESSAGE
408408
@subscribed = false
409-
return
409+
return # rubocop:disable Lint/NonLocalExitFromIterator
410410
end
411411
m = MessageBus::Message.decode m
412412

lib/message_bus/backends/redis.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ def global_subscribe(last_id = nil, &blk)
300300
if m == UNSUB_MESSAGE
301301
@subscribed = false
302302
global_redis.unsubscribe
303-
return
303+
return # rubocop:disable Lint/NonLocalExitFromIterator
304304
end
305305
m = MessageBus::Message.decode m
306306

message_bus.gemspec

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ Gem::Specification.new do |gem|
3535
gem.add_development_dependency 'byebug'
3636
gem.add_development_dependency 'oj'
3737
gem.add_development_dependency 'yard'
38-
gem.add_development_dependency 'rubocop-discourse'
39-
gem.add_development_dependency 'rubocop-rspec'
38+
39+
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.7.0')
40+
gem.add_development_dependency 'rubocop-discourse', '3.8.1'
41+
end
4042
end

spec/lib/message_bus/multi_process_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def work_it
2222
if msg.data == "done"
2323
bus.global_unsubscribe
2424
else
25-
bus.publish("/response", "#{msg.data}-#{Process.pid.to_s}")
25+
bus.publish("/response", "#{msg.data}-#{Process.pid}")
2626
end
2727
end
2828
ensure

spec/spec_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
puts "Running with backend: #{CURRENT_BACKEND}"
2020

2121
def test_only(*backends)
22-
skip "Test doesn't apply to #{CURRENT_BACKEND}" unless backends.include?(CURRENT_BACKEND)
22+
skip "Test doesn't apply to #{CURRENT_BACKEND}" if backends.exclude?(CURRENT_BACKEND)
2323
end
2424

2525
def test_never(*backends)

0 commit comments

Comments
 (0)