rubocop-petal 0.8.0 → 1.0.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
2
  SHA256:
3
- metadata.gz: 424a55f53bbcb88794cf8a0122a376217db95d890fc789d0288a76434cdcb023
4
- data.tar.gz: 838d1178021d47035f10b7fb139e3fb50955b823ec4f94f80bad0f504d042017
3
+ metadata.gz: 1d59a2d5781acf6465d3b1f5fef4575af1db1da8fd4af2d4ec3b0af863139cb2
4
+ data.tar.gz: aa4221534a285b746c8dd195347ab93c27954762bdd26f93242c712c8cbed20f
5
5
  SHA512:
6
- metadata.gz: d1d19b3bb4c94b070a0acb1d06442541aa333ef8a2170a4d2074ab828051909811d90c8e37ad4d10b5f76ba7fde2ba493bb2f1dcbbc9f5e5e2e930561be23412
7
- data.tar.gz: a188cc40b0da58690ef31c33698ba33c6043e0d0a52d474b4ee07be5049991357373c97666b5c42996be7efedb56a8e540a4bbbd9d81ac8761bf6144c121ae73
6
+ metadata.gz: 81707e3d93a3e10e36dcdd299c63f804b8b820a8406b267715c084ed8fd5b0180633ea2e2a335623df414e3251959813332526d1e796fe86771241af85c09920
7
+ data.tar.gz: '048bde3d8f343cb218b2bd25dbbedbd30fc8ff7579028e3a6f3d805800c7212720b7fc48e4b8757dd9948c5775730f27287490b18dc701d15e893800a7c73562'
data/README.md CHANGED
@@ -5,6 +5,14 @@
5
5
 
