ezcater_rubocop 3.0.0 → 3.0.1

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
2
  SHA256:
3
- metadata.gz: 511f81e30ff5765d51a825d7b8606ebfa3c05d34e8c567dc7876ea7140e63d8a
4
- data.tar.gz: f01eb84d2556225ac5be3e2c0ec206b6c1f5f8dc3fa8f6ad5bf6de400b474514
3
+ metadata.gz: 32ed01c4904b105bcd1ac2b3b8871485448284bffe06dc6b90fda19775748175
4
+ data.tar.gz: 19755e3e83359f473ff961e1679c39b1bdb5f6d78a9c78e3ca6118be344c8400
5
5
  SHA512:
6
- metadata.gz: 6283449ed5c2181a90557d786e074e285841c8fc8ea5f0d693fd40d52c536121b50267d0352d266e60ed3bb62e1d2aae0be87f64024cb9418cf65daf7311993f
7
- data.tar.gz: 5385a45fb8dfb260eda7d3fdaf8adaf3dc2b05f6ab6532c622744f4c2c4fab06ac3909b71d74ba7bc4a68fc87bf311f7d69246afcbb84c62f12912c6f215c3f3
6
+ metadata.gz: c215237f6c8fc40398c3947944261a457a2fc3efbebb51bc3e01ba743a3a4ad099a1a3ecfcc2782c056a78df6231b5bc0c258e0fa0f7ab8fd04e13be9ad26f79
7
+ data.tar.gz: f5066524144f916ff5d56c4aa320d916d4ed383b4eee01d20db2809a67eb2ed65bdf541709b8c0c9cec36a977a6ff9c92704564dacd7e9726a5b99bf02c0fffc
data/.tool-versions ADDED
@@ -0,0 +1 @@
1
+ ruby 2.7.3
data/CHANGELOG.md CHANGED
@@ -6,11 +6,16 @@ This gem is moving onto its own [Semantic Versioning](https://semver.org/) schem
6
6
 
7
7
  Prior to v1.0.0 this gem was versioned based on the `MAJOR`.`MINOR` version of RuboCop. The first release of the ezcater_rubocop gem was `v0.49.0`.
8
8
 
9
+ ## v3.0.1
10
+ - Fix the RspecDotNotSelfDot cop to work with rubocop-rspec
11
+ - Exclude appraisal generated gemfiles for possible embedded gems in rails apps
12
+
9
13
  ## v3.0.0
10
- - Upgrade rubocop: 1.16.0
14
+
15
+ - Upgrade rubocop: 1.16.0
11
16
  - Upgrade rubocop-rails: 2.10.1
12
17
  - Upgrade rubocop-rspec: 2.3.0
13
- - This is a major upgrade because a large number of cops have been introduced, tweaked, or renamed. Here is an aggregate of the breaking changes introduced
18
+ - This is a major upgrade because a large number of cops have been introduced, tweaked, or renamed. Here is an aggregate of the breaking changes introduced
14
19
  - RuboCop assumes that Cop classes do not define new `on_<type>` methods at runtime (e.g. via `extend` in `initialize`).
15
20
  - Enable all pending cops for RuboCop 1.0.
16
21
  - Change logic for cop department name computation. Cops inside deep namespaces (5 or more levels deep) now belong to departments with names that are calculated by joining module names starting from the third one with slashes as separators. For example, cop `Rubocop::Cop::Foo::Bar::Baz` now belongs to `Foo/Bar` department (previously it was `Bar`).
data/conf/rubocop.yml CHANGED
@@ -3,6 +3,7 @@ require: ezcater_rubocop
3
3
  AllCops:
4
4
  DisplayCopNames: true
5
5
  NewCops: disable
6
+ SuggestExtensions: false
6
7
 
7
8
  Layout/FirstHashElementIndentation:
8
9
  EnforcedStyle: consistent
@@ -21,8 +22,8 @@ Metrics/AbcSize:
21
22
 
22
23
  Metrics/BlockLength:
23
24
  Exclude:
24
- - "*.gemspec"
25
- - "spec/**/*.rb"
25
+ - "*.gemspec"
26
+ - "spec/**/*.rb"
26
27
 
27
28
  Metrics/CyclomaticComplexity:
28
29
  Enabled: false
@@ -30,7 +31,7 @@ Metrics/CyclomaticComplexity:
30
31
  Layout/LineLength:
31
32
  Max: 120
32
33
  Exclude:
33
- - "Gemfile"
34
+ - "Gemfile"
34
35
 
35
36
  Metrics/MethodLength:
36
37
  Enabled: true
@@ -45,9 +46,9 @@ Naming/MemoizedInstanceVariableName:
45
46
 
46
47
  Naming/MethodParameterName:
47
48
  AllowedNames:
48
- - e
49
- - ex
50
- - id
49
+ - e
50
+ - ex
51
+ - id
51
52
 
52
53
  Naming/VariableNumber:
53
54
  Enabled: false
@@ -60,12 +61,12 @@ RSpec/ContextWording:
60
61
 
61
62
  RSpec/DescribeClass:
62
63
  Exclude:
63
- - "spec/requests/**/*.rb"
64
- - "spec/features/**/*.rb"
65
- - "spec/routing/**/*.rb"
66
- - "spec/views/**/*.rb"
67
- - "spec/system/**/*.rb"
68
- - "spec/integrations/**/*.rb"
64
+ - "spec/requests/**/*.rb"
65
+ - "spec/features/**/*.rb"
66
+ - "spec/routing/**/*.rb"
67
+ - "spec/views/**/*.rb"
68
+ - "spec/system/**/*.rb"
69
+ - "spec/integrations/**/*.rb"
69
70
 
70
71
  RSpec/ExampleLength:
71
72
  Max: 25
@@ -113,12 +114,12 @@ Style/NumericLiterals:
113
114
 
114
115
  Style/PercentLiteralDelimiters:
115
116
  PreferredDelimiters:
116
- default: '()'
117
- '%i': '()'
118
- '%I': '()'
119
- '%r': '{}'
120
- '%w': '()'
121
- '%W': '()'
117
+ default: "()"
118
+ "%i": "()"
119
+ "%I": "()"
120
+ "%r": "{}"
121
+ "%w": "()"
122
+ "%W": "()"
122
123
 
123
124
  Style/RaiseArgs:
124
125
  EnforcedStyle: compact
@@ -9,6 +9,7 @@ AllCops:
9
9
  TargetRailsVersion: 5.2
10
10
  Exclude:
11
11
  - tmp/cache/**/*
12
+ - '**/gemfiles/*.gemfile'
12
13
 
13
14
  Metrics/BlockLength:
14
15
  inherit_mode:
data/config/default.yml CHANGED
@@ -5,57 +5,57 @@ Ezcater/GraphqlFieldsNaming:
5
5
  - snake_case
6
6
  - camelCase
7
7
  Include:
8
- - 'app/graphql/**/*.rb'
8
+ - "app/graphql/**/*.rb"
9
9
 
10
10
  Ezcater/RailsConfiguration:
11
- Description: 'Enforce the use of `Rails.configuration` instead of `Rails.application.config`.'
11
+ Description: "Enforce the use of `Rails.configuration` instead of `Rails.application.config`."
12
12
  Enabled: true
13
13
 
14
14
  Ezcater/RailsEnv:
15
- Description: 'Enforce the use of `Rails.configuration.x.<foo>` instead of checking `Rails.env`.'
15
+ Description: "Enforce the use of `Rails.configuration.x.<foo>` instead of checking `Rails.env`."
16
16
  Enabled: false
17
17
 
18
18
  Ezcater/DirectEnvCheck:
19
- Description: 'Enforce the use of `Rails.configuration.x.<foo>` instead of checking `ENV`.'
19
+ Description: "Enforce the use of `Rails.configuration.x.<foo>` instead of checking `ENV`."
20
20
  Enabled: false
21
21
 
22
22
  Ezcater/FeatureFlagActive:
23
- Description: 'Enforce the proper arguments are given to EzcaterFeatureFlag.active?'
23
+ Description: "Enforce the proper arguments are given to EzcaterFeatureFlag.active?"
24
24
  Enabled: true
25
25
 
26
26
  Ezcater/RspecDotNotSelfDot:
27
27
  Description: 'Enforce ".<class method>" instead of "self.<class method>" for example group description.'
28
28
  Enabled: true
29
29
  Include:
30
- - '**/*_spec.rb'
30
+ - "**/*_spec.rb"
31
31
 
32
32
  Ezcater/RspecRequireBrowserMock:
33
- Description: 'Enforce use of `mock_ezcater_app`, `mock_chrome_browser` & `mock_custom_browser` helpers instead of mocking `Browser` or `EzBrowser` directly.'
33
+ Description: "Enforce use of `mock_ezcater_app`, `mock_chrome_browser` & `mock_custom_browser` helpers instead of mocking `Browser` or `EzBrowser` directly."
34
34
  Enabled: true
35
35
  Include:
36
- - '**/*_spec.rb'
36
+ - "**/*_spec.rb"
37
37
 
38
38
  Ezcater/RspecRequireFeatureFlagMock:
39
- Description: 'Enforce use of `mock_feature_flag` helpers instead of mocking `FeatureFlag.is_active?` directly.'
39
+ Description: "Enforce use of `mock_feature_flag` helpers instead of mocking `FeatureFlag.is_active?` directly."
40
40
  Enabled: true
41
41
  Include:
42
- - '**/*_spec.rb'
42
+ - "**/*_spec.rb"
43
43
 
44
44
  Ezcater/RspecRequireHttpStatusMatcher:
45
- Description: 'Use the HTTP status code matcher, like `expect(response).to have_http_status :bad_request`, rather than `expect(response.code).to eq 400`'
45
+ Description: "Use the HTTP status code matcher, like `expect(response).to have_http_status :bad_request`, rather than `expect(response.code).to eq 400`"
46
46
  Enabled: true
47
47
  Include:
48
- - '**/*_spec.rb'
48
+ - "**/*_spec.rb"
49
49
 
50
50
  Ezcater/RequireGqlErrorHelpers:
51
- Description: 'Use the helpers provided by `GQLErrors` instead of raising `GraphQL::ExecutionError` directly.'
51
+ Description: "Use the helpers provided by `GQLErrors` instead of raising `GraphQL::ExecutionError` directly."
52
52
  Enabled: true
53
53
 
54
54
  Ezcater/StyleDig:
55
- Description: 'Recommend `dig` for deeply nested access.'
55
+ Description: "Recommend `dig` for deeply nested access."
56
56
  Enabled: true
57
57
  AutoCorrect: false
58
58
 
59
59
  Ezcater/RubyTimeout:
60
- Description: 'Disallow use of `Timeout.timeout` because it is unsafe and can cause unexpected behavior.'
60
+ Description: "Disallow use of `Timeout.timeout` because it is unsafe and can cause unexpected behavior."
61
61
  Enabled: true
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EzcaterRubocop
4
- VERSION = "3.0.0"
4
+ VERSION = "3.0.1"
5
5
  end
@@ -66,7 +66,7 @@ module RuboCop
66
66
  end
67
67
 
68
68
  def message(style)
69
- format(MSG, style: style)
69
+ format(MSG, style: style) # Rubocop:disable Style/HashSyntax
70
70
  end
71
71
  end
72
72
  end
@@ -25,26 +25,44 @@ module RuboCop
25
25
 
26
26
  class RspecDotNotSelfDot < Cop
27
27
  include RuboCop::RSpec::Language
28
+ extend RuboCop::RSpec::Language::NodePattern
28
29
 
29
- SELF_DOT_REGEXP = /["']self\./.freeze
30
- COLON_COLON_REGEXP = /["'](\:\:)/.freeze
30
+ RSPEC_EXAMPLE_PREFIXES = ["", "x", "f"].freeze
31
+ EXAMPLE_GROUP_IDENTIFIERS = (RSPEC_EXAMPLE_PREFIXES.map do |prefix|
32
+ %w(describe context feature).map { |identifier| "#{prefix}#{identifier}" }
33
+ end.flatten + %w(example_group)).freeze
34
+ EXAMPLE_IDENTIFIERS = (RSPEC_EXAMPLE_PREFIXES.map do |prefix|
35
+ %w(it specify example scenario).map { |identifier| "#{prefix}#{identifier}" }
36
+ end.flatten + %w(its focus skip)).freeze
37
+
38
+ SELF_DOT_REGEXP = /\Aself\./.freeze
39
+ COLON_COLON_REGEXP = /\A(\:\:)/.freeze
31
40
 
32
41
  SELF_DOT_MSG = 'Use ".<class method>" instead of "self.<class method>" for example group description.'
33
42
  COLON_COLON_MSG = 'Use ".<class method>" instead of "::<class method>" for example group description.'
34
43
 
35
- def on_send(node)
36
- example_group?(node) do |doc|
37
- if doc.source.match?(SELF_DOT_REGEXP)
38
- add_offense(doc, location: :expression, message: SELF_DOT_MSG)
39
- elsif doc.source.match?(COLON_COLON_REGEXP)
40
- add_offense(doc, location: :expression, message: COLON_COLON_MSG)
41
- end
44
+ def_node_matcher :example_group?, <<~PATTERN
45
+ (block
46
+ (send #rspec? {#{EXAMPLE_GROUP_IDENTIFIERS.map { |i| ":#{i}" }.join(' ')}}
47
+ (str ...) ...
48
+ ) ...
49
+ )
50
+ PATTERN
51
+
52
+ def on_block(node)
53
+ return unless example_group?(node)
54
+
55
+ str_node = node.send_node.arguments[0]
56
+ if str_node.value.match?(SELF_DOT_REGEXP)
57
+ add_offense(str_node, location: :expression, message: SELF_DOT_MSG)
58
+ elsif str_node.value.match?(COLON_COLON_REGEXP)
59
+ add_offense(str_node, location: :expression, message: COLON_COLON_MSG)
42
60
  end
43
61
  end
44
62
 
45
63
  def autocorrect(node)
46
64
  lambda do |corrector|
47
- experession_end = node.source.match?(COLON_COLON_REGEXP) ? 3 : 6
65
+ experession_end = node.source.match?("::") ? 3 : 6
48
66
  corrector.replace(Parser::Source::Range.new(node.source_range.source_buffer,
49
67
  node.source_range.begin_pos + 1,
50
68
  node.source_range.begin_pos + experession_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: 3.0.0
4
+ version: 3.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - ezCater, Inc
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-06-09 00:00:00.000000000 Z
11
+ date: 2022-03-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -160,6 +160,7 @@ extra_rdoc_files: []
160
160
  files:
161
161
  - ".github/CODEOWNERS"
162
162
  - ".github/PULL_REQUEST_TEMPLATE.md"
163
+ - ".tool-versions"
163
164
  - CHANGELOG.md
164
165
  - Gemfile
165
166
  - LICENSE.txt
@@ -192,7 +193,7 @@ licenses:
192
193
  - MIT
193
194
  metadata:
194
195
  allowed_push_host: https://rubygems.org
195
- post_install_message:
196
+ post_install_message:
196
197
  rdoc_options: []
197
198
  require_paths:
198
199
  - lib
@@ -208,7 +209,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
208
209
  version: '0'
209
210
  requirements: []
210
211
  rubygems_version: 3.1.6
211
- signing_key:
212
+ signing_key:
212
213
  specification_version: 4
213
214
  summary: ezCater custom cops and shared configuration
214
215
  test_files: []