momocop 0.1.15 → 0.2.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: 711882a976895992e975ef619137dfe75d05cecdd82b249d3d5607aa87bff05d
4
- data.tar.gz: 86b276769f8e043d927b556f245bea1d4c80cea5cae8a2a04b05cbd89f9e14f7
3
+ metadata.gz: f20cc9ff605a765cbb69d7540eab272368da8ec2db1508bf15f68c055256f306
4
+ data.tar.gz: ae33c4d6d07c9db8707f49694b3609f55297280f3910b2fb98613d52a44b2c7b
5
5
  SHA512:
6
- metadata.gz: 4276e49e54c3833cc3a7b701c06fd482ead664d22b3e4add6d7326ba88b78f7dd331f911aac1e9dd1c2e139945f945d766a23d6bfeb484514059ddb5bae0f3b7
7
- data.tar.gz: d6155319eb7e442b886dc8768e88442e86527eefa1af48105d1bcc955a87ed460016122f90e502190978032a88d5724807f4dd4d28400bdc0569b3b5acde21dc
6
+ metadata.gz: f1f054e0cff3c118d11191948622c99e5ccdffde3c09bacc7ea0e9fdffdc6dd2fb61158bc4d30ac7627ac87473a8188de34082780fee715fd7609abe7cadac71
7
+ data.tar.gz: 8838377046d17cf9f238747d0a0c6de7d2d78fbb0f01c672c391c3252dd47cacd962518b23e3f72ff15aeb3acd17d20e71bf2e3eb98557a8c7fccee982e7a279
data/README.ja.md CHANGED
@@ -46,6 +46,8 @@ Momocop/FactoryBotSingleFactoryPerDefine:
46
46
  Enabled: true
47
47
  Momocop/FactoryBotSingularFactoryName:
48
48
  Enabled: true
49
+ Momocop/Layout/LeadingCommentSpace:
50
+ Enabled: true
49
51
  ```
50
52
 
51
53
  ## Cop一覧
@@ -62,6 +64,7 @@ Momocop/FactoryBotSingularFactoryName:
62
64
  |[`Momocop/FactoryBotSingleDefinePerFile`](lib/rubocop/cop/momocop/factory_bot_single_define_per_file.rb)|:white_check_mark:|:white_check_mark:|
63
65
  |[`Momocop/FactoryBotSingleFactoryPerDefine`](lib/rubocop/cop/momocop/factory_bot_single_factory_per_define.rb)|:white_check_mark:|:white_check_mark:|
64
66
  |[`Momocop/FactoryBotSingularFactoryName`](lib/rubocop/cop/momocop/factory_bot_singular_factory_name.rb)|:white_check_mark:|:white_check_mark:|
67
+ |[`Momocop/Layout/LeadingCommentSpace`](lib/rubocop/cop/momocop/layout/leading_comment_space.rb)|||
65
68
 
66
69
  ## 貢献
67
70
 
data/README.ja.md.erb CHANGED
@@ -27,10 +27,11 @@ require:
27
27
  - momocop
28
28
 
29
29
  <%
30
- files = Dir.glob('lib/rubocop/cop/momocop/*.rb').sort_by { |f| File.basename(f)}
30
+ files = Dir.glob('lib/rubocop/cop/momocop/**/*.rb').sort_by { |f| File.basename(f)}
31
31
  files.each do |cop_file_path|
32
32
  base_name = File.basename(cop_file_path, '.rb')
33
- cop_class_name = "Momocop/#{base_name.camelize}"
33
+ namespace = File.dirname(cop_file_path).sub('lib/rubocop/cop/', '').split('/').map(&:camelize).join('/')
34
+ cop_class_name = "#{namespace}/#{base_name.camelize}"
34
35
 
35
36
  -%>
36
37
  <%= cop_class_name %>:
@@ -43,10 +44,11 @@ require:
43
44
  |Cop|Rails|FactoryBot|
44
45
  |---|:-:|:-:|
45
46
  <%
46
- files = Dir.glob('lib/rubocop/cop/momocop/*.rb').sort_by { |f| File.basename(f)}
47
+ files = Dir.glob('lib/rubocop/cop/momocop/**/*.rb').sort_by { |f| File.basename(f)}
47
48
  files.each do |cop_file_path|
48
49
  base_name = File.basename(cop_file_path, '.rb')
49
- cop_class_name = "Momocop/#{base_name.camelize}"
50
+ namespace = File.dirname(cop_file_path).sub('lib/rubocop/cop/', '').split('/').map(&:camelize).join('/')
51
+ cop_class_name = "#{namespace}/#{base_name.camelize}"
50
52
  is_factory_cop = cop_file_path.include?('factory_bot_')
51
53
  is_rails_cop = cop_file_path.match?(/(factory_bot_|rails_)/)
52
54
  rails_mark = is_rails_cop ? ':white_check_mark:' : ''
data/README.md CHANGED
@@ -46,6 +46,8 @@ Momocop/FactoryBotSingleFactoryPerDefine:
46
46
  Enabled: true
47
47
  Momocop/FactoryBotSingularFactoryName:
48
48
  Enabled: true
49
+ Momocop/Layout/LeadingCommentSpace:
50
+ Enabled: true
49
51
  ```
