leftovers 0.2.1 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +42 -0
- data/README.md +35 -49
- data/docs/Configuration.md +627 -0
- data/exe/leftovers +2 -2
- data/leftovers.gemspec +13 -7
- data/lib/config/attr_encrypted.yml +3 -4
- data/lib/config/audited.yml +9 -4
- data/lib/config/datagrid.yml +1 -1
- data/lib/config/flipper.yml +1 -3
- data/lib/config/graphql.yml +15 -13
- data/lib/config/okcomputer.yml +1 -3
- data/lib/config/parser.yml +89 -91
- data/lib/config/rails.yml +160 -97
- data/lib/config/redcarpet.yml +35 -38
- data/lib/config/rollbar.yml +1 -3
- data/lib/config/rspec.yml +18 -10
- data/lib/config/ruby.yml +42 -49
- data/lib/config/selenium-webdriver.yml +19 -0
- data/lib/config/sidekiq.yml +9 -0
- data/lib/config/will_paginate.yml +12 -14
- data/lib/leftovers.rb +61 -43
- data/lib/leftovers/ast.rb +8 -0
- data/lib/leftovers/ast/builder.rb +6 -3
- data/lib/leftovers/ast/node.rb +66 -107
- data/lib/leftovers/backports.rb +24 -40
- data/lib/leftovers/cli.rb +17 -14
- data/lib/leftovers/collector.rb +7 -11
- data/lib/leftovers/config.rb +38 -13
- data/lib/leftovers/config_validator.rb +60 -0
- data/lib/leftovers/config_validator/error_processor.rb +196 -0
- data/lib/leftovers/config_validator/schema_hash.rb +496 -0
- data/lib/leftovers/definition.rb +16 -41
- data/lib/leftovers/definition_node.rb +36 -0
- data/lib/leftovers/definition_set.rb +17 -24
- data/lib/leftovers/dynamic_processors.rb +11 -0
- data/lib/leftovers/dynamic_processors/call.rb +25 -0
- data/lib/leftovers/dynamic_processors/call_definition.rb +31 -0
- data/lib/leftovers/dynamic_processors/definition.rb +26 -0
- data/lib/leftovers/dynamic_processors/each.rb +19 -0
- data/lib/leftovers/dynamic_processors/null.rb +9 -0
- data/lib/leftovers/erb.rb +2 -2
- data/lib/leftovers/file.rb +3 -5
- data/lib/leftovers/file_collector.rb +82 -62
- data/lib/leftovers/file_list.rb +9 -12
- data/lib/leftovers/haml.rb +9 -12
- data/lib/leftovers/matcher_builders.rb +24 -0
- data/lib/leftovers/matcher_builders/and.rb +19 -0
- data/lib/leftovers/matcher_builders/and_not.rb +14 -0
- data/lib/leftovers/matcher_builders/argument_node_value.rb +21 -0
- data/lib/leftovers/matcher_builders/name.rb +29 -0
- data/lib/leftovers/matcher_builders/node.rb +40 -0
- data/lib/leftovers/matcher_builders/node_has_argument.rb +71 -0
- data/lib/leftovers/matcher_builders/node_has_keyword_argument.rb +22 -0
- data/lib/leftovers/matcher_builders/node_has_positional_argument.rb +24 -0
- data/lib/leftovers/matcher_builders/node_name.rb +15 -0
- data/lib/leftovers/matcher_builders/node_pair_name.rb +18 -0
- data/lib/leftovers/matcher_builders/node_pair_value.rb +16 -0
- data/lib/leftovers/matcher_builders/node_path.rb +14 -0
- data/lib/leftovers/matcher_builders/node_type.rb +28 -0
- data/lib/leftovers/matcher_builders/or.rb +73 -0
- data/lib/leftovers/matcher_builders/path.rb +15 -0
- data/lib/leftovers/matcher_builders/string.rb +11 -0
- data/lib/leftovers/matcher_builders/string_pattern.rb +19 -0
- data/lib/leftovers/matcher_builders/unless.rb +13 -0
- data/lib/leftovers/matchers.rb +26 -0
- data/lib/leftovers/matchers/all.rb +25 -0
- data/lib/leftovers/matchers/and.rb +24 -0
- data/lib/leftovers/matchers/any.rb +27 -0
- data/lib/leftovers/matchers/node_has_any_keyword_argument.rb +28 -0
- data/lib/leftovers/matchers/node_has_any_positional_argument_with_value.rb +25 -0
- data/lib/leftovers/matchers/node_has_positional_argument.rb +23 -0
- data/lib/leftovers/matchers/node_has_positional_argument_with_value.rb +25 -0
- data/lib/leftovers/matchers/node_name.rb +23 -0
- data/lib/leftovers/matchers/node_pair_value.rb +23 -0
- data/lib/leftovers/matchers/node_path.rb +23 -0
- data/lib/leftovers/matchers/node_scalar_value.rb +25 -0
- data/lib/leftovers/matchers/node_type.rb +23 -0
- data/lib/leftovers/matchers/not.rb +23 -0
- data/lib/leftovers/matchers/or.rb +26 -0
- data/lib/leftovers/merged_config.rb +24 -14
- data/lib/leftovers/parser.rb +2 -5
- data/lib/leftovers/processor_builders.rb +22 -0
- data/lib/leftovers/processor_builders/action.rb +63 -0
- data/lib/leftovers/processor_builders/add_prefix.rb +20 -0
- data/lib/leftovers/processor_builders/add_suffix.rb +20 -0
- data/lib/leftovers/processor_builders/argument.rb +25 -0
- data/lib/leftovers/processor_builders/dynamic.rb +27 -0
- data/lib/leftovers/processor_builders/each.rb +36 -0
- data/lib/leftovers/processor_builders/each_action.rb +51 -0
- data/lib/leftovers/processor_builders/each_dynamic.rb +54 -0
- data/lib/leftovers/processor_builders/each_for_definition_set.rb +36 -0
- data/lib/leftovers/processor_builders/itself.rb +13 -0
- data/lib/leftovers/processor_builders/keyword.rb +24 -0
- data/lib/leftovers/processor_builders/keyword_argument.rb +14 -0
- data/lib/leftovers/processor_builders/transform.rb +55 -0
- data/lib/leftovers/processor_builders/transform_chain.rb +24 -0
- data/lib/leftovers/processor_builders/transform_set.rb +47 -0
- data/lib/leftovers/processor_builders/value.rb +13 -0
- data/lib/leftovers/rake_task.rb +4 -4
- data/lib/leftovers/reporter.rb +1 -1
- data/lib/leftovers/value_processors.rb +40 -0
- data/lib/leftovers/value_processors/add_dynamic_prefix.rb +31 -0
- data/lib/leftovers/value_processors/add_dynamic_suffix.rb +31 -0
- data/lib/leftovers/value_processors/add_prefix.rb +20 -0
- data/lib/leftovers/value_processors/add_suffix.rb +20 -0
- data/lib/leftovers/value_processors/camelize.rb +24 -0
- data/lib/leftovers/value_processors/capitalize.rb +19 -0
- data/lib/leftovers/value_processors/deconstantize.rb +24 -0
- data/lib/leftovers/value_processors/delete_after.rb +22 -0
- data/lib/leftovers/value_processors/delete_before.rb +22 -0
- data/lib/leftovers/value_processors/delete_prefix.rb +26 -0
- data/lib/leftovers/value_processors/delete_suffix.rb +26 -0
- data/lib/leftovers/value_processors/demodulize.rb +24 -0
- data/lib/leftovers/value_processors/downcase.rb +19 -0
- data/lib/leftovers/value_processors/each.rb +21 -0
- data/lib/leftovers/value_processors/each_for_definition_set.rb +29 -0
- data/lib/leftovers/value_processors/each_keyword.rb +27 -0
- data/lib/leftovers/value_processors/each_keyword_argument.rb +27 -0
- data/lib/leftovers/value_processors/each_positional_argument.rb +24 -0
- data/lib/leftovers/value_processors/itself.rb +17 -0
- data/lib/leftovers/value_processors/keyword.rb +36 -0
- data/lib/leftovers/value_processors/keyword_argument.rb +36 -0
- data/lib/leftovers/value_processors/parameterize.rb +24 -0
- data/lib/leftovers/value_processors/placeholder.rb +18 -0
- data/lib/leftovers/value_processors/pluralize.rb +24 -0
- data/lib/leftovers/value_processors/positional_argument.rb +26 -0
- data/lib/leftovers/value_processors/replace_value.rb +18 -0
- data/lib/leftovers/value_processors/return_definition.rb +26 -0
- data/lib/leftovers/value_processors/return_string.rb +14 -0
- data/lib/leftovers/value_processors/singularize.rb +24 -0
- data/lib/leftovers/value_processors/split.rb +22 -0
- data/lib/leftovers/value_processors/swapcase.rb +19 -0
- data/lib/leftovers/value_processors/titleize.rb +24 -0
- data/lib/leftovers/value_processors/underscore.rb +24 -0
- data/lib/leftovers/value_processors/upcase.rb +19 -0
- data/lib/leftovers/version.rb +1 -1
- metadata +190 -28
- data/lib/config/selenium.yml +0 -21
- data/lib/leftovers/argument_rule.rb +0 -219
- data/lib/leftovers/core_ext.rb +0 -13
- data/lib/leftovers/hash_rule.rb +0 -40
- data/lib/leftovers/name_rule.rb +0 -53
- data/lib/leftovers/rule.rb +0 -74
- data/lib/leftovers/transform_rule.rb +0 -171
- data/lib/leftovers/value_rule.rb +0 -56
data/lib/config/redcarpet.yml
CHANGED
@@ -1,38 +1,35 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
- doc_footer
|
37
|
-
- preprocess
|
38
|
-
- postprocess
|
1
|
+
keep:
|
2
|
+
- autolink
|
3
|
+
- block_code
|
4
|
+
- block_html
|
5
|
+
- block_quote
|
6
|
+
- codespan
|
7
|
+
- doc_footer
|
8
|
+
- doc_header
|
9
|
+
- double_emphasis
|
10
|
+
- emphasis
|
11
|
+
- entity
|
12
|
+
- footnote_def
|
13
|
+
- footnote_ref
|
14
|
+
- footnotes
|
15
|
+
- header
|
16
|
+
- highlight
|
17
|
+
- hrule
|
18
|
+
- image
|
19
|
+
- linebreak
|
20
|
+
- link
|
21
|
+
- list
|
22
|
+
- list_item
|
23
|
+
- normal_text
|
24
|
+
- paragraph
|
25
|
+
- postprocess
|
26
|
+
- preprocess
|
27
|
+
- quote
|
28
|
+
- raw_html
|
29
|
+
- strikethrough
|
30
|
+
- superscript
|
31
|
+
- table
|
32
|
+
- table_cell
|
33
|
+
- table_row
|
34
|
+
- triple_emphasis
|
35
|
+
- underline
|
data/lib/config/rollbar.yml
CHANGED
data/lib/config/rspec.yml
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
test_paths:
|
2
2
|
- /spec/
|
3
3
|
|
4
|
-
|
5
|
-
|
4
|
+
# split into gems too
|
5
|
+
|
6
|
+
keep:
|
7
|
+
- path: /spec/
|
6
8
|
name:
|
7
9
|
# matchers
|
8
10
|
- diffable?
|
@@ -22,28 +24,31 @@ rules:
|
|
22
24
|
- dump_summary
|
23
25
|
- seed
|
24
26
|
- close
|
27
|
+
dynamic:
|
25
28
|
- name:
|
26
29
|
- have_attributes
|
27
30
|
- has_attributes?
|
28
31
|
- receive_messages
|
29
32
|
calls:
|
30
|
-
|
33
|
+
keywords: '**'
|
34
|
+
path: /spec/
|
31
35
|
- name:
|
32
36
|
- receive
|
33
37
|
- respond_to
|
34
38
|
calls:
|
35
|
-
argument:
|
39
|
+
argument: 0
|
40
|
+
path: /spec/
|
36
41
|
- name: define_negated_matcher
|
37
|
-
defines:
|
38
|
-
|
39
|
-
|
40
|
-
argument: 2
|
42
|
+
defines: 0
|
43
|
+
calls: 1
|
44
|
+
path: /spec/
|
41
45
|
- name:
|
42
46
|
has_prefix: be_
|
43
47
|
calls:
|
44
48
|
itself: true
|
45
49
|
delete_prefix: be_
|
46
50
|
add_suffix: '?'
|
51
|
+
path: /spec/
|
47
52
|
- name:
|
48
53
|
has_prefix: have_
|
49
54
|
calls:
|
@@ -51,6 +56,9 @@ rules:
|
|
51
56
|
add_suffix: '?'
|
52
57
|
delete_prefix: have_
|
53
58
|
add_prefix: has_
|
59
|
+
path: /spec/
|
54
60
|
- name: let
|
55
|
-
|
56
|
-
|
61
|
+
unless:
|
62
|
+
has_argument: 1
|
63
|
+
defines: 0
|
64
|
+
path: /spec/
|
data/lib/config/ruby.yml
CHANGED
@@ -1,48 +1,48 @@
|
|
1
1
|
---
|
2
2
|
include_paths:
|
3
|
-
- '
|
4
|
-
- Gemfile
|
5
|
-
- '*.erb'
|
3
|
+
- '#!:ruby'
|
6
4
|
- '*.gemspec'
|
7
5
|
- .irbrc
|
8
6
|
- irb.rc
|
9
7
|
- _irbrc
|
10
8
|
- $irbrc
|
9
|
+
- Gemfile
|
10
|
+
- '*.erb'
|
11
|
+
- '*.rb'
|
11
12
|
|
12
13
|
test_paths:
|
13
14
|
- /tests/
|
14
15
|
- /test/
|
15
16
|
|
16
|
-
|
17
|
-
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
- eql? # called by Hash key equality
|
17
|
+
keep:
|
18
|
+
- initialize # called by new
|
19
|
+
- inspect # called by repl, to_s
|
20
|
+
- respond_to_missing? # called by respond_to?
|
21
|
+
- method_missing # called by method dispatch
|
22
|
+
- coerce # called by Numeric
|
23
|
+
- to_s # called by "#{}"
|
24
|
+
- to_ary # called by Array(), []+
|
25
|
+
- to_a # called by Array(), *splat
|
26
|
+
- to_str # called by String(), ""+
|
27
|
+
- to_hash # called by Hash(), **splat, {}.merge
|
28
|
+
- to_int # called by Integer()
|
29
|
+
- to_i # called by Integer()
|
30
|
+
- to_f # called by Float()
|
31
|
+
- <=> # called by Comparable
|
32
|
+
- each # called by Enumerable
|
33
|
+
- marshal_dump # called by Marshal.dump
|
34
|
+
- marshal_load # called by Marshal.load
|
35
|
+
- _dump # called by Marshal.dump
|
36
|
+
- _load # called by Marshal.load
|
37
|
+
- inherited # called by Subclass < Klass or Class.new(Klass)
|
38
|
+
- extended # called by extend Module
|
39
|
+
- included # called by include Module
|
40
|
+
- $VERBOSE # called by whatever is outputting warnings i guess
|
41
|
+
- === # called by when
|
42
|
+
- == # called by Array value, Hash value equality, ===
|
43
|
+
- hash # called by Hash key equality
|
44
|
+
- eql? # called by Hash key equality
|
45
|
+
dynamic:
|
46
46
|
- name:
|
47
47
|
- send
|
48
48
|
- public_send
|
@@ -50,8 +50,7 @@ rules:
|
|
50
50
|
- method
|
51
51
|
- respond_to?
|
52
52
|
- instance_method
|
53
|
-
calls:
|
54
|
-
argument: 1
|
53
|
+
calls: 0
|
55
54
|
- name: attr_reader
|
56
55
|
defines:
|
57
56
|
argument: '*'
|
@@ -65,27 +64,21 @@ rules:
|
|
65
64
|
- name: attr_accessor
|
66
65
|
defines:
|
67
66
|
- argument: '*'
|
68
|
-
|
69
|
-
|
70
|
-
- add_suffix: '='
|
67
|
+
add_suffix: '='
|
68
|
+
- argument: '*'
|
71
69
|
calls:
|
72
70
|
argument: '*'
|
73
71
|
add_prefix: '@'
|
74
72
|
- name: define_method
|
75
|
-
defines:
|
76
|
-
argument: 1
|
73
|
+
defines: 0
|
77
74
|
- name: alias_method
|
78
|
-
defines:
|
79
|
-
|
80
|
-
calls:
|
81
|
-
argument: 2
|
75
|
+
defines: 0
|
76
|
+
calls: 1
|
82
77
|
- name:
|
83
78
|
- instance_variable_get
|
84
|
-
-
|
85
|
-
calls:
|
86
|
-
argument: 1
|
79
|
+
- class_variable_get
|
80
|
+
calls: 0
|
87
81
|
- name:
|
88
82
|
- instance_variable_set
|
89
83
|
- class_variable_set
|
90
|
-
defines:
|
91
|
-
argument: 1
|
84
|
+
defines: 0
|
@@ -0,0 +1,19 @@
|
|
1
|
+
keep:
|
2
|
+
- before_navigate_to
|
3
|
+
- before_navigate_back
|
4
|
+
- after_navigate_back
|
5
|
+
- before_navigate_forward
|
6
|
+
- after_navigate_forward
|
7
|
+
- before_find
|
8
|
+
- after_find
|
9
|
+
- before_click
|
10
|
+
- before_change_value_of
|
11
|
+
- after_change_value_of
|
12
|
+
- before_execute_script
|
13
|
+
- after_execute_script
|
14
|
+
- before_quit
|
15
|
+
- before_close
|
16
|
+
- after_navigate_to
|
17
|
+
- after_click
|
18
|
+
- after_quit
|
19
|
+
- after_close
|
@@ -1,14 +1,12 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
- to_html
|
14
|
-
- container_attributes
|
1
|
+
keep:
|
2
|
+
# WillPaginate::ViewHelpers::LinkRenderer
|
3
|
+
- page_number
|
4
|
+
- gap
|
5
|
+
- previous_page
|
6
|
+
- next_page
|
7
|
+
- previous_or_next_page
|
8
|
+
- html_container
|
9
|
+
- url
|
10
|
+
- prepare
|
11
|
+
- to_html
|
12
|
+
- container_attributes
|
data/lib/leftovers.rb
CHANGED
@@ -1,35 +1,52 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative './leftovers/core_ext'
|
4
|
-
require_relative './leftovers/backports'
|
5
|
-
require_relative './leftovers/collector'
|
6
|
-
require_relative './leftovers/merged_config'
|
7
|
-
require_relative './leftovers/reporter'
|
8
|
-
|
9
3
|
module Leftovers # rubocop:disable Metrics/ModuleLength
|
4
|
+
class Error < ::StandardError; end
|
5
|
+
|
10
6
|
module_function
|
11
7
|
|
8
|
+
autoload(:AST, "#{__dir__}/leftovers/ast")
|
9
|
+
autoload(:Backports, "#{__dir__}/leftovers/backports")
|
10
|
+
autoload(:CLI, "#{__dir__}/leftovers/cli")
|
11
|
+
autoload(:Collector, "#{__dir__}/leftovers/collector")
|
12
|
+
autoload(:ConfigValidator, "#{__dir__}/leftovers/config_validator")
|
13
|
+
autoload(:Config, "#{__dir__}/leftovers/config")
|
14
|
+
autoload(:DefinitionNode, "#{__dir__}/leftovers/definition_node")
|
15
|
+
autoload(:DefinitionSet, "#{__dir__}/leftovers/definition_set")
|
16
|
+
autoload(:Definition, "#{__dir__}/leftovers/definition")
|
17
|
+
autoload(:ERB, "#{__dir__}/leftovers/erb")
|
18
|
+
autoload(:FileCollector, "#{__dir__}/leftovers/file_collector")
|
19
|
+
autoload(:FileList, "#{__dir__}/leftovers/file_list")
|
20
|
+
autoload(:File, "#{__dir__}/leftovers/file")
|
21
|
+
autoload(:Haml, "#{__dir__}/leftovers/haml")
|
22
|
+
autoload(:MatcherBuilders, "#{__dir__}/leftovers/matcher_builders")
|
23
|
+
autoload(:Matchers, "#{__dir__}/leftovers/matchers")
|
24
|
+
autoload(:MergedConfig, "#{__dir__}/leftovers/merged_config")
|
25
|
+
autoload(:Parser, "#{__dir__}/leftovers/parser")
|
26
|
+
autoload(:ProcessorBuilders, "#{__dir__}/leftovers/processor_builders")
|
27
|
+
autoload(:RakeTask, "#{__dir__}/leftovers/rake_task")
|
28
|
+
autoload(:Reporter, "#{__dir__}/leftovers/reporter")
|
29
|
+
autoload(:DynamicProcessors, "#{__dir__}/leftovers/dynamic_processors")
|
30
|
+
autoload(:ValueProcessors, "#{__dir__}/leftovers/value_processors")
|
31
|
+
autoload(:VERSION, "#{__dir__}/leftovers/version")
|
32
|
+
|
12
33
|
class << self
|
13
|
-
attr_accessor :parallel
|
34
|
+
attr_accessor :parallel, :progress
|
14
35
|
alias_method :parallel?, :parallel
|
15
36
|
|
16
|
-
attr_accessor :quiet
|
17
|
-
alias_method :quiet?, :quiet
|
18
|
-
|
19
|
-
attr_accessor :progress
|
20
37
|
alias_method :progress?, :progress
|
21
38
|
end
|
22
39
|
|
23
40
|
def stdout
|
24
|
-
@stdout ||=
|
41
|
+
@stdout ||= $stdout
|
25
42
|
end
|
26
43
|
|
27
44
|
def stderr
|
28
|
-
@stderr ||=
|
45
|
+
@stderr ||= $stderr
|
29
46
|
end
|
30
47
|
|
31
48
|
def config
|
32
|
-
@config ||= Leftovers::MergedConfig.new
|
49
|
+
@config ||= Leftovers::MergedConfig.new(load_defaults: true)
|
33
50
|
end
|
34
51
|
|
35
52
|
def collector
|
@@ -40,24 +57,21 @@ module Leftovers # rubocop:disable Metrics/ModuleLength
|
|
40
57
|
@reporter ||= Leftovers::Reporter.new
|
41
58
|
end
|
42
59
|
|
43
|
-
def leftovers
|
60
|
+
def leftovers
|
44
61
|
@leftovers ||= begin
|
45
62
|
collector.collect
|
46
|
-
collector.definitions.reject
|
47
|
-
definition.skipped? || definition.in_collection?
|
48
|
-
end
|
63
|
+
collector.definitions.reject(&:in_collection?)
|
49
64
|
end
|
50
65
|
end
|
51
66
|
|
52
|
-
def run(stdout: StringIO.new, stderr: StringIO.new) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
53
|
-
reset
|
67
|
+
def run(stdout: StringIO.new, stderr: StringIO.new) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
54
68
|
@stdout = stdout
|
55
69
|
@stderr = stderr
|
56
70
|
return 0 if leftovers.empty?
|
57
71
|
|
58
72
|
only_test = []
|
59
73
|
none = []
|
60
|
-
leftovers.
|
74
|
+
leftovers.sort_by(&:location_s).each do |definition|
|
61
75
|
if !definition.test? && definition.in_test_collection?
|
62
76
|
only_test << definition
|
63
77
|
else
|
@@ -78,7 +92,7 @@ module Leftovers # rubocop:disable Metrics/ModuleLength
|
|
78
92
|
1
|
79
93
|
end
|
80
94
|
|
81
|
-
def reset # rubocop:disable Metrics/
|
95
|
+
def reset # rubocop:disable Metrics/PerceivedComplexity, Metrics/CyclomaticComplexity
|
82
96
|
remove_instance_variable(:@config) if defined?(@config)
|
83
97
|
remove_instance_variable(:@collector) if defined?(@collector)
|
84
98
|
remove_instance_variable(:@reporter) if defined?(@reporter)
|
@@ -87,20 +101,24 @@ module Leftovers # rubocop:disable Metrics/ModuleLength
|
|
87
101
|
remove_instance_variable(:@stdout) if defined?(@stdout)
|
88
102
|
remove_instance_variable(:@stderr) if defined?(@stderr)
|
89
103
|
remove_instance_variable(:@parallel) if defined?(@parallel)
|
90
|
-
remove_instance_variable(:@quiet) if defined?(@quiet)
|
91
104
|
remove_instance_variable(:@pwd) if defined?(@pwd)
|
92
105
|
end
|
93
106
|
|
94
107
|
def warn(message)
|
95
|
-
stderr.puts("\e[2K#{message}")
|
108
|
+
stderr.puts("\e[2K#{message}")
|
109
|
+
end
|
110
|
+
|
111
|
+
def error(message)
|
112
|
+
warn(message)
|
113
|
+
exit 1
|
96
114
|
end
|
97
115
|
|
98
116
|
def puts(message)
|
99
|
-
stdout.puts("\e[2K#{message}")
|
117
|
+
stdout.puts("\e[2K#{message}")
|
100
118
|
end
|
101
119
|
|
102
120
|
def print(message)
|
103
|
-
stdout.print(message)
|
121
|
+
stdout.print(message)
|
104
122
|
end
|
105
123
|
|
106
124
|
def newline
|
@@ -111,18 +129,26 @@ module Leftovers # rubocop:disable Metrics/ModuleLength
|
|
111
129
|
@pwd ||= Pathname.new(Dir.pwd + '/')
|
112
130
|
end
|
113
131
|
|
114
|
-
def
|
132
|
+
def exit(status = 0)
|
133
|
+
throw :leftovers_exit, status
|
134
|
+
end
|
135
|
+
|
136
|
+
def try_require(requirable, message: nil) # rubocop:disable Metrics/MethodLength
|
115
137
|
@try_require ||= {}
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
@try_require[requirable] = false
|
138
|
+
|
139
|
+
@try_require[requirable] = begin
|
140
|
+
if @try_require.key?(requirable)
|
141
|
+
@try_require[requirable]
|
142
|
+
else
|
143
|
+
require requirable
|
144
|
+
true
|
124
145
|
end
|
146
|
+
rescue LoadError
|
147
|
+
false
|
125
148
|
end
|
149
|
+
|
150
|
+
warn message if !@try_require[requirable] && message
|
151
|
+
@try_require[requirable]
|
126
152
|
end
|
127
153
|
|
128
154
|
def each_or_self(value, &block)
|
@@ -132,12 +158,4 @@ module Leftovers # rubocop:disable Metrics/ModuleLength
|
|
132
158
|
else yield(value)
|
133
159
|
end
|
134
160
|
end
|
135
|
-
|
136
|
-
def array_wrap(value)
|
137
|
-
case value
|
138
|
-
when nil then [].freeze
|
139
|
-
when Array then value
|
140
|
-
else [value]
|
141
|
-
end
|
142
|
-
end
|
143
161
|
end
|