rubocop 0.77.0 → 0.81.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.
Files changed (129) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE.txt +1 -1
  3. data/README.md +3 -3
  4. data/config/default.yml +136 -60
  5. data/lib/rubocop.rb +20 -4
  6. data/lib/rubocop/ast/builder.rb +45 -42
  7. data/lib/rubocop/ast/node.rb +11 -18
  8. data/lib/rubocop/ast/node/block_node.rb +5 -1
  9. data/lib/rubocop/ast/node/case_match_node.rb +56 -0
  10. data/lib/rubocop/ast/node/def_node.rb +11 -0
  11. data/lib/rubocop/ast/node/forward_args_node.rb +18 -0
  12. data/lib/rubocop/ast/node/regexp_node.rb +2 -4
  13. data/lib/rubocop/ast/traversal.rb +29 -10
  14. data/lib/rubocop/cli/command/auto_genenerate_config.rb +7 -7
  15. data/lib/rubocop/cli/command/show_cops.rb +11 -4
  16. data/lib/rubocop/comment_config.rb +6 -1
  17. data/lib/rubocop/config.rb +28 -10
  18. data/lib/rubocop/config_loader.rb +19 -19
  19. data/lib/rubocop/config_obsoletion.rb +6 -4
  20. data/lib/rubocop/config_validator.rb +55 -95
  21. data/lib/rubocop/cop/autocorrect_logic.rb +7 -4
  22. data/lib/rubocop/cop/bundler/insecure_protocol_source.rb +2 -2
  23. data/lib/rubocop/cop/cop.rb +3 -1
  24. data/lib/rubocop/cop/gemspec/ordered_dependencies.rb +1 -1
  25. data/lib/rubocop/cop/generator.rb +3 -4
  26. data/lib/rubocop/cop/generator/configuration_injector.rb +1 -1
  27. data/lib/rubocop/cop/layout/array_alignment.rb +53 -10
  28. data/lib/rubocop/cop/layout/block_end_newline.rb +5 -3
  29. data/lib/rubocop/cop/layout/else_alignment.rb +8 -0
  30. data/lib/rubocop/cop/layout/empty_line_between_defs.rb +2 -1
  31. data/lib/rubocop/cop/layout/first_argument_indentation.rb +2 -2
  32. data/lib/rubocop/cop/layout/hash_alignment.rb +8 -4
  33. data/lib/rubocop/cop/layout/heredoc_indentation.rb +4 -4
  34. data/lib/rubocop/cop/layout/leading_comment_space.rb +33 -2
  35. data/lib/rubocop/cop/{metrics → layout}/line_length.rb +35 -79
  36. data/lib/rubocop/cop/layout/multiline_block_layout.rb +14 -5
  37. data/lib/rubocop/cop/layout/multiline_hash_brace_layout.rb +0 -4
  38. data/lib/rubocop/cop/layout/multiline_method_call_indentation.rb +1 -1
  39. data/lib/rubocop/cop/layout/space_around_operators.rb +49 -6
  40. data/lib/rubocop/cop/layout/space_before_block_braces.rb +17 -0
  41. data/lib/rubocop/cop/layout/space_before_first_arg.rb +8 -0
  42. data/lib/rubocop/cop/layout/space_inside_hash_literal_braces.rb +2 -9
  43. data/lib/rubocop/cop/lint/boolean_symbol.rb +12 -0
  44. data/lib/rubocop/cop/lint/debugger.rb +1 -1
  45. data/lib/rubocop/cop/lint/each_with_object_argument.rb +1 -1
  46. data/lib/rubocop/cop/lint/erb_new_arguments.rb +1 -1
  47. data/lib/rubocop/cop/lint/loop.rb +6 -4
  48. data/lib/rubocop/cop/lint/nested_method_definition.rb +2 -2
  49. data/lib/rubocop/cop/lint/non_deterministic_require_order.rb +89 -0
  50. data/lib/rubocop/cop/lint/raise_exception.rb +39 -0
  51. data/lib/rubocop/cop/lint/redundant_cop_disable_directive.rb +3 -3
  52. data/lib/rubocop/cop/lint/redundant_cop_enable_directive.rb +13 -8
  53. data/lib/rubocop/cop/lint/safe_navigation_chain.rb +1 -1
  54. data/lib/rubocop/cop/lint/struct_new_override.rb +58 -0
  55. data/lib/rubocop/cop/lint/suppressed_exception.rb +12 -22
  56. data/lib/rubocop/cop/lint/unused_method_argument.rb +32 -6
  57. data/lib/rubocop/cop/lint/useless_setter_call.rb +4 -0
  58. data/lib/rubocop/cop/migration/department_name.rb +47 -6
  59. data/lib/rubocop/cop/mixin/alignment.rb +1 -1
  60. data/lib/rubocop/cop/mixin/configurable_enforced_style.rb +4 -0
  61. data/lib/rubocop/cop/mixin/end_keyword_alignment.rb +6 -1
  62. data/lib/rubocop/cop/mixin/frozen_string_literal.rb +7 -7
  63. data/lib/rubocop/cop/mixin/hash_transform_method.rb +171 -0
  64. data/lib/rubocop/cop/mixin/line_length_help.rb +88 -0
  65. data/lib/rubocop/cop/mixin/method_complexity.rb +5 -0
  66. data/lib/rubocop/cop/mixin/rational_literal.rb +18 -0
  67. data/lib/rubocop/cop/mixin/statement_modifier.rb +2 -2
  68. data/lib/rubocop/cop/mixin/trailing_comma.rb +8 -12
  69. data/lib/rubocop/cop/naming/memoized_instance_variable_name.rb +1 -1
  70. data/lib/rubocop/cop/naming/method_name.rb +30 -0
  71. data/lib/rubocop/cop/naming/method_parameter_name.rb +1 -1
  72. data/lib/rubocop/cop/offense.rb +11 -0
  73. data/lib/rubocop/cop/registry.rb +7 -2
  74. data/lib/rubocop/cop/style/access_modifier_declarations.rb +26 -6
  75. data/lib/rubocop/cop/style/attr.rb +8 -0
  76. data/lib/rubocop/cop/style/block_delimiters.rb +60 -1
  77. data/lib/rubocop/cop/style/collection_methods.rb +2 -0
  78. data/lib/rubocop/cop/style/conditional_assignment.rb +2 -2
  79. data/lib/rubocop/cop/style/documentation.rb +43 -5
  80. data/lib/rubocop/cop/style/end_block.rb +6 -0
  81. data/lib/rubocop/cop/style/frozen_string_literal_comment.rb +89 -11
  82. data/lib/rubocop/cop/style/guard_clause.rb +3 -2
  83. data/lib/rubocop/cop/style/hash_each_methods.rb +89 -0
  84. data/lib/rubocop/cop/style/hash_transform_keys.rb +83 -0
  85. data/lib/rubocop/cop/style/hash_transform_values.rb +83 -0
  86. data/lib/rubocop/cop/style/if_unless_modifier.rb +38 -3
  87. data/lib/rubocop/cop/style/infinite_loop.rb +1 -1
  88. data/lib/rubocop/cop/style/inverse_methods.rb +9 -5
  89. data/lib/rubocop/cop/style/lambda.rb +1 -0
  90. data/lib/rubocop/cop/style/method_call_with_args_parentheses.rb +7 -205
  91. data/lib/rubocop/cop/style/method_call_with_args_parentheses/omit_parentheses.rb +169 -0
  92. data/lib/rubocop/cop/style/method_call_with_args_parentheses/require_parentheses.rb +54 -0
  93. data/lib/rubocop/cop/style/module_function.rb +56 -10
  94. data/lib/rubocop/cop/style/multiline_method_signature.rb +1 -1
  95. data/lib/rubocop/cop/style/multiline_when_then.rb +5 -1
  96. data/lib/rubocop/cop/style/nested_parenthesized_calls.rb +4 -4
  97. data/lib/rubocop/cop/style/numeric_predicate.rb +4 -3
  98. data/lib/rubocop/cop/style/one_line_conditional.rb +3 -2
  99. data/lib/rubocop/cop/style/or_assignment.rb +3 -2
  100. data/lib/rubocop/cop/style/percent_literal_delimiters.rb +7 -7
  101. data/lib/rubocop/cop/style/redundant_condition.rb +17 -4
  102. data/lib/rubocop/cop/style/redundant_sort.rb +2 -2
  103. data/lib/rubocop/cop/style/symbol_array.rb +2 -2
  104. data/lib/rubocop/cop/style/ternary_parentheses.rb +1 -1
  105. data/lib/rubocop/cop/style/trailing_comma_in_arguments.rb +34 -22
  106. data/lib/rubocop/cop/style/trailing_comma_in_array_literal.rb +41 -0
  107. data/lib/rubocop/cop/style/trailing_comma_in_block_args.rb +85 -0
  108. data/lib/rubocop/cop/style/trailing_comma_in_hash_literal.rb +44 -0
  109. data/lib/rubocop/cop/style/trailing_underscore_variable.rb +7 -1
  110. data/lib/rubocop/cop/style/while_until_modifier.rb +1 -1
  111. data/lib/rubocop/cop/style/yoda_condition.rb +16 -1
  112. data/lib/rubocop/cop/variable_force.rb +4 -1
  113. data/lib/rubocop/formatter/base_formatter.rb +2 -2
  114. data/lib/rubocop/formatter/clang_style_formatter.rb +1 -1
  115. data/lib/rubocop/formatter/formatter_set.rb +1 -0
  116. data/lib/rubocop/formatter/json_formatter.rb +6 -5
  117. data/lib/rubocop/formatter/junit_formatter.rb +74 -0
  118. data/lib/rubocop/formatter/tap_formatter.rb +1 -1
  119. data/lib/rubocop/node_pattern.rb +97 -11
  120. data/lib/rubocop/options.rb +8 -8
  121. data/lib/rubocop/processed_source.rb +1 -1
  122. data/lib/rubocop/result_cache.rb +2 -0
  123. data/lib/rubocop/rspec/shared_contexts.rb +5 -0
  124. data/lib/rubocop/runner.rb +5 -1
  125. data/lib/rubocop/target_ruby.rb +151 -0
  126. data/lib/rubocop/version.rb +1 -1
  127. metadata +38 -10
  128. data/lib/rubocop/cop/lint/end_in_method.rb +0 -40
  129. data/lib/rubocop/cop/style/braces_around_hash_parameters.rb +0 -209
