rubocop-discourse 2.1.0 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -19
- data/README.md +1 -1
- data/config/default.yml +17 -3
- data/default.yml +20 -0
- data/lib/rubocop/cop/discourse/no_json_parse_response.rb +38 -0
- data/rubocop-discourse.gemspec +1 -1
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d87c5bc1d76fa5c4d785017af0f514bfd836d0a35a5b3ecb35d34c3c08f311b1
|
4
|
+
data.tar.gz: 9469659b2155d8acb12d82ce1a7bca26771862cd16975c520f8e86028f96918d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cf4d58947738c5c37cc396579058bab0241cbd5dc7d3c654be92c74fca0b4fe51fcb892f8f590738aaa4f93a76fc431632fefa50bd1994eb82b5cab989decd83
|
7
|
+
data.tar.gz: 291d805bc86a3bca91c6e32d547c8ae27bcce4335a00922ed9da22bd3d0c4cbaa2df991b8ff7c2f17a222c9fea41452c5cc9ba9f736f7d910b1c677d44978b92
|
data/.rubocop.yml
CHANGED
@@ -1,20 +1,2 @@
|
|
1
|
-
require:
|
2
|
-
- rubocop-discourse
|
3
|
-
|
4
1
|
inherit_from:
|
5
|
-
-
|
6
|
-
- ./rubocop-rspec.yml
|
7
|
-
|
8
|
-
AllCops:
|
9
|
-
TargetRubyVersion: 2.6
|
10
|
-
DisabledByDefault: true
|
11
|
-
Exclude:
|
12
|
-
- "db/schema.rb"
|
13
|
-
- "bundle/**/*"
|
14
|
-
- "vendor/**/*"
|
15
|
-
- "node_modules/**/*"
|
16
|
-
- "public/**/*"
|
17
|
-
- "plugins/**/gems/**/*"
|
18
|
-
|
19
|
-
Discourse:
|
20
|
-
Enabled: true
|
2
|
+
- default.yml
|
data/README.md
CHANGED
data/config/default.yml
CHANGED
@@ -4,14 +4,28 @@ Discourse/NoChdir:
|
|
4
4
|
- 'spec/**/*' # Specs are run sequentially, so chdir can be used
|
5
5
|
- 'plugins/*/spec/**/*'
|
6
6
|
|
7
|
-
Discourse/NoDirectMultisiteManipulation:
|
8
|
-
Enabled: true
|
9
|
-
|
10
7
|
Discourse/NoTimeNewWithoutArgs:
|
11
8
|
Enabled: true
|
12
9
|
|
13
10
|
Discourse/NoUriEscapeEncode:
|
14
11
|
Enabled: true
|
15
12
|
|
13
|
+
# Specs
|
14
|
+
|
15
|
+
Discourse/NoDirectMultisiteManipulation:
|
16
|
+
Enabled: true
|
17
|
+
Patterns:
|
18
|
+
- _spec.rb
|
19
|
+
- "(?:^|/)spec/"
|
20
|
+
|
16
21
|
Discourse/TimeEqMatcher:
|
17
22
|
Enabled: true
|
23
|
+
Patterns:
|
24
|
+
- _spec.rb
|
25
|
+
- "(?:^|/)spec/"
|
26
|
+
|
27
|
+
Discourse/NoJsonParseResponse:
|
28
|
+
Enabled: true
|
29
|
+
Patterns:
|
30
|
+
- _spec.rb
|
31
|
+
- "(?:^|/)spec/"
|
data/default.yml
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require:
|
2
|
+
- rubocop-discourse
|
3
|
+
|
4
|
+
inherit_from:
|
5
|
+
- ./rubocop-core.yml
|
6
|
+
- ./rubocop-rspec.yml
|
7
|
+
|
8
|
+
AllCops:
|
9
|
+
TargetRubyVersion: 2.6
|
10
|
+
DisabledByDefault: true
|
11
|
+
Exclude:
|
12
|
+
- "db/schema.rb"
|
13
|
+
- "bundle/**/*"
|
14
|
+
- "vendor/**/*"
|
15
|
+
- "node_modules/**/*"
|
16
|
+
- "public/**/*"
|
17
|
+
- "plugins/**/gems/**/*"
|
18
|
+
|
19
|
+
Discourse:
|
20
|
+
Enabled: true
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module Cop
|
5
|
+
module Discourse
|
6
|
+
# Use `response.parsed_body` instead of `JSON.parse(response.body)` in specs.
|
7
|
+
#
|
8
|
+
# @example
|
9
|
+
# # bad
|
10
|
+
# expect(::JSON.parse(response.body)).to eq({})
|
11
|
+
#
|
12
|
+
# # good
|
13
|
+
# expect(response.parsed_body).to eq({})
|
14
|
+
class NoJsonParseResponse < Cop
|
15
|
+
MSG = "Use `response.parsed_body` instead of `JSON.parse(response.body)` in specs."
|
16
|
+
|
17
|
+
def_node_matcher :json_parse_body?, <<-MATCHER
|
18
|
+
(send
|
19
|
+
(const {cbase nil?} :JSON) :parse
|
20
|
+
(send
|
21
|
+
(send nil? :response) :body))
|
22
|
+
MATCHER
|
23
|
+
|
24
|
+
def on_send(node)
|
25
|
+
return unless json_parse_body?(node)
|
26
|
+
|
27
|
+
add_offense(node, message: MSG)
|
28
|
+
end
|
29
|
+
|
30
|
+
def autocorrect(node)
|
31
|
+
lambda do |corrector|
|
32
|
+
corrector.replace(node.loc.expression, "response.parsed_body")
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
data/rubocop-discourse.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubocop-discourse
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Taylor
|
@@ -66,9 +66,11 @@ files:
|
|
66
66
|
- README.md
|
67
67
|
- Rakefile
|
68
68
|
- config/default.yml
|
69
|
+
- default.yml
|
69
70
|
- lib/rubocop-discourse.rb
|
70
71
|
- lib/rubocop/cop/discourse/no_chdir.rb
|
71
72
|
- lib/rubocop/cop/discourse/no_direct_multisite_manipulation.rb
|
73
|
+
- lib/rubocop/cop/discourse/no_json_parse_response.rb
|
72
74
|
- lib/rubocop/cop/discourse/no_time_new_without_args.rb
|
73
75
|
- lib/rubocop/cop/discourse/no_uri_escape_encode.rb
|
74
76
|
- lib/rubocop/cop/discourse/time_eq_matcher.rb
|