Skip to content

Commit 951c21a

Browse files
author
Alex Evanczuk
authored
Remove some unnecessary caching (#55)
* Remove some unnecessary caching * bump version
1 parent f1be52a commit 951c21a

File tree

6 files changed

+7
-25
lines changed

6 files changed

+7
-25
lines changed

Gemfile.lock

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
code_ownership (1.32.9)
4+
code_ownership (1.32.10)
55
code_teams (~> 1.0)
66
packs
77
sorbet-runtime

code_ownership.gemspec

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Gem::Specification.new do |spec|
2-
spec.name = "code_ownership"
3-
spec.version = '1.32.9'
2+
spec.name = 'code_ownership'
3+
spec.version = '1.32.10'
44
spec.authors = ['Gusto Engineers']
55
spec.email = ['[email protected]']
66
spec.summary = 'A gem to help engineering teams declare ownership of code'
@@ -30,8 +30,8 @@ Gem::Specification.new do |spec|
3030
spec.add_dependency 'packs'
3131
spec.add_dependency 'sorbet-runtime'
3232

33-
spec.add_development_dependency 'rake'
3433
spec.add_development_dependency 'pry'
34+
spec.add_development_dependency 'rake'
3535
spec.add_development_dependency 'rspec', '~> 3.0'
3636
spec.add_development_dependency 'sorbet'
3737
spec.add_development_dependency 'tapioca'

lib/code_ownership/private/ownership_mappers/file_annotations.rb

+1-6
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ class FileAnnotations
1818
extend T::Sig
1919
include Mapper
2020

21-
@@map_files_to_owners = T.let({}, T.nilable(T::Hash[String, ::CodeTeams::Team])) # rubocop:disable Style/ClassVars
22-
2321
TEAM_PATTERN = T.let(/\A(?:#|\/\/) @team (?<team>.*)\Z/.freeze, Regexp)
2422
DESCRIPTION = 'Annotations at the top of file'
2523

@@ -37,9 +35,7 @@ def map_file_to_owner(file)
3735
returns(T::Hash[String, ::CodeTeams::Team])
3836
end
3937
def globs_to_owner(files)
40-
return @@map_files_to_owners if @@map_files_to_owners&.keys && @@map_files_to_owners.keys.count > 0
41-
42-
@@map_files_to_owners = files.each_with_object({}) do |filename_relative_to_root, mapping| # rubocop:disable Style/ClassVars
38+
files.each_with_object({}) do |filename_relative_to_root, mapping| # rubocop:disable Style/ClassVars
4339
owner = file_annotation_based_owner(filename_relative_to_root)
4440
next unless owner
4541

@@ -119,7 +115,6 @@ def description
119115

120116
sig { override.void }
121117
def bust_caches!
122-
@@map_files_to_owners = {} # rubocop:disable Style/ClassVars
123118
end
124119
end
125120
end

lib/code_ownership/private/ownership_mappers/package_ownership.rb

-3
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ class PackageOwnership
99
extend T::Sig
1010
include Mapper
1111

12-
@@package_yml_cache = T.let({}, T::Hash[String, T.nilable(Packs::Pack)]) # rubocop:disable Style/ClassVars
13-
1412
sig do
1513
override.params(file: String).
1614
returns(T.nilable(::CodeTeams::Team))
@@ -69,7 +67,6 @@ def owner_for_package(package)
6967

7068
sig { override.void }
7169
def bust_caches!
72-
@@package_yml_cache = {} # rubocop:disable Style/ClassVars
7370
end
7471
end
7572
end

lib/code_ownership/private/ownership_mappers/team_globs.rb

+1-6
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ class TeamGlobs
1212

1313
@@map_files_to_owners = T.let(@map_files_to_owners, T.nilable(T::Hash[String, ::CodeTeams::Team])) # rubocop:disable Style/ClassVars
1414
@@map_files_to_owners = {} # rubocop:disable Style/ClassVars
15-
@@codeowners_lines_to_owners = T.let(@codeowners_lines_to_owners, T.nilable(T::Hash[String, ::CodeTeams::Team])) # rubocop:disable Style/ClassVars
16-
@@codeowners_lines_to_owners = {} # rubocop:disable Style/ClassVars
1715

1816
sig do
1917
params(files: T::Array[String]).
@@ -103,9 +101,7 @@ def update_cache(cache, files)
103101
returns(T::Hash[String, ::CodeTeams::Team])
104102
end
105103
def globs_to_owner(files)
106-
return @@codeowners_lines_to_owners if @@codeowners_lines_to_owners&.keys && @@codeowners_lines_to_owners.keys.count > 0
107-
108-
@@codeowners_lines_to_owners = CodeTeams.all.each_with_object({}) do |team, map| # rubocop:disable Style/ClassVars
104+
CodeTeams.all.each_with_object({}) do |team, map| # rubocop:disable Style/ClassVars
109105
TeamPlugins::Ownership.for(team).owned_globs.each do |owned_glob|
110106
map[owned_glob] = team
111107
end
@@ -114,7 +110,6 @@ def globs_to_owner(files)
114110

115111
sig { override.void }
116112
def bust_caches!
117-
@@codeowners_lines_to_owners = {} # rubocop:disable Style/ClassVars
118113
@@map_files_to_owners = {} # rubocop:disable Style/ClassVars
119114
end
120115

lib/code_ownership/private/ownership_mappers/team_yml_ownership.rb

+1-6
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ class TeamYmlOwnership
1111

1212
@@map_files_to_owners = T.let(@map_files_to_owners, T.nilable(T::Hash[String, ::CodeTeams::Team])) # rubocop:disable Style/ClassVars
1313
@@map_files_to_owners = {} # rubocop:disable Style/ClassVars
14-
@@codeowners_lines_to_owners = T.let(@codeowners_lines_to_owners, T.nilable(T::Hash[String, ::CodeTeams::Team])) # rubocop:disable Style/ClassVars
15-
@@codeowners_lines_to_owners = {} # rubocop:disable Style/ClassVars
1614

1715
sig do
1816
params(files: T::Array[String]).
@@ -39,16 +37,13 @@ def map_file_to_owner(file)
3937
returns(T::Hash[String, ::CodeTeams::Team])
4038
end
4139
def globs_to_owner(files)
42-
return @@codeowners_lines_to_owners if @@codeowners_lines_to_owners&.keys && @@codeowners_lines_to_owners.keys.count > 0
43-
44-
@@codeowners_lines_to_owners = CodeTeams.all.each_with_object({}) do |team, map| # rubocop:disable Style/ClassVars
40+
CodeTeams.all.each_with_object({}) do |team, map| # rubocop:disable Style/ClassVars
4541
map[team.config_yml] = team
4642
end
4743
end
4844

4945
sig { override.void }
5046
def bust_caches!
51-
@@codeowners_lines_to_owners = {} # rubocop:disable Style/ClassVars
5247
@@map_files_to_owners = {} # rubocop:disable Style/ClassVars
5348
end
5449

0 commit comments

Comments
 (0)