@@ -46,7 +46,7 @@ module RuboCop
46
46
  def autocorrect(node)
47
47
  lambda do |corrector|
48
48
  if node.ternary?
49
- corrector.replace(range_of_offense(node), '||')
49
+ correct_ternary(corrector, node)
50
50
  elsif node.modifier_form? || !node.else_branch
51
51
  corrector.replace(node.source_range, node.if_branch.source)
52
52
  else
@@ -90,9 +90,13 @@ module RuboCop
90
90
  end
91
91
 
92
92
  def else_source(else_branch)
93
- wrap_else =
94
- else_branch.basic_conditional? && else_branch.modifier_form?
95
- wrap_else ? "(#{else_branch.source})" : else_branch.source
93
+ if else_branch.basic_conditional? &&
94
+ else_branch.modifier_form? ||
95
+ else_branch.range_type?
96
+ "(#{else_branch.source})"
97
+ else
98
+ else_branch.source
99
+ end
96
100
  end
97
101
 
98
102
  def make_ternary_form(node)
@@ -106,6 +110,15 @@ module RuboCop
106
110
  ternary_form
107
111
  end
108
112
  end
113
+
114
+ def correct_ternary(corrector, node)
115
+ corrector.replace(range_of_offense(node), '||')
116
+
117
+ return unless node.else_branch.range_type?
118
+
119
+ corrector.insert_before(node.else_branch.loc.expression, '(')
120
+ corrector.insert_after(node.else_branch.loc.expression, ')')
121
+ end
109
122
  end
