ezcater_rubocop 0.52.4 → 0.52.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +4 -0
- data/README.md +1 -0
- data/lib/ezcater_rubocop.rb +1 -0
- data/lib/ezcater_rubocop/version.rb +1 -1
- data/lib/rubocop/cop/ezcater/rspec_match_ordered_array.rb +45 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 36a6c9f976b293c7d962dcc016e7ce4578f61a91
|
4
|
+
data.tar.gz: 3329ea5257d891dc1cf54a724f8401c2db5d634f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dfd4b6760cf5084baf9e066065acf65c30894ede346426e92a5e93209caf673acf463b3eee7ab9b58ae835108f4e538537022c5714cb406f8b4de743e3adbd5d
|
7
|
+
data.tar.gz: 32228db40690919db39fd4e6c24c9727e74c254a48425cc5716003d71f922551bf561fa32ad66ea08d1fc6bd47a5a01c66d910c1fb0c0ce37ca70c634c8cbe5a
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -86,6 +86,7 @@ is updated.
|
|
86
86
|
1. [RailsConfiguration](https://github.com/ezcater/ezcater_rubocop/blob/master/lib/rubocop/cop/ezcater/rails_configuration.rb) - Enforce use of `Rails.configuration` instead of `Rails.application.config`.
|
87
87
|
1. [RequireGqlErrorHelpers](https://github.com/ezcater/ezcater_rubocop/blob/master/lib/rubocop/cop/ezcater/require_gql_error_helpers.rb) - Use the helpers provided by `GQLErrors` instead of raising `GraphQL::ExecutionError` directly.
|
88
88
|
1. [RspecDotNotSelfDot](https://github.com/ezcater/ezcater_rubocop/blob/master/lib/rubocop/cop/ezcater/rspec_dot_not_self_dot.rb) - Enforce ".<class method>" instead of "self.<class method>" for example group description.
|
89
|
+
1. [RspecMatchOrderedArray](https://github.com/ezcater/ezcater_rubocop/blob/master/lib/rubocop/cop/ezcater/rspec_match_ordered_array.rb) - Enforce use of `match_ordered_array` matcher instead of `eq` matcher. This matcher comes from the [ezcater_matchers](https://github.com/ezcater/ezcater_matchers) gem.
|
89
90
|
1. [RspecRequireBrowserMock](https://github.com/ezcater/ezcater_rubocop/blob/master/lib/rubocop/cop/ezcater/rspec_require_browser_mock.rb) - Enforce use of `mock_ezcater_app`, `mock_chrome_browser` & `mock_custom_browser` helpers instead of mocking `Browser` or `EzBrowser` directly.
|
90
91
|
1. [RspecRequireFeatureFlagMock](https://github.com/ezcater/ezcater_rubocop/blob/master/lib/rubocop/cop/ezcater/rspec_require_feature_flag_mock.rb) - Enforce use of `mock_feature_flag` helper instead of mocking `FeatureFlag.is_active?` directly.
|
91
92
|
1. [StyleDig](https://github.com/ezcater/ezcater_rubocop/blob/master/lib/rubocop/cop/ezcater/style_dig.rb) - Recommend `dig` for deeply nested access.
|
data/lib/ezcater_rubocop.rb
CHANGED
@@ -15,6 +15,7 @@ RuboCop::ConfigLoader.instance_variable_set(:@default_configuration, config)
|
|
15
15
|
require "rubocop/cop/ezcater/private_attr"
|
16
16
|
require "rubocop/cop/ezcater/rails_configuration"
|
17
17
|
require "rubocop/cop/ezcater/require_gql_error_helpers"
|
18
|
+
require "rubocop/cop/ezcater/rspec_match_ordered_array"
|
18
19
|
require "rubocop/cop/ezcater/rspec_require_browser_mock"
|
19
20
|
require "rubocop/cop/ezcater/rspec_require_feature_flag_mock"
|
20
21
|
require "rubocop/cop/ezcater/rspec_dot_not_self_dot"
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module RuboCop
|
2
|
+
module Cop
|
3
|
+
module Ezcater
|
4
|
+
# Enforce use of `match_ordered_array` matcher instead of using `eq` matcher
|
5
|
+
#
|
6
|
+
# @example
|
7
|
+
#
|
8
|
+
# # good
|
9
|
+
# expect(foo).to match_ordered_array([1, 2, 3])
|
10
|
+
# expect(foo).to match_ordered_array [1, 2, 3]
|
11
|
+
#
|
12
|
+
# # bad
|
13
|
+
# expect(foo).to eq([1, 2, 3])
|
14
|
+
# expect(foo).to eq [1, 2, 3]
|
15
|
+
class RspecMatchOrderedArray < Cop
|
16
|
+
MATCH_ORDERED_ARRAY = "match_ordered_array".freeze
|
17
|
+
MSG = "Use the `match_ordered_array` matcher from ezcater_matchers gem "\
|
18
|
+
"instead of `eq` when comparing collections".freeze
|
19
|
+
|
20
|
+
def_node_matcher "eq_array", <<~PATTERN
|
21
|
+
(send nil? :eq (array ...))
|
22
|
+
PATTERN
|
23
|
+
|
24
|
+
def on_send(node)
|
25
|
+
eq_array(node) do
|
26
|
+
add_offense(node, location: :expression, message: MSG)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def autocorrect(node)
|
31
|
+
lambda do |corrector|
|
32
|
+
corrector.replace(
|
33
|
+
Parser::Source::Range.new(
|
34
|
+
node.source_range.source_buffer,
|
35
|
+
node.source_range.begin_pos,
|
36
|
+
node.source_range.begin_pos + 2
|
37
|
+
),
|
38
|
+
MATCH_ORDERED_ARRAY
|
39
|
+
)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ezcater_rubocop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.52.
|
4
|
+
version: 0.52.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ezCater, Inc
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-04-
|
11
|
+
date: 2018-04-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -131,6 +131,7 @@ files:
|
|
131
131
|
- lib/rubocop/cop/ezcater/rails_configuration.rb
|
132
132
|
- lib/rubocop/cop/ezcater/require_gql_error_helpers.rb
|
133
133
|
- lib/rubocop/cop/ezcater/rspec_dot_not_self_dot.rb
|
134
|
+
- lib/rubocop/cop/ezcater/rspec_match_ordered_array.rb
|
134
135
|
- lib/rubocop/cop/ezcater/rspec_require_browser_mock.rb
|
135
136
|
- lib/rubocop/cop/ezcater/rspec_require_feature_flag_mock.rb
|
136
137
|
- lib/rubocop/cop/ezcater/style_dig.rb
|
@@ -156,7 +157,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
156
157
|
version: '0'
|
157
158
|
requirements: []
|
158
159
|
rubyforge_project:
|
159
|
-
rubygems_version: 2.
|
160
|
+
rubygems_version: 2.6.11
|
160
161
|
signing_key:
|
161
162
|
specification_version: 4
|
162
163
|
summary: ezCater custom cops and shared configuration
|