Skip to content

Commit 84f3477

Browse files
committed
rubocop fixes
1 parent 35a1c38 commit 84f3477

File tree

118 files changed

+324172
-1827
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

118 files changed

+324172
-1827
lines changed

.rubocop.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,18 @@ AllCops:
2727
Gemspec/RequireMFA:
2828
Enabled: false
2929

30+
# Allow extend self pattern
31+
Style/ModuleFunction:
32+
Enabled: false
33+
34+
# Allow expect_any_instance_of in tests for specific testing patterns
35+
RSpec/AnyInstance:
36+
Enabled: false
37+
38+
# Allow after(:all) for necessary cleanup
39+
RSpec/BeforeAfterAll:
40+
Enabled: false
41+
3042
# This leads to code that is not very readable at times (very long lines)
3143
Layout/ArgumentAlignment:
3244
Enabled: false
@@ -124,6 +136,10 @@ Style/NegatedIf:
124136
Style/RedundantCondition:
125137
Enabled: false
126138

139+
Style/StringLiterals:
140+
EnforcedStyle: single_quotes
141+
Enabled: true
142+
127143
# This cop is annoying with typed configuration
128144
Style/TrivialAccessors:
129145
Enabled: false

Gemfile

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
source "https://rubygems.org"
1+
source 'https://rubygems.org'
22

33
gemspec
44

5-
gem "debug"
6-
gem "packwerk"
7-
gem "railties"
8-
gem "rake"
9-
gem "rspec"
10-
gem "rubocop"
11-
gem "rubocop-gusto", "~> 10.0"
12-
gem "sorbet"
13-
gem "tapioca"
5+
gem 'debug'
6+
gem 'packwerk'
7+
gem 'railties'
8+
gem 'rake'
9+
gem 'rspec'
10+
gem 'rubocop'
11+
gem 'rubocop-gusto', '~> 10.0'
12+
gem 'sorbet'
13+
gem 'tapioca'

bin/rubocop

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
# this file is here to facilitate running it.
99
#
1010

11-
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
11+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
1212

13-
require "rubygems"
14-
require "bundler/setup"
13+
require 'rubygems'
14+
require 'bundler/setup'
1515

16-
load Gem.bin_path("rubocop", "rubocop")
16+
load Gem.bin_path('rubocop', 'rubocop')

bin/tapioca

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env ruby
2+
# frozen_string_literal: true
3+
4+
#
5+
# This file was generated by Bundler.
6+
#
7+
# The application 'tapioca' is installed as part of a gem, and
8+
# this file is here to facilitate running it.
9+
#
10+
11+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
12+
13+
require 'rubygems'
14+
require 'bundler/setup'
15+
16+
load Gem.bin_path('tapioca', 'tapioca')

lib/code_ownership.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
# typed: strict
44

5-
require 'set'
65
require 'code_teams'
76
require 'sorbet-runtime'
87
require 'json'
@@ -17,7 +16,7 @@
1716
end
1817

1918
module CodeOwnership
20-
module_function
19+
extend self
2120

2221
extend T::Sig
2322
extend T::Helpers

lib/code_ownership/cli.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,12 @@ def self.validate!(argv)
5656
parser.parse!(args)
5757

5858
files = if options[:diff]
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
59+
ENV.fetch('CODEOWNERS_GIT_STAGED_FILES') { %x(git diff --staged --name-only) }.split("\n").select do |file|
60+
File.exist?(file)
61+
end
62+
else
63+
nil
64+
end
6565

