ezcater_rubocop 0.49.7 → 0.50.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA256:
3
- metadata.gz: 01b8ae39e587051553ed1979e7410bebe28b49255fed22ab2f172309062de15c
4
- data.tar.gz: 47f5fe4870214a610c829a34d5e24f0d2a82465a1ff87fb2afe29318f51cdf4b
2
+ SHA1:
3
+ metadata.gz: 506db29e071d65b4cdb7f397b5b5d4a9251ec56f
4
+ data.tar.gz: ae1917de476959e962b786408bf788bae33ad31d
5
5
  SHA512:
6
- metadata.gz: 554df818dd198c62de1b9e24484b01f79da68b1a1df53fdfe33f655391ffb3bd913cd67ec7264e44fc0fff1a65bee7aa997a2b64b6133b8ae8f43fb10c3d7584
7
- data.tar.gz: 32441e5bd8a5352e79acdeb7167855c026cde646ebb820ec2a2b9762fc091aa6dcb89c4bdecc31b08b7f77d1ec74fb905d05283e683c309e6292f9e26a099d31
6
+ metadata.gz: 02aed155f78cda26fdf898a66aae1e798bb77dca7b6aa29ab975d855ff1dbab87baacf20509dd234bbe8be7e7e87a60c68ef31d559bfd14a88e5766b60e80917
7
+ data.tar.gz: 1b5e49ff7b0cf8c3f66d597b02f26bc85dedbbe7a8e7e02bcf7f30c1dc746c2534f43f0c4beea6cf2bbcb361273afec8622a6044bdb833a71e459d26de34c0ed
data/.circleci/config.yml CHANGED
@@ -4,15 +4,15 @@ jobs:
4
4
  parallelism: 1
5
5
  working_directory: ~/ezcater
6
6
  docker:
7
- - image: circleci/ruby:2.3.3
7
+ - image: circleci/ruby:2.4.1
8
8
  steps:
9
9
  - checkout
10
10
 
11
11
  # Restore bundle cache
12
12
  - restore_cache:
13
13
  keys:
14
- - ruby-cache-{{ .Branch }}-{{ checksum "Gemfile" }}-{{ checksum "ezcater_rubocop.gemspec" }}
15
- - ruby-cache-{{ .Branch }}-
14
+ - ruby-cache-{{ arch }}-{{ .Branch }}-{{ checksum "Gemfile" }}-{{ checksum "ezcater_rubocop.gemspec" }}
15
+ - ruby-cache-{{ arch }}-{{ .Branch }}-
16
16
  - ruby-cache-
17
17
 
18
18
  # Bundle install dependencies
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.3.3
1
+ 2.4.1
data/CHANGELOG.md CHANGED
@@ -1,27 +1,13 @@
1
1
  # ezcater_rubocop
2
2
 
3
- ## v0.49.7
4
- - Fix `Ezcater/RspecRequireHttpStatusMatcher` cop.
3
+ # v0.50.0
4
+ - Update to rubocop v0.50.0 and rubocop-rspec v1.18.0.
5
+ - Do not apply `Ezcater/StyleDig` to assignments with nested access.
5
6
 
6
- ## v0.49.6
7
- - Rename `Ezcater/RspecRequireGqlErrorHelpers` cop to `Ezcater/RequireGqlErrorHelpers`.
8
-
9
- ## v0.49.5
10
- - Add `Ezcater/RailsConfiguration` cop.
11
-
12
- ## v0.49.4
13
- - Add `Ezcater/RspecRequireGqlErrorHelpers` cop.
14
-
15
- ## v0.49.3
16
- - Do not apply `Ezcater/StyleDig` to access using a range.
17
-
18
- ## v0.49.2
19
- - Do not apply `Ezcater/StyleDig` to assignments to with nested access.
20
-
21
- ## v0.49.1
7
+ # v0.49.1
22
8
  - Add `Ezcater/RspecRequireBrowserMock` cop.
23
9
 
24
- ## v0.49.0
10
+ # v0.49.0
25
11
  - Initial release.
26
12
  - Add `Ezcater/RspecRequireFeatureFlagMock` cop.
27
13
  - Add `Ezcater/RspecDotNotSelfDot` cop.
