Class: Packwerk::ReferenceChecking::Checkers::DependencyChecker
- Inherits:
-
Object
- Object
- Packwerk::ReferenceChecking::Checkers::DependencyChecker
- Extended by:
- T::Sig
- Includes:
- Checker
- Defined in:
- lib/packwerk/reference_checking/checkers/dependency_checker.rb
Overview
Checks whether a given reference conforms to the configured graph of dependencies.
Constant Summary collapse
- VIOLATION_TYPE =
T.let("dependency", String)
Instance Method Summary collapse
- #invalid_reference?(reference) ⇒ Boolean
- #message(reference) ⇒ Object
- #strict_mode_violation?(offense) ⇒ Boolean
- #violation_type ⇒ Object
Methods included from Checker
Instance Method Details
#invalid_reference?(reference) ⇒ Boolean
24 25 26 27 28 29 |
# File 'lib/packwerk/reference_checking/checkers/dependency_checker.rb', line 24 def invalid_reference?(reference) return false unless reference.package.enforce_dependencies? return false if reference.package.dependency?(reference.constant.package) true end |
#message(reference) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/packwerk/reference_checking/checkers/dependency_checker.rb', line 36 def (reference) const_name = reference.constant.name const_package = reference.constant.package ref_package = reference.package <<~EOS Dependency violation: #{const_name} belongs to '#{const_package}', but '#{ref_package}' does not specify a dependency on '#{const_package}'. Are we missing an abstraction? Is the code making the reference, and the referenced constant, in the right packages? #{(reference)} EOS end |
#strict_mode_violation?(offense) ⇒ Boolean
51 52 53 54 |
# File 'lib/packwerk/reference_checking/checkers/dependency_checker.rb', line 51 def strict_mode_violation?(offense) referencing_package = offense.reference.package referencing_package.config["enforce_dependencies"] == "strict" end |
#violation_type ⇒ Object
15 16 17 |
# File 'lib/packwerk/reference_checking/checkers/dependency_checker.rb', line 15 def violation_type VIOLATION_TYPE end |