6
6
  Petal custom cops. List of cops can be find [here](https://github.com/petalmd/rubocop-petal/tree/main/lib/rubocop/cop).
7
7
 
8
+ Petal global cops configuration for:
9
+
10
+ * rubocop
11
+ * rubocop-rspec
12
+ * rubocop-performance
13
+ * rubocop-rails
14
+ * rubocop-petal
15
+
8
16
  ## Installation
9
17
 
10
18
  Add this line to your application's Gemfile:
@@ -23,11 +31,11 @@ Or install it yourself as:
23
31
 
24
32
  ## Usage
25
33
 
26
- In your `.rubocop.yml` file, add `rubocop-petal`
34
+ In your `.rubocop.yml` file, add
27
35
 
28
36
  ```yaml
29
- require:
30
- - rubocop-petal
37
+ inherit_gem:
38
+ rubocop-petal: 'config/base.yml'
31
39
  ```
32
40
 
33
41
  ## Development
data/config/base.yml ADDED
@@ -0,0 +1,108 @@
1
+ require:
2
+ - rubocop-rails
3
+ - rubocop-performance
4
+ - rubocop-rspec
5
+ - rubocop-petal
6
+
7
+ AllCops:
8
+ SuggestExtensions: false
9
+ DisplayCopNames: true
10
+ NewCops: enable
11
+ DisplayStyleGuide: true
12
+ ExtraDetails: true
13
+ StyleGuideBaseURL: https://rubystyle.guide
14
+ Layout/CaseIndentation:
15
+ IndentOneStep: true
16
+ Layout/MultilineAssignmentLayout:
17
+ SupportedTypes:
18
+ - case
19
+ - if
20
+ Layout/MultilineMethodCallIndentation:
21
+ EnforcedStyle: indented
22
+ IndentationWidth: 2
23
+ Layout/MultilineArrayLineBreaks:
24
+ Enabled: true
25
+ Layout/MultilineHashKeyLineBreaks:
26
+ Enabled: true
27
+ Layout/MultilineMethodArgumentLineBreaks:
28
+ Enabled: true
29
+ Lint/AmbiguousBlockAssociation:
30
+ Exclude:
31
+ - spec/**/*
32
+ Metrics/AbcSize:
33
+ Max: 20
34
+ Metrics/BlockLength:
35
+ Enabled: false
36
+ Metrics/BlockNesting:
37
+ Enabled: false
38
+ Metrics/ClassLength:
39
+ Enabled: false
40
+ Metrics/CyclomaticComplexity:
41
+ Max: 10
42
+ Metrics/MethodLength:
43
+ Enabled: false
44
+ Metrics/ModuleLength:
45
+ Enabled: false
46
+ Metrics/PerceivedComplexity:
47
+ Max: 12
48
+ RSpec:
49
+ StyleGuideBaseURL: https://rspec.rubystyle.guide
50
+ RSpec/ContextWording:
51
+ Prefixes:
52
+ - when
53
+ - with
54
+ - without
55
+ - if
56
+ - unless
57
+ - for
58
+ RSpec/ExampleLength:
59
+ Enabled: false
60
+ RSpec/ExampleWithoutDescription:
61
+ EnforcedStyle: single_line_only
62
+ RSpec/HookArgument:
63
+ Enabled: false
64
+ RSpec/LetSetup:
65
+ Enabled: false
66
+ RSpec/MessageSpies:
67
+ EnforcedStyle: receive
68
+ RSpec/MultipleExpectations:
69
+ Enabled: false
70
+ RSpec/MultipleMemoizedHelpers:
71
+ Enabled: false
72
+ RSpec/NamedSubject:
73
+ Enabled: false
74
+ RSpec/NestedGroups:
75
+ Max: 5
76
+ RSpec/PredicateMatcher:
77
+ Enabled: false
78
+ RSpec/StubbedMock:
79
+ Enabled: false
80
+ RSpec/DescribeClass:
81
+ Exclude:
82
+ - spec/integration/**/*.rb
83
+ Rails/SaveBang:
84
+ Enabled: true
85
+ Rails/NotNullColumn:
86
+ Enabled: false
87
+ Rails/UnknownEnv:
88
+ Environments:
89
+ - production
90
+ - development
91
+ - test
92
+ - staging
93
+ Rails/WhereExists:
94
+ Enabled: false
95
+ Style/CollectionMethods:
96
+ PreferredMethods:
97
+ detect: detect
98
+ collect: map
99
+ Style/DateTime:
100
+ Enabled: true
101
+ Style/Documentation:
102
+ Enabled: false
103
+ Style/FrozenStringLiteralComment:
104
+ EnforcedStyle: always_true
105
+ Style/NumericLiterals:
106
+ MinDigits: 8
107
+ Style/ReturnNil:
108
+ Enabled: true
data/config/default.yml CHANGED
@@ -78,13 +78,6 @@ Chewy/ResetOnType:
78
78
  Description: 'Prevent using reset! methods on Chewy type class'
79
79
  Enabled: true
80
80
 
81
- RSpec/JsonParseResponseBody:
82
- Description: 'Prevent JSON.parse(response.body) in favor of response.parsed_body'
83
- Enabled: true
84
- SafeAutoCorrect: true
85
- Include:
86
- - spec/**/*
87
-
88
81
  RSpec/JsonResponse:
89
82
  Description: 'Prevent json_response in favor of response.parsed_body'
90
83
  Enabled: true
@@ -14,7 +14,7 @@ module RuboCop
14
14
  # get :some_path {}
15
15
  #
16
16
  class UnnecessaryNamespace < Base
17
- MSG = 'Unnecessary usage of Grape namespace. '\
17
+ MSG = 'Unnecessary usage of Grape namespace. ' \
18
18
  'Specify endpoint name with an argument: `get :some_path`.'
19
19
  HTTP_ACTIONS = Set.new(%i[get head put post patch delete])
20
20
  GRAPE_NAMESPACE_ALIAS = Set.new(%i[namespace resource resources])
@@ -50,7 +50,7 @@ module RuboCop
50
50
  return if http_action_node.size != 1
51
51
 
52
52
  paths = paths_added_with_http_action(http_action_node.first)
53
- add_offense(node) if paths.size.zero?
53
+ add_offense(node) if paths.empty?
54
54
  end
55
55
 
56
56
  private
@@ -7,19 +7,21 @@ module RuboCop
7
7
  # The method will execute inline every perform_async called.
8
8
  # Must likely a spec want to test a specific worker and called it.
9
9
  # If you don't need to execute it, consider using `have_enqueued_sidekiq_job`
10
- # matcher.
10
+ # matcher. Or if you need to perform the jobs in queue for this worker, use
11
+ # `drain` method on the worker class.
11
12
  #
12
13
  # @example
13
14
  # # bad
14
- # Sidekiq::Testing.inline! do; end
15
+ # Sidekiq::Testing.inline! do
16
+ # OperationThatTriggerWorker.call(some_id)
17
+ # end
15
18
  #
16
19
  # # good
17
- # expect(MyWorker).to receive(:perform_async).with(some_id) do |id|
18
- # MyWorker.new.perform(id)
19
- # end
20
+ # OperationThatTriggerWorker.call(some_id)
21
+ # MyWorker.drain
20
22
  #
21
23
  class SidekiqInline < Base
22
- MSG = 'Stub `perform_async` and call inline worker with `new.perform`.'
24
+ MSG = 'Use `MyWorker.drain` method instead of `Sidekiq::Testing.inline!`.'
23
25
  RESTRICT_ON_SEND = [:inline!].freeze
24
26
 
25
27
  def_node_matcher :sidekiq_inline?, <<~PATTERN
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RuboCop
4
4
  module Petal
5
- VERSION = '0.8.0'
5
+ VERSION = '1.0.0'
6
6
  end
7
7
  end
data/lib/rubocop/petal.rb CHANGED
@@ -3,9 +3,8 @@
3
3
  require_relative 'petal/version'
4
4
 
5
5
  module RuboCop
6
- module Petal # rubocop:disable Style/Documentation
6
+ module Petal
7
7
  class Error < StandardError; end
8
- # Your code goes here...
9
8
  PROJECT_ROOT = Pathname.new(__dir__).parent.parent.expand_path.freeze
10
9
  CONFIG_DEFAULT = PROJECT_ROOT.join('config', 'default.yml').freeze
11
10
  CONFIG = YAML.safe_load(CONFIG_DEFAULT.read).freeze
metadata CHANGED
@@ -1,49 +1,71 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubocop-petal
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jean-Francis Bastien
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-02-21 00:00:00.000000000 Z
11
+ date: 2023-05-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubocop
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: 1.7.0
20
- - - "<"
17
+ - - "~>"
21
18
  - !ruby/object:Gem::Version
22
- version: '2.0'
19
+ version: 1.50.0
23
20
  type: :runtime
24
21
  prerelease: false
25
22
  version_requirements: !ruby/object:Gem::Requirement
26
23
  requirements:
27
- - - ">="
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 1.50.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: rubocop-performance
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
28
32
  - !ruby/object:Gem::Version
29
- version: 1.7.0
30
- - - "<"
33
+ version: 1.17.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
31
39
  - !ruby/object:Gem::Version
32
- version: '2.0'
40
+ version: 1.17.0
33
41
  - !ruby/object:Gem::Dependency
34
42
  name: rubocop-rails
35
43
  requirement: !ruby/object:Gem::Requirement
36
44
  requirements:
37
45
  - - "~>"
38
46
  - !ruby/object:Gem::Version
39
- version: '2.10'
47
+ version: '2.19'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '2.19'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rubocop-rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 2.17.0
40
62
  type: :runtime
41
63
  prerelease: false
42
64
  version_requirements: !ruby/object:Gem::Requirement
43
65
  requirements:
44
66
  - - "~>"
45
67
  - !ruby/object:Gem::Version
46
- version: '2.10'
68
+ version: 2.17.0
47
69
  description:
48
70
  email:
49
71
  - jfbastien@petalmd.com
@@ -55,6 +77,7 @@ extra_rdoc_files:
55
77
  files:
56
78
  - LICENSE.txt
57
79
  - README.md
80
+ - config/base.yml
58
81
  - config/default.yml
59
82
  - lib/rubocop-petal.rb
60
83
  - lib/rubocop/cop/chewy/reset_on_type.rb
@@ -70,7 +93,6 @@ files:
70
93
  - lib/rubocop/cop/rails/table_name.rb
71
94
  - lib/rubocop/cop/rspec/authenticated_as.rb
72
95
  - lib/rubocop/cop/rspec/create_list_max.rb
73
- - lib/rubocop/cop/rspec/json_parse_response_body.rb
74
96
  - lib/rubocop/cop/rspec/json_response.rb
75
97
  - lib/rubocop/cop/rspec/sidekiq_inline.rb
76
98
  - lib/rubocop/cop/rspec/stub_products.rb
@@ -101,7 +123,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
101
123
  - !ruby/object:Gem::Version
102
124
  version: '0'
103
125
  requirements: []
104
- rubygems_version: 3.0.3
126
+ rubygems_version: 3.2.3
105
127
  signing_key:
106
128
  specification_version: 4
107
129
  summary: Petal custom cops
@@ -1,35 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module RuboCop
4
- module Cop
5
- module RSpec
6
- # Prevent using `JSON.parse(response.body)` in spec.
7
- # Consider using `response.parsed_body`.
8
- #
9
- # @example
10
- # # bad
11
- # JSON.parse(response.body) do; end
12
- #
13
- # # good
14
- # response.parsed_body
15
- #
16
- class JsonParseResponseBody < Base
17
- extend AutoCorrector
18
-
19
- MSG = 'Use `response.parsed_body` instead.'
20
-
21
- def_node_matcher :json_parse_response_body?, <<~PATTERN
22
- (send (const _ :JSON) :parse (send (send _ :response) :body))
23
- PATTERN
24
-
25
- def on_send(node)
26
- return unless json_parse_response_body?(node)
27
-
28
- add_offense(node) do |corrector|
29
- corrector.replace(node, 'response.parsed_body')
30
- end
31
- end
32
- end
33
- end
34
- end
35
- end