rubocop-discourse 3.1.0 → 3.3.0
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 +1 -1
- data/config/default.yml +16 -16
- data/lib/rubocop/cop/discourse/no_add_reference_active_record_migrations.rb +8 -6
- data/lib/rubocop/cop/discourse/no_direct_multisite_manipulation.rb +2 -1
- data/lib/rubocop/cop/discourse/no_json_parse_response.rb +2 -1
- data/lib/rubocop/cop/discourse/no_mixing_multisite_and_standard_specs.rb +3 -6
- data/lib/rubocop/cop/discourse/no_mocking_jobs.rb +2 -1
- data/lib/rubocop/cop/discourse/no_reset_column_information_in_migrations.rb +5 -4
- data/lib/rubocop/cop/discourse/no_uri_escape_encode.rb +10 -7
- data/lib/rubocop/cop/discourse/only_top_level_multisite_specs.rb +1 -5
- data/lib/rubocop/discourse.rb +3 -3
- data/rubocop-core.yml +4 -0
- data/rubocop-discourse.gemspec +6 -6
- data/rubocop-rspec.yml +15 -15
- data/spec/lib/rubocop/cop/no_add_reference_active_record_migrations_spec.rb +9 -9
- data/spec/lib/rubocop/cop/no_mixing_multisite_and_standard_specs_spec.rb +4 -6
- data/spec/lib/rubocop/cop/no_mocking_jobs_enqueue_spec.rb +4 -6
- data/spec/lib/rubocop/cop/no_reset_column_information_migrations_spec.rb +8 -7
- data/spec/lib/rubocop/cop/only_top_level_multisite_specs_spec.rb +6 -8
- data/spec/lib/rubocop/cop/time_eq_matcher_spec.rb +3 -5
- data/spec/spec_helper.rb +4 -4
- data/stree-compat.yml +8 -8
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c437452f89089230f8ab04486bbe351745b094292c80f838671fdcd33d83bdab
|
4
|
+
data.tar.gz: d4438004c26aee64eff9e6a2f0d335767b412ab2563e5e9d3bdbc1833be1a678
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3a19afd24871782b52660905e0f211287fa41779994c21160baeb5c5e3963ea63482d7ea980ac9398a86b0f40c37056fdf82f982afc851bd6632fc6458d803ed
|
7
|
+
data.tar.gz: 6b6ee9c891637c8c2355bc1cf451d96245960700ef3d8f859a0845ee3a258eae70cf7c85b19493a2d32f7277a69bd4adbc4a16527eaf4e4c1f96509f14fbb64d
|
data/.github/workflows/ci.yml
CHANGED
data/config/default.yml
CHANGED
@@ -13,8 +13,8 @@ Discourse/NoURIEscapeEncode:
|
|
13
13
|
Discourse/NoAddReferenceOrAliasesActiveRecordMigration:
|
14
14
|
Enabled: true
|
15
15
|
Include:
|
16
|
-
|
17
|
-
|
16
|
+
- '**/db/migrate/*'
|
17
|
+
- '**/db/post_migrate/*'
|
18
18
|
|
19
19
|
Discourse/NoNokogiriHtmlFragment:
|
20
20
|
Enabled: true
|
@@ -22,43 +22,43 @@ Discourse/NoNokogiriHtmlFragment:
|
|
22
22
|
Discourse/NoResetColumnInformationInMigrations:
|
23
23
|
Enabled: false
|
24
24
|
Include:
|
25
|
-
|
26
|
-
|
25
|
+
- '**/db/migrate/*'
|
26
|
+
- '**/db/post_migrate/*'
|
27
27
|
|
28
28
|
# Specs
|
29
29
|
|
30
30
|
Discourse/NoDirectMultisiteManipulation:
|
31
31
|
Enabled: true
|
32
32
|
Patterns:
|
33
|
-
|
34
|
-
|
33
|
+
- _spec.rb
|
34
|
+
- '(?:^|/)spec/'
|
35
35
|
|
36
36
|
Discourse/TimeEqMatcher:
|
37
37
|
Enabled: true
|
38
38
|
Patterns:
|
39
|
-
|
40
|
-
|
39
|
+
- _spec.rb
|
40
|
+
- '(?:^|/)spec/'
|
41
41
|
|
42
42
|
Discourse/NoJsonParseResponse:
|
43
43
|
Enabled: false
|
44
44
|
Patterns:
|
45
|
-
|
46
|
-
|
45
|
+
- _spec.rb
|
46
|
+
- '(?:^|/)spec/'
|
47
47
|
|
48
48
|
Discourse/NoMockingJobs:
|
49
49
|
Enabled: true
|
50
50
|
Patterns:
|
51
|
-
|
52
|
-
|
51
|
+
- _spec.rb
|
52
|
+
- '(?:^|/)spec/'
|
53
53
|
|
54
54
|
Discourse/OnlyTopLevelMultisiteSpecs:
|
55
55
|
Enabled: true
|
56
56
|
Patterns:
|
57
|
-
|
58
|
-
|
57
|
+
- _spec.rb
|
58
|
+
- '(?:^|/)spec/'
|
59
59
|
|
60
60
|
Discourse/NoMixingMultisiteAndStandardSpecs:
|
61
61
|
Enabled: true
|
62
62
|
Patterns:
|
63
|
-
|
64
|
-
|
63
|
+
- _spec.rb
|
64
|
+
- '(?:^|/)spec/'
|
@@ -70,12 +70,14 @@ module RuboCop
|
|
70
70
|
MATCHER
|
71
71
|
|
72
72
|
def on_send(node)
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
73
|
+
if [
|
74
|
+
using_add_reference?(node),
|
75
|
+
using_add_belongs_to?(node),
|
76
|
+
using_t_references?(node),
|
77
|
+
using_t_belongs_to?(node)
|
78
|
+
].none?
|
79
|
+
return
|
80
|
+
end
|
79
81
|
add_offense(node, message: MSG)
|
80
82
|
end
|
81
83
|
end
|
@@ -17,7 +17,8 @@ module RuboCop
|
|
17
17
|
# do_something
|
18
18
|
# end
|
19
19
|
class NoDirectMultisiteManipulation < Cop
|
20
|
-
MSG =
|
20
|
+
MSG =
|
21
|
+
"Use `type: :multisite` example setting instead of modifying `Rails.configuration.multisite`."
|
21
22
|
|
22
23
|
def_node_matcher :multisite_setter?, <<-MATCHER
|
23
24
|
(send
|
@@ -12,7 +12,8 @@ module RuboCop
|
|
12
12
|
# # good
|
13
13
|
# expect(response.parsed_body).to eq({})
|
14
14
|
class NoJsonParseResponse < Cop
|
15
|
-
MSG =
|
15
|
+
MSG =
|
16
|
+
"Use `response.parsed_body` instead of `JSON.parse(response.body)` in specs."
|
16
17
|
|
17
18
|
def_node_matcher :json_parse_body?, <<-MATCHER
|
18
19
|
(send
|
@@ -24,7 +24,8 @@ module RuboCop
|
|
24
24
|
# describe "x", type: :multisite do
|
25
25
|
# end
|
26
26
|
class NoMixingMultisiteAndStandardSpecs < Cop
|
27
|
-
MSG =
|
27
|
+
MSG =
|
28
|
+
"Do not mix multisite and standard specs. Consider moving multisite describes to a separate file."
|
28
29
|
|
29
30
|
def initialize(config = nil, options = nil)
|
30
31
|
super
|
@@ -64,11 +65,7 @@ module RuboCop
|
|
64
65
|
MATCHER
|
65
66
|
|
66
67
|
def top_level?(node)
|
67
|
-
|
68
|
-
node.parent.root?
|
69
|
-
else
|
70
|
-
node.root?
|
71
|
-
end
|
68
|
+
node.parent&.begin_type? ? node.parent.root? : node.root?
|
72
69
|
end
|
73
70
|
end
|
74
71
|
end
|
@@ -4,7 +4,8 @@ module RuboCop
|
|
4
4
|
module Cop
|
5
5
|
module Discourse
|
6
6
|
class NoMockingJobs < Cop
|
7
|
-
MSG =
|
7
|
+
MSG =
|
8
|
+
"Use the test helpers provided by Sidekiq instead of mocking `Jobs.expects(:enqueue)`."
|
8
9
|
|
9
10
|
def_node_matcher :mocking_jobs_enqueue?, <<~MATCHER
|
10
11
|
(send (const nil? :Jobs) :expects (:sym :enqueue))
|
@@ -8,10 +8,11 @@ module RuboCop
|
|
8
8
|
# concurrently for multisites. Also, we don't encourage the use of
|
9
9
|
# ActiveRecord methods in migrations and prefer to write SQL directly.
|
10
10
|
class NoResetColumnInformationInMigrations < Cop
|
11
|
-
MSG =
|
12
|
-
"
|
13
|
-
|
14
|
-
|
11
|
+
MSG =
|
12
|
+
"ActiveRecord::ModelSchema.reset_column_information is not thread-safe " \
|
13
|
+
"and we run migrations concurrently on multisite clusters. Using this " \
|
14
|
+
"method also means ActiveRecord methods are being used in migration " \
|
15
|
+
"which is discouraged at Discourse. Instead, you should write SQL in your migrations instead."
|
15
16
|
|
16
17
|
def on_send(node)
|
17
18
|
return if node.method_name != :reset_column_information
|
@@ -16,7 +16,8 @@ module RuboCop
|
|
16
16
|
# UrlHelper.encode("https://a%20a.com?a='a%22")
|
17
17
|
# Addressable::URI.encode("https://a%20a.com?a='a%22")
|
18
18
|
class NoURIEscapeEncode < Cop
|
19
|
-
MSG =
|
19
|
+
MSG =
|
20
|
+
"URI.escape, URI.encode, URI.unescape, URI.decode are deprecated and should not be used."
|
20
21
|
|
21
22
|
def_node_matcher :using_uri_escape?, <<-MATCHER
|
22
23
|
(send (const nil? :URI) :escape ...)
|
@@ -35,12 +36,14 @@ module RuboCop
|
|
35
36
|
MATCHER
|
36
37
|
|
37
38
|
def on_send(node)
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
39
|
+
if [
|
40
|
+
using_uri_escape?(node),
|
41
|
+
using_uri_encode?(node),
|
42
|
+
using_uri_unescape?(node),
|
43
|
+
using_uri_decode?(node)
|
44
|
+
].none?
|
45
|
+
return
|
46
|
+
end
|
44
47
|
add_offense(node, message: MSG)
|
45
48
|
end
|
46
49
|
end
|
data/lib/rubocop/discourse.rb
CHANGED
@@ -3,9 +3,9 @@
|
|
3
3
|
module RuboCop
|
4
4
|
# RuboCop Discourse project namespace
|
5
5
|
module Discourse
|
6
|
-
PROJECT_ROOT
|
7
|
-
CONFIG_DEFAULT = PROJECT_ROOT.join(
|
8
|
-
CONFIG
|
6
|
+
PROJECT_ROOT = Pathname.new(__dir__).parent.parent.expand_path.freeze
|
7
|
+
CONFIG_DEFAULT = PROJECT_ROOT.join("config", "default.yml").freeze
|
8
|
+
CONFIG = YAML.safe_load(CONFIG_DEFAULT.read).freeze
|
9
9
|
|
10
10
|
private_constant(:CONFIG_DEFAULT, :PROJECT_ROOT)
|
11
11
|
end
|
data/rubocop-core.yml
CHANGED
@@ -4,6 +4,9 @@ Security:
|
|
4
4
|
Security/IoMethods:
|
5
5
|
Enabled: true
|
6
6
|
|
7
|
+
Security/CompoundHash:
|
8
|
+
Enabled: true
|
9
|
+
|
7
10
|
# Prefer &&/|| over and/or.
|
8
11
|
Style/AndOr:
|
9
12
|
Enabled: true
|
@@ -14,6 +17,7 @@ Style/FrozenStringLiteralComment:
|
|
14
17
|
# Use Ruby >= 1.9 syntax for hashes. Prefer { a: :b } over { :a => :b }.
|
15
18
|
Style/HashSyntax:
|
16
19
|
Enabled: true
|
20
|
+
EnforcedShorthandSyntax: either
|
17
21
|
|
18
22
|
# Defining a method with parameters needs parentheses.
|
19
23
|
Style/MethodDefParentheses:
|
data/rubocop-discourse.gemspec
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
|
-
s.name
|
5
|
-
s.version
|
6
|
-
s.summary
|
7
|
-
s.authors
|
8
|
-
s.license
|
9
|
-
s.homepage
|
4
|
+
s.name = "rubocop-discourse"
|
5
|
+
s.version = "3.3.0"
|
6
|
+
s.summary = "Custom rubocop cops used by Discourse"
|
7
|
+
s.authors = ["Discourse Team"]
|
8
|
+
s.license = "MIT"
|
9
|
+
s.homepage = "https://github.com/discourse/rubocop-discourse"
|
10
10
|
|
11
11
|
s.files = `git ls-files`.split($/)
|
12
12
|
s.require_paths = ["lib"]
|
data/rubocop-rspec.yml
CHANGED
@@ -31,17 +31,17 @@ RSpec/ContextWording:
|
|
31
31
|
RSpec/DescribeClass:
|
32
32
|
Enabled: true
|
33
33
|
Exclude:
|
34
|
-
-
|
35
|
-
-
|
36
|
-
-
|
37
|
-
-
|
38
|
-
-
|
39
|
-
-
|
40
|
-
-
|
41
|
-
-
|
42
|
-
-
|
43
|
-
-
|
44
|
-
-
|
34
|
+
- '**/spec/features/**/*'
|
35
|
+
- '**/spec/requests/**/*'
|
36
|
+
- '**/spec/routing/**/*'
|
37
|
+
- '**/spec/system/**/*'
|
38
|
+
- '**/spec/views/**/*'
|
39
|
+
- '**/spec/initializers/**/*'
|
40
|
+
- '**/spec/integration/**/*'
|
41
|
+
- '**/spec/integrity/**/*'
|
42
|
+
- '**/spec/tasks/**/*'
|
43
|
+
- '**/spec/lib/freedom_patches/**/*'
|
44
|
+
- '**/spec/multisite/**/*'
|
45
45
|
|
46
46
|
RSpec/DescribeMethod:
|
47
47
|
Enabled: true
|
@@ -73,7 +73,7 @@ RSpec/EmptyLineAfterHook:
|
|
73
73
|
Enabled: false # TODO
|
74
74
|
|
75
75
|
RSpec/EmptyLineAfterSubject:
|
76
|
-
Enabled:
|
76
|
+
Enabled: true
|
77
77
|
|
78
78
|
RSpec/ExampleLength:
|
79
79
|
Enabled: false # To be decided
|
@@ -130,7 +130,7 @@ RSpec/IteratedExpectation:
|
|
130
130
|
Enabled: false # To be decided
|
131
131
|
|
132
132
|
RSpec/LeadingSubject:
|
133
|
-
Enabled:
|
133
|
+
Enabled: true
|
134
134
|
|
135
135
|
RSpec/LeakyConstantDeclaration:
|
136
136
|
Enabled: false # To be decided
|
@@ -157,7 +157,7 @@ RSpec/MultipleSubjects:
|
|
157
157
|
Enabled: true
|
158
158
|
|
159
159
|
RSpec/NamedSubject:
|
160
|
-
Enabled:
|
160
|
+
Enabled: true
|
161
161
|
|
162
162
|
RSpec/NestedGroups:
|
163
163
|
Enabled: false # To be decided
|
@@ -213,7 +213,7 @@ RSpec/VoidExpect:
|
|
213
213
|
RSpec/Yield:
|
214
214
|
Enabled: true
|
215
215
|
|
216
|
-
|
216
|
+
Capybara/CurrentPathExpectation:
|
217
217
|
Enabled: true
|
218
218
|
|
219
219
|
RSpec/Capybara/FeatureMethods:
|
@@ -1,25 +1,25 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "spec_helper"
|
4
4
|
|
5
|
-
describe RuboCop::Cop::Discourse::NoAddReferenceOrAliasesActiveRecordMigration,
|
5
|
+
describe RuboCop::Cop::Discourse::NoAddReferenceOrAliasesActiveRecordMigration,
|
6
|
+
:config do
|
6
7
|
subject(:cop) { described_class.new(config) }
|
7
|
-
|
8
|
-
|
9
|
-
end
|
8
|
+
|
9
|
+
let(:config) { RuboCop::Config.new }
|
10
10
|
|
11
11
|
it "raises an offense if add_reference is used, with or without arguments" do
|
12
12
|
inspect_source(<<~RUBY)
|
13
13
|
add_reference :posts, :users, foreign_key: true, null: false
|
14
14
|
RUBY
|
15
|
-
expect(cop.offenses.first.message).to
|
15
|
+
expect(cop.offenses.first.message).to match(described_class::MSG)
|
16
16
|
end
|
17
17
|
|
18
18
|
it "raises an offense if add_belongs_to is used, with or without arguments" do
|
19
19
|
inspect_source(<<~RUBY)
|
20
20
|
add_belongs_to :posts, :users, foreign_key: true, null: false
|
21
21
|
RUBY
|
22
|
-
expect(cop.offenses.first.message).to
|
22
|
+
expect(cop.offenses.first.message).to match(described_class::MSG)
|
23
23
|
end
|
24
24
|
|
25
25
|
it "raises an offense if t.references, or any variable.references is used, with or without arguments" do
|
@@ -32,7 +32,7 @@ describe RuboCop::Cop::Discourse::NoAddReferenceOrAliasesActiveRecordMigration,
|
|
32
32
|
end
|
33
33
|
RUBY
|
34
34
|
expect(cop.offenses.count).to eq(2)
|
35
|
-
expect(cop.offenses.first.message).to
|
35
|
+
expect(cop.offenses.first.message).to match(described_class::MSG)
|
36
36
|
end
|
37
37
|
|
38
38
|
it "raises an offense if t.belongs_to, or any variable.belongs_to is used, with or without arguments" do
|
@@ -45,6 +45,6 @@ describe RuboCop::Cop::Discourse::NoAddReferenceOrAliasesActiveRecordMigration,
|
|
45
45
|
end
|
46
46
|
RUBY
|
47
47
|
expect(cop.offenses.count).to eq(2)
|
48
|
-
expect(cop.offenses.first.message).to
|
48
|
+
expect(cop.offenses.first.message).to match(described_class::MSG)
|
49
49
|
end
|
50
50
|
end
|
@@ -1,13 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "spec_helper"
|
4
4
|
|
5
5
|
describe RuboCop::Cop::Discourse::NoMixingMultisiteAndStandardSpecs, :config do
|
6
6
|
subject(:cop) { described_class.new(config) }
|
7
7
|
|
8
|
-
let(:config)
|
9
|
-
RuboCop::Config.new
|
10
|
-
end
|
8
|
+
let(:config) { RuboCop::Config.new }
|
11
9
|
|
12
10
|
it "raises an offense if there are multisite and standard top-level describes" do
|
13
11
|
inspect_source(<<~RUBY)
|
@@ -18,7 +16,7 @@ describe RuboCop::Cop::Discourse::NoMixingMultisiteAndStandardSpecs, :config do
|
|
18
16
|
end
|
19
17
|
RUBY
|
20
18
|
|
21
|
-
expect(cop.offenses.first.message).to
|
19
|
+
expect(cop.offenses.first.message).to match(described_class::MSG)
|
22
20
|
end
|
23
21
|
|
24
22
|
it "raises an offense if there are multiple multisite and standard top-level describes" do
|
@@ -33,7 +31,7 @@ describe RuboCop::Cop::Discourse::NoMixingMultisiteAndStandardSpecs, :config do
|
|
33
31
|
end
|
34
32
|
RUBY
|
35
33
|
|
36
|
-
expect(cop.offenses.first.message).to
|
34
|
+
expect(cop.offenses.first.message).to match(described_class::MSG)
|
37
35
|
end
|
38
36
|
|
39
37
|
it "does not raise an offense if there are only multisite describes" do
|
@@ -1,20 +1,18 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "spec_helper"
|
4
4
|
|
5
5
|
describe RuboCop::Cop::Discourse::NoMockingJobs, :config do
|
6
6
|
subject(:cop) { described_class.new(config) }
|
7
7
|
|
8
|
-
let(:config)
|
9
|
-
RuboCop::Config.new
|
10
|
-
end
|
8
|
+
let(:config) { RuboCop::Config.new }
|
11
9
|
|
12
10
|
it "raises an offense if Jobs is mocked with :enqueue" do
|
13
11
|
inspect_source(<<~RUBY)
|
14
12
|
Jobs.expects(:enqueue)
|
15
13
|
RUBY
|
16
14
|
|
17
|
-
expect(cop.offenses.first.message).to
|
15
|
+
expect(cop.offenses.first.message).to end_with(described_class::MSG)
|
18
16
|
end
|
19
17
|
|
20
18
|
it "raises an offense if Jobs is mocked with :enqueue_in" do
|
@@ -22,7 +20,7 @@ describe RuboCop::Cop::Discourse::NoMockingJobs, :config do
|
|
22
20
|
Jobs.expects(:enqueue_in)
|
23
21
|
RUBY
|
24
22
|
|
25
|
-
expect(cop.offenses.first.message).to
|
23
|
+
expect(cop.offenses.first.message).to end_with(described_class::MSG)
|
26
24
|
end
|
27
25
|
|
28
26
|
it "does not raise an offense if Jobs is not mocked with :enqueue or :enqueue_in" do
|
@@ -1,13 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "spec_helper"
|
4
4
|
|
5
|
-
describe RuboCop::Cop::Discourse::NoResetColumnInformationInMigrations,
|
5
|
+
describe RuboCop::Cop::Discourse::NoResetColumnInformationInMigrations,
|
6
|
+
:config do
|
6
7
|
subject(:cop) { described_class.new(config) }
|
7
8
|
|
8
|
-
let(:config)
|
9
|
-
|
10
|
-
|
9
|
+
let(:config) { RuboCop::Config.new }
|
10
|
+
|
11
|
+
before { config["Discourse/NoResetColumnInformationInMigrations"]["Enabled"] = true }
|
11
12
|
|
12
13
|
it "raises an offense if reset_column_information is used" do
|
13
14
|
inspect_source(<<~RUBY)
|
@@ -18,7 +19,7 @@ describe RuboCop::Cop::Discourse::NoResetColumnInformationInMigrations, :config
|
|
18
19
|
end
|
19
20
|
RUBY
|
20
21
|
|
21
|
-
expect(cop.offenses.first.message).to
|
22
|
+
expect(cop.offenses.first.message).to match(described_class::MSG)
|
22
23
|
end
|
23
24
|
|
24
25
|
it "raise an offense if reset_column_information is used without AR model" do
|
@@ -30,6 +31,6 @@ describe RuboCop::Cop::Discourse::NoResetColumnInformationInMigrations, :config
|
|
30
31
|
end
|
31
32
|
RUBY
|
32
33
|
|
33
|
-
expect(cop.offenses.first.message).to
|
34
|
+
expect(cop.offenses.first.message).to match(described_class::MSG)
|
34
35
|
end
|
35
36
|
end
|
@@ -1,13 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "spec_helper"
|
4
4
|
|
5
5
|
describe RuboCop::Cop::Discourse::OnlyTopLevelMultisiteSpecs, :config do
|
6
6
|
subject(:cop) { described_class.new(config) }
|
7
7
|
|
8
|
-
let(:config)
|
9
|
-
RuboCop::Config.new
|
10
|
-
end
|
8
|
+
let(:config) { RuboCop::Config.new }
|
11
9
|
|
12
10
|
it "raises an offense if multisite config option is used in a sub-describe" do
|
13
11
|
inspect_source(<<~RUBY)
|
@@ -17,7 +15,7 @@ describe RuboCop::Cop::Discourse::OnlyTopLevelMultisiteSpecs, :config do
|
|
17
15
|
end
|
18
16
|
RUBY
|
19
17
|
|
20
|
-
expect(cop.offenses.first.message).to
|
18
|
+
expect(cop.offenses.first.message).to match(described_class::MSG)
|
21
19
|
end
|
22
20
|
|
23
21
|
it "raises an offense if multisite config option is used in a sub-describe (RSpec const version)" do
|
@@ -28,7 +26,7 @@ describe RuboCop::Cop::Discourse::OnlyTopLevelMultisiteSpecs, :config do
|
|
28
26
|
end
|
29
27
|
RUBY
|
30
28
|
|
31
|
-
expect(cop.offenses.first.message).to
|
29
|
+
expect(cop.offenses.first.message).to match(described_class::MSG)
|
32
30
|
end
|
33
31
|
|
34
32
|
it "raises an offense if multisite config option is used in an example" do
|
@@ -42,7 +40,7 @@ describe RuboCop::Cop::Discourse::OnlyTopLevelMultisiteSpecs, :config do
|
|
42
40
|
end
|
43
41
|
RUBY
|
44
42
|
|
45
|
-
expect(cop.offenses.first.message).to
|
43
|
+
expect(cop.offenses.first.message).to match(described_class::MSG)
|
46
44
|
end
|
47
45
|
|
48
46
|
it "raises an offense if multisite config option is used in a context" do
|
@@ -53,7 +51,7 @@ describe RuboCop::Cop::Discourse::OnlyTopLevelMultisiteSpecs, :config do
|
|
53
51
|
end
|
54
52
|
RUBY
|
55
53
|
|
56
|
-
expect(cop.offenses.first.message).to
|
54
|
+
expect(cop.offenses.first.message).to match(described_class::MSG)
|
57
55
|
end
|
58
56
|
|
59
57
|
it "does not raise an offense if multisite config option is used on top-level describe" do
|
@@ -1,20 +1,18 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "spec_helper"
|
4
4
|
|
5
5
|
describe RuboCop::Cop::Discourse::TimeEqMatcher, :config do
|
6
6
|
subject(:cop) { described_class.new(config) }
|
7
7
|
|
8
|
-
let(:config)
|
9
|
-
RuboCop::Config.new
|
10
|
-
end
|
8
|
+
let(:config) { RuboCop::Config.new }
|
11
9
|
|
12
10
|
it "raises an offense if a timestamp is compared using `eq`" do
|
13
11
|
inspect_source(<<~RUBY)
|
14
12
|
expect(user.created_at).to eq(Time.zone.now)
|
15
13
|
RUBY
|
16
14
|
|
17
|
-
expect(cop.offenses.first.message).to
|
15
|
+
expect(cop.offenses.first.message).to match(described_class::MSG)
|
18
16
|
end
|
19
17
|
|
20
18
|
it "passes if a timestamp is compared using `eq_time`" do
|
data/spec/spec_helper.rb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "bundler/setup"
|
4
4
|
Bundler.setup
|
5
5
|
|
6
6
|
# Require supporting files exposed for testing.
|
7
|
-
require
|
8
|
-
require
|
7
|
+
require "rubocop"
|
8
|
+
require "rubocop/rspec/support"
|
9
9
|
|
10
|
-
require
|
10
|
+
require "rubocop-discourse" # and any other gems you need
|
11
11
|
|
12
12
|
RSpec.configure do |config|
|
13
13
|
config.include RuboCop::RSpec::ExpectOffense
|
data/stree-compat.yml
CHANGED
@@ -6,16 +6,16 @@ inherit_from:
|
|
6
6
|
- ./rubocop-rspec.yml
|
7
7
|
|
8
8
|
AllCops:
|
9
|
-
TargetRubyVersion: 2
|
9
|
+
TargetRubyVersion: 3.2
|
10
10
|
DisabledByDefault: true
|
11
11
|
Exclude:
|
12
|
-
-
|
13
|
-
-
|
14
|
-
-
|
15
|
-
-
|
16
|
-
-
|
17
|
-
-
|
18
|
-
-
|
12
|
+
- 'db/schema.rb'
|
13
|
+
- 'bundle/**/*'
|
14
|
+
- 'vendor/**/*'
|
15
|
+
- '**/node_modules/**/*'
|
16
|
+
- 'public/**/*'
|
17
|
+
- 'plugins/**/gems/**/*'
|
18
|
+
- 'plugins/**/vendor/**/*'
|
19
19
|
|
20
20
|
Discourse:
|
21
21
|
Enabled: true
|
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: 3.
|
4
|
+
version: 3.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Discourse Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-06-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubocop
|