rubocop-cobra 0.3.0 → 0.4.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1ed15eb1f676621c8de867b79b277b407fb36c862ef88291a732d84859799dda
4
- data.tar.gz: 9e9de6b0bcc5c13b049b86ac861d5986fe0b79d016b7b14cf3d3dc14ea098a17
3
+ metadata.gz: 07b98212c7432d3e5fd8d00f879f6c242d121c74e9d24ba1b1d56c708410d78b
4
+ data.tar.gz: bbc10babcde31d9bcbadebf4dd8970f113ecbfc2737c8c459a9a2677e2fa3e35
5
5
  SHA512:
6
- metadata.gz: bea53660dadb8c6518e1bfd9da50655db656aa0780aac9c0414fc28d54da82484726cd4934ee9d293c618ea1043a5e2a762922873319fcefd946abc76847a2f2
7
- data.tar.gz: edd88e7a7d8224e3c2bb968fbeb5fa519c21971978d97e92adb901f955e1526b159c348cbf93d1875627f752f1371ac5f194ffe891edb6ce60287b11278190bb
6
+ metadata.gz: 502c3e50f0e19b791160b2b0ef46e3439525ca0fa67fa1b3df225dcc854e8187221bb8004f4b2a926714c970fa8db38dfbca28a876c500297aaa403a79ec37b5
7
+ data.tar.gz: 00625d665102cbab491e723b57911c005078b89a41ddd5007e5394db1023f621ec192c45fc06ecec1fd78844bf658a8ac3d9b857362c6a5a4db21b24ff26d10a
data/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.4.2] - 2023-02-08
4
+
5
+ - Permit Rubocop upgrades again because bug was fixed.
6
+
7
+ ## [0.4.1] - 2023-02-08
8
+
9
+ - Hold back version of Rubocop that's permitted due to incompatibility with our implementation.
10
+
11
+ ## [0.4.0] - 2022-06-01
12
+
13
+ - Adds Cobra/ViewComponentFilePlacement cop
14
+
3
15
  ## [0.1.0] - 2022-05-18
4
16
 
5
17
  - Initial release
data/Gemfile CHANGED
@@ -7,6 +7,6 @@ gemspec
7
7
 
8
8
  gem "rake", "~> 13.0"
9
9
  gem "rspec", "~> 3.0"
10
- gem "rubocop", "~> 1.29.1"
10
+ gem "rubocop", "~> 1.44.0"
11
11
 
12
12
  gem "rubocop-powerhome", path: "../rubocop-powerhome"
data/Gemfile.lock CHANGED
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: ../rubocop-powerhome
3
3
  specs:
4
- rubocop-powerhome (0.3.0)
5
- rubocop
4
+ rubocop-powerhome (0.5.2)
5
+ rubocop (~> 1.37)
6
6
  rubocop-performance
7
7
  rubocop-rails
8
8
  rubocop-rake
@@ -11,82 +11,113 @@ PATH
11
11
  PATH
12
12
  remote: .
13
13
  specs:
14
- rubocop-cobra (0.3.0)
15
- rubocop
14
+ rubocop-cobra (0.4.2)
15
+ rubocop (~> 1.37)
16
16
  rubocop-powerhome
17
17
 
18
18
  GEM
19
19
  remote: https://rubygems.org/
20
20
  specs:
21
- activesupport (7.0.3)
21
+ activesupport (7.0.4.2)
22
22
  concurrent-ruby (~> 1.0, >= 1.0.2)
23
23
  i18n (>= 1.6, < 2)
24
24
  minitest (>= 5.1)
25
25
  tzinfo (~> 2.0)
26
26
  ast (2.4.2)
27
- concurrent-ruby (1.1.10)
27
+ byebug (11.1.3)
28
+ coderay (1.1.3)
29
+ concurrent-ruby (1.2.0)
28
30
  diff-lcs (1.5.0)
29
- i18n (1.10.0)
31
+ i18n (1.12.0)
30
32
  concurrent-ruby (~> 1.0)
31
- minitest (5.15.0)
33
+ json (2.6.3)
34
+ license_finder (7.1.0)
35
+ bundler
36
+ rubyzip (>= 1, < 3)
37
+ thor (~> 1.2)
38
+ tomlrb (>= 1.3, < 2.1)
39
+ with_env (= 1.1.0)
40
+ xml-simple (~> 1.1.9)
41
+ method_source (1.0.0)
42
+ minitest (5.17.0)
32
43
  parallel (1.22.1)
33
- parser (3.1.2.0)
44
+ parser (3.2.0.0)
34
45
  ast (~> 2.4.1)
