rubocops/livecheck: minor changes

This commit is contained in:
nandahkrishna 2020-09-17 15:56:40 +05:30
parent 7c3c459f47
commit e6ed3a0568
No known key found for this signature in database
GPG Key ID: 067E5FCD58ADF3AA

View File

@ -15,7 +15,9 @@ module RuboCop
return if livecheck_node.blank? return if livecheck_node.blank?
skip = find_every_method_call_by_name(livecheck_node, :skip).first skip = find_every_method_call_by_name(livecheck_node, :skip).first
return unless skip.present? && find_every_method_call_by_name(livecheck_node).length > 2 return if skip.blank?
return if find_every_method_call_by_name(livecheck_node).length < 3
offending_node(livecheck_node) offending_node(livecheck_node)
problem "Skipped formulae must not contain other livecheck information." problem "Skipped formulae must not contain other livecheck information."
@ -28,7 +30,11 @@ module RuboCop
skip = string_content(skip) if skip.present? skip = string_content(skip) if skip.present?
corrector.replace( corrector.replace(
node.source_range, node.source_range,
"livecheck do\n skip#{" \"#{skip}\"" if skip.present?}\n end", <<~EOS.strip,
livecheck do
skip#{" \"#{skip}\"" if skip.present?}
end
EOS
) )
end end
end end
@ -100,7 +106,7 @@ module RuboCop
formula_urls = { head: head_url, stable: stable_url, homepage: homepage_url }.compact formula_urls = { head: head_url, stable: stable_url, homepage: homepage_url }.compact
formula_urls.each do |symbol, url| formula_urls.each do |symbol, url|
next unless url == livecheck_url || url == "#{livecheck_url}/" || "#{url}/" == livecheck_url next if url != livecheck_url && url != "#{livecheck_url}/" && "#{url}/" != livecheck_url
offending_node(livecheck_url_node) offending_node(livecheck_url_node)
@offense = symbol @offense = symbol