Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,6 @@ DEPENDENCIES
rubocop-gusto
rubocop-sorbet!
sorbet
sorbet-static
tapioca

BUNDLED WITH
Expand Down
5 changes: 2 additions & 3 deletions lib/packwerk/privacy/checker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def publicized_location?(location)
publicized_locations[location] = check_for_publicized_sigil(location)
end

publicized_locations[location] #: as !nil
publicized_locations.fetch(location)
end

#: (String location) -> bool
Expand All @@ -35,8 +35,7 @@ def check_for_publicized_sigil(location)

#: (Array[String] lines) -> bool
def content_contains_sigil?(lines)
first_lines = lines[0..4] #: as !nil
first_lines.any? { |l| l =~ PUBLICIZED_SIGIL_REGEX }
lines.first(5).any? { |l| l =~ PUBLICIZED_SIGIL_REGEX }
end
end

Expand Down
1 change: 0 additions & 1 deletion packwerk-extensions.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,5 @@ Gem::Specification.new do |spec|
spec.add_development_dependency 'rubocop'
spec.add_development_dependency 'rubocop-gusto'
spec.add_development_dependency 'sorbet'
spec.add_development_dependency 'sorbet-static'
spec.add_development_dependency 'tapioca'
end
7 changes: 1 addition & 6 deletions test/integration/extension_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
module Packwerk
module Privacy
class ExtensionTest < Minitest::Test
extend T::Sig

include ApplicationFixtureHelper

setup do
Expand All @@ -22,10 +20,7 @@ class ExtensionTest < Minitest::Test
use_template(:extended)
Packwerk::Checker.all
assert_equal(Packwerk::Checker.all.count, 5)
found_checker = Packwerk::Checker.all.any? do |checker|
T.unsafe(checker).is_a?(Packwerk::Privacy::Checker)
end
assert found_checker
assert(Packwerk::Checker.all.any?(Packwerk::Privacy::Checker))
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
module Packwerk
module Privacy
class ExtensionWithUnrecognizedConfigTest < Minitest::Test
extend T::Sig

include ApplicationFixtureHelper

setup do
Expand All @@ -22,10 +20,7 @@ class ExtensionWithUnrecognizedConfigTest < Minitest::Test
use_template(:with_unrecognized_config)
Packwerk::Checker.all
assert_equal(Packwerk::Checker.all.count, 5)
found_checker = Packwerk::Checker.all.any? do |checker|
T.unsafe(checker).is_a?(Packwerk::Privacy::Checker)
end
assert found_checker
assert(Packwerk::Checker.all.any?(Packwerk::Privacy::Checker))
end
end
end
Expand Down
10 changes: 3 additions & 7 deletions test/support/application_fixture_helper.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
# typed: true
# frozen_string_literal: true

# @requires_ancestor: Minitest::Runnable
module ApplicationFixtureHelper
TEMP_FIXTURE_DIR = ROOT.join('tmp', 'fixtures').to_s
DEFAULT_TEMPLATE = :minimal

extend T::Helpers

requires_ancestor { Kernel }

def setup_application_fixture
@old_working_dir = Dir.pwd
end
Expand Down Expand Up @@ -80,13 +77,12 @@ def using_template?
end

def copy_dir(path)
root = FileUtils.mkdir_p(fixture_path).last
FileUtils.cp_r("#{path}/.", T.must(root))
root = FileUtils.mkdir_p(fixture_path).fetch(-1)
FileUtils.cp_r("#{path}/.", root)
@app_dir = root
end

def fixture_path
T.bind(self, Minitest::Runnable)
File.join(TEMP_FIXTURE_DIR, "#{name}-#{Time.now.strftime('%Y_%m_%d_%H_%M_%S')}")
end
end
3 changes: 1 addition & 2 deletions test/unit/folder_privacy/checker_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
module Packwerk
module FolderPrivacy
class CheckerTest < Minitest::Test
extend T::Sig
include FactoryHelper
include RailsApplicationFixtureHelper

Expand Down Expand Up @@ -61,7 +60,7 @@ class CheckerTest < Minitest::Test

private

sig { returns(Checker) }
#: -> Checker
def folder_privacy_checker
FolderPrivacy::Checker.new
end
Expand Down
3 changes: 1 addition & 2 deletions test/unit/folder_privacy/validator_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
module Packwerk
module FolderPrivacy
class ValidatorTest < Minitest::Test
extend T::Sig
include ApplicationFixtureHelper
include RailsApplicationFixtureHelper

Expand Down Expand Up @@ -40,7 +39,7 @@ class ValidatorTest < Minitest::Test
assert result.ok?
end

sig { returns(Packwerk::FolderPrivacy::Validator) }
#: -> Packwerk::FolderPrivacy::Validator
def validator
@validator ||= Packwerk::FolderPrivacy::Validator.new
end
Expand Down
3 changes: 1 addition & 2 deletions test/unit/layer/checker_architecture_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
module Packwerk
module Layer
class CheckerTest < Minitest::Test
extend T::Sig
include FactoryHelper
include RailsApplicationFixtureHelper

