Sha256: 8a98dcc024bb8e50a62e5e945ec7598c65b036a8d20bec574844b5dad92be6b7

Contents?: true

Size: 1.03 KB

Versions: 4

Compression:

Stored size: 1.03 KB

Contents

# typed: strict

module CodeOwnership
  module Private
    module Validations
      class FilesHaveOwners
        extend T::Sig
        extend T::Helpers
        include Validator

        sig { override.params(files: T::Array[String], autocorrect: T::Boolean, stage_changes: T::Boolean).returns(T::Array[String]) }
        def validation_errors(files:, autocorrect: true, stage_changes: true)
          allow_list = Dir.glob(Private.configuration.unowned_globs)
          files_by_mapper = Private.files_by_mapper(files)
          files_not_mapped_at_all = files_by_mapper.select { |_file, mapper_descriptions| mapper_descriptions.count == 0 }.keys

          files_without_owners = files_not_mapped_at_all - allow_list

          errors = T.let([], T::Array[String])

          if files_without_owners.any?
            errors << <<~MSG
              Some files are missing ownership:

              #{files_without_owners.map { |file| "- #{file}" }.join("\n")}
            MSG
          end

          errors
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
code_ownership-1.32.3 lib/code_ownership/private/validations/files_have_owners.rb
code_ownership-1.32.2 lib/code_ownership/private/validations/files_have_owners.rb
code_ownership-1.32.1 lib/code_ownership/private/validations/files_have_owners.rb
code_ownership-1.32.0 lib/code_ownership/private/validations/files_have_owners.rb