Class: RuboCop::Cop::Style::SpaceAroundKeyword
- Inherits:
-
Cop
- Object
- Cop
- RuboCop::Cop::Style::SpaceAroundKeyword
show all
- Defined in:
- lib/rubocop/cop/style/space_around_keyword.rb
Overview
Checks the spacing around the keywords.
Constant Summary
collapse
- MSG_BEFORE =
'Space before keyword `%s` is missing.'.freeze
- MSG_AFTER =
'Space after keyword `%s` is missing.'.freeze
- DO =
'do'.freeze
- ACCEPT_LEFT_PAREN =
%w(break defined? next not rescue return super yield).freeze
Constants included
from Util
Util::ASGN_NODES, Util::BYTE_ORDER_MARK, Util::EQUALS_ASGN_NODES, Util::LITERAL_REGEX, Util::OPERATOR_METHODS, Util::SHORTHAND_ASGN_NODES, Util::STRING_ESCAPES, Util::STRING_ESCAPE_REGEX
Instance Attribute Summary
Attributes inherited from Cop
#config, #corrections, #offenses, #processed_source
Instance Method Summary
collapse
Methods inherited from Cop
#add_offense, all, #config_to_allow_offenses, #config_to_allow_offenses=, #cop_config, cop_name, #cop_name, cop_type, #correct, #debug?, #details, #display_cop_names?, #display_style_guide?, #excluded_file?, #extra_details?, inherited, #initialize, #join_force?, lint?, match?, #message, non_rails, #parse, qualified_cop_name, #reference_url, #relevant_file?, #style_guide_url, #target_ruby_version
Methods included from Sexp
#s
#def_node_matcher, #def_node_search, #node_search_body
#autocorrect?, #autocorrect_enabled?, #autocorrect_requested?, #support_autocorrect?
#ignore_node, #ignored_node?, #part_of_ignored_node?
Methods included from Util
begins_its_line?, block_length, comment_line?, directions, double_quotes_acceptable?, double_quotes_required?, effective_column, ends_its_line?, first_part_of_call_chain, interpret_string_escapes, line_range, move_pos, numeric_range_size, on_node, operator?, parentheses?, parenthesized_call?, range_with_surrounding_comma, range_with_surrounding_space, source_range, strip_quotes, ternary_op?, to_string_literal, to_symbol_literal, within_node?
Methods included from PathUtil
absolute?, hidden?, issue_deprecation_warning, match_path?, relative_path
Instance Method Details
#on_and(node) ⇒ Object
36
37
38
|
# File 'lib/rubocop/cop/style/space_around_keyword.rb', line 36
def on_and(node)
check(node, [:operator].freeze) if node.keyword?
end
|
#on_block(node) ⇒ Object
40
41
42
|
# File 'lib/rubocop/cop/style/space_around_keyword.rb', line 40
def on_block(node)
check(node, [:begin, :end].freeze)
end
|
#on_break(node) ⇒ Object
44
45
46
|
# File 'lib/rubocop/cop/style/space_around_keyword.rb', line 44
def on_break(node)
check(node, [:keyword].freeze)
end
|
#on_case(node) ⇒ Object
48
49
50
|
# File 'lib/rubocop/cop/style/space_around_keyword.rb', line 48
def on_case(node)
check(node, [:keyword, :else].freeze)
end
|
#on_defined?(node) ⇒ Boolean
124
125
126
|
# File 'lib/rubocop/cop/style/space_around_keyword.rb', line 124
def on_defined?(node)
check(node, [:keyword].freeze)
end
|
#on_ensure(node) ⇒ Object
52
53
54
|
# File 'lib/rubocop/cop/style/space_around_keyword.rb', line 52
def on_ensure(node)
check(node, [:keyword].freeze)
end
|
#on_for(node) ⇒ Object
56
57
58
|
# File 'lib/rubocop/cop/style/space_around_keyword.rb', line 56
def on_for(node)
check(node, [:begin, :end].freeze)
end
|
#on_if(node) ⇒ Object
60
61
62
|
# File 'lib/rubocop/cop/style/space_around_keyword.rb', line 60
def on_if(node)
check(node, [:keyword, :else, :begin, :end].freeze, 'then'.freeze)
end
|
#on_kwbegin(node) ⇒ Object
64
65
66
|
# File 'lib/rubocop/cop/style/space_around_keyword.rb', line 64
def on_kwbegin(node)
check(node, [:begin, :end].freeze, nil)
end
|
#on_next(node) ⇒ Object
68
69
70
|
# File 'lib/rubocop/cop/style/space_around_keyword.rb', line 68
def on_next(node)
check(node, [:keyword].freeze)
end
|
#on_or(node) ⇒ Object
72
73
74
|
# File 'lib/rubocop/cop/style/space_around_keyword.rb', line 72
def on_or(node)
check(node, [:operator].freeze) if node.keyword?
end
|
#on_postexe(node) ⇒ Object
76
77
78
|
# File 'lib/rubocop/cop/style/space_around_keyword.rb', line 76
def on_postexe(node)
check(node, [:keyword].freeze)
end
|
#on_preexe(node) ⇒ Object
80
81
82
|
# File 'lib/rubocop/cop/style/space_around_keyword.rb', line 80
def on_preexe(node)
check(node, [:keyword].freeze)
end
|
#on_resbody(node) ⇒ Object
84
85
86
|
# File 'lib/rubocop/cop/style/space_around_keyword.rb', line 84
def on_resbody(node)
check(node, [:keyword].freeze)
end
|
#on_rescue(node) ⇒ Object
88
89
90
|
# File 'lib/rubocop/cop/style/space_around_keyword.rb', line 88
def on_rescue(node)
check(node, [:else].freeze)
end
|
#on_return(node) ⇒ Object
92
93
94
|
# File 'lib/rubocop/cop/style/space_around_keyword.rb', line 92
def on_return(node)
check(node, [:keyword].freeze)
end
|
#on_send(node) ⇒ Object
96
97
98
|
# File 'lib/rubocop/cop/style/space_around_keyword.rb', line 96
def on_send(node)
check(node, [:selector].freeze) if node.keyword_not?
end
|
#on_super(node) ⇒ Object
100
101
102
|
# File 'lib/rubocop/cop/style/space_around_keyword.rb', line 100
def on_super(node)
check(node, [:keyword].freeze)
end
|
#on_until(node) ⇒ Object
108
109
110
|
# File 'lib/rubocop/cop/style/space_around_keyword.rb', line 108
def on_until(node)
check(node, [:begin, :end, :keyword].freeze)
end
|
#on_when(node) ⇒ Object
112
113
114
|
# File 'lib/rubocop/cop/style/space_around_keyword.rb', line 112
def on_when(node)
check(node, [:keyword].freeze)
end
|
#on_while(node) ⇒ Object
116
117
118
|
# File 'lib/rubocop/cop/style/space_around_keyword.rb', line 116
def on_while(node)
check(node, [:begin, :end, :keyword].freeze)
end
|
#on_yield(node) ⇒ Object
120
121
122
|
# File 'lib/rubocop/cop/style/space_around_keyword.rb', line 120
def on_yield(node)
check(node, [:keyword].freeze)
end
|
#on_zsuper(node) ⇒ Object
104
105
106
|
# File 'lib/rubocop/cop/style/space_around_keyword.rb', line 104
def on_zsuper(node)
check(node, [:keyword].freeze)
end
|