leftovers 0.2.3 → 0.4.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (147) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +39 -0
  3. data/README.md +65 -49
  4. data/docs/Configuration.md +627 -0
  5. data/exe/leftovers +2 -2
  6. data/leftovers.gemspec +13 -6
  7. data/lib/config/attr_encrypted.yml +3 -4
  8. data/lib/config/audited.yml +9 -4
  9. data/lib/config/datagrid.yml +1 -1
  10. data/lib/config/flipper.yml +1 -3
  11. data/lib/config/graphql.yml +15 -13
  12. data/lib/config/okcomputer.yml +1 -3
  13. data/lib/config/parser.yml +89 -91
  14. data/lib/config/rails.yml +126 -107
  15. data/lib/config/redcarpet.yml +35 -38
  16. data/lib/config/rollbar.yml +1 -3
  17. data/lib/config/rspec.yml +18 -10
  18. data/lib/config/ruby.yml +42 -49
  19. data/lib/config/selenium-webdriver.yml +19 -0
  20. data/lib/config/sidekiq.yml +4 -8
  21. data/lib/config/will_paginate.yml +12 -14
  22. data/lib/leftovers.rb +66 -54
  23. data/lib/leftovers/ast.rb +8 -0
  24. data/lib/leftovers/ast/builder.rb +6 -3
  25. data/lib/leftovers/ast/node.rb +66 -107
  26. data/lib/leftovers/backports.rb +24 -40
  27. data/lib/leftovers/cli.rb +27 -15
  28. data/lib/leftovers/collector.rb +8 -11
  29. data/lib/leftovers/config.rb +38 -13
  30. data/lib/leftovers/config_validator.rb +60 -0
  31. data/lib/leftovers/config_validator/error_processor.rb +196 -0
  32. data/lib/leftovers/config_validator/schema_hash.rb +496 -0
  33. data/lib/leftovers/definition.rb +16 -41
  34. data/lib/leftovers/definition_node.rb +36 -0
  35. data/lib/leftovers/definition_set.rb +17 -24
  36. data/lib/leftovers/dynamic_processors.rb +11 -0
  37. data/lib/leftovers/dynamic_processors/call.rb +25 -0
  38. data/lib/leftovers/dynamic_processors/call_definition.rb +31 -0
  39. data/lib/leftovers/dynamic_processors/definition.rb +26 -0
  40. data/lib/leftovers/dynamic_processors/each.rb +19 -0
  41. data/lib/leftovers/dynamic_processors/null.rb +9 -0
  42. data/lib/leftovers/erb.rb +2 -2
  43. data/lib/leftovers/file.rb +3 -5
  44. data/lib/leftovers/file_collector.rb +79 -61
  45. data/lib/leftovers/file_list.rb +9 -15
  46. data/lib/leftovers/haml.rb +9 -12
  47. data/lib/leftovers/matcher_builders.rb +24 -0
  48. data/lib/leftovers/matcher_builders/and.rb +19 -0
  49. data/lib/leftovers/matcher_builders/and_not.rb +14 -0
  50. data/lib/leftovers/matcher_builders/argument_node_value.rb +21 -0
  51. data/lib/leftovers/matcher_builders/name.rb +29 -0
  52. data/lib/leftovers/matcher_builders/node.rb +40 -0
  53. data/lib/leftovers/matcher_builders/node_has_argument.rb +71 -0
  54. data/lib/leftovers/matcher_builders/node_has_keyword_argument.rb +22 -0
  55. data/lib/leftovers/matcher_builders/node_has_positional_argument.rb +24 -0
  56. data/lib/leftovers/matcher_builders/node_name.rb +15 -0
  57. data/lib/leftovers/matcher_builders/node_pair_name.rb +18 -0
  58. data/lib/leftovers/matcher_builders/node_pair_value.rb +16 -0
  59. data/lib/leftovers/matcher_builders/node_path.rb +14 -0
  60. data/lib/leftovers/matcher_builders/node_type.rb +28 -0
  61. data/lib/leftovers/matcher_builders/or.rb +73 -0
  62. data/lib/leftovers/matcher_builders/path.rb +15 -0
  63. data/lib/leftovers/matcher_builders/string.rb +11 -0
  64. data/lib/leftovers/matcher_builders/string_pattern.rb +19 -0
  65. data/lib/leftovers/matcher_builders/unless.rb +13 -0
  66. data/lib/leftovers/matchers.rb +26 -0
  67. data/lib/leftovers/matchers/all.rb +25 -0
  68. data/lib/leftovers/matchers/and.rb +24 -0
  69. data/lib/leftovers/matchers/any.rb +27 -0
  70. data/lib/leftovers/matchers/node_has_any_keyword_argument.rb +28 -0
  71. data/lib/leftovers/matchers/node_has_any_positional_argument_with_value.rb +25 -0
  72. data/lib/leftovers/matchers/node_has_positional_argument.rb +23 -0
  73. data/lib/leftovers/matchers/node_has_positional_argument_with_value.rb +25 -0
  74. data/lib/leftovers/matchers/node_name.rb +23 -0
  75. data/lib/leftovers/matchers/node_pair_value.rb +23 -0
  76. data/lib/leftovers/matchers/node_path.rb +23 -0
  77. data/lib/leftovers/matchers/node_scalar_value.rb +25 -0
  78. data/lib/leftovers/matchers/node_type.rb +23 -0
  79. data/lib/leftovers/matchers/not.rb +23 -0
  80. data/lib/leftovers/matchers/or.rb +26 -0
  81. data/lib/leftovers/merged_config.rb +29 -14
  82. data/lib/leftovers/parser.rb +1 -4
  83. data/lib/leftovers/processor_builders.rb +22 -0
  84. data/lib/leftovers/processor_builders/action.rb +63 -0
  85. data/lib/leftovers/processor_builders/add_prefix.rb +20 -0
  86. data/lib/leftovers/processor_builders/add_suffix.rb +20 -0
  87. data/lib/leftovers/processor_builders/argument.rb +25 -0
  88. data/lib/leftovers/processor_builders/dynamic.rb +27 -0
  89. data/lib/leftovers/processor_builders/each.rb +36 -0
  90. data/lib/leftovers/processor_builders/each_action.rb +51 -0
  91. data/lib/leftovers/processor_builders/each_dynamic.rb +54 -0
  92. data/lib/leftovers/processor_builders/each_for_definition_set.rb +36 -0
  93. data/lib/leftovers/processor_builders/itself.rb +13 -0
  94. data/lib/leftovers/processor_builders/keyword.rb +24 -0
  95. data/lib/leftovers/processor_builders/keyword_argument.rb +14 -0
  96. data/lib/leftovers/processor_builders/transform.rb +55 -0
  97. data/lib/leftovers/processor_builders/transform_chain.rb +24 -0
  98. data/lib/leftovers/processor_builders/transform_set.rb +47 -0
  99. data/lib/leftovers/processor_builders/value.rb +13 -0
  100. data/lib/leftovers/rake_task.rb +4 -4
  101. data/lib/leftovers/reporter.rb +56 -4
  102. data/lib/leftovers/todo_reporter.rb +124 -0
  103. data/lib/leftovers/value_processors.rb +40 -0
  104. data/lib/leftovers/value_processors/add_dynamic_prefix.rb +31 -0
  105. data/lib/leftovers/value_processors/add_dynamic_suffix.rb +31 -0
  106. data/lib/leftovers/value_processors/add_prefix.rb +20 -0
  107. data/lib/leftovers/value_processors/add_suffix.rb +20 -0
  108. data/lib/leftovers/value_processors/camelize.rb +24 -0
  109. data/lib/leftovers/value_processors/capitalize.rb +19 -0
  110. data/lib/leftovers/value_processors/deconstantize.rb +24 -0
  111. data/lib/leftovers/value_processors/delete_after.rb +22 -0
  112. data/lib/leftovers/value_processors/delete_before.rb +22 -0
  113. data/lib/leftovers/value_processors/delete_prefix.rb +26 -0
  114. data/lib/leftovers/value_processors/delete_suffix.rb +26 -0
  115. data/lib/leftovers/value_processors/demodulize.rb +24 -0
  116. data/lib/leftovers/value_processors/downcase.rb +19 -0
  117. data/lib/leftovers/value_processors/each.rb +21 -0
  118. data/lib/leftovers/value_processors/each_for_definition_set.rb +29 -0
  119. data/lib/leftovers/value_processors/each_keyword.rb +27 -0
  120. data/lib/leftovers/value_processors/each_keyword_argument.rb +27 -0
  121. data/lib/leftovers/value_processors/each_positional_argument.rb +24 -0
  122. data/lib/leftovers/value_processors/itself.rb +17 -0
  123. data/lib/leftovers/value_processors/keyword.rb +36 -0
  124. data/lib/leftovers/value_processors/keyword_argument.rb +36 -0
  125. data/lib/leftovers/value_processors/parameterize.rb +24 -0
  126. data/lib/leftovers/value_processors/placeholder.rb +18 -0
  127. data/lib/leftovers/value_processors/pluralize.rb +24 -0
  128. data/lib/leftovers/value_processors/positional_argument.rb +26 -0
  129. data/lib/leftovers/value_processors/replace_value.rb +18 -0
  130. data/lib/leftovers/value_processors/return_definition.rb +26 -0
  131. data/lib/leftovers/value_processors/return_string.rb +14 -0
  132. data/lib/leftovers/value_processors/singularize.rb +24 -0
  133. data/lib/leftovers/value_processors/split.rb +22 -0
  134. data/lib/leftovers/value_processors/swapcase.rb +19 -0
  135. data/lib/leftovers/value_processors/titleize.rb +24 -0
  136. data/lib/leftovers/value_processors/underscore.rb +24 -0
  137. data/lib/leftovers/value_processors/upcase.rb +19 -0
  138. data/lib/leftovers/version.rb +1 -1
  139. metadata +201 -25
  140. data/lib/config/selenium.yml +0 -21
  141. data/lib/leftovers/argument_rule.rb +0 -219
  142. data/lib/leftovers/core_ext.rb +0 -13
  143. data/lib/leftovers/hash_rule.rb +0 -40
  144. data/lib/leftovers/name_rule.rb +0 -53
  145. data/lib/leftovers/rule.rb +0 -74
  146. data/lib/leftovers/transform_rule.rb +0 -171
  147. data/lib/leftovers/value_rule.rb +0 -56
