sevencop 0.30.0 → 0.31.0
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/Gemfile.lock +1 -1
- data/README.md +1 -0
- data/config/default.yml +6 -0
- data/lib/rubocop/cop/sevencop/constant_base.rb +66 -0
- data/lib/sevencop/version.rb +1 -1
- data/lib/sevencop.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ee749fe11f72d661269fa08344e0b5f578a21517375a75d58f5c2bab1877fdcd
|
4
|
+
data.tar.gz: 15a392c82cc473f1a5c327e2b1a6f0e1620d3b8e405aa6e548b020559bd24afd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9c2ea95803821697a72157ab0608459b44467cb2ec868ba66dc21f2613f7ac4eb52745d69d19d5ea43dff6fb40e70ebc2b59110a7bd58ff9ece189b401532c74
|
7
|
+
data.tar.gz: f3e26944c43c61b5ccf1f0875117ce77aba7b1ca8f223e5b174ea7a2d4737407b949bc1e362aa1363ee350106b60dc1852ee89af55b5953393b5d7dec432c8d2
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -29,6 +29,7 @@ Note that all cops are `Enabled: false` by default.
|
|
29
29
|
## Cops
|
30
30
|
|
31
31
|
- [Sevencop/AutoloadOrdered](lib/rubocop/cop/sevencop/autoload_ordered.rb)
|
32
|
+
- [Sevencop/ConstantBase](lib/rubocop/cop/sevencop/constant_base.rb)
|
32
33
|
- [Sevencop/FactoryBotAssociationOption](lib/rubocop/cop/sevencop/factory_bot_association_option.rb)
|
33
34
|
- [Sevencop/FactoryBotAssociationStyle](lib/rubocop/cop/sevencop/factory_bot_association_style.rb)
|
34
35
|
- [Sevencop/HashElementOrdered](lib/rubocop/cop/sevencop/hash_element_ordered.rb)
|
data/config/default.yml
CHANGED
@@ -5,6 +5,12 @@ Sevencop/AutoloadOrdered:
|
|
5
5
|
Safe: false
|
6
6
|
VersionAdded: '0.12'
|
7
7
|
|
8
|
+
Sevencop/ConstantBase:
|
9
|
+
Description: |
|
10
|
+
Remove unnecessary `::` prefix from constant.
|
11
|
+
Enabled: false
|
12
|
+
VersionAdded: '0.31'
|
13
|
+
|
8
14
|
Sevencop/FactoryBotAssociationOption:
|
9
15
|
Description: |
|
10
16
|
Remove redundant options from FactoryBot associations.
|
@@ -0,0 +1,66 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module Cop
|
5
|
+
module Sevencop
|
6
|
+
# Remove unnecessary `::` prefix from constant.
|
7
|
+
#
|
8
|
+
# @example
|
9
|
+
# # bad
|
10
|
+
# ::Const
|
11
|
+
#
|
12
|
+
# # good
|
13
|
+
# Const
|
14
|
+
#
|
15
|
+
# # bad
|
16
|
+
# class << self
|
17
|
+
# ::Const
|
18
|
+
# end
|
19
|
+
#
|
20
|
+
# # good
|
21
|
+
# class << self
|
22
|
+
# Const
|
23
|
+
# end
|
24
|
+
#
|
25
|
+
# # good
|
26
|
+
# class Klass
|
27
|
+
# ::Const
|
28
|
+
# end
|
29
|
+
#
|
30
|
+
# # good
|
31
|
+
# class module
|
32
|
+
# ::Const
|
33
|
+
# end
|
34
|
+
class ConstantBase < Base
|
35
|
+
extend AutoCorrector
|
36
|
+
|
37
|
+
MSG = 'Remove unnecessary `::` prefix from constant.'
|
38
|
+
|
39
|
+
# @param node [RuboCop::AST::CbaseNode]
|
40
|
+
# @return [void]
|
41
|
+
def on_cbase(node)
|
42
|
+
return unless bad?(node)
|
43
|
+
|
44
|
+
add_offense(node) do |corrector|
|
45
|
+
corrector.remove(node)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
private
|
50
|
+
|
51
|
+
# @!method named_class_or_module?(node)
|
52
|
+
# @param node [RuboCop::AST::Node]
|
53
|
+
# @return [Boolean]
|
54
|
+
def_node_matcher :named_class_or_module?, <<~PATTERN
|
55
|
+
({class module} const ...)
|
56
|
+
PATTERN
|
57
|
+
|
58
|
+
# @param node [RuboCop::AST::CbaseNode]
|
59
|
+
# @return [Boolean]
|
60
|
+
def bad?(node)
|
61
|
+
node.each_ancestor(:class, :module).none?
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
data/lib/sevencop/version.rb
CHANGED
data/lib/sevencop.rb
CHANGED
@@ -5,6 +5,7 @@ require_relative 'sevencop/rubocop_extension'
|
|
5
5
|
require_relative 'sevencop/version'
|
6
6
|
|
7
7
|
require_relative 'rubocop/cop/sevencop/autoload_ordered'
|
8
|
+
require_relative 'rubocop/cop/sevencop/constant_base'
|
8
9
|
require_relative 'rubocop/cop/sevencop/factory_bot_association_option'
|
9
10
|
require_relative 'rubocop/cop/sevencop/factory_bot_association_style'
|
10
11
|
require_relative 'rubocop/cop/sevencop/hash_element_ordered'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sevencop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.31.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryo Nakamura
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-11-
|
11
|
+
date: 2022-11-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -57,6 +57,7 @@ files:
|
|
57
57
|
- config/default.yml
|
58
58
|
- data/reserved_words_mysql.txt
|
59
59
|
- lib/rubocop/cop/sevencop/autoload_ordered.rb
|
60
|
+
- lib/rubocop/cop/sevencop/constant_base.rb
|
60
61
|
- lib/rubocop/cop/sevencop/factory_bot_association_option.rb
|
61
62
|
- lib/rubocop/cop/sevencop/factory_bot_association_style.rb
|
62
63
|
- lib/rubocop/cop/sevencop/hash_element_ordered.rb
|