File tree Expand file tree Collapse file tree 2 files changed +9
-5
lines changed
lib/cc/engine/bundler_audit Expand file tree Collapse file tree 2 files changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ def run
13
13
if gemfile_lock_exists?
14
14
Dir . chdir ( directory ) do
15
15
Bundler ::Audit ::Scanner . new . scan do |vulnerability |
16
- result = Result . new ( vulnerability , File . open ( gemfile_lock_path ) )
16
+ result = Result . new ( vulnerability , gemfile_lock_lines )
17
17
issue = result . to_issue
18
18
19
19
io . print ( "#{ issue . to_json } \0 " )
@@ -28,6 +28,10 @@ def run
28
28
29
29
attr_reader :directory , :io
30
30
31
+ def gemfile_lock_lines
32
+ @gemfile_lock_lines ||= File . open ( gemfile_lock_path ) . lines . to_a
33
+ end
34
+
31
35
def gemfile_lock_exists?
32
36
File . exist? ( gemfile_lock_path )
33
37
end
Original file line number Diff line number Diff line change @@ -9,10 +9,10 @@ class Result
9
9
low : "info" ,
10
10
} . freeze
11
11
12
- def initialize ( result , gemfile_lock )
12
+ def initialize ( result , gemfile_lock_lines )
13
13
@gem = result . gem
14
14
@advisory = result . advisory
15
- @gemfile_lock = gemfile_lock
15
+ @gemfile_lock_lines = gemfile_lock_lines
16
16
end
17
17
18
18
def to_issue
@@ -38,7 +38,7 @@ def to_issue
38
38
39
39
private
40
40
41
- attr_reader :advisory , :gem , :gemfile_lock
41
+ attr_reader :advisory , :gem , :gemfile_lock_lines
42
42
43
43
def content_body
44
44
[
@@ -51,7 +51,7 @@ def content_body
51
51
52
52
def line_number
53
53
@line_number ||= begin
54
- gemfile_lock . find_index do |line |
54
+ gemfile_lock_lines . find_index do |line |
55
55
( match = GEM_REGEX . match ( line ) ) && match [ :name ] == gem . name
56
56
end + 1
57
57
end
You can’t perform that action at this time.
0 commit comments