50
52
 
51
53
  ## Cops
@@ -62,6 +64,7 @@ Momocop/FactoryBotSingularFactoryName:
62
64
  |[`Momocop/FactoryBotSingleDefinePerFile`](lib/rubocop/cop/momocop/factory_bot_single_define_per_file.rb)|:white_check_mark:|:white_check_mark:|
63
65
  |[`Momocop/FactoryBotSingleFactoryPerDefine`](lib/rubocop/cop/momocop/factory_bot_single_factory_per_define.rb)|:white_check_mark:|:white_check_mark:|
64
66
  |[`Momocop/FactoryBotSingularFactoryName`](lib/rubocop/cop/momocop/factory_bot_singular_factory_name.rb)|:white_check_mark:|:white_check_mark:|
67
+ |[`Momocop/Layout/LeadingCommentSpace`](lib/rubocop/cop/momocop/layout/leading_comment_space.rb)|||
65
68
 
66
69
  ## Contributing
67
70
 
data/README.md.erb CHANGED
@@ -27,10 +27,11 @@ require:
27
27
  - momocop
28
28
 
29
29
  <%
30
- files = Dir.glob('lib/rubocop/cop/momocop/*.rb').sort_by { |f| File.basename(f)}
30
+ files = Dir.glob('lib/rubocop/cop/momocop/**/*.rb').sort_by { |f| File.basename(f)}
31
31
  files.each do |cop_file_path|
32
32
  base_name = File.basename(cop_file_path, '.rb')
33
- cop_class_name = "Momocop/#{base_name.camelize}"
33
+ namespace = File.dirname(cop_file_path).sub('lib/rubocop/cop/', '').split('/').map(&:camelize).join('/')
34
+ cop_class_name = "#{namespace}/#{base_name.camelize}"
34
35
 
35
36
  -%>
36
37
  <%= cop_class_name %>:
@@ -43,10 +44,11 @@ require:
43
44
  |Cop|Rails|FactoryBot|
44
45
  |---|:-:|:-:|
45
46
  <%
46
- files = Dir.glob('lib/rubocop/cop/momocop/*.rb').sort_by { |f| File.basename(f)}
47
+ files = Dir.glob('lib/rubocop/cop/momocop/**/*.rb').sort_by { |f| File.basename(f)}
47
48
  files.each do |cop_file_path|
48
49
  base_name = File.basename(cop_file_path, '.rb')
49
- cop_class_name = "Momocop/#{base_name.camelize}"
50
+ namespace = File.dirname(cop_file_path).sub('lib/rubocop/cop/', '').split('/').map(&:camelize).join('/')
51
+ cop_class_name = "#{namespace}/#{base_name.camelize}"
50
52
  is_factory_cop = cop_file_path.include?('factory_bot_')
51
53
  is_rails_cop = cop_file_path.match?(/(factory_bot_|rails_)/)
