Sha256: 66405d5c2edf552ec62736713f185c781308e786e80377e9d222cd3486423ea5
Contents?: true
Size: 1.78 KB
Versions: 1
Compression:
Stored size: 1.78 KB
Contents
# typed: strict module DangerPackwerk module Private class DefaultAddedOffensesFormatter extend T::Sig sig { params(violations: T::Array[BasicReferenceOffense]).returns(String) } def self.format(violations) violation = T.must(violations.first) # We remove leading double colons as they feel like an implementation detail of packwerk. constant_name = violation.class_name.gsub(/\A::/, '') link_to_docs = '[the docs](https://github.com/Shopify/packwerk/blob/b647594f93c8922c038255a7aaca125d391a1fbf/docs/new_violation_flow_chart.pdf)' disclaimer = "We noticed you ran `bin/packwerk update-deprecations`. Make sure to read through #{link_to_docs} for other ways to resolve. " pluralized_violation = violations.count > 1 ? 'these violations' : 'this violation' request_to_add_context = "Could you add some context as a reply here about why we needed to add #{pluralized_violation}?" if violations.any?(&:dependency?) && violations.any?(&:privacy?) <<~MESSAGE Hi! It looks like the pack defining `#{constant_name}` considers this private API, and it's also not in the referencing pack's list of dependencies. #{disclaimer}#{request_to_add_context} MESSAGE elsif violations.any?(&:dependency?) <<~MESSAGE Hi! It looks like the pack defining `#{constant_name}` is not in the referencing pack's list of dependencies. #{disclaimer}#{request_to_add_context} MESSAGE else # violations.any?(&:privacy?) <<~MESSAGE Hi! It looks like the pack defining `#{constant_name}` considers this private API. #{disclaimer} #{request_to_add_context} MESSAGE end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
danger-packwerk-0.1.0 | lib/danger-packwerk/private/default_offenses_formatter.rb |