Avoid one-letter names if possible

This commit is contained in:
Sijawusz Pur Rahnama 2022-11-25 04:00:15 +01:00
parent 20935ae381
commit 0f893971dc
5 changed files with 18 additions and 18 deletions

View file

@ -5,11 +5,11 @@ module Ameba::Formatter
output << "Disabled rules using inline directives: \n\n"
sources.each do |source|
source.issues.select(&.disabled?).each do |e|
next unless loc = e.location
source.issues.select(&.disabled?).each do |issue|
next unless loc = issue.location
output << "#{source.path}:#{loc.line_number}".colorize(:cyan)
output << " #{e.rule.name}\n"
output << " #{issue.rule.name}\n"
end
end
end

View file

@ -3,16 +3,16 @@ module Ameba::Formatter
@mutex = Mutex.new
def source_finished(source : Source)
source.issues.each do |e|
next if e.disabled?
next if e.correctable? && config[:autocorrect]?
source.issues.each do |issue|
next if issue.disabled?
next if issue.correctable? && config[:autocorrect]?
next unless loc = e.location
next unless loc = issue.location
@mutex.synchronize do
output.printf "%s:%d:%d: %s: [%s] %s\n",
source.path, loc.line_number, loc.column_number, e.rule.severity.symbol,
e.rule.name, e.message.gsub('\n', " ")
source.path, loc.line_number, loc.column_number, issue.rule.severity.symbol,
issue.rule.name, issue.message.gsub('\n', " ")
end
end
end

View file

@ -26,8 +26,8 @@ module Ameba::Rule::Lint
def test(source, node : Crystal::StringInterpolation)
node.expressions
.select { |e| !e.is_a?(Crystal::StringLiteral) && literal?(e) }
.each { |n| issue_for n, MSG }
.select { |exp| !exp.is_a?(Crystal::StringLiteral) && literal?(exp) }
.each { |exp| issue_for exp, MSG }
end
end
end

View file

@ -36,12 +36,12 @@ module Ameba::Rule::Lint
end
private def string_coercion_nodes(node)
node.expressions.select do |e|
e.is_a?(Crystal::Call) &&
e.name == "to_s" &&
e.args.size.zero? &&
e.named_args.nil? &&
e.obj
node.expressions.select do |exp|
exp.is_a?(Crystal::Call) &&
exp.name == "to_s" &&
exp.args.size.zero? &&
exp.named_args.nil? &&
exp.obj
end
end
end

View file

@ -42,7 +42,7 @@ module Ameba::Rule::Style
when Crystal::BinaryOp
negated_condition?(node.left) || negated_condition?(node.right)
when Crystal::Expressions
node.expressions.any? { |e| negated_condition?(e) }
node.expressions.any? { |exp| negated_condition?(exp) }
when Crystal::Not
true
else