data/README.md CHANGED
@@ -47,12 +47,9 @@ the latest compatible version each time that the MAJOR.MINOR version of `rubocop
47
47
  is updated.
48
48
 
49
49
  ## Custom Cops
50
- 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`.
51
- 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.
52
50
  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.
53
51
  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.
54
52
  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.
55
- 1. [RspecRequireHttpStatusMatcher](https://github.com/ezcater/ezcater_rubocop/blob/master/lib/rubocop/cop/ezcater/rspec_require_http_status_matcher.rb) - Use the HTTP status code matcher, like `expect(response).to have_http_status :bad_request`, rather than `expect(response.code).to eq 400`
56
53
  1. [StyleDig](https://github.com/ezcater/ezcater_rubocop/blob/master/lib/rubocop/cop/ezcater/style_dig.rb) - Recommend `dig` for deeply nested access.
57
54
 
58
55
  ## Development
data/config/default.yml CHANGED
@@ -1,7 +1,3 @@
1
- Ezcater/RailsConfiguration:
2
- Description: 'Enforce the use of `Rails.configuration` instead of `Rails.application.config`.'
3
- Enabled: true
4
-
5
1
  Ezcater/RspecDotNotSelfDot:
6
2
  Description: 'Enforce ".<class method>" instead of "self.<class method>" for example group description.'
7
3
  Enabled: true
@@ -20,16 +16,6 @@ Ezcater/RspecRequireFeatureFlagMock:
20
16
  Include:
21
17
  - '**/*_spec.rb'
22
18
 
23
- Ezcater/RspecRequireHttpStatusMatcher:
24
- Description: 'Use the HTTP status code matcher, like `expect(response).to have_http_status :bad_request`, rather than `expect(response.code).to eq 400`'
25
- Enabled: true
26
- Include:
27
- - '**/*_spec.rb'
28
-
29
- Ezcater/RequireGqlErrorHelpers:
30
- Description: 'Use the helpers provided by `GQLErrors` instead of raising `GraphQL::ExecutionError` directly.'
31
- Enabled: true
32
-
33
19
  Ezcater/StyleDig:
34
20
  Description: 'Recommend `dig` for deeply nested access.'
35
21
  Enabled: true
@@ -1,5 +1,3 @@
1
- # coding: utf-8
2
-
3
1
  lib = File.expand_path("../lib", __FILE__)
4
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
3
  require "ezcater_rubocop/version"
@@ -37,6 +35,6 @@ Gem::Specification.new do |spec|
37
35
  spec.add_development_dependency "rspec_junit_formatter"
38
36
  spec.add_development_dependency "pry-byebug"
39
37
 
40
- spec.add_runtime_dependency "rubocop", "~> 0.49.1"
41
- spec.add_runtime_dependency "rubocop-rspec", "~> 1.15.1"
38
+ spec.add_runtime_dependency "rubocop", "~> 0.50.0"
39
+ spec.add_runtime_dependency "rubocop-rspec", "~> 1.18.0"
42
40
  end
@@ -12,10 +12,7 @@ puts "configuration from #{DEFAULT_FILES}" if RuboCop::ConfigLoader.debug?
12
12
  config = RuboCop::ConfigLoader.merge_with_default(config, path)
13
13
  RuboCop::ConfigLoader.instance_variable_set(:@default_configuration, config)
14
14
 
15
- require "rubocop/cop/ezcater/rails_configuration"
16
- require "rubocop/cop/ezcater/require_gql_error_helpers"
17
15
  require "rubocop/cop/ezcater/rspec_require_browser_mock"
18
16
  require "rubocop/cop/ezcater/rspec_require_feature_flag_mock"
19
- require "rubocop/cop/ezcater/rspec_require_http_status_matcher"
20
17
  require "rubocop/cop/ezcater/rspec_dot_not_self_dot"
21
18
  require "rubocop/cop/ezcater/style_dig"
@@ -1,3 +1,3 @@
1
1
  module EzcaterRubocop
2
- VERSION = "0.49.7".freeze
2
+ VERSION = "0.50.0".freeze
3
3
  end
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  module RuboCop
4
2
  module Cop
5
3
  module Ezcater
@@ -27,7 +25,7 @@ module RuboCop
27
25
 
28
26
  def on_send(node)
29
27
  example_group_match(node) do |doc|
30
- add_offense(doc, :expression, MSG) if SELF_DOT_REGEXP =~ doc.source
28
+ add_offense(doc, :expression, MSG) if doc.source.match?(SELF_DOT_REGEXP)
31
29
  end
32
30
  end
33
31
 
@@ -21,7 +21,7 @@ module RuboCop
21
21
  MSG = "Use the mocks provided by `BrowserHelpers` instead of mocking `%s`".freeze
22
22
 
23
23
  def_node_matcher :browser_const?, <<~PATTERN
24
- (const _ {:Browser, :EzBrowser})
24
+ (const _ {:Browser :EzBrowser})
25
25
  PATTERN
26
26
 
27
27
  def on_const(node)
@@ -47,7 +47,7 @@ module RuboCop
47
47
  end
48
48
 
49
49
  def allow_send_node?(node)
50
- node && node.send_type? && node.method_name == :allow
50
+ node&.send_type? && node.method_name == :allow
51
51
  end
52
52
  end
53
53
  end
@@ -43,7 +43,7 @@ module RuboCop
43
43
  end
44
44
 
45
45
  def allow_send_node?(node)
46
- node && node.send_type? && node.method_name == :allow
46
+ node&.send_type? && node.method_name == :allow
47
47
  end
48
48
  end
49
49
  end
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  module RuboCop
4
2
  module Cop
5
3
  module Ezcater
@@ -24,7 +22,7 @@ module RuboCop
24
22
  MSG = "Use `dig` for nested access.".freeze
25
23
 
26
24
  def_node_matcher :nested_access_match, <<-PATTERN
27
- (send (send (send _receiver !:[]) :[] !{irange erange}) :[] !{irange erange})
25
+ (send (send (send _receiver !:[]) :[] _) :[] _)
28
26
  PATTERN
29
27
 
30
28
  def on_send(node)
@@ -37,10 +35,10 @@ module RuboCop
37
35
 
38
36
  def autocorrect(node)
39
37
  access_node = node
40
- source_args = [access_node.method_args.first.source]
38
+ source_args = [access_node.first_argument.source]
41
39
  while access_node?(access_node.children.first)
42
40
  access_node = access_node.children.first
43
- source_args << access_node.method_args.first.source
41
+ source_args << access_node.first_argument.source
44
42
  end
45
43
  root_node = access_node.children.first
46
44
 
@@ -59,11 +57,7 @@ module RuboCop
59
57
  end
60
58
 
61
59
  def access_node?(node)
62
- node && node.send_type? && node.method_name == :[] && !range?(node.method_args.first)
63
- end
64
-
65
- def range?(node)
66
- node.irange_type? || node.erange_type?
60
+ node&.send_type? && node.method_name == :[]
67
61
  end
68
62
  end
69
63
  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.49.7
4
+ version: 0.50.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ezCater, Inc
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-07-06 00:00:00.000000000 Z
11
+ date: 2017-10-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -86,28 +86,28 @@ dependencies:
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: 0.49.1
89
+ version: 0.50.0
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: 0.49.1
96
+ version: 0.50.0
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: rubocop-rspec
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: 1.15.1
103
+ version: 1.18.0
104
104
  type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: 1.15.1
110
+ version: 1.18.0
111
111
  description: ezCater custom cops and shared configuration
112
112
  email:
113
113
  - engineering@ezcater.com
@@ -133,12 +133,9 @@ files:
133
133
  - ezcater_rubocop.gemspec
134
134
  - lib/ezcater_rubocop.rb
135
135
  - lib/ezcater_rubocop/version.rb
136
- - lib/rubocop/cop/ezcater/rails_configuration.rb
137
- - lib/rubocop/cop/ezcater/require_gql_error_helpers.rb
138
136
  - lib/rubocop/cop/ezcater/rspec_dot_not_self_dot.rb
139
137
  - lib/rubocop/cop/ezcater/rspec_require_browser_mock.rb
140
138
  - lib/rubocop/cop/ezcater/rspec_require_feature_flag_mock.rb
141
- - lib/rubocop/cop/ezcater/rspec_require_http_status_matcher.rb
142
139
  - lib/rubocop/cop/ezcater/style_dig.rb
143
140
  - lib/rubocop/rspec/language/each_selector.rb
144
141
  homepage: https://github.com/ezcater/ezcater_rubocop
@@ -162,7 +159,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
162
159
  version: '0'
163
160
  requirements: []
164
161
  rubyforge_project:
165
- rubygems_version: 2.7.4
162
+ rubygems_version: 2.6.13
166
163
  signing_key:
167
164
  specification_version: 4
168
165
  summary: ezCater custom cops and shared configuration
@@ -1,26 +0,0 @@
1
- module RuboCop
2
- module Cop
3
- module Ezcater
4
- class RailsConfiguration < Cop
5
- MSG = "Use `Rails.configuration` instead of `Rails.application.config`.".freeze
6
- RAILS_CONFIGURATION = "Rails.configuration".freeze
7
-
8
- def_node_matcher "rails_application_config", <<-PATTERN
9
- (send (send (const _ :Rails) :application) :config)
10
- PATTERN
11
-
12
- def on_send(node)
13
- rails_application_config(node) do
14
- add_offense(node, :expression, MSG)
15
- end
16
- end
17
-
18
- def autocorrect(node)
19
- lambda do |corrector|
20
- corrector.replace(node.source_range, RAILS_CONFIGURATION)
21
- end
22
- end
23
- end
24
- end
25
- end
26
- end
@@ -1,35 +0,0 @@
1
- module RuboCop
2
- module Cop
3
- module Ezcater
4
- # Enforce use of GQLErrors helpers instead of throwing
5
- # GraphQL::ExecutionErrors directly
6
- #
7
- # @example
8
- #
9
- # # good
10
- # GQLErrors.summary_error("An error occurred")
11
- # GQLErrors.request_error("You can't access this", 401)
12
- # GQLErrors.field_error("is invalid", :first_name, "First Name")
13
- # GQLErrors.field_errors_for(my_model, context)
14
- # GQLErrors.field_errors_for(my_model, context, summary_error: "An error occurred")
15
- # GQLErrors.field_errors_for(my_model, context, field_mapping: { first: :first_name })
16
- #
17
- # # bad
18
- # GraphQL::ExecutionError.new("An error occurred")
19
- # GraphQL::ExecutionError.new("You can't access this", options: { status_code: 401 })
20
- class RequireGqlErrorHelpers < Cop
21
- MSG = "Use the helpers provided by `GQLErrors` instead of raising `GraphQL::ExecutionError` directly.".freeze
22
-
23
- def_node_matcher :graphql_const?, <<~PATTERN
24
- (const (const _ :GraphQL) :ExecutionError)
25
- PATTERN
26
-
27
- def on_const(node)
28
- return unless graphql_const?(node)
29
-
30
- add_offense(node, :expression, MSG)
31
- end
32
- end
33
- end
34
- end
35
- end
@@ -1,37 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module RuboCop
4
- module Cop
5
- module Ezcater
6
- # Enforce use of HTTP status code matchers rather than asserting on on random numbers.
7
- #
8
- # @example
9
- #
10
- # # good
11
- # expect(response).to have_http_status :created
12
- # expect(response).to have_http_status :bad_request
13
- #
14
- # # bad
15
- # expect(response.code).to eq 201
16
- # expect(response.code).to eq 400
17
- class RspecRequireHttpStatusMatcher < Cop
18
- MSG = "Use the `have_http_status` matcher, like `expect(response).to have_http_status :bad_request`, "\
19
- "rather than `%<node_source>s`"
20
-
21
- def_node_matcher :response_status_assertion, <<~PATTERN
22
- (send (send _ :expect (send (send _ :response) :status)) :to (send _ :eq (int _)))
23
- PATTERN
24
-
25
- def_node_matcher :response_code_assertion, <<~PATTERN
26
- (send (send _ :expect (send (send _ :response) :code)) :to (send _ :eq (str _)))
27
- PATTERN
28
-
29
- def on_send(node)
30
- return if !response_status_assertion(node) && !response_code_assertion(node)
31
-
32
- add_offense(node, :expression, format(MSG, node_source: node.source))
33
- end
34
- end
35
- end
36
- end
37
- end