52
54
  rails_mark = is_rails_cop ? ':white_check_mark:' : ''
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Momocop
4
- VERSION = '0.1.15'
4
+ VERSION = '0.2.0'
5
5
  end
data/lib/momocop.rb CHANGED
@@ -23,6 +23,6 @@ end
23
23
 
24
24
  Momocop::ConfigInjector.inject_default_config!
25
25
 
26
- Dir[File.join(__dir__, 'rubocop/cop/momocop', '*.rb')].each do |file|
26
+ Dir[File.join(__dir__, 'rubocop/cop/momocop', '**', '*.rb')].each do |file|
27
27
  require file
28
28
  end
@@ -0,0 +1,77 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RuboCop
4
+ module Cop
5
+ module Momocop
6
+ module Layout
7
+ # Checks whether comments have a leading space after the
8
+ # `#` denoting the start of the comment. The leading space is not
9
+ # required for some RDoc special syntax, like `#++`, `#--`,
10
+ # `#:nodoc`, `=begin`- and `=end` comments, "shebang" directives,
11
+ # or rackup options, or rbs-inline typing.
12
+ #
13
+ # @example
14
+ #
15
+ # # bad
16
+ # #Some comment
17
+ #
18
+ # # good
19
+ # # Some comment
20
+ #
21
+ # @example AllowDoxygenCommentStyle: false (default)
22
+ #
23
+ # # bad
24
+ #
25
+ # #**
26
+ # # Some comment
27
+ # # Another line of comment
28
+ # #*
29
+ #
30
+ # @example AllowDoxygenCommentStyle: true
31
+ #
32
+ # # good
33
+ #
34
+ # #**
35
+ # # Some comment
36
+ # # Another line of comment
37
+ # #*
38
+ #
39
+ # @example AllowGemfileRubyComment: false (default)
40
+ #
41
+ # # bad
42
+ #
43
+ # #ruby=2.7.0
44
+ # #ruby-gemset=myproject
45
+ #
46
+ # @example AllowGemfileRubyComment: true
47
+ #
48
+ # # good
49
+ #
50
+ # #ruby=2.7.0
51
+ # #ruby-gemset=myproject
52
+ #
53
+ class LeadingCommentSpace < RuboCop::Cop::Layout::LeadingCommentSpace
54
+ def on_new_investigation
55
+ processed_source.comments.each do |comment|
56
+ next unless /\A(?!#\+\+|#--)(#+[^#\s=])/.match?(comment.text)
57
+ next if comment.loc.line == 1 && allowed_on_first_line?(comment)
58
+ next if doxygen_comment_style?(comment)
59
+ next if gemfile_ruby_comment?(comment)
60
+ next if rbs_inline_comment_style?(comment)
61
+
62
+ add_offense(comment) do |corrector|
63
+ expr = comment.source_range
64
+
65
+ corrector.insert_after(hash_mark(expr), ' ')
66
+ end
67
+ end
68
+ end
69
+
70
+ def rbs_inline_comment_style?(comment)
71
+ comment.text.start_with?('#:')
72
+ end
73
+ end
74
+ end
75
+ end
76
+ end
77
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: momocop
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.15
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - supermomonga
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-03-02 00:00:00.000000000 Z
11
+ date: 2024-08-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -103,6 +103,7 @@ files:
103
103
  - lib/rubocop/cop/momocop/factory_bot_single_define_per_file.rb
104
104
  - lib/rubocop/cop/momocop/factory_bot_single_factory_per_define.rb
105
105
  - lib/rubocop/cop/momocop/factory_bot_singular_factory_name.rb
106
+ - lib/rubocop/cop/momocop/layout/leading_comment_space.rb
106
107
  - sig/momocop.rbs
107
108
  homepage: https://github.com/supermomonga/momocop
108
109
  licenses:
@@ -126,7 +127,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
126
127
  - !ruby/object:Gem::Version
127
128
  version: '0'
128
129
  requirements: []
129
- rubygems_version: 3.3.26
130
+ rubygems_version: 3.3.27
130
131
  signing_key:
131
132
  specification_version: 4
132
133
  summary: Convention focused opinionated custom cops for RuboCop.