Skip to content

Commit fc8dae6

Browse files
committed
(CONT-811) Correct Style/SoleNestedConditional
1 parent 47f4258 commit fc8dae6

File tree

3 files changed

+13
-19
lines changed

3 files changed

+13
-19
lines changed

lib/puppet-lint/data.rb

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -318,19 +318,17 @@ def definition_indexes(type)
318318
brace_depth += 1
319319
when :RBRACE
320320
brace_depth -= 1
321-
if brace_depth.zero? && !in_params
322-
if token.next_code_token.type != :LBRACE
323-
result << {
324-
start: i,
325-
end: i + j + 1,
326-
tokens: tokens[i..(i + j + 1)],
327-
param_tokens: param_tokens(tokens[i..(i + j + 1)]),
328-
type: type,
329-
name_token: token.next_code_token,
330-
inherited_token: inherited_class,
331-
}
332-
break
333-
end
321+
if brace_depth.zero? && !in_params && (token.next_code_token.type != :LBRACE)
322+
result << {
323+
start: i,
324+
end: i + j + 1,
325+
tokens: tokens[i..(i + j + 1)],
326+
param_tokens: param_tokens(tokens[i..(i + j + 1)]),
327+
type: type,
328+
name_token: token.next_code_token,
329+
inherited_token: inherited_class,
330+
}
331+
break
334332
end
335333
end
336334
end

lib/puppet-lint/lexer/token.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,7 @@ def find_token_of(direction, type, opts = {})
176176

177177
token_iter = send("#{direction}_token".to_sym)
178178
until token_iter.nil?
179-
if to_find.include?(token_iter.type)
180-
return token_iter if opts[:value].nil? || token_iter.value == opts[:value]
181-
end
179+
return token_iter if to_find.include?(token_iter.type) && (opts[:value].nil? || token_iter.value == opts[:value])
182180

183181
opening_token = (direction == :next) ? 'L' : 'R'
184182
closing_token = (direction == :next) ? 'R' : 'L'

lib/puppet-lint/plugins/check_classes/variable_scope.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,7 @@ def check
117117

118118
msg = 'top-scope variable being used without an explicit namespace'
119119
referenced_variables.each do |token|
120-
unless future_parser_scopes[token.line].nil?
121-
next if future_parser_scopes[token.line].include?(token.value.gsub(%r{\[.+\]\Z}, ''))
122-
end
120+
next if !future_parser_scopes[token.line].nil? && future_parser_scopes[token.line].include?(token.value.gsub(%r{\[.+\]\Z}, ''))
123121

124122
next if token.value.include?('::')
125123
next if %r{^(facts|trusted)\[.+\]}.match?(token.value)

0 commit comments

Comments
 (0)