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 +4 -4
- data/CHANGELOG.md +12 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +67 -36
- data/config/default.yml +5 -0
- data/doc/dependency_decisions.yml +3 -0
- data/{README.md → docs/README.md} +0 -0
- data/lib/rubocop/cobra/version.rb +1 -1
- data/lib/rubocop/cop/cobra/view_component_file_placement.rb +100 -0
- data/lib/rubocop/cop/cobra_cops.rb +1 -0
- data/mkdocs.yml +9 -0
- data/rubocop-cobra.gemspec +6 -3
- metadata +41 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 07b98212c7432d3e5fd8d00f879f6c242d121c74e9d24ba1b1d56c708410d78b
|
4
|
+
data.tar.gz: bbc10babcde31d9bcbadebf4dd8970f113ecbfc2737c8c459a9a2677e2fa3e35
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
data/Gemfile.lock
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
PATH
|
2
2
|
remote: ../rubocop-powerhome
|
3
3
|
specs:
|
4
|
-
rubocop-powerhome (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.
|
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.
|
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
|
-
|
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.
|
31
|
+
i18n (1.12.0)
|
30
32
|
concurrent-ruby (~> 1.0)
|
31
|
-
|
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.
|
44
|
+
parser (3.2.0.0)
|
34
45
|
ast (~> 2.4.1)
|
35
|
-
|
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.
|
55
|
+
regexp_parser (2.6.2)
|
39
56
|
rexml (3.2.5)
|
40
|
-
rspec (3.
|
41
|
-
rspec-core (~> 3.
|
42
|
-
rspec-expectations (~> 3.
|
43
|
-
rspec-mocks (~> 3.
|
44
|
-
rspec-core (3.
|
45
|
-
rspec-support (~> 3.
|
46
|
-
rspec-expectations (3.
|
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.
|
49
|
-
rspec-mocks (3.
|
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.
|
52
|
-
rspec-support (3.
|
53
|
-
rubocop (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.
|
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.
|
77
|
+
rubocop-ast (>= 1.24.1, < 2.0)
|
60
78
|
ruby-progressbar (~> 1.7)
|
61
|
-
unicode-display_width (>=
|
62
|
-
rubocop-ast (1.
|
79
|
+
unicode-display_width (>= 2.4.0, < 3.0)
|
80
|
+
rubocop-ast (1.24.1)
|
63
81
|
parser (>= 3.1.1.0)
|
64
|
-
rubocop-
|
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.
|
87
|
+
rubocop-rails (2.17.4)
|
68
88
|
activesupport (>= 4.2.0)
|
69
89
|
rack (>= 1.1)
|
70
|
-
rubocop (>= 1.
|
90
|
+
rubocop (>= 1.33.0, < 2.0)
|
71
91
|
rubocop-rake (0.6.0)
|
72
92
|
rubocop (~> 1.0)
|
73
|
-
rubocop-rspec (2.
|
74
|
-
rubocop (~> 1.
|
93
|
+
rubocop-rspec (2.18.1)
|
94
|
+
rubocop (~> 1.33)
|
95
|
+
rubocop-capybara (~> 2.17)
|
75
96
|
ruby-progressbar (1.11.0)
|
76
|
-
|
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.
|
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.
|
118
|
+
rubocop (~> 1.44.0)
|
88
119
|
rubocop-cobra!
|
89
120
|
rubocop-powerhome!
|
90
121
|
|
91
122
|
BUNDLED WITH
|
92
|
-
2.3.
|
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'
|
File without changes
|
@@ -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
|
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
|
data/rubocop-cobra.gemspec
CHANGED
@@ -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.
|
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:
|
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: '
|
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: '
|
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.
|
132
|
+
rubygems_version: 3.4.1
|
100
133
|
signing_key:
|
101
134
|
specification_version: 4
|
102
135
|
summary: Cobra rubocop linters
|