rubocop-discourse 2.3.0 → 2.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +2 -3
- data/.gitignore +0 -2
- data/default.yml +1 -0
- data/lib/rubocop/cop/discourse/no_mocking_jobs.rb +10 -5
- data/lib/rubocop/cop/discourse/time_eq_matcher.rb +2 -2
- data/rubocop-discourse.gemspec +7 -5
- data/rubocop-rspec.yml +6 -9
- data/spec/lib/rubocop/cop/{no_mocking_jobs_spec.rb → no_mocking_jobs_enqueue_spec.rb} +10 -2
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a72b547f01dafa6cb189e9bfa4478817b6235ae725707b36e4b7f692351c3707
|
4
|
+
data.tar.gz: 2bfc96ac97e72886e781ddf5bc94f38c04a6f7ce45946dea2823f35d8db8e798
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cbcd4c1f22751539ee6a1c9550a08170d91f92b26e7098362bcf3039f0d3658b5df789c72b947e857fa38ba7523ca53b5061feff1b9bd6135940db61ce6baef6
|
7
|
+
data.tar.gz: 1f1d6460703cf74e03ce57ac50deed273f7a1a0f2df3d8a1ab9d6a9d0ec18aa53be63ad442c79dd08cfbf664811ea79caa02ae65127b23ae78a14c1c8721d71f
|
data/.github/workflows/ci.yml
CHANGED
@@ -19,7 +19,6 @@ jobs:
|
|
19
19
|
uses: actions/setup-ruby@v1
|
20
20
|
with:
|
21
21
|
ruby-version: 2.6
|
22
|
-
architecture: 'x64'
|
23
22
|
|
24
23
|
- name: Setup bundler
|
25
24
|
run: gem install bundler
|
@@ -29,7 +28,7 @@ jobs:
|
|
29
28
|
|
30
29
|
- name: Rubocop
|
31
30
|
run: bundle exec rubocop
|
32
|
-
|
31
|
+
|
33
32
|
- name: Rspec
|
34
33
|
run: bundle exec rspec spec
|
35
34
|
|
@@ -42,6 +41,6 @@ jobs:
|
|
42
41
|
- uses: actions/checkout@v2
|
43
42
|
|
44
43
|
- name: Release Gem
|
45
|
-
uses:
|
44
|
+
uses: discourse/publish-rubygems-action@main
|
46
45
|
env:
|
47
46
|
RUBYGEMS_API_KEY: ${{secrets.RUBYGEMS_API_KEY}}
|
data/.gitignore
CHANGED
data/default.yml
CHANGED
@@ -4,15 +4,20 @@ module RuboCop
|
|
4
4
|
module Cop
|
5
5
|
module Discourse
|
6
6
|
class NoMockingJobs < Cop
|
7
|
-
MSG = "Use the test helpers provided by Sidekiq instead of mocking `Jobs`."
|
7
|
+
MSG = "Use the test helpers provided by Sidekiq instead of mocking `Jobs.expects(:enqueue)`."
|
8
8
|
|
9
|
-
def_node_matcher :
|
10
|
-
(send (const nil? :Jobs) :expects
|
9
|
+
def_node_matcher :mocking_jobs_enqueue?, <<~MATCHER
|
10
|
+
(send (const nil? :Jobs) :expects (:sym :enqueue))
|
11
|
+
MATCHER
|
12
|
+
|
13
|
+
def_node_matcher :mocking_jobs_enqueue_in?, <<~MATCHER
|
14
|
+
(send (const nil? :Jobs) :expects (:sym :enqueue_in))
|
11
15
|
MATCHER
|
12
16
|
|
13
17
|
def on_send(node)
|
14
|
-
|
15
|
-
|
18
|
+
if mocking_jobs_enqueue?(node) || mocking_jobs_enqueue_in?(node)
|
19
|
+
add_offense(node, message: MSG)
|
20
|
+
end
|
16
21
|
end
|
17
22
|
end
|
18
23
|
end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
module RuboCop
|
4
4
|
module Cop
|
5
5
|
module Discourse
|
6
|
-
# Use `
|
6
|
+
# Use `eq_time` matcher with timestamps in specs.
|
7
7
|
#
|
8
8
|
# @example
|
9
9
|
# # bad
|
@@ -12,7 +12,7 @@ module RuboCop
|
|
12
12
|
# # good
|
13
13
|
# expect(user.created_at).to eq_time(Time.zone.now)
|
14
14
|
class TimeEqMatcher < Cop
|
15
|
-
MSG = "Use
|
15
|
+
MSG = "Use eq_time when testing timestamps"
|
16
16
|
|
17
17
|
def_node_matcher :using_eq_matcher_with_timestamp?, <<-MATCHER
|
18
18
|
(send
|
data/rubocop-discourse.gemspec
CHANGED
@@ -2,15 +2,17 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = "rubocop-discourse"
|
5
|
-
s.version = "2.
|
5
|
+
s.version = "2.4.2"
|
6
6
|
s.summary = "Custom rubocop cops used by Discourse"
|
7
7
|
s.authors = ["David Taylor"]
|
8
|
-
s.
|
9
|
-
s.
|
8
|
+
s.license = "MIT"
|
9
|
+
s.homepage = "https://github.com/discourse/rubocop-discourse"
|
10
|
+
|
11
|
+
s.files = `git ls-files`.split($/)
|
10
12
|
s.require_paths = ["lib"]
|
11
13
|
|
12
|
-
s.add_runtime_dependency "rubocop", ">=
|
13
|
-
s.add_runtime_dependency "rubocop-rspec", ">=
|
14
|
+
s.add_runtime_dependency "rubocop", ">= 1.1.0"
|
15
|
+
s.add_runtime_dependency "rubocop-rspec", ">= 2.0.0"
|
14
16
|
|
15
17
|
s.add_development_dependency "rake", "~> 13.0"
|
16
18
|
s.add_development_dependency "rspec"
|
data/rubocop-rspec.yml
CHANGED
@@ -99,9 +99,6 @@ RSpec/InstanceSpy:
|
|
99
99
|
RSpec/InstanceVariable:
|
100
100
|
Enabled: false # TODO
|
101
101
|
|
102
|
-
RSpec/InvalidPredicateMatcher:
|
103
|
-
Enabled: true
|
104
|
-
|
105
102
|
RSpec/ItBehavesLike:
|
106
103
|
Enabled: true
|
107
104
|
|
@@ -192,20 +189,20 @@ RSpec/VoidExpect:
|
|
192
189
|
RSpec/Yield:
|
193
190
|
Enabled: true
|
194
191
|
|
195
|
-
Capybara/CurrentPathExpectation:
|
192
|
+
RSpec/Capybara/CurrentPathExpectation:
|
196
193
|
Enabled: true
|
197
194
|
|
198
|
-
Capybara/FeatureMethods:
|
195
|
+
RSpec/Capybara/FeatureMethods:
|
199
196
|
Enabled: true
|
200
197
|
|
201
|
-
FactoryBot/AttributeDefinedStatically:
|
198
|
+
RSpec/FactoryBot/AttributeDefinedStatically:
|
202
199
|
Enabled: true
|
203
200
|
|
204
|
-
FactoryBot/CreateList:
|
201
|
+
RSpec/FactoryBot/CreateList:
|
205
202
|
Enabled: true
|
206
203
|
|
207
|
-
FactoryBot/FactoryClassName:
|
204
|
+
RSpec/FactoryBot/FactoryClassName:
|
208
205
|
Enabled: true
|
209
206
|
|
210
|
-
Rails/HttpStatus:
|
207
|
+
RSpec/Rails/HttpStatus:
|
211
208
|
Enabled: true
|
@@ -9,7 +9,7 @@ describe RuboCop::Cop::Discourse::NoMockingJobs, :config do
|
|
9
9
|
RuboCop::Config.new
|
10
10
|
end
|
11
11
|
|
12
|
-
it "raises an offense if Jobs is mocked" do
|
12
|
+
it "raises an offense if Jobs is mocked with :enqueue" do
|
13
13
|
inspect_source(<<~RUBY)
|
14
14
|
Jobs.expects(:enqueue)
|
15
15
|
RUBY
|
@@ -17,7 +17,15 @@ describe RuboCop::Cop::Discourse::NoMockingJobs, :config do
|
|
17
17
|
expect(cop.offenses.first.message).to eq(described_class::MSG)
|
18
18
|
end
|
19
19
|
|
20
|
-
it "
|
20
|
+
it "raises an offense if Jobs is mocked with :enqueue_in" do
|
21
|
+
inspect_source(<<~RUBY)
|
22
|
+
Jobs.expects(:enqueue_in)
|
23
|
+
RUBY
|
24
|
+
|
25
|
+
expect(cop.offenses.first.message).to eq(described_class::MSG)
|
26
|
+
end
|
27
|
+
|
28
|
+
it "does not raise an offense if Jobs is not mocked with :enqueue or :enqueue_in" do
|
21
29
|
inspect_source(<<~RUBY)
|
22
30
|
Jobs.enqueue(:some_job)
|
23
31
|
RUBY
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubocop-discourse
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Taylor
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-06-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubocop
|
@@ -16,28 +16,28 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 1.1.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 1.1.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rubocop-rspec
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 2.0.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 2.0.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -99,10 +99,10 @@ files:
|
|
99
99
|
- rubocop-discourse.gemspec
|
100
100
|
- rubocop-rspec.yml
|
101
101
|
- spec/lib/rubocop/cop/no_add_reference_active_record_migrations_spec.rb
|
102
|
-
- spec/lib/rubocop/cop/
|
102
|
+
- spec/lib/rubocop/cop/no_mocking_jobs_enqueue_spec.rb
|
103
103
|
- spec/lib/rubocop/cop/no_reset_column_information_migrations_spec.rb
|
104
104
|
- spec/spec_helper.rb
|
105
|
-
homepage:
|
105
|
+
homepage: https://github.com/discourse/rubocop-discourse
|
106
106
|
licenses:
|
107
107
|
- MIT
|
108
108
|
metadata: {}
|