2019-04-19 15:38:03 +09:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-10-26 19:41:14 +01:00
|
|
|
require "rubocops/extend/formula"
|
2018-09-02 23:30:07 +02:00
|
|
|
require "extend/string"
|
2017-05-24 13:04:55 +05:30
|
|
|
|
|
|
|
module RuboCop
|
|
|
|
module Cop
|
|
|
|
module FormulaAudit
|
2018-10-18 21:42:43 -04:00
|
|
|
# This cop audits versioned Formulae for `conflicts_with`.
|
2017-05-24 13:04:55 +05:30
|
|
|
class Conflicts < FormulaCop
|
2017-10-21 03:12:50 +02:00
|
|
|
MSG = "Versioned formulae should not use `conflicts_with`. " \
|
2019-04-19 15:38:03 +09:00
|
|
|
"Use `keg_only :versioned_formula` instead."
|
2017-05-24 13:04:55 +05:30
|
|
|
|
2020-06-06 19:12:12 +01:00
|
|
|
ALLOWLIST = %w[
|
2020-04-11 14:19:04 +01:00
|
|
|
bash-completion@2
|
2017-05-24 13:04:55 +05:30
|
|
|
].freeze
|
|
|
|
|
|
|
|
def audit_formula(_node, _class_node, _parent_class_node, body)
|
|
|
|
return unless versioned_formula?
|
2018-09-17 02:45:00 +02:00
|
|
|
|
2020-06-06 19:12:12 +01:00
|
|
|
problem MSG if !ALLOWLIST.include?(@formula_name) &&
|
2017-05-24 13:04:55 +05:30
|
|
|
method_called_ever?(body, :conflicts_with)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|