rubocop-powerhome 0.2.0 → 0.4.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: 39410b7a81b2f413f11e1d7a47c47fcff5a16d5ad1c0967cc687fb94595354e4
4
- data.tar.gz: 4e8c866ddee5a181de4b72a28aa739052e74c5071d7f75dbc4b2fa546574eeac
3
+ metadata.gz: dd64fd1998b87999ae9bb7099b5679bb6a30761b12737cd35f88e49781fc4e7c
4
+ data.tar.gz: 4396dfb22ae26ef117a7c68c90deaba21702c47621eb70c5a4685118aec74850
5
5
  SHA512:
6
- metadata.gz: dc6ddad8767fe3f5f5c8a1574f3a69214d870e46e8b7e182bd53c4d4f02a3a586e5a74cd9d85d18a5cc01419171849ef71bb64c1503f5f50ed55b1404d62aee8
7
- data.tar.gz: 219f37850a53709de7b8953899da72ff31edb5e3dcb50b459d55451d24f0050a7e5ec685449ebbded657106bc1f21ee4820e05e90444f6cee6f2a3055cb05212
6
+ metadata.gz: e402c21a5d9f395620d5681c40f7738aebbd50666f94dacb14db765f66f749768bbe8f4cf030e4761449b99073264315c945b65b49229b55c91d632280d21600
7
+ data.tar.gz: 7b722eab1a5f6bdbcb4d2e3b52b5d694aca839745079263e421d6c4740216d0ca4d0148783032fa119ecc07e35f6a0fe2f2ab6a9139ee41f408c4a5ca32f984b
data/.rubocop.yml CHANGED
@@ -5,5 +5,10 @@ Naming/FileName:
5
5
  Exclude:
6
6
  - lib/rubocop-powerhome.rb
7
7
 
8
+ Metrics/BlockLength:
9
+ Exclude:
10
+ - 'spec/**/*'
11
+ - 'rubocop-powerhome.gemspec'
12
+
8
13
  Rails:
9
14
  Enabled: false
data/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.4.1] - 2022-06-02
4
+
5
+ - Fix bug in Naming/ViewComponent when class does not inherit
6
+
7
+ ## [0.4.0] - 2022-06-01
8
+
9
+ - Adds Naming/ViewComponent cop
10
+ - Adds Style/NoHelpers cop
11
+
3
12
  ## [0.1.0] - 2022-05-18
4
13
 
5
14
  - Initial release
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rubocop-powerhome (0.2.0)
4
+ rubocop-powerhome (0.4.1)
5
5
  rubocop
6
6
  rubocop-performance
7
7
  rubocop-rails
@@ -17,15 +17,24 @@ GEM
17
17
  minitest (>= 5.1)
18
18
  tzinfo (~> 2.0)
19
19
  ast (2.4.2)
20
+ byebug (11.1.3)
21
+ coderay (1.1.3)
20
22
  concurrent-ruby (1.1.10)
21
23
  diff-lcs (1.5.0)
22
24
  i18n (1.10.0)
23
25
  concurrent-ruby (~> 1.0)
26
+ method_source (1.0.0)
24
27
  minitest (5.15.0)
25
28
  parallel (1.22.1)
26
29
  parser (3.1.2.0)
27
30
  ast (~> 2.4.1)
28
- rack (2.2.3)
31
+ pry (0.13.1)
32
+ coderay (~> 1.1)
33
+ method_source (~> 1.0)
34
+ pry-byebug (3.9.0)
35
+ byebug (~> 11.0)
36
+ pry (~> 0.13.0)
37
+ rack (2.2.3.1)
29
38
  rainbow (3.1.1)
30
39
  rake (13.0.6)
31
40
  regexp_parser (2.4.0)
@@ -76,6 +85,7 @@ PLATFORMS
76
85
  x86_64-linux
77
86
 
78
87
  DEPENDENCIES