@@ -0,0 +1,8 @@
1
+ # frozen-string-literal: true
2
+
3
+ module Leftovers
4
+ module AST
5
+ autoload(:Builder, "#{__dir__}/ast/builder")
6
+ autoload(:Node, "#{__dir__}/ast/node")
7
+ end
8
+ end
@@ -1,17 +1,20 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'parser'
4
+
3
5
  module Leftovers
4
6
  module AST
5
7
  class Builder < ::Parser::Builders::Default
6
8
  # Generates {Node} from the given information.
7
9
  #
8
10
  # @return [Node] the generated node
9
- def n(type, children, source_map)
10
- Leftovers::AST::Node.new(type, children, location: source_map)
11
+
12
+ def n(type, children, source_map) # leftovers:keep
13
+ ::Leftovers::AST::Node.new(type, children, location: source_map)
11
14
  end
12
15
 
13
16
  # Don't complain about invalid strings
14
- def string_value(token)
17
+ def string_value(token) # leftovers:keep
15
18
  value(token)
16
19
  end
17
20
  end
@@ -4,7 +4,7 @@ require 'parser'
4
4
 
5
5
  module Leftovers
6
6
  module AST
7
- class Node < Parser::AST::Node # rubocop:disable Metrics/ClassLength
7
+ class Node < ::Parser::AST::Node # rubocop:disable Metrics/ClassLength
8
8
  def initialize(type, children = [], properties = {})