110
123
  end
111
124
  end
@@ -63,9 +63,9 @@ module RuboCop
63
63
  (send $(send _ $:sort_by _) ${:last :first})
64
64
  (send $(send _ $:sort_by _) ${:[] :at :slice} {(int 0) (int -1)})
65
65
 
66
- (send (block $(send _ ${:sort_by :sort}) ...) ${:last :first})
66
+ (send ({block numblock} $(send _ ${:sort_by :sort}) ...) ${:last :first})
67
67
  (send
68
- (block $(send _ ${:sort_by :sort}) ...)
68
+ ({block numblock} $(send _ ${:sort_by :sort}) ...)
69
69
  ${:[] :at :slice} {(int 0) (int -1)}
70
70
  )
71
71
  }
@@ -11,8 +11,8 @@ module RuboCop
11
11
  #
12
12
  # Configuration option: MinSize
13
13
  # If set, arrays with fewer elements than this value will not trigger the
14
- # cop. For example, a `MinSize of `3` will not enforce a style on an array
15
- # of 2 or fewer elements.
14
+ # cop. For example, a `MinSize` of `3` will not enforce a style on an
15
+ # array of 2 or fewer elements.
16
16
  #
17
17
  # @example EnforcedStyle: percent (default)
18
18
  # # good
@@ -162,7 +162,7 @@ module RuboCop
162
162
  # `RedundantParentheses` cop is enabled, it will cause an infinite loop