Expand Down Expand Up @@ -120,7 +119,7 @@ def utility_pack(enforce: false)

private

sig { returns(Checker) }
#: -> Checker
def layer_checker
Packwerk::Layer::Checker.new
end
Expand Down
3 changes: 1 addition & 2 deletions test/unit/layer/checker_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
module Packwerk
module Layer
class CheckerTest < Minitest::Test
extend T::Sig
include FactoryHelper
include RailsApplicationFixtureHelper

Expand Down Expand Up @@ -124,7 +123,7 @@ def utility_pack(enforce: false)

private

sig { returns(Checker) }
#: -> Checker
def layer_checker
Packwerk::Layer::Checker.new
end
Expand Down
3 changes: 1 addition & 2 deletions test/unit/layer/config_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
module Packwerk
module Layer
class ConfigTest < Minitest::Test
extend T::Sig
include FactoryHelper
include RailsApplicationFixtureHelper

Expand Down Expand Up @@ -58,7 +57,7 @@ def write_architecture_config

private

sig { returns(Config) }
#: -> Config
def config_instance
Packwerk::Layer::Config.new
end
Expand Down
3 changes: 1 addition & 2 deletions test/unit/layer/layers_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
module Packwerk
module Layer
class LayersTest < Minitest::Test
extend T::Sig
include FactoryHelper
include RailsApplicationFixtureHelper

Expand Down Expand Up @@ -34,7 +33,7 @@ def write_config

private

sig { returns(Layers) }
#: -> Layers
def layers_class
Packwerk::Layer::Layers.new
end
Expand Down
3 changes: 1 addition & 2 deletions test/unit/layer/validator_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
module Packwerk
module Layer
class ValidatorTest < Minitest::Test
extend T::Sig
include ApplicationFixtureHelper
include RailsApplicationFixtureHelper

Expand Down Expand Up @@ -175,7 +174,7 @@ def write_architecture_config
assert_equal validator.permitted_keys, %w(enforce_architecture layer)
end

sig { returns(Packwerk::Layer::Validator) }
#: -> Packwerk::Layer::Validator
def validator
@validator ||= Packwerk::Layer::Validator.new
end
Expand Down
3 changes: 1 addition & 2 deletions test/unit/privacy/checker_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
module Packwerk
module Privacy
class CheckerTest < Minitest::Test
extend T::Sig
include FactoryHelper
include RailsApplicationFixtureHelper

Expand Down Expand Up @@ -169,7 +168,7 @@ class CheckerTest < Minitest::Test

private

sig { returns(Checker) }
#: -> Checker
def privacy_checker
Privacy::Checker.new
end
Expand Down
4 changes: 1 addition & 3 deletions test/unit/privacy/package_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
module Packwerk
module Privacy
class PackageTest < Minitest::Test
extend T::Sig

include RailsApplicationFixtureHelper

setup do
Expand All @@ -19,7 +17,7 @@ class PackageTest < Minitest::Test
teardown_application_fixture
end

sig { returns(Package) }
#: -> Package
def privacy_package
Package.from(@package)
end
Expand Down
3 changes: 1 addition & 2 deletions test/unit/privacy/validator_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
module Packwerk
module Privacy
class ValidatorTest < Minitest::Test
extend T::Sig
include ApplicationFixtureHelper
include RailsApplicationFixtureHelper

Expand Down Expand Up @@ -128,7 +127,7 @@ class ValidatorTest < Minitest::Test

private

sig { returns(ApplicationValidator) }
#: -> ApplicationValidator
def validator
@validator ||= ApplicationValidator.new
end
Expand Down
3 changes: 1 addition & 2 deletions test/unit/visibility/checker_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
module Packwerk
module Visibility
class CheckerTest < Minitest::Test
extend T::Sig
include FactoryHelper
include RailsApplicationFixtureHelper

Expand Down Expand Up @@ -59,7 +58,7 @@ class CheckerTest < Minitest::Test

private

sig { returns(Checker) }
#: -> Checker
def visibility_checker
Visibility::Checker.new
end
Expand Down
3 changes: 1 addition & 2 deletions test/unit/visibility/validator_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
module Packwerk
module Visibility
class ValidatorTest < Minitest::Test
extend T::Sig
include ApplicationFixtureHelper
include RailsApplicationFixtureHelper

Expand Down Expand Up @@ -69,7 +68,7 @@ class ValidatorTest < Minitest::Test
assert result.ok?
end

sig { returns(Packwerk::Visibility::Validator) }
#: -> Packwerk::Visibility::Validator
def validator
@validator ||= Packwerk::Visibility::Validator.new
end
Expand Down