9
9
  # ::AST::Node#initialize freezes itself.
10
10
  # so can't use normal memoizations
@@ -17,85 +17,93 @@ module Leftovers
17
17
  children.first
18
18
  end
19
19
 
20
- def file
21
- @memo[:file]
20
+ def second
21
+ children[1]
22
22
  end
23
23
 
24
- def file=(value)
25
- @memo[:file] = value
24
+ def path
25
+ @memo[:path] ||= loc.expression.source_buffer.name.to_s
26
26
  end
27
27
 
28
- def test
29
- @memo[:test]
28
+ def test_line?
29
+ @memo[:test_line]
30
30
  end
31
- alias_method :test?, :test
32
31
 
33
- def test=(value)
34
- @memo[:test] = value
32
+ def test_line=(value)
33
+ @memo[:test_line] = value
35
34
  end
36
35
 
37
- def to_scalar_value # rubocop:disable Metrics/MethodLength
38
- @memo[:scalar_value] ||= case type
39
- when :sym
36
+ def keep_line=(value)
37
+ @memo[:keep_line] = value
38
+ end
39
+
40
+ def keep_line?
41
+ @memo[:keep_line]
42
+ end
43
+
44
+ def to_scalar_value
45
+ case type
46
+ when :sym, :int, :float, :str
40
47
  first
41
- when :str
42
- first.to_s.freeze
43
48
  when :true
44
49
  true
45
50
  when :false
