Skip to content

Commit 02b328e

Browse files
committed
Fix non-initialized ivar warning
1 parent 663debf commit 02b328e

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

lib/routes_coverage/result.rb

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -90,20 +90,20 @@ def initialize(all_routes, hit_routes, settings)
9090
attr_reader :all_routes, :route_hit_counts
9191

9292
def expected_routes
93-
return @expected_routes if @expected_routes
94-
95-
filter_regex = Regexp.union(@settings.exclude_patterns)
96-
namespaces_regex = Regexp.union(@settings.exclude_namespaces.map { |n| %r{^/#{n}} })
93+
@expected_routes ||= begin
94+
filter_regex = Regexp.union(@settings.exclude_patterns)
95+
namespaces_regex = Regexp.union(@settings.exclude_namespaces.map { |n| %r{^/#{n}} })
96+
97+
routes_groups = all_routes.group_by do |r|
98+
(
99+
("#{r.verb.to_s[8..-3]} #{r.path.spec}".strip =~ filter_regex) ||
100+
(r.path.spec.to_s =~ namespaces_regex)
101+
).present?
102+
end
97103

98-
routes_groups = all_routes.group_by do |r|
99-
(
100-
("#{r.verb.to_s[8..-3]} #{r.path.spec}".strip =~ filter_regex) ||
101-
(r.path.spec.to_s =~ namespaces_regex)
102-
).present?
104+
@excluded_routes = routes_groups[true] || []
105+
routes_groups[false] || []
103106
end
104-
105-
@excluded_routes = routes_groups[true] || []
106-
@expected_routes = routes_groups[false] || []
107107
end
108108

109109
def pending_routes

0 commit comments

Comments
 (0)