6666
CodeOwnership.validate!(
6767
files: files,
@@ -107,7 +107,7 @@ def self.for_file(argv)
107107
if options[:json]
108108
json = {
109109
team_name: team_name,
110-
team_yml: team_yml
110+
team_yml: team_yml,
111111
}
112112

113113
puts json.to_json
@@ -121,7 +121,7 @@ def self.for_file(argv)
121121

122122
def self.for_team(argv)
123123
parser = OptionParser.new do |opts|
124-
opts.banner = 'Usage: bin/codeownership for_team \'Team Name\''
124+
opts.banner = "Usage: bin/codeownership for_team 'Team Name'"
125125

126126
opts.on('--help', 'Shows this prompt') do
127127
puts opts

lib/code_ownership/configuration.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
module CodeOwnership
44
class Configuration < T::Struct
55
extend T::Sig
6+
67
DEFAULT_JS_PACKAGE_PATHS = T.let(['**/'], T::Array[String])
78

89
const :owned_globs, T::Array[String]
@@ -31,7 +32,7 @@ def self.fetch
3132
skip_codeowners_validation: config_hash.fetch('skip_codeowners_validation', false),
3233
raw_hash: config_hash,
3334
require_github_teams: config_hash.fetch('require_github_teams', false),
34-
codeowners_path: config_hash.fetch('codeowners_path', '.github'),
35+
codeowners_path: config_hash.fetch('codeowners_path', '.github')
3536
)
3637
end
3738

lib/code_ownership/mapper.rb

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ def all
3232
abstract.params(file: String)
3333
.returns(T.nilable(::CodeTeams::Team))
3434
end
35-
def map_file_to_owner(file); end
35+
def map_file_to_owner(file)
36+
end
3637

3738
#
3839
# This should be fast when run with MANY files
@@ -41,21 +42,25 @@ def map_file_to_owner(file); end
4142
abstract.params(files: T::Array[String])
4243
.returns(T::Hash[String, ::CodeTeams::Team])
4344
end
44-
def globs_to_owner(files); end
45+
def globs_to_owner(files)
46+
end
4547

4648
#
4749
# This should be fast when run with MANY files
4850
#
4951
sig do
5052
abstract.params(cache: GlobsToOwningTeamMap, files: T::Array[String]).returns(GlobsToOwningTeamMap)
5153
end
52-
def update_cache(cache, files); end
54+
def update_cache(cache, files)
55+
end
5356

5457
sig { abstract.returns(String) }
55-
def description; end
58+
def description
59+
end
5660

5761
sig { abstract.void }
58-
def bust_caches!; end
62+
def bust_caches!
63+
end
5964

6065
sig { returns(Private::GlobCache) }
6166
def self.to_glob_cache

lib/code_ownership/private/codeowners_file.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,10 @@ def self.expected_contents_lines
6464
# 1) It allows the CODEOWNERS file to be used as a cache for validations
6565
# 2) It allows users to specifically see what their team will not be notified about.
6666
entry = if ignored_teams.include?(code_team.name)
67-
"# /#{path} #{team_mapping}"
68-
else
69-
"/#{path} #{team_mapping}"
70-
end
67+
"# /#{path} #{team_mapping}"
68+
else
69+
"/#{path} #{team_mapping}"
70+
end
7171
ownership_entries << entry
7272
end
7373

@@ -99,7 +99,7 @@ def self.expected_contents_lines
9999
*header.split("\n"),
100100
'', # For line between header and codeowners_file_lines
101101
*codeowners_file_lines,
102-
'' # For end-of-file newline
102+
'', # For end-of-file newline
103103
]
104104
end
105105

@@ -156,7 +156,7 @@ def self.to_glob_cache
156156
# The codeowners file stores paths relative to the root of directory
157157
# Since a `/` means root of the file system from the perspective of ruby,
158158
# we remove that beginning slash so we can correctly glob the files out.
159-
normalized_line = line.gsub(/^# /, '').gsub(%r{^/}, '')
159+
normalized_line = line.delete_prefix('# ').delete_prefix('/')
160160
split_line = normalized_line.split
161161
# Most lines will be in the format: /path/to/file my-github-team
162162
# This will skip over lines that are not of the correct form

lib/code_ownership/private/extension_loader.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ module Private
88
module ExtensionLoader
99
class << self
1010
extend T::Sig
11+
1112
sig { params(require_directive: String).void }
1213
def load(require_directive)
1314
# We want to transform the require directive to behave differently

0 commit comments

Comments
 (0)