Skip to content

Commit d848688

Browse files
committed
add Problem class
1 parent c81e537 commit d848688

1 file changed

Lines changed: 42 additions & 0 deletions

File tree

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
module ProblematicVariableFinder
2+
class Problem
3+
attr_accessor \
4+
:gem_name,
5+
:gem_version,
6+
:file_name,
7+
:line_number,
8+
:out_of_date,
9+
:type,
10+
:code
11+
12+
def initialize(**attrs)
13+
attrs.each do |key, value|
14+
send("#{key}=", value)
15+
end
16+
end
17+
18+
def github_link
19+
@github_link ||=
20+
begin
21+
if source_code_uri
22+
"#{source_code_uri}/#{file_name}:#{line_number}"
23+
else
24+
"#{gem_name} #{file_name}:#{line_number}"
25+
end
26+
end
27+
end
28+
29+
def source_code_uri
30+
gem_spec&.metadata['source_code_uri']
31+
32+
end
33+
34+
def gem_spec
35+
return nil if gem_name.nil?
36+
37+
@gem_spec ||= Gem::Specification.find_all_by_name(gem_name).find do |s|
38+
s.version.to_s == gem_version
39+
end
40+
end
41+
end
42+
end

0 commit comments

Comments
 (0)