@@ -14,7 +14,7 @@ def self.run!(argv)
1414 for_file ( argv )
1515 elsif command == 'for_team'
1616 for_team ( argv )
17- elsif [ nil , " help" ] . include? ( command )
17+ elsif [ nil , ' help' ] . include? ( command )
1818 puts <<~USAGE
1919 Usage: bin/codeownership <subcommand>
2020
@@ -27,7 +27,6 @@ def self.run!(argv)
2727 else
2828 puts "'#{ command } ' is not a code_ownership command. See `bin/codeownership help`."
2929 end
30-
3130 end
3231
3332 def self . validate! ( argv )
@@ -53,16 +52,16 @@ def self.validate!(argv)
5352 exit
5453 end
5554 end
56- args = parser . order! ( argv ) { }
55+ args = parser . order! ( argv )
5756 parser . parse! ( args )
5857
5958 files = if options [ :diff ]
60- ENV . fetch ( 'CODEOWNERS_GIT_STAGED_FILES' ) { `git diff --staged --name-only` } . split ( "\n " ) . select do |file |
61- File . exist? ( file )
62- end
63- else
64- nil
65- end
59+ ENV . fetch ( 'CODEOWNERS_GIT_STAGED_FILES' ) { `git diff --staged --name-only` } . split ( "\n " ) . select do |file |
60+ File . exist? ( file )
61+ end
62+ else
63+ nil
64+ end
6665
6766 CodeOwnership . validate! (
6867 files : files ,
@@ -79,7 +78,7 @@ def self.for_file(argv)
7978 # Long-term, we probably want to use something like `thor` so we don't have to implement logic
8079 # like this. In the short-term, this is a simple way for us to use the built-in OptionParser
8180 # while having an ergonomic CLI.
82- files = argv . select { |arg | ! arg . start_with? ( '--' ) }
81+ files = argv . reject { |arg | arg . start_with? ( '--' ) }
8382
8483 parser = OptionParser . new do |opts |
8584 opts . banner = 'Usage: bin/codeownership for_file [options]'
@@ -93,22 +92,22 @@ def self.for_file(argv)
9392 exit
9493 end
9594 end
96- args = parser . order! ( argv ) { }
95+ args = parser . order! ( argv )
9796 parser . parse! ( args )
9897
9998 if files . count != 1
100- raise " Please pass in one file. Use `bin/codeownership for_file --help` for more info"
99+ raise ' Please pass in one file. Use `bin/codeownership for_file --help` for more info'
101100 end
102-
101+
103102 team = CodeOwnership . for_file ( files . first )
104103
105- team_name = team &.name || " Unowned"
106- team_yml = team &.config_yml || " Unowned"
104+ team_name = team &.name || ' Unowned'
105+ team_yml = team &.config_yml || ' Unowned'
107106
108107 if options [ :json ]
109108 json = {
110109 team_name : team_name ,
111- team_yml : team_yml ,
110+ team_yml : team_yml
112111 }
113112
114113 puts json . to_json
@@ -121,8 +120,6 @@ def self.for_file(argv)
121120 end
122121
123122 def self . for_team ( argv )
124- options = { }
125-
126123 parser = OptionParser . new do |opts |
127124 opts . banner = 'Usage: bin/codeownership for_team \'Team Name\''
128125
@@ -131,14 +128,14 @@ def self.for_team(argv)
131128 exit
132129 end
133130 end
134- teams = argv . select { |arg | ! arg . start_with? ( '--' ) }
135- args = parser . order! ( argv ) { }
131+ teams = argv . reject { |arg | arg . start_with? ( '--' ) }
132+ args = parser . order! ( argv )
136133 parser . parse! ( args )
137134
138135 if teams . count != 1
139- raise " Please pass in one team. Use `bin/codeownership for_team --help` for more info"
136+ raise ' Please pass in one team. Use `bin/codeownership for_team --help` for more info'
140137 end
141-
138+
142139 puts CodeOwnership . for_team ( teams . first )
143140 end
144141
0 commit comments