35
- rack (2.2.3)
46
+ pry (0.13.1)
47
+ coderay (~> 1.1)
48
+ method_source (~> 1.0)
49
+ pry-byebug (3.9.0)
50
+ byebug (~> 11.0)
51
+ pry (~> 0.13.0)
52
+ rack (3.0.4.1)
36
53
  rainbow (3.1.1)
37
54
  rake (13.0.6)
38
- regexp_parser (2.4.0)
55
+ regexp_parser (2.6.2)
39
56
  rexml (3.2.5)
40
- rspec (3.11.0)
41
- rspec-core (~> 3.11.0)
42
- rspec-expectations (~> 3.11.0)
43
- rspec-mocks (~> 3.11.0)
44
- rspec-core (3.11.0)
45
- rspec-support (~> 3.11.0)
46
- rspec-expectations (3.11.0)
57
+ rspec (3.12.0)
58
+ rspec-core (~> 3.12.0)
59
+ rspec-expectations (~> 3.12.0)
60
+ rspec-mocks (~> 3.12.0)
61
+ rspec-core (3.12.1)
62
+ rspec-support (~> 3.12.0)
63
+ rspec-expectations (3.12.2)
47
64
  diff-lcs (>= 1.2.0, < 2.0)
48
- rspec-support (~> 3.11.0)
49
- rspec-mocks (3.11.1)
65
+ rspec-support (~> 3.12.0)
66
+ rspec-mocks (3.12.3)
50
67
  diff-lcs (>= 1.2.0, < 2.0)
51
- rspec-support (~> 3.11.0)
52
- rspec-support (3.11.0)
53
- rubocop (1.29.1)
68
+ rspec-support (~> 3.12.0)
69
+ rspec-support (3.12.0)
70
+ rubocop (1.44.1)
71
+ json (~> 2.3)
54
72
  parallel (~> 1.10)
55
- parser (>= 3.1.0.0)
73
+ parser (>= 3.2.0.0)
56
74
  rainbow (>= 2.2.2, < 4.0)
57
75
  regexp_parser (>= 1.8, < 3.0)
58
76
  rexml (>= 3.2.5, < 4.0)
59
- rubocop-ast (>= 1.17.0, < 2.0)
77
+ rubocop-ast (>= 1.24.1, < 2.0)
60
78
  ruby-progressbar (~> 1.7)
61
- unicode-display_width (>= 1.4.0, < 3.0)
62
- rubocop-ast (1.18.0)
79
+ unicode-display_width (>= 2.4.0, < 3.0)
80
+ rubocop-ast (1.24.1)
63
81
  parser (>= 3.1.1.0)
64
- rubocop-performance (1.13.3)
82
+ rubocop-capybara (2.17.0)
83
+ rubocop (~> 1.41)
84
+ rubocop-performance (1.16.0)
65
85
  rubocop (>= 1.7.0, < 2.0)
66
86
  rubocop-ast (>= 0.4.0)
67
- rubocop-rails (2.14.2)
87
+ rubocop-rails (2.17.4)
68
88
  activesupport (>= 4.2.0)
69
89
  rack (>= 1.1)
70
- rubocop (>= 1.7.0, < 2.0)
90
+ rubocop (>= 1.33.0, < 2.0)
71
91
  rubocop-rake (0.6.0)
72
92
  rubocop (~> 1.0)
73
- rubocop-rspec (2.11.1)
74
- rubocop (~> 1.19)
93
+ rubocop-rspec (2.18.1)
94
+ rubocop (~> 1.33)
95
+ rubocop-capybara (~> 2.17)
75
96
  ruby-progressbar (1.11.0)
76
- tzinfo (2.0.4)
97
+ rubyzip (2.3.2)
98
+ thor (1.2.1)
99
+ tomlrb (2.0.3)
100
+ tzinfo (2.0.6)
77
101
  concurrent-ruby (~> 1.0)
78
- unicode-display_width (2.1.0)
102
+ unicode-display_width (2.4.2)
103
+ with_env (1.1.0)
104
+ xml-simple (1.1.9)
105
+ rexml
79
106
 
80
107
  PLATFORMS
81
108
  arm64-darwin-21
109
+ ruby
110
+ x86_64-darwin-21
82
111
  x86_64-linux
83
112
 
84
113
  DEPENDENCIES
114
+ license_finder (~> 7.0)
115
+ pry-byebug (= 3.9.0)
85
116
  rake (~> 13.0)
86
117
  rspec (~> 3.0)
87
- rubocop (~> 1.29.1)
118
+ rubocop (~> 1.44.0)
88
119
  rubocop-cobra!
89
120
  rubocop-powerhome!
90
121
 
91
122
  BUNDLED WITH
92
- 2.3.7
123
+ 2.3.14
data/config/default.yml CHANGED
@@ -55,3 +55,8 @@ Cobra/PresenterFilePlacement:
55
55
  Description: 'This cop disallows adding global presenters to the `app/presenters` directory.'