46
51
  false
47
52
  when :nil
48
53
  nil
49
- else
50
- raise "Not scalar node, (#{type})"
51
54
  end
52
55
  end
53
56
 
54
- def to_s # rubocop:disable Metrics/MethodLength
55
- @memo[:to_s] ||= if scalar?
56
- to_scalar_value
57
- elsif named?
58
- name
59
- else
60
- raise "No to_s, (#{type})"
61
- end.to_s.freeze
57
+ def scalar?
58
+ case type
59
+ when :sym, :int, :float, :str, :true, :false, :nil
60
+ true
61
+ else false
62
+ end
63
+ end
64
+
65
+ def to_s
66
+ @memo[:to_s] ||= name ? name.to_s : to_scalar_value.to_s
62
67
  end
63
68
 
64
69
  def to_sym
65
70
  case type
66
- when :str, :sym then first
71
+ when :sym then first
67
72
  when :nil, :true, :false then type
68
73
  else to_s.to_sym
69
74
  end
70
75
  end
71
76
 
72
- SCALAR_TYPES = %i{sym str true false nil}.freeze
73
- def scalar?
74
- SCALAR_TYPES.include?(type)
75
- end
76
-
77
77
  def string_or_symbol?
78
78
  type == :str || type == :sym
79
79
  end
80
80
 
81
- def send?
82
- type == :send || type == :csend
83
- end
84
-
85
- def named?
86
- send? || type == :casgn
81
+ def arguments
82
+ @memo.fetch(:arguments) do
83
+ @memo[:arguments] = case type
84
+ when :send, :csend then children.drop(2)
85
+ when :casgn then assign_arguments(children[2])
86
+ when :ivasgn, :cvasgn, :gvasgn then assign_arguments(second)
87
+ when :array then children
88
+ when :hash then [self]
89
+ end
90
+ end
87
91
  end
88
92
 
89
- def arguments
90
- @memo[:arguments] ||= case type
91
- when :send, :csend then children.drop(2)
92
- when :casgn then [children[2]]
93
- else raise "Not argument node (#{type})"
93
+ def assign_arguments(arguments_list)
94
+ arguments_list = arguments_list.unwrap_freeze
95
+ case arguments_list.type
96
+ when :array
97
+ arguments_list.children
98
+ when :hash, :str, :sym
99
+ [arguments_list]
94
100
  end
95
101
  end
96
102
 
97
103
  def positional_arguments
98
- @memo[:positional_arguments] ||= kwargs ? arguments[0...-1] : arguments
104
+ @memo.fetch(:positional_arguments) do
105
+ @memo[:positional_arguments] = kwargs ? arguments[0...-1] : arguments
106
+ end
99
107
  end
100
108
 
101
109
  def unwrap_freeze
@@ -106,75 +114,26 @@ module Leftovers
106
114
 
107
115
  def kwargs
108
116
  @memo.fetch(:kwargs) do
109
- last_arg = arguments[-1]&.unwrap_freeze
110
- @memo[:kwargs] = (last_arg if last_arg&.type == :hash)
111
- end
112
- end
113
-
114
- def keys
115
- each_pair.map { |k, _| k }
116
- end
117
-
118
- def key?(key)
119
- each_pair.find do |k, _v|
120
- next unless k.string_or_symbol?
117
+ @memo[:kwargs] = begin
118
+ args = arguments
119
+ next unless args
121
120
 
122
- k.to_sym == key
123
- end
124
- end
125
-
126
- def values
127
- @memo[:kwargs] ||= case type
128
- when :hash then each_pair.map { |_, v| v }
129
- when :array then children
130
- else []
131
- end
132
- end
133
-
134
- def values_at_match(matcher)
135
- each_pair.with_object([]) do |(key, value), values|
136
- values << value if matcher.match?(key.to_sym, key.to_s)
137
- end
138
- end
139
-
140
- def positional_arguments_at(positions)
141
- positional_arguments.values_at(*positions).compact
142
- end
143
-
144
- def each_pair
145
- raise "not hash node (#{type})" unless type == :hash
146
-
147
- return enum_for(:each_pair) unless block_given?
148
-
149
- children.each do |pair|
150
- yield(*pair.children) if pair.type == :pair
121
+ last_arg = args[-1]
122
+ last_arg if last_arg && last_arg.type == :hash
123
+ end
151
124
  end
152
125
  end
153
126
 
154
127
  def name