88
+ pry-byebug (= 3.9.0)
79
89
  rake (~> 13.0)
80
90
  rspec (~> 3.0)
81
91
  rubocop (~> 1.29.1)
data/README.md CHANGED
@@ -1,13 +1,13 @@
1
1
  # Rubocop::Powerhome
2
2
 
3
- This gem is focused on providing standard rubocop configuration for Power Home Remodeling ruby apps.
3
+ This gem is focused on providing standard Rubocop configuration for Power Home Remodeling ruby apps.
4
4
 
5
5
  ## Installation
6
6
 
7
7
  Add this line to your application's Gemfile under development:
8
8
 
9
9
  ```ruby
10
- gem 'rubocop-powerhome', require: false
10
+ gem "rubocop-powerhome", require: false
11
11
  ```
12
12
 
13
13
  And then execute:
@@ -25,6 +25,8 @@ require:
25
25
 
26
26
  That's it! You can override the standard configuration after that.
27
27
 
28
+ It's recommended that you set `AllCops/TargetRubyVersion` in your project because some cops are Ruby version-dependent. See more [here](https://docs.rubocop.org/rubocop/configuration.html#setting-the-target-ruby-version).
29
+
28
30
  ## Development
29
31
 
30
32
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -37,4 +39,4 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/powerh
37
39
 
38
40
  ## License
39
41
 
40
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
42
+ The gem is available as open-source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/config/default.yml CHANGED
@@ -24,6 +24,11 @@ Naming/MethodParameterName:
24
24
  - in
25
25
  - at
26
26
 
27
+ Naming/ViewComponent:
28
+ Description: 'This cop requires ViewComponent classes to end with Component in their classname.'
29
+ Enabled: true
30
+ VersionAdded: '0.4.0'
31
+
27
32
  Rails:
28
33
  Enabled: true
29
34
 
@@ -59,6 +64,11 @@ Style/HashTransformValues:
59
64
  Style/Lambda:
60
65
  EnforcedStyle: literal
61
66
 
67
+ Style/NoHelpers:
68
+ Description: 'This cop blocks global helper modules from existing in an application.'
69
+ Enabled: true
70
+ VersionAdded: '0.4.0'
71
+
62
72
  Style/NumericPredicate:
63
73
  Enabled: false
64
74
 
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RuboCop
4
+ module Cop
5
+ module Naming
6
+ # This cop requires ViewComponent classes to end with Component in their classname.
7
+ #
8
+ # @example
9
+ # # bad
10
+ # class Foo < ::ViewComponent::Base
11
+ # # ...
12
+ # end
13
+ #
14
+ # # good
15
+ # class FooComponent < ::ViewComponent::Base
16
+ # # ...
17
+ # end
18
+ #
19
+ class ViewComponent < RuboCop::Cop::Cop
20
+ def on_class(node)
21
+ inheritance_klass = node.node_parts[1]&.source
22
+ return unless view_component_class?(inheritance_klass)
23
+
24
+ klass = node.node_parts[0]&.source
25
+ return if klass.end_with?("Component")
26
+
27
+ add_offense(node.node_parts[0], message: "End ViewComponent classnames with 'Component'")
28
+ end
29
+
30
+ private
31
+
32
+ def view_component_class?(inheritance_klass)
33
+ inheritance_klass&.end_with?("::ApplicationComponent", "ViewComponent::Base")
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RuboCop
4
+ module Cop
5
+ module Naming
6
+ require_relative "naming/view_component"
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RuboCop
4
+ module Cop
5
+ module Style
6
+ # This cop does not allow helpers to be placed in an application. View objects,
7
+ # specifically ViewComponent, create better Object Oriented design.
8
+ # Global helper methods tightly couple templates.
9
+ #
10
+ class NoHelpers < RuboCop::Cop::Cop
11
+ MSG = "Helpers create global view methods. Instead, use view objects to " \
12
+ "encapsulate your display logic."
13
+
14
+ def investigate(processed_source)
15
+ return if processed_source.blank?
16
+ return unless helper_path?
17
+
18
+ add_offense(processed_source.ast, message: format(MSG))
19
+ end
20
+
21
+ private
22
+
23
+ def helper_path?
24
+ processed_source.file_path.include?("app/helpers/")
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RuboCop
4
+ module Cop
5
+ module Style
6
+ require_relative "style/no_helpers"
7
+ end
8
+ end
9
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RuboCop
4
4
  module Powerhome