56
56
  Enabled: true
57
57
  VersionAdded: '0.1.0'
58
+
59
+ Cobra/ViewComponentFilePlacement:
60
+ Description: 'This cop disallows adding global view_components to the `app/components` directory.'
61
+ Enabled: true
62
+ VersionAdded: '0.4.0'
@@ -0,0 +1,3 @@
1
+ ---
2
+ - - :inherit_from
3
+ - https://raw.githubusercontent.com/powerhome/oss-guide/master/license_rules.yml
File without changes
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RuboCop
4
4
  module Cobra
5
- VERSION = "0.3.0"
5
+ VERSION = "0.4.2"
6
6
  end
7
7
  end
@@ -0,0 +1,100 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RuboCop
4
+ module Cop
5
+ module Cobra
6
+ # This cop disallows adding global view_components to the `app/components` directory.
7
+ #
8
+ # The goal is to encourage developers to put new view_components inside the correct
9
+ # namespace, where they can be more modularly isolated and ownership is clear.
10
+ #
11
+ # The correct namespace is `app/components/my_component/resource/view_component.rb.
12
+ # Similar to how `app/views` templates are nested in a directory named after the controller's resource.
13
+ #
14
+ # @example
15
+ # # bad
16
+ # # path: components/my_component/app/components/foo_component.rb
17
+ # class FooComponent < ::ViewComponent::Base
18
+ # # ...
19
+ # end
20
+ #
21
+ # # bad
22
+ # # path: components/my_component/app/components/my_component/foo_component.rb
23
+ # module MyComponent
24
+ # class FooComponent < MyComponent::ApplicationComponent
25
+ # # ...
26
+ # end
27
+ # end
28
+ #
29
+ # # acceptable
30
+ # # path: components/my_component/app/components/my_component/application_component.rb
31
+ # module MyComponent
32
+ # class ApplicationComponent < ::ViewComponent::Base
33
+ # # ...
34
+ # end
35
+ # end
36
+ # end
37
+ #
38
+ # # good
39
+ # # path: components/my_component/app/components/my_component/resource/foo_component.rb
40
+ # module MyComponent
41
+ # module Resource
42
+ # class FooComponent < MyComponent::ApplicationComponent
43
+ # # ...
44
+ # end
45
+ # end
46
+ # end
47
+ #
48
+ class ViewComponentFilePlacement < RuboCop::Cop::Cop
49
+ FILE_PLACEMENT_MSG =
50
+ "Nest ViewComponent definitions in the parent component and resource namespace. " \
51
+ "For example: `%<correct_path>s`"
52
+
53
+ def investigate(processed_source)
54
+ return if processed_source.blank?
55
+ return unless path_contains_matcher?
56
+ return if namespaced_correctly?
57
+
58
+ add_offense(processed_source.ast,
59
+ message: format(FILE_PLACEMENT_MSG, correct_path: correct_path))
60
+ end
61
+
62
+ private
63
+
64
+ def view_components_path
65
+ "app/components/"
66
+ end
67
+
68
+ def path
69
+ @path ||= processed_source.file_path
70
+ end
71
+
72
+ def namespaced_correctly?
73
+ potential_component_name = component_name
74
+ component_path = File.join(
75
+ potential_component_name,
76
+ view_components_path,
77
+ potential_component_name
78
+ )
79
+ return false unless path.include?("#{component_path}/")
80
+
81
+ sub_path = path.split("#{component_path}/").last
82
+ sub_path.include?("/") || sub_path == "application_component.rb"
83
+ end
84
+
85
+ def correct_path
86
+ file = path.split("/").last
87
+ "#{view_components_path}#{component_name}/<resource>/#{file}"
88
+ end
89
+
90
+ def component_name
91
+ path.split(view_components_path).first.split("/").last
92
+ end
93
+
94
+ def path_contains_matcher?
95
+ path.include?(view_components_path)
96
+ end
97
+ end
98
+ end
99
+ end
100
+ end
@@ -16,6 +16,7 @@ module RuboCop
16
16
  require_relative "cobra/mailer_file_placement"
17
17
  require_relative "cobra/model_file_placement"
18
18
  require_relative "cobra/presenter_file_placement"
19
+ require_relative "cobra/view_component_file_placement"
19
20
  end
20
21
  end
21
22
  end
data/mkdocs.yml ADDED
@@ -0,0 +1,9 @@
1
+ site_name: Rubocop Cobra
2
+ site_description: Gem focused on providing Cops to support a healthy cobra app development
3
+ repo_url: https://github.com/powerhome/power_linting
4
+ edit_uri: edit/main/rubocop_cobra/docs/
5
+ nav:
6
+ - 'Home': 'README.md'
7
+
8
+ plugins:
9
+ - techdocs-core
@@ -5,8 +5,8 @@ require_relative "lib/rubocop/cobra/version"
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "rubocop-cobra"
7
7
  spec.version = RuboCop::Cobra::VERSION