155
- return "Not named node (#{type})" unless named?
156
-
157
- @memo[:name] ||= children[1]
158
- end
159
-
160
- def name_s
161
- @memo[:name_s] ||= name.to_s.freeze
162
- end
163
-
164
- def [](index) # rubocop:disable Metrics/MethodLength, Metrics/CyclomaticComplexity
165
- case type
166
- when :send, :csend
167
- index.is_a?(Integer) ? arguments[index] : kwargs && kwargs[index]
168
- when :array
169
- children[index]
170
- when :hash
171
- each_pair do |key, value|
172
- next unless key.string_or_symbol?
173
-
174
- return value if key.to_sym == index
175
- end
176
-
177
- nil
128
+ @memo[:name] ||= case type
129
+ when :send, :csend, :casgn, :const
130
+ second
131
+ when :def, :ivasgn, :ivar, :gvar, :cvar, :gvasgn, :cvasgn, :sym
132
+ first
133
+ when :str
134
+ first.to_sym
135
+ when :module, :class, :pair
136
+ first.name
178
137
  end
179
138
  end
180
139
  end
@@ -1,54 +1,38 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Leftovers
4
- ruby_version = Gem::Version.new(RUBY_VERSION)
5
- unless ruby_version >= Gem::Version.new('2.5')
6
- module StringDeletePrefixSuffix
7
- refine ::String do
8
- def delete_prefix!(str)
9
- slice!(0..(str.length - 1)) if start_with?(str)
10
- self
11
- end
12
-
13
- def delete_suffix!(str)
14
- slice!(-str.length..-1) if end_with?(str)
15
- self
16
- end
4
+ module Backports
5
+ ruby_version = Gem::Version.new(RUBY_VERSION)
17
6
 
18
- def delete_prefix(str)
19
- dup.delete_prefix!(str)
20
- end
21
-
22
- def delete_suffix(str)
23
- dup.delete_suffix!(str)
7
+ unless ruby_version >= Gem::Version.new('2.5')
8
+ require 'set'
9
+ module SetCaseEq
10
+ refine ::Set do
11
+ def ===(value)
12
+ include?(value)
13
+ end
24
14
  end
25
15
  end
26
- end
27
16
 
28
- require 'yaml'
29
- module YAMLSymbolizeNames
30
- refine YAML.singleton_class do
31
- alias_method :safe_load_without_symbolize_names, :safe_load
32
- def safe_load(path, *args, symbolize_names: false, **kwargs)
33
- if symbolize_names
34
- symbolize_names!(safe_load_without_symbolize_names(path, *args, **kwargs))
35
- else
36
- safe_load_without_symbolize_names(path, *args, **kwargs)
17
+ module StringDeletePrefixSuffix
18
+ refine ::String do
19
+ def delete_prefix!(str)
20
+ slice!(0..(str.length - 1)) if start_with?(str)
21
+ self
37
22
  end
38
- end
39
23
 
40
- private
24
+ def delete_suffix!(str)
25
+ slice!(-str.length..-1) if end_with?(str)
26
+ self
27
+ end
28
+
29
+ def delete_prefix(str)
30
+ dup.delete_prefix!(str)
31
+ end
41
32
 
42
- def symbolize_names!(obj) # rubocop:disable Metrics/MethodLength
43
- case obj
44
- when Hash
45
- obj.keys.each do |key| # rubocop:disable Style/HashEachMethods # each_key never finishes.
46
- obj[key.to_sym] = symbolize_names!(obj.delete(key))
47
- end
48
- when Array
49
- obj.map! { |ea| symbolize_names!(ea) }
33
+ def delete_suffix(str)
34
+ dup.delete_suffix!(str)
50
35
  end
51
- obj
52
36
  end
53
37
  end
54
38
  end
data/lib/leftovers/cli.rb CHANGED
@@ -1,47 +1,59 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'optparse'
4
- require_relative '../leftovers'
5
- require_relative 'version'
6
-
7
4
  module Leftovers
8
5
  class CLI
9
- attr_reader :argv, :stdout, :stderr
10
-
11
6
  def initialize(argv: [], stdout: $stdout, stderr: $stderr)
12
7
  @argv = argv
13
8
  @stdout = stdout
14
9
  @stderr = stderr
10
+ end
15
11
 
16
- parse_options
12
+ def run
13
+ catch(:leftovers_exit) do
14
+ Leftovers.reset
15
+ parse_options
17
16
 
18
- exit Leftovers.run(stdout: stdout, stderr: stderr)
17
+ Leftovers.run(stdout: stdout, stderr: stderr)
18
+ end
19
19
  end