163
163
  # as they compete to add and remove the parentheses respectively.
164
164
  def infinite_loop?
165
- require_parentheses? &&
165
+ (require_parentheses? || require_parentheses_when_complex?) &&
166
166
  redundant_parentheses_enabled?
167
167
  end
168
168
 
@@ -4,6 +4,13 @@ module RuboCop
4
4
  module Cop
5
5
  module Style
6
6
  # This cop checks for trailing comma in argument lists.
7
+ # The supported styles are:
8
+ #
9
+ # - `consistent_comma`: Requires a comma after the last argument,
10
+ # for all parenthesized method calls with arguments.
11
+ # - `comma`: Requires a comma after the last argument, but only for
12
+ # parenthesized method calls where each argument is on its own line.
13
+ # - `no_comma`: Does not requires a comma after the last argument.
7
14
  #
8
15
  # @example EnforcedStyleForMultiline: consistent_comma
9
16
  # # bad
@@ -20,6 +27,11 @@ module RuboCop
20
27
  #
21
28
  # # good
22
29
  # method(
30
+ # 1, 2, 3,
31
+ # )
32
+ #
33
+ # # good
34
+ # method(
23
35
  # 1,
24
36
  # 2,
25
37
  # )
@@ -31,6 +43,28 @@ module RuboCop
31
43
  # # good
32
44
  # method(1, 2)
33
45
  #
46
+ # # bad
47
+ # method(
48
+ # 1, 2,
49
+ # 3,
50
+ # )
51
+ #
52
+ # # good
53
+ # method(
54
+ # 1, 2,
55
+ # 3
56
+ # )
57
+ #
58
+ # # bad
59
+ # method(
60
+ # 1, 2, 3,
61
+ # )
62
+ #
63
+ # # good
64
+ # method(
65
+ # 1, 2, 3
66
+ # )
67
+ #
34
68
  # # good
35
69
  # method(
36
70
  # 1,
@@ -68,28 +102,6 @@ module RuboCop
68
102
  def self.autocorrect_incompatible_with
69
103
  [Layout::HeredocArgumentClosingParenthesis]
70
104
  end
71
-
72
- private
73
-
74
- def avoid_autocorrect?(args)
75
- args.last.hash_type? && args.last.braces? &&
76
- braces_will_be_removed?(args)
77
- end
78
-
79
- # Returns true if running with --auto-correct would remove the braces
80
- # of the last argument.
81
- def braces_will_be_removed?(args)
82
- brace_config = config.for_cop('Style/BracesAroundHashParameters')
83
- return false unless brace_config.fetch('Enabled')
84
- return false if brace_config['AutoCorrect'] == false
85
-
86
- brace_style = brace_config['EnforcedStyle']
87
- return true if brace_style == 'no_braces'
88
-
89
- return false unless brace_style == 'context_dependent'
90
-
91
- args.one? || !args[-2].hash_type?
92
- end
93
105
  end
94
106
  end
95
107
  end
@@ -4,12 +4,23 @@ module RuboCop
4
4
  module Cop
5
5
  module Style
6
6
  # This cop checks for trailing comma in array literals.
7
+ # The configuration options are:
8
+ #
9
+ # - `consistent_comma`: Requires a comma after the
10
+ # last item of all non-empty, multiline array literals.
11
+ # - `comma`: Requires a comma after last item in an array,
12
+ # but only when each item is on its own line.
13
+ # - `no_comma`: Does not requires a comma after the
14
+ # last item in an array
7
15
  #
8
16
  # @example EnforcedStyleForMultiline: consistent_comma
9
17
  # # bad
10
18
  # a = [1, 2,]
11
19
  #
12
20
  # # good
