rubocop-sorted_methods_by_call 1.2.1 → 1.2.3
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/.rubocop.yml +4 -1
- data/.rubocop_todo.yml +2 -57
- data/CHANGELOG.md +42 -0
- data/CODE_OF_CONDUCT.md +1 -1
- data/CONTRIBUTING.md +38 -0
- data/README.md +5 -8
- data/SECURITY.md +9 -0
- data/Steepfile +6 -0
- data/config/default.yml +1 -1
- data/docscribe.yml +18 -0
- data/lib/rubocop/cop/sorted_methods_by_call/waterfall.rb +394 -377
- data/lib/rubocop/sorted_methods_by_call/compare.rb +11 -41
- data/lib/rubocop/sorted_methods_by_call/plugin.rb +9 -18
- data/lib/rubocop/sorted_methods_by_call/version.rb +1 -1
- data/rbs_collection.lock.yaml +120 -0
- data/rbs_collection.yaml +19 -0
- data/sig/rubocop/cop/auto_corrector.rbs +11 -0
- data/sig/rubocop/cop/sorted_methods_by_call/waterfall.rbs +71 -0
- data/sig/rubocop/sorted_methods_by_call/compare.rbs +8 -0
- data/sig/rubocop/sorted_methods_by_call/plugin.rbs +9 -0
- data/sig/rubocop/sorted_methods_by_call/version.rbs +5 -0
- metadata +14 -3
- data/lib/rubocop/sorted_methods_by_call/extensions/util.rb +0 -32
|
@@ -8,24 +8,11 @@ module RuboCop
|
|
|
8
8
|
# relative order as they are defined (not necessarily contiguously).
|
|
9
9
|
module Compare
|
|
10
10
|
class << self
|
|
11
|
-
#
|
|
11
|
+
# Check that each scope's call list is an ordered subsequence of its definition list.
|
|
12
12
|
#
|
|
13
|
-
#
|
|
14
|
-
#
|
|
15
|
-
#
|
|
16
|
-
#
|
|
17
|
-
# @example
|
|
18
|
-
# defs = { main: %i[abc foo bar a hello] }
|
|
19
|
-
# calls = { main: %i[foo bar hello] }
|
|
20
|
-
# RuboCop::SortedMethodsByCall::Compare.hashes_ordered_equal?(defs, calls) #=> true
|
|
21
|
-
#
|
|
22
|
-
# calls2 = { main: %i[bar foo] }
|
|
23
|
-
# RuboCop::SortedMethodsByCall::Compare.hashes_ordered_equal?(defs, calls2) #=> false
|
|
24
|
-
#
|
|
25
|
-
# @param [Hash{Object=>Array<Symbol>}] actual Actual definitions per scope.
|
|
26
|
-
# @param [Hash{Object=>Array<Symbol>}] expected Expected calls per scope.
|
|
27
|
-
# @return [Bool] true if for every scope +k+, +expected[k]+ is a subsequence of +actual[k]+
|
|
28
|
-
# and contains no unknown methods.
|
|
13
|
+
# @param [Hash<Object, Array<Symbol>>] actual Per-scope definition method names.
|
|
14
|
+
# @param [Hash<Object, Array<Symbol>>] expected Per-scope called method names.
|
|
15
|
+
# @return [Boolean]
|
|
29
16
|
def hashes_ordered_equal?(actual, expected)
|
|
30
17
|
return false unless actual.is_a?(Hash) && expected.is_a?(Hash)
|
|
31
18
|
|
|
@@ -36,36 +23,19 @@ module RuboCop
|
|
|
36
23
|
end
|
|
37
24
|
end
|
|
38
25
|
|
|
39
|
-
# +
|
|
40
|
-
#
|
|
41
|
-
# Returns true if +sub+ is a subsequence of +arr+ (order preserved),
|
|
42
|
-
# not necessarily contiguous. An empty +sub+ returns true.
|
|
43
|
-
#
|
|
44
|
-
# @example
|
|
45
|
-
# arr = %i[abc foo bar a hello]
|
|
46
|
-
# RuboCop::SortedMethodsByCall::Compare.subsequence?(arr, %i[foo bar hello]) #=> true
|
|
47
|
-
# RuboCop::SortedMethodsByCall::Compare.subsequence?(arr, %i[bar foo]) #=> false
|
|
26
|
+
# Check if +sub+ appears as an ordered (not necessarily contiguous) subsequence of +arr+.
|
|
48
27
|
#
|
|
49
|
-
# @param [Array
|
|
50
|
-
# @param [Array
|
|
51
|
-
# @return [
|
|
28
|
+
# @param [Array<Symbol>] arr The full sequence to search within.
|
|
29
|
+
# @param [Array<Symbol>] sub The subsequence to search for.
|
|
30
|
+
# @return [Boolean]
|
|
52
31
|
def subsequence?(arr, sub)
|
|
53
32
|
return true if sub.nil? || sub.empty?
|
|
54
33
|
|
|
55
34
|
i = 0
|
|
56
|
-
sub.
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
if arr[i] == el
|
|
60
|
-
found = true
|
|
61
|
-
i += 1
|
|
62
|
-
break
|
|
63
|
-
end
|
|
64
|
-
i += 1
|
|
65
|
-
end
|
|
66
|
-
return false unless found
|
|
35
|
+
sub.all? do |el|
|
|
36
|
+
i += 1 while i < arr.length && arr[i] != el
|
|
37
|
+
(i < arr.length).tap { i += 1 }
|
|
67
38
|
end
|
|
68
|
-
true
|
|
69
39
|
end
|
|
70
40
|
end
|
|
71
41
|
end
|
|
@@ -16,11 +16,9 @@ module RuboCop
|
|
|
16
16
|
# It will automatically apply rules (config/default.yml) and make the cops
|
|
17
17
|
# available to the engine.
|
|
18
18
|
class Plugin < LintRoller::Plugin
|
|
19
|
-
#
|
|
19
|
+
# Return plugin metadata for lint_roller discovery.
|
|
20
20
|
#
|
|
21
|
-
#
|
|
22
|
-
#
|
|
23
|
-
# @return [LintRoller::About] Metadata describing this plugin.
|
|
21
|
+
# @return [About]
|
|
24
22
|
def about
|
|
25
23
|
LintRoller::About.new(
|
|
26
24
|
name: 'rubocop-sorted_methods_by_call',
|
|
@@ -30,30 +28,23 @@ module RuboCop
|
|
|
30
28
|
)
|
|
31
29
|
end
|
|
32
30
|
|
|
33
|
-
#
|
|
34
|
-
#
|
|
35
|
-
# Indicates that this plugin supports RuboCop as the lint engine.
|
|
31
|
+
# Check if the plugin is supported for the given lint_roller context.
|
|
36
32
|
#
|
|
37
|
-
# @param [Object] context
|
|
38
|
-
# @return [
|
|
33
|
+
# @param [Object] context The lint_roller context to check.
|
|
34
|
+
# @return [Object]
|
|
39
35
|
def supported?(context)
|
|
40
36
|
context.engine == :rubocop
|
|
41
37
|
end
|
|
42
38
|
|
|
43
|
-
#
|
|
44
|
-
#
|
|
45
|
-
# Returns the plugin rules for RuboCop. This points RuboCop to the default
|
|
46
|
-
# configuration file shipped with the gem (config/default.yml).
|
|
47
|
-
#
|
|
48
|
-
# @param [Object] _context LintRoller context (unused).
|
|
49
|
-
# @return [LintRoller::Rules] Rule declaration for RuboCop to load.
|
|
39
|
+
# Return the RuboCop rules configuration path.
|
|
50
40
|
#
|
|
51
|
-
# @
|
|
41
|
+
# @param [Object] _context The lint_roller context (unused).
|
|
42
|
+
# @return [Rules]
|
|
52
43
|
def rules(_context)
|
|
53
44
|
LintRoller::Rules.new(
|
|
54
45
|
type: :path,
|
|
55
46
|
config_format: :rubocop,
|
|
56
|
-
value: Pathname.new(__dir__).join('../../../config/default.yml')
|
|
47
|
+
value: Pathname.new(__dir__ || '').realpath.join('../../../config/default.yml')
|
|
57
48
|
)
|
|
58
49
|
end
|
|
59
50
|
end
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
---
|
|
2
|
+
path: ".gem_rbs_collection"
|
|
3
|
+
gems:
|
|
4
|
+
- name: ast
|
|
5
|
+
version: '2.4'
|
|
6
|
+
source:
|
|
7
|
+
type: git
|
|
8
|
+
name: ruby/gem_rbs_collection
|
|
9
|
+
revision: 3f5e8df1ce89ea06067fa42263012c968b4e583e
|
|
10
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
|
11
|
+
repo_dir: gems
|
|
12
|
+
- name: diff-lcs
|
|
13
|
+
version: '1.5'
|
|
14
|
+
source:
|
|
15
|
+
type: git
|
|
16
|
+
name: ruby/gem_rbs_collection
|
|
17
|
+
revision: 3f5e8df1ce89ea06067fa42263012c968b4e583e
|
|
18
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
|
19
|
+
repo_dir: gems
|
|
20
|
+
- name: fileutils
|
|
21
|
+
version: '0'
|
|
22
|
+
source:
|
|
23
|
+
type: stdlib
|
|
24
|
+
- name: json
|
|
25
|
+
version: '0'
|
|
26
|
+
source:
|
|
27
|
+
type: stdlib
|
|
28
|
+
- name: lint_roller
|
|
29
|
+
version: '1.1'
|
|
30
|
+
source:
|
|
31
|
+
type: git
|
|
32
|
+
name: ruby/gem_rbs_collection
|
|
33
|
+
revision: 3f5e8df1ce89ea06067fa42263012c968b4e583e
|
|
34
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
|
35
|
+
repo_dir: gems
|
|
36
|
+
- name: logger
|
|
37
|
+
version: '0'
|
|
38
|
+
source:
|
|
39
|
+
type: stdlib
|
|
40
|
+
- name: monitor
|
|
41
|
+
version: '0'
|
|
42
|
+
source:
|
|
43
|
+
type: stdlib
|
|
44
|
+
- name: optparse
|
|
45
|
+
version: '0'
|
|
46
|
+
source:
|
|
47
|
+
type: stdlib
|
|
48
|
+
- name: parallel
|
|
49
|
+
version: '1.20'
|
|
50
|
+
source:
|
|
51
|
+
type: git
|
|
52
|
+
name: ruby/gem_rbs_collection
|
|
53
|
+
revision: 3f5e8df1ce89ea06067fa42263012c968b4e583e
|
|
54
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
|
55
|
+
repo_dir: gems
|
|
56
|
+
- name: parser
|
|
57
|
+
version: '3.2'
|
|
58
|
+
source:
|
|
59
|
+
type: git
|
|
60
|
+
name: ruby/gem_rbs_collection
|
|
61
|
+
revision: 3f5e8df1ce89ea06067fa42263012c968b4e583e
|
|
62
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
|
63
|
+
repo_dir: gems
|
|
64
|
+
- name: prism
|
|
65
|
+
version: 1.9.0
|
|
66
|
+
source:
|
|
67
|
+
type: rubygems
|
|
68
|
+
- name: rainbow
|
|
69
|
+
version: '3.0'
|
|
70
|
+
source:
|
|
71
|
+
type: git
|
|
72
|
+
name: ruby/gem_rbs_collection
|
|
73
|
+
revision: 3f5e8df1ce89ea06067fa42263012c968b4e583e
|
|
74
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
|
75
|
+
repo_dir: gems
|
|
76
|
+
- name: rake
|
|
77
|
+
version: '13.0'
|
|
78
|
+
source:
|
|
79
|
+
type: git
|
|
80
|
+
name: ruby/gem_rbs_collection
|
|
81
|
+
revision: 3f5e8df1ce89ea06067fa42263012c968b4e583e
|
|
82
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
|
83
|
+
repo_dir: gems
|
|
84
|
+
- name: regexp_parser
|
|
85
|
+
version: '2.8'
|
|
86
|
+
source:
|
|
87
|
+
type: git
|
|
88
|
+
name: ruby/gem_rbs_collection
|
|
89
|
+
revision: 3f5e8df1ce89ea06067fa42263012c968b4e583e
|
|
90
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
|
91
|
+
repo_dir: gems
|
|
92
|
+
- name: ripper
|
|
93
|
+
version: '0'
|
|
94
|
+
source:
|
|
95
|
+
type: stdlib
|
|
96
|
+
- name: rubocop
|
|
97
|
+
version: '1.57'
|
|
98
|
+
source:
|
|
99
|
+
type: git
|
|
100
|
+
name: ruby/gem_rbs_collection
|
|
101
|
+
revision: 3f5e8df1ce89ea06067fa42263012c968b4e583e
|
|
102
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
|
103
|
+
repo_dir: gems
|
|
104
|
+
- name: rubocop-ast
|
|
105
|
+
version: '1.46'
|
|
106
|
+
source:
|
|
107
|
+
type: git
|
|
108
|
+
name: ruby/gem_rbs_collection
|
|
109
|
+
revision: 3f5e8df1ce89ea06067fa42263012c968b4e583e
|
|
110
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
|
111
|
+
repo_dir: gems
|
|
112
|
+
- name: yard
|
|
113
|
+
version: '0.9'
|
|
114
|
+
source:
|
|
115
|
+
type: git
|
|
116
|
+
name: ruby/gem_rbs_collection
|
|
117
|
+
revision: 3f5e8df1ce89ea06067fa42263012c968b4e583e
|
|
118
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
|
119
|
+
repo_dir: gems
|
|
120
|
+
gemfile_lock_path: Gemfile.lock
|
data/rbs_collection.yaml
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Download sources
|
|
2
|
+
sources:
|
|
3
|
+
- type: git
|
|
4
|
+
name: ruby/gem_rbs_collection
|
|
5
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
|
6
|
+
revision: main
|
|
7
|
+
repo_dir: gems
|
|
8
|
+
|
|
9
|
+
# You can specify local directories as sources also.
|
|
10
|
+
# - type: local
|
|
11
|
+
# path: path/to/your/local/repository
|
|
12
|
+
|
|
13
|
+
# A directory to install the downloaded RBSs
|
|
14
|
+
path: .gem_rbs_collection
|
|
15
|
+
|
|
16
|
+
# gems:
|
|
17
|
+
# # If you want to avoid installing rbs files for gems, you can specify them here.
|
|
18
|
+
# - name: GEM_NAME
|
|
19
|
+
# ignore: true
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Patch: the RBS collection places AutoCorrector at RuboCop::AutoCorrector
|
|
2
|
+
# (matching older rubocop), but the actual rubocop gem defines it inside
|
|
3
|
+
# the Cop module. Re-export at the correct path so steep can find it
|
|
4
|
+
# when the Ruby code says `extend ::RuboCop::Cop::AutoCorrector`.
|
|
5
|
+
module RuboCop
|
|
6
|
+
module Cop
|
|
7
|
+
module AutoCorrector
|
|
8
|
+
def support_autocorrect?: () -> true
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
end
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
module RuboCop
|
|
2
|
+
module Cop
|
|
3
|
+
module SortedMethodsByCall
|
|
4
|
+
class Waterfall < ::RuboCop::Cop::Base
|
|
5
|
+
extend ::RuboCop::Cop::AutoCorrector
|
|
6
|
+
|
|
7
|
+
include ::RuboCop::Cop::RangeHelp
|
|
8
|
+
|
|
9
|
+
type data = Hash[Symbol, untyped]
|
|
10
|
+
type section = Hash[Symbol, untyped]
|
|
11
|
+
|
|
12
|
+
VISIBILITY_METHODS: Array[Symbol]
|
|
13
|
+
|
|
14
|
+
MSG: String
|
|
15
|
+
SIBLING_MSG: String
|
|
16
|
+
MSG_CROSS_VISIBILITY_NOTE: String
|
|
17
|
+
MSG_SIBLING_CYCLE_NOTE: String
|
|
18
|
+
|
|
19
|
+
def on_begin: (::RuboCop::AST::Node node) -> void
|
|
20
|
+
def on_class: (::RuboCop::AST::Node node) -> void
|
|
21
|
+
def on_module: (::RuboCop::AST::Node node) -> void
|
|
22
|
+
def on_sclass: (::RuboCop::AST::Node node) -> void
|
|
23
|
+
|
|
24
|
+
private
|
|
25
|
+
|
|
26
|
+
def analyze_scope: (::RuboCop::AST::Node scope_node) -> void
|
|
27
|
+
def scope_data: (::RuboCop::AST::Node scope_node) -> data?
|
|
28
|
+
def register_violation: (data data) -> void
|
|
29
|
+
def auto_correct_violation: (::RuboCop::Cop::Corrector corrector, data data) -> void
|
|
30
|
+
def scope_body_nodes: (untyped node) -> Array[::RuboCop::AST::Node]
|
|
31
|
+
def method_def_nodes: (Array[::RuboCop::AST::Node] body_nodes) -> Array[::RuboCop::AST::DefNode]
|
|
32
|
+
def method_name_index: (Array[::RuboCop::AST::DefNode] def_nodes) -> [ Array[Symbol], Set[Symbol], Hash[Symbol, Integer] ]
|
|
33
|
+
def build_direct_edges: (Array[::RuboCop::AST::DefNode] def_nodes, Set[Symbol] names_set) -> Array[ [Symbol, Symbol] ]
|
|
34
|
+
def build_sibling_edges: (Array[::RuboCop::AST::DefNode] def_nodes, Set[Symbol] names_set, Array[ [Symbol, Symbol] ] direct_edges, Array[Symbol] names) -> Array[ [Symbol, Symbol] ]
|
|
35
|
+
def sibling_edges_for_method: (::RuboCop::AST::DefNode def_node, Set[Symbol] names_set, Set[ [Symbol, Symbol] ] direct_pair_set, Hash[Symbol, Array[Symbol]] adj_for_siblings) -> Array[ [Symbol, Symbol] ]
|
|
36
|
+
def find_violation: (Array[ [Symbol, Symbol] ] direct_edges, Array[ [Symbol, Symbol] ] sibling_edges, Hash[Symbol, Integer] index_of, Hash[Symbol, Array[Symbol]] adj_direct) -> [ Symbol, [Symbol, Symbol]? ]?
|
|
37
|
+
def first_backward_edge: (Array[ [Symbol, Symbol] ] edges, Hash[Symbol, Integer] index_of, Hash[Symbol, Array[Symbol]] adj_direct, bool allow_recursion) -> [Symbol, Symbol]?
|
|
38
|
+
def build_offense_message: (violation_type: Symbol, violation: [Symbol, Symbol], names: Array[Symbol], edges_for_sort: Array[ [Symbol, Symbol] ], body_nodes: Array[::RuboCop::AST::Node]) -> String
|
|
39
|
+
def base_message_for: (Symbol violation_type, Symbol caller_name, Symbol callee_name) -> String
|
|
40
|
+
def add_sibling_cycle_note_if_needed: (String base_message, Symbol violation_type, Symbol caller_name, Symbol callee_name, Hash[Symbol, Array[Symbol]] adj_all) -> String
|
|
41
|
+
def add_cross_visibility_note_if_needed: (String base_message, Array[::RuboCop::AST::Node] body_nodes, Symbol caller_name, Symbol callee_name) -> String
|
|
42
|
+
def try_autocorrect: (::RuboCop::Cop::Corrector corrector, Array[::RuboCop::AST::Node] body_nodes, Array[::RuboCop::AST::DefNode] def_nodes, Array[ [Symbol, Symbol] ] edges, ?[Symbol, Symbol]? initial_violation) -> void
|
|
43
|
+
def correction_order: (Array[::RuboCop::AST::DefNode] defs, data data, [Symbol, Symbol] violation) -> Array[Symbol]?
|
|
44
|
+
def auto_correct_data: (Array[::RuboCop::AST::DefNode] def_nodes, Array[ [Symbol, Symbol] ] edges, [Symbol, Symbol]? initial_violation) -> data?
|
|
45
|
+
def edges_for_section: (data data, Array[Symbol] section_names, Symbol caller_name, Symbol callee_name) -> Array[ [Symbol, Symbol] ]
|
|
46
|
+
def filter_names: (Array[ [Symbol, Symbol] ] edges, Array[Symbol] names) -> Array[ [Symbol, Symbol] ]
|
|
47
|
+
def reject_reciprocal: (Array[ [Symbol, Symbol] ] edges) -> Array[ [Symbol, Symbol] ]
|
|
48
|
+
def section_containing: (Array[section] sections, *Symbol method_names) -> section?
|
|
49
|
+
def replace_sorted_section: (::RuboCop::Cop::Corrector corrector, Array[::RuboCop::AST::DefNode] defs, Array[Symbol] sorted_names) -> void
|
|
50
|
+
def bounds: (Hash[Symbol, untyped] ranges, Array[::RuboCop::AST::DefNode] defs) -> ::Parser::Source::Range
|
|
51
|
+
def local_calls: (::RuboCop::AST::DefNode def_node, Set[Symbol] names_set) -> Array[Symbol]
|
|
52
|
+
def build_adj: (Array[Symbol] names, Array[ [Symbol, Symbol] ] edges) -> Hash[Symbol, Array[Symbol]]
|
|
53
|
+
def path_exists?: (Symbol src, Symbol dst, Hash[Symbol, Array[Symbol]] adj, ?Integer limit) -> bool
|
|
54
|
+
def extract_visibility_sections: (Array[::RuboCop::AST::Node] body_nodes) -> Array[section]
|
|
55
|
+
def not_def_node?: (untyped node) -> bool
|
|
56
|
+
def vis_node: (Array[::RuboCop::AST::Node] group) -> ::RuboCop::AST::Node?
|
|
57
|
+
def make_section: (::RuboCop::AST::Node? vis, Array[::RuboCop::AST::DefNode] defs) -> section
|
|
58
|
+
def bare_visibility_send?: (untyped node) -> bool
|
|
59
|
+
def section_for_method: (Array[section] sections, Symbol method_name) -> section?
|
|
60
|
+
def visibility_label: (section? section) -> String
|
|
61
|
+
def topo_sort: (Array[Symbol] names, Array[ [Symbol, Symbol] ] edges, Hash[Symbol, Integer] idx_of) -> Array[Symbol]?
|
|
62
|
+
def kahn_sort: (Hash[Symbol, Integer] indegree, Hash[Symbol, Array[Symbol]] adj, Array[Symbol] queue, Hash[Symbol, Integer] idx_of) -> Array[Symbol]
|
|
63
|
+
def graph: (Array[Symbol] names, Array[ [Symbol, Symbol] ] edges) -> [ Hash[Symbol, Integer], Hash[Symbol, Array[Symbol]] ]
|
|
64
|
+
def range_with_leading_comments: (::RuboCop::AST::Node node) -> ::Parser::Source::Range
|
|
65
|
+
def analyze_nested_scopes: (Array[::RuboCop::AST::Node] body_nodes) -> void
|
|
66
|
+
def allowed_recursion?: -> bool
|
|
67
|
+
def skip_cyclic_sibling_edges?: -> bool
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
end
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
module RuboCop
|
|
2
|
+
module SortedMethodsByCall
|
|
3
|
+
module Compare
|
|
4
|
+
def self?.hashes_ordered_equal?: (Hash[untyped, Array[Symbol]] actual, Hash[untyped, Array[Symbol]] expected) -> bool
|
|
5
|
+
def self?.subsequence?: (Array[Symbol] arr, Array[Symbol] sub) -> bool
|
|
6
|
+
end
|
|
7
|
+
end
|
|
8
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rubocop-sorted_methods_by_call
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.2.
|
|
4
|
+
version: 1.2.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- unurgunite
|
|
@@ -131,16 +131,27 @@ files:
|
|
|
131
131
|
- ".rubocop.yml"
|
|
132
132
|
- ".rubocop_todo.yml"
|
|
133
133
|
- ".ruby-version"
|
|
134
|
+
- CHANGELOG.md
|
|
134
135
|
- CODE_OF_CONDUCT.md
|
|
136
|
+
- CONTRIBUTING.md
|
|
135
137
|
- LICENSE.txt
|
|
136
138
|
- README.md
|
|
139
|
+
- SECURITY.md
|
|
140
|
+
- Steepfile
|
|
137
141
|
- config/default.yml
|
|
142
|
+
- docscribe.yml
|
|
138
143
|
- lib/rubocop-sorted_methods_by_call.rb
|
|
139
144
|
- lib/rubocop/cop/sorted_methods_by_call/waterfall.rb
|
|
140
145
|
- lib/rubocop/sorted_methods_by_call/compare.rb
|
|
141
|
-
- lib/rubocop/sorted_methods_by_call/extensions/util.rb
|
|
142
146
|
- lib/rubocop/sorted_methods_by_call/plugin.rb
|
|
143
147
|
- lib/rubocop/sorted_methods_by_call/version.rb
|
|
148
|
+
- rbs_collection.lock.yaml
|
|
149
|
+
- rbs_collection.yaml
|
|
150
|
+
- sig/rubocop/cop/auto_corrector.rbs
|
|
151
|
+
- sig/rubocop/cop/sorted_methods_by_call/waterfall.rbs
|
|
152
|
+
- sig/rubocop/sorted_methods_by_call/compare.rbs
|
|
153
|
+
- sig/rubocop/sorted_methods_by_call/plugin.rbs
|
|
154
|
+
- sig/rubocop/sorted_methods_by_call/version.rbs
|
|
144
155
|
homepage: https://github.com/unurgunite/rubocop-sorted_methods_by_call
|
|
145
156
|
licenses: []
|
|
146
157
|
metadata:
|
|
@@ -164,7 +175,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
164
175
|
- !ruby/object:Gem::Version
|
|
165
176
|
version: '0'
|
|
166
177
|
requirements: []
|
|
167
|
-
rubygems_version: 4.0.
|
|
178
|
+
rubygems_version: 4.0.13
|
|
168
179
|
specification_version: 4
|
|
169
180
|
summary: RuboCop extension for method sorting in AST by stack trace.
|
|
170
181
|
test_files: []
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module RuboCop
|
|
4
|
-
module SortedMethodsByCall
|
|
5
|
-
module Util # :nodoc:
|
|
6
|
-
# +RuboCop::SortedMethodsByCall::Util.deep_merge(hash, other)+ -> Hash
|
|
7
|
-
#
|
|
8
|
-
# Merges two hashes without overwriting values that share the same key.
|
|
9
|
-
# When a key exists in both hashes, values are accumulated into an array
|
|
10
|
-
# ("buckets"). Scalars are wrapped to arrays automatically.
|
|
11
|
-
#
|
|
12
|
-
# - Non-destructive: returns a new Hash; does not mutate +hash+.
|
|
13
|
-
# - If +other+ is not a Hash, the original +hash+ is returned as-is.
|
|
14
|
-
#
|
|
15
|
-
# @example Accumulate values into buckets
|
|
16
|
-
# base = { main: :abc, class_T: :hi }
|
|
17
|
-
# other = { class_T: :h1 }
|
|
18
|
-
# RuboCop::SortedMethodsByCall::Util.deep_merge(base, other)
|
|
19
|
-
# #=> { main: [:abc], class_T: [:hi, :h1] }
|
|
20
|
-
#
|
|
21
|
-
# @param [Hash] h The base hash to merge from.
|
|
22
|
-
# @param [Hash] other The hash to merge into +hash+.
|
|
23
|
-
# @return [Hash] A new hash with accumulated values per key.
|
|
24
|
-
# @see Hash#merge
|
|
25
|
-
def self.deep_merge(h, other)
|
|
26
|
-
return h unless other.is_a?(Hash)
|
|
27
|
-
|
|
28
|
-
h.merge(other) { |_, a, b| Array(a) + Array(b) }
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
end
|