lib/packwerk/privacy_checker.rb in packwerk-1.1.3 vs lib/packwerk/privacy_checker.rb in packwerk-1.2.0

- old
+ new

@@ -1,11 +1,8 @@ # typed: strict # frozen_string_literal: true -require "packwerk/violation_type" -require "packwerk/checker" - module Packwerk class PrivacyChecker extend T::Sig include Checker @@ -14,32 +11,22 @@ ViolationType::Privacy end sig do override - .params(reference: Packwerk::Reference, reference_lister: Packwerk::ReferenceLister) + .params(reference: Packwerk::Reference) .returns(T::Boolean) end - def invalid_reference?(reference, reference_lister) + def invalid_reference?(reference) return false if reference.constant.public? privacy_option = reference.constant.package.enforce_privacy return false if enforcement_disabled?(privacy_option) return false unless privacy_option == true || explicitly_private_constant?(reference.constant, explicitly_private_constants: privacy_option) - return false if reference_lister.listed?(reference, violation_type: violation_type) - true - end - - sig { override.params(reference: Packwerk::Reference).returns(String) } - def message_for(reference) - source_desc = reference.source_package ? "'#{reference.source_package}'" : "here" - "Privacy violation: '#{reference.constant.name}' is private to '#{reference.constant.package}' but " \ - "referenced from #{source_desc}.\n" \ - "Is there a public entrypoint in '#{reference.constant.package.public_path}' that you can use instead?" end private sig do