5
- VERSION = "0.2.0"
5
+ VERSION = "0.4.1"
6
6
  end
7
7
  end
@@ -9,3 +9,6 @@ require "rubocop-rspec"
9
9
  require_relative "rubocop/powerhome"
10
10
 
11
11
  RuboCop::Powerhome::Inject.defaults!
12
+
13
+ require_relative "rubocop/cop/naming_cops"
14
+ require_relative "rubocop/cop/style_cops"
@@ -5,14 +5,14 @@ require_relative "lib/rubocop/powerhome/version"
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "rubocop-powerhome"
7
7
  spec.version = RuboCop::Powerhome::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 = "Powerhome Rubocop standard rules"
12
12
  spec.description = "Powerhome Rubocop standard rules"
13
13
  spec.homepage = "https://github.com/powerhome/power_linting"
14
14
  spec.license = "MIT"
15
- spec.required_ruby_version = ">= 2.6.0"
15
+ spec.required_ruby_version = ">= 2.7.0"
16
16
 
17
17
  spec.metadata["homepage_uri"] = spec.homepage
18
18
  spec.metadata["source_code_uri"] = spec.homepage
@@ -41,4 +41,6 @@ Gem::Specification.new do |spec|
41
41
  spec.add_runtime_dependency "rubocop-rake"
42
42
  spec.add_runtime_dependency "rubocop-rspec"
43
43
  spec.metadata["rubygems_mfa_required"] = "true"
44
+
45
+ spec.add_development_dependency "pry-byebug", "3.9.0"
44
46
  end
metadata CHANGED
@@ -1,14 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubocop-powerhome
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.4.1
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-19 00:00:00.000000000 Z
12
+ date: 2022-06-02 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: rubocop
@@ -80,9 +81,24 @@ dependencies:
80
81
  - - ">="
81
82
  - !ruby/object:Gem::Version
82
83
  version: '0'
84
+ - !ruby/object:Gem::Dependency
85
+ name: pry-byebug
86
+ requirement: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - '='
89
+ - !ruby/object:Gem::Version
90
+ version: 3.9.0
91
+ type: :development
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - '='
96
+ - !ruby/object:Gem::Version
97
+ version: 3.9.0
83
98
  description: Powerhome Rubocop standard rules
84
99
  email:
85
100
  - chjunior@gmail.com
101
+ - garettarrowood@gmail.com
86
102
  executables: []
87
103
  extensions: []
88
104
  extra_rdoc_files: []
@@ -96,6 +112,10 @@ files:
96
112
  - Rakefile
97
113
  - config/default.yml
98
114
  - lib/rubocop-powerhome.rb
115
+ - lib/rubocop/cop/naming/view_component.rb
116
+ - lib/rubocop/cop/naming_cops.rb
117
+ - lib/rubocop/cop/style/no_helpers.rb
118
+ - lib/rubocop/cop/style_cops.rb
99
119
  - lib/rubocop/powerhome.rb
100
120
  - lib/rubocop/powerhome/inject.rb
101
121
  - lib/rubocop/powerhome/version.rb
@@ -117,7 +137,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
117
137
  requirements:
118
138
  - - ">="
119
139
  - !ruby/object:Gem::Version
120
- version: 2.6.0
140
+ version: 2.7.0
121
141
  required_rubygems_version: !ruby/object:Gem::Requirement
122
142
  requirements:
123
143
  - - ">="