20
20
 
21
+ private
22
+
23
+ attr_reader :argv, :stdout, :stderr
24
+
21
25
  def parse_options # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
22
26
  opts = OptionParser.new
23
27
  Leftovers.parallel = true
24
28
  Leftovers.progress = true
25
29
 
26
30
  opts.banner = 'Usage: leftovers [options]'
27
- opts.on('-q', '--quiet', 'Silences output') { Leftovers.quiet = true }
31
+
28
32
  opts.on('--[no-]parallel', 'Run in parallel or not, default --parallel') do |p|
29
33
  Leftovers.parallel = p
30
34
  end
35
+
31
36
  opts.on('--[no-]progress', 'Show progress counts or not, default --progress') do |p|
32
37
  Leftovers.progress = p
33
38
  end
34
- opts.on('-v', '--version', 'Returns the current version') do
35
- stdout.puts(Leftovers::Version)
36
- exit
37
- end
39
+
38
40
  opts.on('--dry-run', 'Output files that will be looked at') do
39
- stdout.puts(Leftovers::FileList.new.to_a.map(&:relative_path).join("\n"))
40
- exit
41
+ Leftovers::FileList.new.each { |f| stdout.puts f.relative_path }
42
+ Leftovers.exit
43
+ end
44
+
45
+ opts.on('--write-todo', 'Outputs the unused items in a todo file to gradually fix') do
46
+ Leftovers.reporter = Leftovers::TodoReporter.new
41
47
  end
48
+
49
+ opts.on('-v', '--version', 'Returns the current version') do
50
+ stdout.puts(Leftovers::VERSION)
51
+ Leftovers.exit
52
+ end
53
+
42
54
  opts.on('-h', '--help', 'Shows this message') do
43
55
  stdout.puts(opts.help)
44
- exit
56
+ Leftovers.exit
45
57
  end
46
58
 
47
59
  opts.parse(argv)
@@ -3,16 +3,12 @@
3
3
  require 'fast_ignore'
4
4
  require 'set'
5
5
  require 'parallel'
6
- require_relative 'file_collector'
7
- require_relative 'file_list'
8
6
 
9
7
  module Leftovers
10
8
  class Collector
11
- attr_reader :calls
12
- attr_reader :test_calls
13
- attr_reader :definitions
9
+ attr_reader :calls, :test_calls, :definitions
14
10
 
15
- def initialize # rubocop:disable Metrics/MethodLength
11
+ def initialize
16
12
  @calls = []
17
13
  @test_calls = []
18
14
  @definitions = []
@@ -22,6 +18,7 @@ module Leftovers
22
18
  end
23
19
 
24
20
  def collect
21
+ Leftovers.reporter.prepare
25
22
  collect_file_list(Leftovers::FileList.new)
26
23
  print_progress
27
24
  Leftovers.newline
@@ -31,14 +28,14 @@ module Leftovers
31
28
 
32
29
  def collect_file_list(list)
33
30
  if Leftovers.parallel?
34
- Parallel.each(list, finish: method(:finish_parallel), &method(:collect_file))
31
+ Parallel.each(list, finish: method(:finish_file), &method(:collect_file))
35
32
  else
36
- list.each { |file| finish_parallel(nil, nil, collect_file(file)) }
33
+ list.each { |file| finish_file(nil, nil, collect_file(file)) }
37
34
  end
38
35
  end
39
36
 
40
37
  def collect_file(file)
41
- file_collector = Leftovers::FileCollector.new(file.ruby, file)
38
+ file_collector = ::Leftovers::FileCollector.new(file.ruby, file)
42
39
  file_collector.collect
43
40
 
44
41
  file_collector.to_h
@@ -46,11 +43,11 @@ module Leftovers
46
43
 
47
44
  def print_progress
48
45
  Leftovers.print(
49
- "checked #{@count} files, collected #{@count_calls} calls, #{@count_definitions} definitions\r" # rubocop:disable Layout/LineLength
46
+ "\e[2Kchecked #{@count} files, collected #{@count_calls} calls, #{@count_definitions} definitions\r" # rubocop:disable Layout/LineLength
50
47
  )
51
48
  end
52
49
 
53
- def finish_parallel(_, _, result) # rubocop:disable Metrics/MethodLength
50
+ def finish_file(_item, _index, result)
54
51
  @count += 1
55
52
  @count_calls += result[:calls].length
56
53
  @count_definitions += result[:definitions].length