Sha256: 344576f910e9ac3eea9cc6be3063ace850e2946a77aa8451fdbb9f43c919412e

Contents?: true

Size: 1.63 KB

Versions: 27

Compression:

Stored size: 1.63 KB

Contents

# typed: strict

require 'rubocop-sorbet'

module RuboCop
  module Cop
    module Packs
      # This cop helps ensure that each pack's public API is strictly typed, enforcing strong boundaries.
      #
      # @example
      #
      #   # bad
      #   # packs/foo/app/public/foo.rb
      #   # typed: false
      #   module Foo; end
      #
      #   # good
      #   # packs/foo/app/public/foo.rb
      #   # typed: strict
      #   module Foo; end
      #
      class TypedPublicApis < Sorbet::StrictSigil
        #
        # This inherits from `Sorbet::StrictSigil` and doesn't change any behavior of it.
        # The only reason we do this is so that configuration for this cop can live under a different cop namespace.
        # This prevents this cop's configuration from clashing with other configurations for the same cop.
        # A concrete example of this would be if a user is using this package protection to make sure public APIs are typed,
        # and separately the application as a whole requiring strict typing in certain parts of the application.
        #
        # To prevent problems associated with needing to manage identical configurations for the same cop, we simply call it
        # something else in the context of this protection.
        #
        # We can apply this same pattern if we want to use other cops in the context of package protections and prevent clashing.
        #
        extend T::Sig

        sig { params(processed_source: T.untyped).void }
        def investigate(processed_source)
          return unless processed_source.path.include?('app/public')

          super
        end
      end
    end
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
rubocop-packs-0.0.44 lib/rubocop/cop/packs/typed_public_apis.rb
rubocop-packs-0.0.43 lib/rubocop/cop/packs/typed_public_apis.rb
rubocop-packs-0.0.42 lib/rubocop/cop/packs/typed_public_apis.rb
rubocop-packs-0.0.41 lib/rubocop/cop/packs/typed_public_apis.rb
rubocop-packs-0.0.40 lib/rubocop/cop/packs/typed_public_apis.rb
rubocop-packs-0.0.39 lib/rubocop/cop/packs/typed_public_apis.rb
rubocop-packs-0.0.38 lib/rubocop/cop/packs/typed_public_apis.rb
rubocop-packs-0.0.37 lib/rubocop/cop/packs/typed_public_apis.rb
rubocop-packs-0.0.36 lib/rubocop/cop/packs/typed_public_apis.rb
rubocop-packs-0.0.35 lib/rubocop/cop/packs/typed_public_apis.rb
rubocop-packs-0.0.34 lib/rubocop/cop/packs/typed_public_apis.rb
rubocop-packs-0.0.33 lib/rubocop/cop/packs/typed_public_apis.rb
rubocop-packs-0.0.32 lib/rubocop/cop/packs/typed_public_apis.rb
rubocop-packs-0.0.31 lib/rubocop/cop/packs/typed_public_apis.rb
rubocop-packs-0.0.30 lib/rubocop/cop/packs/typed_public_apis.rb
rubocop-packs-0.0.29 lib/rubocop/cop/packs/typed_public_apis.rb
rubocop-packs-0.0.28 lib/rubocop/cop/packs/typed_public_apis.rb
rubocop-packs-0.0.27 lib/rubocop/cop/packs/typed_public_apis.rb
rubocop-packs-0.0.26 lib/rubocop/cop/packs/typed_public_apis.rb
rubocop-packs-0.0.25 lib/rubocop/cop/packs/typed_public_apis.rb