21
+ # a = [1, 2]
22
+ #
23
+ # # good
13
24
  # a = [
14
25
  # 1, 2,
15
26
  # 3,
@@ -17,6 +28,11 @@ module RuboCop
17
28
  #
18
29
  # # good
19
30
  # a = [
31
+ # 1, 2, 3,
32
+ # ]
33
+ #
34
+ # # good
35
+ # a = [
20
36
  # 1,
21
37
  # 2,
22
38
  # ]
@@ -26,6 +42,31 @@ module RuboCop
26
42
  # a = [1, 2,]
27
43
  #
28
44
  # # good
45
+ # a = [1, 2]
46
+ #
47
+ # # bad
48
+ # a = [
49
+ # 1, 2,
50
+ # 3,
51
+ # ]
52
+ #
53
+ # # good
54
+ # a = [
55
+ # 1, 2,
56
+ # 3
57
+ # ]
58
+ #
59
+ # # bad
60
+ # a = [
61
+ # 1, 2, 3,
62
+ # ]
63
+ #
64
+ # # good
65
+ # a = [
66
+ # 1, 2, 3
67
+ # ]
68
+ #
69
+ # # good
29
70
  # a = [
30
71
  # 1,
31
72
  # 2,
@@ -0,0 +1,85 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RuboCop
4
+ module Cop
5
+ module Style
6
+ # This cop checks whether trailing commas in block arguments are
7
+ # required. Blocks with only one argument and a trailing comma require
8
+ # that comma to be present. Blocks with more than one argument never
9
+ # require a trailing comma.
10
+ #
11
+ # @example
12
+ # # bad
13
+ # add { |foo, bar,| foo + bar }
14
+ #
15
+ # # good
16
+ # add { |foo, bar| foo + bar }
17
+ #
18
+ # # good
19
+ # add { |foo,| foo }
20
+ #
21
+ # # good
22
+ # add { foo }
23
+ #
24
+ # # bad
25
+ # add do |foo, bar,|
26
+ # foo + bar
27
+ # end
28
+ #
29
+ # # good
30
+ # add do |foo, bar|
31
+ # foo + bar
32
+ # end
33
+ #
34
+ # # good
35
+ # add do |foo,|
36
+ # foo
37
+ # end
38
+ #
39
+ # # good
40
+ # add do
41
+ # foo + bar
42
+ # end
43
+ class TrailingCommaInBlockArgs < Cop
44
+ MSG = 'Useless trailing comma present in block arguments.'
45
+
46
+ def on_block(node)
47
+ return unless useless_trailing_comma?(node)
48
+
49
+ add_offense(node, location: last_comma(node).pos)
50
+ end
51
+
52
+ def autocorrect(node)
53
+ ->(corrector) { corrector.replace(last_comma(node).pos, '') }
54
+ end
55
+
56
+ private
57
+
58
+ def useless_trailing_comma?(node)
59
+ arg_count(node) > 1 && trailing_comma?(node)
60
+ end
61
+
62
+ def arg_count(node)
63
+ node.arguments.each_descendant(:arg, :optarg, :kwoptarg).to_a.size
64
+ end
65
+
66
+ def trailing_comma?(node)
67
+ argument_tokens(node).last.comma?
68
+ end
69
+
70
+ def last_comma(node)
71
+ argument_tokens(node).last
72
+ end
73
+
74
+ def argument_tokens(node)
75
+ pipes = tokens(node).select { |token| token.type == :tPIPE }
76
+ begin_pos, end_pos = pipes.map do |pipe|
77
+ tokens(node).index(pipe)
78
+ end
79
+
80
+ tokens(node)[begin_pos + 1..end_pos - 1]
81
+ end
82
+ end
83
+ end
84
+ end
85
+ end
@@ -4,12 +4,24 @@ module RuboCop
4
4
  module Cop
5
5
  module Style
6
6
  # This cop checks for trailing comma in hash literals.
7
+ # The configuration options are:
8
+ #
9
+ # - `consistent_comma`: Requires a comma after the
10
+ # last item of all non-empty, multiline hash literals.
11
+ # - `comma`: Requires a comma after the last item in a hash,
12
+ # but only when each item is on its own line.
13
+ # - `no_comma`: Does not requires a comma after the
14
+ # last item in a hash
7
15
  #
