Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add rubocop #20

Merged
merged 4 commits into from
Sep 28, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
initial rubocop autocorrect
  • Loading branch information
Alex Evanczuk committed Sep 28, 2022
commit 3de60b514d89103e500ab28e7e23757e0f6697d7
30 changes: 15 additions & 15 deletions lib/use_packwerk.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@
module UsePackwerk
extend T::Sig

PERMITTED_PACK_LOCATIONS = T.let([
'gems',
'components',
'packs',
], T::Array[String])
PERMITTED_PACK_LOCATIONS = T.let(%w[
gems
components
packs
], T::Array[String])

sig do
params(
Expand All @@ -45,15 +45,15 @@ def self.create_pack!(
Private.create_pack!(
pack_name: pack_name,
enforce_privacy: enforce_privacy,
enforce_dependencies: enforce_dependencies,
enforce_dependencies: enforce_dependencies
)
end

sig do
params(
pack_name: String,
paths_relative_to_root: T::Array[String],
per_file_processors: T::Array[PerFileProcessorInterface],
per_file_processors: T::Array[PerFileProcessorInterface]
).void
end
def self.move_to_pack!(
Expand All @@ -74,7 +74,7 @@ def self.move_to_pack!(
Private.move_to_pack!(
pack_name: pack_name,
paths_relative_to_root: paths_relative_to_root,
per_file_processors: per_file_processors,
per_file_processors: per_file_processors
)

Logging.section('Next steps') do
Expand All @@ -99,7 +99,7 @@ def self.move_to_pack!(
sig do
params(
paths_relative_to_root: T::Array[String],
per_file_processors: T::Array[PerFileProcessorInterface],
per_file_processors: T::Array[PerFileProcessorInterface]
).void
end
def self.make_public!(
Expand All @@ -117,7 +117,7 @@ def self.make_public!(
paths_relative_to_root: paths_relative_to_root,
per_file_processors: per_file_processors
)

Logging.section('Next steps') do
next_steps = <<~NEXT_STEPS
Your next steps might be:
Expand Down Expand Up @@ -174,7 +174,7 @@ def self.add_dependency!(
params(
pack_name: String,
parent_name: String,
per_file_processors: T::Array[PerFileProcessorInterface],
per_file_processors: T::Array[PerFileProcessorInterface]
).void
end
def self.move_to_parent!(
Expand All @@ -195,7 +195,7 @@ def self.move_to_parent!(
Private.move_to_parent!(
pack_name: pack_name,
parent_name: parent_name,
per_file_processors: per_file_processors,
per_file_processors: per_file_processors
)

Logging.section('Next steps') do
Expand All @@ -214,7 +214,7 @@ def self.move_to_parent!(
sig do
params(
pack_name: T.nilable(String),
limit: Integer,
limit: Integer
).void
end
def self.list_top_privacy_violations(
Expand Down Expand Up @@ -247,14 +247,14 @@ def self.list_top_dependency_violations(
params(
file: String,
find: Pathname,
replace_with: Pathname,
replace_with: Pathname
).void
end
def self.replace_in_file(file:, find:, replace_with:)
Private.replace_in_file(
file: file,
find: find,
replace_with: replace_with,
replace_with: replace_with
)
end
end
20 changes: 10 additions & 10 deletions lib/use_packwerk/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ module UsePackwerk
class CLI < Thor
extend T::Sig

desc "create packs/your_pack", "Create pack with name packs/your_pack"
desc 'create packs/your_pack', 'Create pack with name packs/your_pack'
sig { params(pack_name: String).void }
def create(pack_name)
UsePackwerk.create_pack!(pack_name: pack_name)
end

desc "add_dependency packs/from_pack packs/to_pack", "Add packs/to_pack to packs/from_pack/package.yml list of dependencies"
desc 'add_dependency packs/from_pack packs/to_pack', 'Add packs/to_pack to packs/from_pack/package.yml list of dependencies'
long_desc <<~LONG_DESC
Use this to add a dependency between packs.

Expand All @@ -29,7 +29,7 @@ def add_dependency(from_pack, to_pack)
)
end

desc "list_top_dependency_violations packs/your_pack", "List the top dependency violations of packs/your_pack"
desc 'list_top_dependency_violations packs/your_pack', 'List the top dependency violations of packs/your_pack'
option :limit, type: :numeric, default: 10, aliases: :l, banner: 'Specify the limit of constants to analyze'
sig { params(pack_name: String).void }
def list_top_dependency_violations(pack_name)
Expand All @@ -39,7 +39,7 @@ def list_top_dependency_violations(pack_name)
)
end

desc "list_top_privacy_violations packs/your_pack", "List the top privacy violations of packs/your_pack"
desc 'list_top_privacy_violations packs/your_pack', 'List the top privacy violations of packs/your_pack'
option :limit, type: :numeric, default: 10, aliases: :l, banner: 'Specify the limit of constants to analyze'
sig { params(pack_name: String).void }
def list_top_privacy_violations(pack_name)
Expand All @@ -49,32 +49,32 @@ def list_top_privacy_violations(pack_name)
)
end

desc "make_public path/to/file.rb path/to/directory", "Pass in a space-separated list of file or directory paths to make public"
desc 'make_public path/to/file.rb path/to/directory', 'Pass in a space-separated list of file or directory paths to make public'
sig { params(paths: String).void }
def make_public(*paths)
UsePackwerk.make_public!(
paths_relative_to_root: paths,
per_file_processors: [UsePackwerk::RubocopPostProcessor.new, UsePackwerk::CodeOwnershipPostProcessor.new],
per_file_processors: [UsePackwerk::RubocopPostProcessor.new, UsePackwerk::CodeOwnershipPostProcessor.new]
)
end

desc "move packs/destination_pack path/to/file.rb path/to/directory", "Pass in a destination pack and a space-separated list of file or directory paths to move to the destination pack"
desc 'move packs/destination_pack path/to/file.rb path/to/directory', 'Pass in a destination pack and a space-separated list of file or directory paths to move to the destination pack'
sig { params(pack_name: String, paths: String).void }
def move(pack_name, *paths)
UsePackwerk.move_to_pack!(
pack_name: pack_name,
paths_relative_to_root: paths,
per_file_processors: [UsePackwerk::RubocopPostProcessor.new, UsePackwerk::CodeOwnershipPostProcessor.new],
per_file_processors: [UsePackwerk::RubocopPostProcessor.new, UsePackwerk::CodeOwnershipPostProcessor.new]
)
end

desc "move_to_parent packs/parent_pack packs/child_pack", "Pass in a parent pack and another pack to be made as a child to the parent pack!"
desc 'move_to_parent packs/parent_pack packs/child_pack', 'Pass in a parent pack and another pack to be made as a child to the parent pack!'
sig { params(parent_name: String, pack_name: String).void }
def move_to_parent(parent_name, pack_name)
UsePackwerk.move_to_parent!(
parent_name: parent_name,
pack_name: pack_name,
per_file_processors: [UsePackwerk::RubocopPostProcessor.new, UsePackwerk::CodeOwnershipPostProcessor.new],
per_file_processors: [UsePackwerk::RubocopPostProcessor.new, UsePackwerk::CodeOwnershipPostProcessor.new]
)
end
end
Expand Down
6 changes: 3 additions & 3 deletions lib/use_packwerk/code_ownership_post_processor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def before_move_file!(file_move_operation)
UsePackwerk.replace_in_file(
file: code_owners_allow_list_file.to_s,
find: relative_path_to_origin,
replace_with: relative_path_to_destination,
replace_with: relative_path_to_destination
)
end

Expand All @@ -45,11 +45,11 @@ def print_final_message!
if @teams.any?
Logging.section('Code Ownership') do
Logging.print('This section contains info about the current ownership distribution of the moved files.')
@teams.group_by { |team| team }.sort_by { |team, instances| -instances.count }.each do |team, instances|
@teams.group_by { |team| team }.sort_by { |_team, instances| -instances.count }.each do |team, instances|
Logging.print " #{team} - #{instances.count} files"
end
if @did_move_files
Logging.print "Since the destination package has package-based ownership, file-annotations were removed from moved files."
Logging.print 'Since the destination package has package-based ownership, file-annotations were removed from moved files.'
end
end
end
Expand Down
12 changes: 6 additions & 6 deletions lib/use_packwerk/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,22 @@ class Configuration
sig { void }
def initialize
@enforce_dependencies = T.let(@enforce_dependencies, T.nilable(T::Boolean))
@documentation_link = T.let(documentation_link, T.nilable(String) )
@documentation_link = T.let(documentation_link, T.nilable(String))
end

sig { returns(T::Boolean) }
def enforce_dependencies
if !@enforce_dependencies.nil?
@enforce_dependencies
else
if @enforce_dependencies.nil?
true
else
@enforce_dependencies
end
end

# Configure a link to show up for users who are looking for more info
sig { returns(String) }
def documentation_link
"https://go/packwerk"
'https://go/packwerk'
end
end

Expand All @@ -42,7 +42,7 @@ def config
end

sig { params(blk: T.proc.params(arg0: Configuration).void).void }
def configure(&blk) # rubocop:disable Lint/UnusedMethodArgument
def configure(&blk)
yield(config)
end
end
Expand Down
1 change: 0 additions & 1 deletion lib/use_packwerk/logging.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,3 @@ def self.out(str)
end
end
end

3 changes: 1 addition & 2 deletions lib/use_packwerk/per_file_processor_interface.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ module PerFileProcessorInterface
abstract!

sig { abstract.params(file_move_operation: Private::FileMoveOperation).void }
def before_move_file!(file_move_operation)
end
def before_move_file!(file_move_operation); end

sig { void }
def print_final_message!
Expand Down
Loading