11require 'problematic_variable_finder/main_finder'
2+ require 'problematic_variable_finder/problem'
23
34module ProblematicVariableFinder
45 class ProblemFinder
@@ -7,15 +8,15 @@ class ProblemFinder
78 def find_problems_in_directory ( path , remove_paths = [ ] )
89 key = [ path , remove_paths ] . inspect
910
10- files = Dir . glob ( "#{ path } /**/*.rb" )
11+ files = Dir . glob ( "#{ path } /**/*.rb" )
1112
12- files . reject! do |f |
13- filename = f
14- filename = remove_paths . each do |path |
15- filename = filename . gsub ( path , '' )
16- end
13+ files . reject! do |f |
14+ filename = f
15+ filename = remove_paths . each do |path |
16+ filename = filename . gsub ( path , '' )
17+ end
1718
18- %w(
19+ %w(
1920 /spec/
2021 /.bundle/
2122 /.gems/
@@ -27,20 +28,31 @@ def find_problems_in_directory(path, remove_paths=[])
2728 /vendor/
2829 _spec.rb
2930 _test.rb
30- ) . any? do |s |
31- filename . include? ( s )
32- end
31+ ) . any? do |s |
32+ filename . include? ( s )
3333 end
34+ end
3435
35- directory_problems = { }
36+ directory_problems = { }
3637
37- files . each do |f |
38- puts f
39- full_path , path , problems = find_file_problems ( f , remove_paths )
40- directory_problems [ path ] = [ full_path , problems ] if problems . any?
38+ files . each do |f |
39+ puts f
40+ full_path , path , problems = find_file_problems ( f , remove_paths )
41+ problems . map! do |problem |
42+ Problem . new (
43+ gem_name : name ,
44+ gem_version : version ,
45+ type : problem [ :type ] ,
46+ filename : filename ,
47+ line_number : problem [ :line_number ] ,
48+ code : problem [ :name ] . to_s ,
49+ out_of_date : outdated_gems . include? ( name )
50+ )
4151 end
52+ directory_problems [ path ] = [ full_path , problems ] if problems . any?
53+ end
4254
43- directory_problems
55+ directory_problems
4456 end
4557
4658 def find_file_problems ( f , remove_paths )
0 commit comments