8
16
  # @example EnforcedStyleForMultiline: consistent_comma
17
+ #
9
18
  # # bad
10
19
  # a = { foo: 1, bar: 2, }
11
20
  #
12
21
  # # good
22
+ # a = { foo: 1, bar: 2 }
23
+ #
24
+ # # good
13
25
  # a = {
14
26
  # foo: 1, bar: 2,
15
27
  # qux: 3,
@@ -17,21 +29,53 @@ module RuboCop
17
29
  #
18
30
  # # good
19
31
  # a = {
32
+ # foo: 1, bar: 2, qux: 3,
33
+ # }
34
+ #
35
+ # # good
36
+ # a = {
20
37
  # foo: 1,
21
38
  # bar: 2,
22
39
  # }
23
40
  #
24
41
  # @example EnforcedStyleForMultiline: comma
42
+ #
25
43
  # # bad
26
44
  # a = { foo: 1, bar: 2, }
27
45
  #
28
46
  # # good
47
+ # a = { foo: 1, bar: 2 }
48
+ #
49
+ # # bad
50
+ # a = {
51
+ # foo: 1, bar: 2,
52
+ # qux: 3,
53
+ # }
54
+ #
55
+ # # good
56
+ # a = {
57
+ # foo: 1, bar: 2,
58
+ # qux: 3
59
+ # }
60
+ #
61
+ # # bad
62
+ # a = {
63
+ # foo: 1, bar: 2, qux: 3,
64
+ # }
65
+ #
66
+ # # good
67
+ # a = {
68
+ # foo: 1, bar: 2, qux: 3
69
+ # }
70
+ #
71
+ # # good
29
72
  # a = {
30
73
  # foo: 1,
31
74
  # bar: 2,
32
75
  # }
33
76
  #
34
77
  # @example EnforcedStyleForMultiline: no_comma (default)
78
+ #
35
79
  # # bad
36
80
  # a = { foo: 1, bar: 2, }
37
81
  #
@@ -20,8 +20,14 @@ module RuboCop
20
20
  # a, *b, _ = foo()
21
21
  # # => The correction `a, *b, = foo()` is a syntax error
22
22
  #
23
- # # good if AllowNamedUnderscoreVariables is true
23
+ # @example AllowNamedUnderscoreVariables: true (default)
24
+ # # good
24
25
  # a, b, _something = foo()
26
+ #
27
+ # @example AllowNamedUnderscoreVariables: false
28
+ # # bad
29
+ # a, b, _something = foo()
30
+ #
25
31
  class TrailingUnderscoreVariable < Cop
26
32
  include SurroundingSpace
27
33
  include RangeHelp
@@ -5,7 +5,7 @@ module RuboCop
5
5
  module Style
6
6
  # Checks for while and until statements that would fit on one line
7
7
  # if written as a modifier while/until. The maximum line length is
8
- # configured in the `Metrics/LineLength` cop.
8
+ # configured in the `Layout/LineLength` cop.
9
9
  #
10
10
  # @example
11
11
  # # bad
@@ -67,9 +67,16 @@ module RuboCop
67
67
 
68
68
  NONCOMMUTATIVE_OPERATORS = %i[===].freeze
69
69
 
70
+ PROGRAM_NAMES = %i[$0 $PROGRAM_NAME].freeze
71
+
72
+ def_node_matcher :file_constant_equal_program_name?, <<~PATTERN
73
+ (send #source_file_path_constant? {:== :!=} (gvar #program_name?))
74
+ PATTERN
75
+
70
76
  def on_send(node)
71
77
  return unless yoda_compatible_condition?(node)
72
- return if equality_only? && non_equality_operator?(node)
78
+ return if equality_only? && non_equality_operator?(node) ||
79
+ file_constant_equal_program_name?(node)
73
80
 
74
81
  valid_yoda?(node) || add_offense(node)
75
82
  end
@@ -135,6 +142,14 @@ module RuboCop
135
142
  def noncommutative_operator?(node)
136
143
  NONCOMMUTATIVE_OPERATORS.include?(node.method_name)
137
144
  end
145
+
146
+ def source_file_path_constant?(node)
147
+ node.source == '__FILE__'
148
+ end
149
+
150
+ def program_name?(name)
151
+ PROGRAM_NAMES.include?(name)
152
+ end
138
153
  end
139
154
  end
140
155
  end