8
- spec.authors = ["Carlos Palhares"]
9
- spec.email = ["chjunior@gmail.com"]
8
+ spec.authors = ["Carlos Palhares", "Garett Arrowood"]
9
+ spec.email = ["chjunior@gmail.com", "garettarrowood@gmail.com"]
10
10
 
11
11
  spec.summary = "Cobra rubocop linters"
12
12
  spec.description = "Cobra rubocop linters"
@@ -35,7 +35,10 @@ Gem::Specification.new do |spec|
35
35
  # For more information and examples about making a new gem, check out our
36
36
  # guide at: https://bundler.io/guides/creating_gem.html
37
37
 
38
- spec.add_runtime_dependency "rubocop"
38
+ spec.add_runtime_dependency "rubocop", "~> 1.37"
39
39
  spec.add_runtime_dependency "rubocop-powerhome"
40
40
  spec.metadata["rubygems_mfa_required"] = "true"
41
+
42
+ spec.add_development_dependency "license_finder", "~> 7.0"
43
+ spec.add_development_dependency "pry-byebug", "3.9.0"
41
44
  end
metadata CHANGED
@@ -1,29 +1,30 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubocop-cobra
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carlos Palhares
8
+ - Garett Arrowood
8
9
  autorequire:
9
10
  bindir: exe
10
11
  cert_chain: []
11
- date: 2022-05-20 00:00:00.000000000 Z
12
+ date: 2023-02-08 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: rubocop
15
16
  requirement: !ruby/object:Gem::Requirement
16
17
  requirements:
17
- - - ">="
18
+ - - "~>"
18
19
  - !ruby/object:Gem::Version
19
- version: '0'
20
+ version: '1.37'
20
21
  type: :runtime
21
22
  prerelease: false
22
23
  version_requirements: !ruby/object:Gem::Requirement
23
24
  requirements:
24
- - - ">="
25
+ - - "~>"
25
26
  - !ruby/object:Gem::Version
26
- version: '0'
27
+ version: '1.37'
27
28
  - !ruby/object:Gem::Dependency
28
29
  name: rubocop-powerhome
29
30
  requirement: !ruby/object:Gem::Requirement
@@ -38,9 +39,38 @@ dependencies:
38
39
  - - ">="
39
40
  - !ruby/object:Gem::Version
40
41
  version: '0'
42
+ - !ruby/object:Gem::Dependency
43
+ name: license_finder
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - "~>"
47
+ - !ruby/object:Gem::Version
48
+ version: '7.0'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - "~>"
54
+ - !ruby/object:Gem::Version
55
+ version: '7.0'
56
+ - !ruby/object:Gem::Dependency
57
+ name: pry-byebug
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - '='
61
+ - !ruby/object:Gem::Version
62
+ version: 3.9.0
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - '='
68
+ - !ruby/object:Gem::Version
69
+ version: 3.9.0
41
70
  description: Cobra rubocop linters
42
71
  email:
43
72
  - chjunior@gmail.com
73
+ - garettarrowood@gmail.com
44
74
  executables: []
45
75
  extensions: []
46
76
  extra_rdoc_files: []
@@ -51,9 +81,10 @@ files:
51
81
  - Gemfile
52
82
  - Gemfile.lock
53
83
  - LICENSE.txt
54
- - README.md
55
84
  - Rakefile
56
85
  - config/default.yml
86
+ - doc/dependency_decisions.yml
87
+ - docs/README.md
57
88
  - lib/rubocop-cobra.rb
58
89
  - lib/rubocop/cobra.rb
59
90
  - lib/rubocop/cobra/inject.rb
@@ -70,7 +101,9 @@ files:
70
101
  - lib/rubocop/cop/cobra/mailer_file_placement.rb
71
102
  - lib/rubocop/cop/cobra/model_file_placement.rb
72
103
  - lib/rubocop/cop/cobra/presenter_file_placement.rb
104
+ - lib/rubocop/cop/cobra/view_component_file_placement.rb
73
105
  - lib/rubocop/cop/cobra_cops.rb
106
+ - mkdocs.yml
74
107
  - rubocop-cobra.gemspec
75
108
  - sig/rubocop/cobra.rbs
76
109
  homepage: https://github.com/powerhome/power_linting
@@ -96,7 +129,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
96
129
  - !ruby/object:Gem::Version
97
130
  version: '0'
98
131
  requirements: []
99
- rubygems_version: 3.3.7
132
+ rubygems_version: 3.4.1
100
133
  signing_key:
101
134
  specification_version: 4
102
135
  summary: Cobra rubocop linters