repo_analyzer 1.3.0 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 54ba42a406d9f7d7b89588217709447e77a85619969e38d2ad07b683ef3b7308
4
- data.tar.gz: 349ad885453dbfffe666b3968f6a89064094c05635552130e1e2596f94a8219c
3
+ metadata.gz: bb655decd9592215cda4751bd7e134ad5252b2b292492b2d71771cb0fe2443ad
4
+ data.tar.gz: c0c009b39bf8e30f23e198593ee42fd8e9616ee76e5b1074026434b9e0d61727
5
5
  SHA512:
6
- metadata.gz: 1547a6ca87bf7aa12f063019b06eaec47d068390e5706fbcce14ec40da76a42ec67fb88090dd645ebf451332b401d3fc36039a0e21ab0817691197bb3ba40175
7
- data.tar.gz: 56b67a96d0fad9e2130d6785e73882731a3cacc927e166bd733ef0e0981154ec523204b59492b9db6470a14cb7aad8610039fee2e2b421ad5658db2d116f01db
6
+ metadata.gz: b546db4302e6aeafd82fff62f77dbea3bab62e70b1ed6a7e98623c7f5cb540cd640633ad75cd1324efc5291c1d653f2cb699eee288a7a7f1a0c06222f2bd9aef
7
+ data.tar.gz: 7ad4fdda952618118f75465f9e64fd21550df01a0234a237456b1ca210c13194b5d9155365d688fe934bc8a59dd808752d96031927e106a4e8b4e8d02a6831a0
data/CHANGELOG.md CHANGED
@@ -1,7 +1,13 @@
1
1
  # Change Log
2
2
  All notable changes to this project will be documented in this file.
3
3
  This project adheres to [Semantic Versioning](http://semver.org/).
4
+ ### v1.4.0
5
+ #### Added
4
6
 
7
+ * Add [reek](https://github.com/troessner/reek) extractor.
8
+ * Add [fasterer](https://github.com/DamirSvrtan/fasterer) extractor.
9
+ * Add [bundler-audit](https://github.com/rubysec/bundler-audit) extractor.
10
+ * Add [bundler-stats](https://github.com/jmmastey/bundler-stats) extractor.
5
11
 
6
12
  ### v1.3.0
7
13
 
data/Gemfile.lock CHANGED
@@ -1,11 +1,16 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- repo_analyzer (1.3.0)
4
+ repo_analyzer (1.4.0)
5
5
  brakeman
6
+ bundler-audit
7
+ bundler-stats
8
+ faraday-retry
9
+ fasterer
6
10
  octokit (~> 4.0)
7
11
  rails (>= 6.0)
8
12
  rails_best_practices
13
+ reek
9
14
  rubocop (~> 1.9)
10
15
  rubocop-performance
11
16
  rubocop-platanus (~> 0.2)
@@ -79,9 +84,16 @@ GEM
79
84
  ast (2.4.2)
80
85
  brakeman (5.3.1)
81
86
  builder (3.2.4)
87
+ bundler-audit (0.9.1)
88
+ bundler (>= 1.2.0, < 3)
89
+ thor (~> 1.0)
90
+ bundler-stats (2.3.0)
91
+ bundler (>= 1.9, < 3)
92
+ thor (>= 0.19.0, < 2.0)
82
93
  code_analyzer (0.5.5)
83
94
  sexp_processor
84
95
  coderay (1.1.3)
96
+ colorize (0.8.1)
85
97
  concurrent-ruby (1.1.10)
86
98
  coveralls (0.8.23)
87
99
  json (>= 1.8, < 3)
@@ -104,6 +116,11 @@ GEM
104
116
  faraday-net_http (>= 2.0, < 3.1)
105
117
  ruby2_keywords (>= 0.0.4)
106
118
  faraday-net_http (3.0.2)
119
+ faraday-retry (2.1.0)
120
+ faraday (~> 2.0)
121
+ fasterer (0.10.1)
122
+ colorize (~> 0.7)
123
+ ruby_parser (>= 3.19.1)
107
124
  ffi (1.15.5)
108
125
  formatador (1.1.0)
109
126
  globalid (1.0.0)
@@ -125,6 +142,7 @@ GEM
125
142
  i18n (1.12.0)
126
143
  concurrent-ruby (~> 1.0)
127
144
  json (2.6.3)
145
+ kwalify (0.7.2)
128
146
  listen (3.7.1)
129
147
  rb-fsevent (~> 0.10, >= 0.10.3)
130
148
  rb-inotify (~> 0.9, >= 0.9.10)
@@ -165,7 +183,7 @@ GEM
165
183
  faraday (>= 1, < 3)
166
184
  sawyer (~> 0.9)
167
185
  parallel (1.22.1)
168
- parser (3.1.3.0)
186
+ parser (3.2.2.1)
169
187
  ast (~> 2.4.1)
170
188
  pry (0.14.1)
171
189
  coderay (~> 1.1)
@@ -216,6 +234,11 @@ GEM
216
234
  rb-fsevent (0.11.2)
217
235
  rb-inotify (0.10.1)
218
236
  ffi (~> 1.0)
237
+ reek (6.1.4)
238
+ kwalify (~> 0.7.0)
239
+ parser (~> 3.2.0)
240
+ rainbow (>= 2.0, < 4.0)
241
+ rexml (~> 3.1)
219
242
  regexp_parser (2.6.1)
220
243
  require_all (3.0.0)
221
244
  rexml (3.2.5)
@@ -267,6 +290,8 @@ GEM
267
290
  rubocop (~> 1.33)
268
291
  ruby-progressbar (1.11.0)
269
292
  ruby2_keywords (0.0.5)
293
+ ruby_parser (3.20.1)
294
+ sexp_processor (~> 4.16)
270
295
  sawyer (0.9.2)
271
296
  addressable (>= 2.3.5)
272
297
  faraday (>= 0.17.3, < 3)
@@ -316,8 +341,6 @@ DEPENDENCIES
316
341
  repo_analyzer!
317
342
  rspec-rails
318
343
  rspec_junit_formatter
319
- rubocop (~> 1.9)
320
- rubocop-rails
321
344
  sqlite3
322
345
 
323
346
  BUNDLED WITH
@@ -0,0 +1,50 @@
1
+ module RepoAnalyzer
2
+ class BundlerAuditExtractor < ProjectInfoExtractor
3
+ KEY_VALUE_REGEXP = /\A(.*):\s(.*)\z/
4
+
5
+ private
6
+
7
+ def extracted_info
8
+ { vulnerabilities: audit_info }
9
+ end
10
+
11
+ def audit_info
12
+ audit_collection.inject({}) do |memo, row|
13
+ category = nil
14
+
15
+ formatted_item = row.split("\n").inject({}) do |item, line|
16
+ key, value = extract_key_value_form_row(line)
17
+
18
+ if key == :criticality
19
+ category = value
20
+ memo[category] ||= []
21
+ next item
22
+ end
23
+
24
+ item[key] = value
25
+ item
26
+ end
27
+
28
+ memo[category] << formatted_item
29
+ memo
30
+ end
31
+ end
32
+
33
+ def audit_collection
34
+ collection = audit_raw_result.split("\n\n")
35
+ collection.pop
36
+ collection
37
+ end
38
+
39
+ def extract_key_value_form_row(line)
40
+ key, value = line.scan(KEY_VALUE_REGEXP).flatten
41
+ key = key.gsub(" ", "_").downcase.to_sym
42
+ [key, value]
43
+ end
44
+
45
+ def audit_raw_result
46
+ `bundle exec bundle-audit update`
47
+ `bundle exec bundle-audit check #{project_data_bridge.project_path}`
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,10 @@
1
+ module RepoAnalyzer
2
+ class BundlerStatsExtractor < ProjectInfoExtractor
3
+ private
4
+
5
+ def extracted_info
6
+ result = `bundle exec bundle-stats stats -f json`
7
+ JSON.parse(result)
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,34 @@
1
+ require "fasterer/file_traverser"
2
+
3
+ module RepoAnalyzer
4
+ class FastererExtractor < ProjectInfoExtractor
5
+ private
6
+
7
+ def extracted_info
8
+ { speedups: fasterer_info }
9
+ end
10
+
11
+ def fasterer_info
12
+ @fasterer_info ||= fasterer_text.split("\n").inject([]) do |memo, row|
13
+ next memo if row.blank?
14
+
15
+ row_parts = row.split("\e")
16
+ file_path_and_line = row_parts.second.gsub('[0;31;49m', '')
17
+ file_path, line = file_path_and_line.split(':')
18
+ next memo if file_path.include?("files inspected")
19
+
20
+ message = row_parts.last.gsub('[0m ', '')
21
+ memo << {
22
+ file_path: file_path,
23
+ line: line,
24
+ message: message
25
+ }
26
+ end
27
+ end
28
+
29
+ def fasterer_text
30
+ file_traverser = Fasterer::FileTraverser.new(".")
31
+ OutputUtils.with_captured_stdout { file_traverser.traverse }
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,38 @@
1
+ require "reek/cli/application"
2
+
3
+ module RepoAnalyzer
4
+ class ReekExtractor < ProjectInfoExtractor
5
+ private
6
+
7
+ def extracted_info
8
+ { warnings: reek_info }
9
+ end
10
+
11
+ def reek_info
12
+ @reek_info ||= reek_json.inject({}) do |memo, warning|
13
+ memo[warning["smell_type"]] ||= []
14
+ memo[warning["smell_type"]] << {
15
+ lines: warning["lines"],
16
+ message: warning["message"],
17
+ source: relative_file_name(warning["source"]),
18
+ name: warning["name"],
19
+ documentation_link: warning["documentation_link"]
20
+ }
21
+ memo
22
+ end
23
+ end
24
+
25
+ def relative_file_name(file_path)
26
+ file_path.gsub(%r{\A\D*#{project_data_bridge.project_path}/}, "")
27
+ end
28
+
29
+ def reek_json
30
+ application = Reek::CLI::Application.new(
31
+ ["--format=json", project_data_bridge.project_path]
32
+ )
33
+
34
+ result = OutputUtils.with_captured_stdout { application.execute }
35
+ JSON.parse(result)
36
+ end
37
+ end
38
+ end
@@ -1,3 +1,3 @@
1
1
  module RepoAnalyzer
2
- VERSION = '1.3.0'
2
+ VERSION = '1.4.0'
3
3
  end
data/lib/repo_analyzer.rb CHANGED
@@ -1,6 +1,10 @@
1
+ require "bundler/audit"
2
+ require "bundler/stats"
1
3
  require "brakeman"
4
+ require "fasterer"
2
5
  require "octokit"
3
6
  require "rails_best_practices"
7
+ require "reek"
4
8
  require "rubocop"
5
9
  require "rubocop-performance"
6
10
  require "rubocop-platanus"
@@ -19,10 +19,15 @@ Gem::Specification.new do |s|
19
19
  s.executables = s.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
20
  s.test_files = Dir["spec/**/*"]
21
21
 
22
+ s.add_dependency "bundler-audit"
23
+ s.add_dependency "bundler-stats"
22
24
  s.add_dependency "brakeman"
25
+ s.add_dependency "faraday-retry"
26
+ s.add_dependency "fasterer"
23
27
  s.add_dependency "octokit", "~> 4.0"
24
28
  s.add_dependency "rails", ">= 6.0"
25
29
  s.add_dependency "rails_best_practices"
30
+ s.add_dependency "reek"
26
31
  s.add_dependency "rubocop", "~> 1.9"
27
32
  s.add_dependency "rubocop-performance"
28
33
  s.add_dependency "rubocop-platanus", "~> 0.2"
@@ -37,6 +42,4 @@ Gem::Specification.new do |s|
37
42
  s.add_development_dependency "pry-rails"
38
43
  s.add_development_dependency "rspec_junit_formatter"
39
44
  s.add_development_dependency "rspec-rails"
40
- s.add_development_dependency "rubocop", "~> 1.9"
41
- s.add_development_dependency "rubocop-rails"
42
45
  end
@@ -0,0 +1,141 @@
1
+ require 'rails_helper'
2
+
3
+ describe RepoAnalyzer::BundlerAuditExtractor, repo_analyzer_extractor_helpers: true do
4
+ describe "#extract" do
5
+ let(:audit_result_content) do
6
+ <<~TEXT
7
+ Name: actionpack
8
+ Version: 6.1.7
9
+ CVE: CVE-2023-22792
10
+ GHSA: GHSA-p84v-45xj-wwqj
11
+ Criticality: Unknown
12
+ URL: https://github.com/rails/rails/releases/tag/v7.0.4.1
13
+ Title: ReDoS based DoS vulnerability in Action Dispatch
14
+ Solution: upgrade to '~> 5.2.8, >= 5.2.8.15', '~> 6.1.7, >= 6.1.7.1', '>= 7.0.4.1'
15
+
16
+ Name: actionpack
17
+ Version: 6.1.7
18
+ CVE: CVE-2023-22795
19
+ GHSA: GHSA-8xww-x3g3-6jcv
20
+ Criticality: Unknown
21
+ URL: https://github.com/rails/rails/releases/tag/v7.0.4.1
22
+ Title: ReDoS based DoS vulnerability in Action Dispatch
23
+ Solution: upgrade to '~> 5.2.8, >= 5.2.8.15', '~> 6.1.7, >= 6.1.7.1', '>= 7.0.4.1'
24
+
25
+ Name: activerecord
26
+ Version: 6.1.7
27
+ CVE: CVE-2022-44566
28
+ GHSA: GHSA-579w-22j4-4749
29
+ Criticality: High
30
+ URL: https://github.com/rails/rails/releases/tag/v7.0.4.1
31
+ Title: Denial of Service Vulnerability in ActiveRecord's PostgreSQL adapter
32
+ Solution: upgrade to '~> 5.2.8, >= 5.2.8.15', '~> 6.1.7, >= 6.1.7.1', '>= 7.0.4.1'
33
+
34
+ Name: activerecord
35
+ Version: 6.1.7
36
+ CVE: CVE-2023-22794
37
+ GHSA: GHSA-hq7p-j377-6v63
38
+ Criticality: High
39
+ URL: https://github.com/rails/rails/releases/tag/v7.0.4.1
40
+ Title: SQL Injection Vulnerability via ActiveRecord comments
41
+ Solution: upgrade to '~> 6.0.6, >= 6.0.6.1', '~> 6.1.7, >= 6.1.7.1', '>= 7.0.4.1'
42
+
43
+ Name: loofah
44
+ Version: 2.19.0
45
+ CVE: CVE-2022-23515
46
+ GHSA: GHSA-228g-948r-83gx
47
+ Criticality: Medium
48
+ URL: https://github.com/flavorjones/loofah/security/advisories/GHSA-228g-948r-83gx
49
+ Title: Improper neutralization of data URIs may allow XSS in Loofah
50
+ Solution: upgrade to '>= 2.19.1'
51
+
52
+ Name: rails-html-sanitizer
53
+ Version: 1.4.3
54
+ CVE: CVE-2022-23520
55
+ GHSA: GHSA-rrfc-7g8p-99q8
56
+ Criticality: Medium
57
+ URL: https://github.com/rails/rails-html-sanitizer/security/advisories/GHSA-rrfc-7g8p-99q8
58
+ Title: Possible XSS vulnerability with certain configurations of rails-html-sanitizer
59
+ Solution: upgrade to '>= 1.4.4'
60
+
61
+ Vulnerabilities found!
62
+ TEXT
63
+ end
64
+
65
+ before do
66
+ allow(extractor).to receive(:`).with('bundle exec bundle-audit update')
67
+ allow(extractor).to receive(:`).with(
68
+ 'bundle exec bundle-audit check spec/assets/test_project'
69
+ ).and_return(audit_result_content)
70
+ end
71
+
72
+ let(:expected) do
73
+ {
74
+ "vulnerabilities" => {
75
+ "Unknown" => [
76
+ {
77
+ name: "actionpack",
78
+ version: "6.1.7",
79
+ cve: "CVE-2023-22792",
80
+ ghsa: "GHSA-p84v-45xj-wwqj",
81
+ url: "https://github.com/rails/rails/releases/tag/v7.0.4.1",
82
+ title: "ReDoS based DoS vulnerability in Action Dispatch",
83
+ solution: "upgrade to '~> 5.2.8, >= 5.2.8.15', '~> 6.1.7, >= 6.1.7.1', '>= 7.0.4.1'"
84
+ },
85
+ {
86
+ name: "actionpack",
87
+ version: "6.1.7",
88
+ cve: "CVE-2023-22795",
89
+ ghsa: "GHSA-8xww-x3g3-6jcv",
90
+ url: "https://github.com/rails/rails/releases/tag/v7.0.4.1",
91
+ title: "ReDoS based DoS vulnerability in Action Dispatch",
92
+ solution: "upgrade to '~> 5.2.8, >= 5.2.8.15', '~> 6.1.7, >= 6.1.7.1', '>= 7.0.4.1'"
93
+ }
94
+ ],
95
+ "High" => [
96
+ {
97
+ name: "activerecord",
98
+ version: "6.1.7",
99
+ cve: "CVE-2022-44566",
100
+ ghsa: "GHSA-579w-22j4-4749",
101
+ url: "https://github.com/rails/rails/releases/tag/v7.0.4.1",
102
+ title: "Denial of Service Vulnerability in ActiveRecord's PostgreSQL adapter",
103
+ solution: "upgrade to '~> 5.2.8, >= 5.2.8.15', '~> 6.1.7, >= 6.1.7.1', '>= 7.0.4.1'"
104
+ },
105
+ {
106
+ name: "activerecord",
107
+ version: "6.1.7",
108
+ cve: "CVE-2023-22794",
109
+ ghsa: "GHSA-hq7p-j377-6v63",
110
+ url: "https://github.com/rails/rails/releases/tag/v7.0.4.1",
111
+ title: "SQL Injection Vulnerability via ActiveRecord comments",
112
+ solution: "upgrade to '~> 6.0.6, >= 6.0.6.1', '~> 6.1.7, >= 6.1.7.1', '>= 7.0.4.1'"
113
+ }
114
+ ],
115
+ "Medium" => [
116
+ {
117
+ name: "loofah",
118
+ version: "2.19.0",
119
+ cve: "CVE-2022-23515",
120
+ ghsa: "GHSA-228g-948r-83gx",
121
+ url: "https://github.com/flavorjones/loofah/security/advisories/GHSA-228g-948r-83gx",
122
+ title: "Improper neutralization of data URIs may allow XSS in Loofah",
123
+ solution: "upgrade to '>= 2.19.1'"
124
+ },
125
+ {
126
+ name: "rails-html-sanitizer",
127
+ version: "1.4.3",
128
+ cve: "CVE-2022-23520",
129
+ ghsa: "GHSA-rrfc-7g8p-99q8",
130
+ url: "https://github.com/rails/rails-html-sanitizer/security/advisories/GHSA-rrfc-7g8p-99q8",
131
+ title: "Possible XSS vulnerability with certain configurations of rails-html-sanitizer",
132
+ solution: "upgrade to '>= 1.4.4'"
133
+ }
134
+ ]
135
+ }
136
+ }.with_indifferent_access
137
+ end
138
+
139
+ it { expect(extract[:bundler_audit_extractor]).to eq(expected) }
140
+ end
141
+ end
@@ -0,0 +1,285 @@
1
+ require 'rails_helper'
2
+
3
+ describe RepoAnalyzer::BundlerStatsExtractor, repo_analyzer_extractor_helpers: true do
4
+ describe "#extract" do
5
+ let(:stats) do
6
+ {
7
+ "summary": {
8
+ "declared": 10,
9
+ "unpinned": 9,
10
+ "total": 117,
11
+ "github": 0
12
+ },
13
+ "gems": [
14
+ {
15
+ "name": "repo_analyzer",
16
+ "total_dependencies": 84,
17
+ "first_level_dependencies": 14,
18
+ "top_level_dependencies": {},
19
+ "transitive_dependencies": [
20
+ "brakeman (>= 0)",
21
+ "bundler-audit (>= 0)",
22
+ "bundler-stats (>= 0)",
23
+ "faraday-retry (>= 0)",
24
+ "fasterer (>= 0)",
25
+ "octokit (~> 4.0)",
26
+ "rails (>= 6.0)",
27
+ "rails_best_practices (>= 0)",
28
+ "reek (>= 0)",
29
+ "rubocop (~> 1.9)",
30
+ "rubocop-performance (>= 0)",
31
+ "rubocop-platanus (~> 0.2)",
32
+ "rubocop-rails (>= 0)",
33
+ "rubocop-rspec (~> 2.2)",
34
+ "bundler (>= 1.2.0, < 3)",
35
+ "thor (~> 1.0)",
36
+ "faraday (~> 2.0)",
37
+ "faraday-net_http (>= 2.0, < 3.1)",
38
+ "ruby2_keywords (>= 0.0.4)",
39
+ "colorize (~> 0.7)",
40
+ "ruby_parser (>= 3.19.1)",
41
+ "sexp_processor (~> 4.16)",
42
+ "sawyer (~> 0.9)",
43
+ "addressable (>= 2.3.5)",
44
+ "public_suffix (>= 2.0.2, < 6.0)",
45
+ "actioncable (= 6.1.7)",
46
+ "actionmailbox (= 6.1.7)",
47
+ "actionmailer (= 6.1.7)",
48
+ "actionpack (= 6.1.7)",
49
+ "actiontext (= 6.1.7)",
50
+ "actionview (= 6.1.7)",
51
+ "activejob (= 6.1.7)",
52
+ "activemodel (= 6.1.7)",
53
+ "activerecord (= 6.1.7)",
54
+ "activestorage (= 6.1.7)",
55
+ "activesupport (= 6.1.7)",
56
+ "railties (= 6.1.7)",
57
+ "sprockets-rails (>= 2.0.0)",
58
+ "nio4r (~> 2.0)",
59
+ "websocket-driver (>= 0.6.1)",
60
+ "rack (~> 2.0, >= 2.0.9)",
61
+ "rack-test (>= 0.6.3)",
62
+ "rails-dom-testing (~> 2.0)",
63
+ "rails-html-sanitizer (~> 1.0, >= 1.2.0)",
64
+ "builder (~> 3.1)",
65
+ "erubi (~> 1.4)",
66
+ "concurrent-ruby (~> 1.0, >= 1.0.2)",
67
+ "i18n (>= 1.6, < 2)",
68
+ "minitest (>= 5.1)",
69
+ "tzinfo (~> 2.0)",
70
+ "zeitwerk (~> 2.3)",
71
+ "nokogiri (>= 1.6)",
72
+ "mini_portile2 (~> 2.8.0)",
73
+ "racc (~> 1.4)",
74
+ "loofah (~> 2.3)",
75
+ "crass (~> 1.0.2)",
76
+ "websocket-extensions (>= 0.1.0)",
77
+ "mail (>= 2.7.1)",
78
+ "globalid (>= 0.3.6)",
79
+ "marcel (~> 1.0)",
80
+ "mini_mime (>= 1.1.0)",
81
+ "net-imap (>= 0)",
82
+ "net-pop (>= 0)",
83
+ "net-smtp (>= 0)",
84
+ "date (>= 0)",
85
+ "net-protocol (>= 0)",
86
+ "timeout (>= 0)",
87
+ "method_source (>= 0)",
88
+ "rake (>= 12.2)",
89
+ "sprockets (>= 3.0.0)",
90
+ "code_analyzer (~> 0.5.5)",
91
+ "erubis (>= 0)",
92
+ "json (>= 0)",
93
+ "require_all (~> 3.0)",
94
+ "ruby-progressbar (>= 0)",
95
+ "kwalify (~> 0.7.0)",
96
+ "parser (~> 3.2.0)",
97
+ "rainbow (>= 2.0, < 4.0)",
98
+ "rexml (~> 3.1)",
99
+ "ast (~> 2.4.1)",
100
+ "parallel (~> 1.10)",
101
+ "regexp_parser (>= 1.8, < 3.0)",
102
+ "rubocop-ast (>= 1.23.0, < 2.0)",
103
+ "unicode-display_width (>= 1.4.0, < 3.0)"
104
+ ]
105
+ },
106
+ {
107
+ "name": "rspec-rails",
108
+ "total_dependencies": 28,
109
+ "first_level_dependencies": 7,
110
+ "top_level_dependencies": {},
111
+ "transitive_dependencies": [
112
+ "actionpack (>= 6.1)",
113
+ "activesupport (>= 6.1)",
114
+ "railties (>= 6.1)",
115
+ "rspec-core (~> 3.11)",
116
+ "rspec-expectations (~> 3.11)",
117
+ "rspec-mocks (~> 3.11)",
118
+ "rspec-support (~> 3.11)",
119
+ "actionview (= 6.1.7)",
120
+ "rack (~> 2.0, >= 2.0.9)",
121
+ "rack-test (>= 0.6.3)",
122
+ "rails-dom-testing (~> 2.0)",
123
+ "rails-html-sanitizer (~> 1.0, >= 1.2.0)",
124
+ "builder (~> 3.1)",
125
+ "erubi (~> 1.4)",
126
+ "concurrent-ruby (~> 1.0, >= 1.0.2)",
127
+ "i18n (>= 1.6, < 2)",
128
+ "minitest (>= 5.1)",
129
+ "tzinfo (~> 2.0)",
130
+ "zeitwerk (~> 2.3)",
131
+ "nokogiri (>= 1.6)",
132
+ "mini_portile2 (~> 2.8.0)",
133
+ "racc (~> 1.4)",
134
+ "loofah (~> 2.3)",
135
+ "crass (~> 1.0.2)",
136
+ "method_source (>= 0)",
137
+ "rake (>= 12.2)",
138
+ "thor (~> 1.0)",
139
+ "diff-lcs (>= 1.2.0, < 2.0)"
140
+ ]
141
+ },
142
+ {
143
+ "name": "factory_bot_rails",
144
+ "total_dependencies": 24,
145
+ "first_level_dependencies": 2,
146
+ "top_level_dependencies": {},
147
+ "transitive_dependencies": [
148
+ "factory_bot (~> 6.2.0)",
149
+ "railties (>= 5.0.0)",
150
+ "activesupport (>= 5.0.0)",
151
+ "concurrent-ruby (~> 1.0, >= 1.0.2)",
152
+ "i18n (>= 1.6, < 2)",
153
+ "minitest (>= 5.1)",
154
+ "tzinfo (~> 2.0)",
155
+ "zeitwerk (~> 2.3)",
156
+ "actionpack (= 6.1.7)",
157
+ "method_source (>= 0)",
158
+ "rake (>= 12.2)",
159
+ "thor (~> 1.0)",
160
+ "actionview (= 6.1.7)",
161
+ "rack (~> 2.0, >= 2.0.9)",
162
+ "rack-test (>= 0.6.3)",
163
+ "rails-dom-testing (~> 2.0)",
164
+ "rails-html-sanitizer (~> 1.0, >= 1.2.0)",
165
+ "builder (~> 3.1)",
166
+ "erubi (~> 1.4)",
167
+ "nokogiri (>= 1.6)",
168
+ "mini_portile2 (~> 2.8.0)",
169
+ "racc (~> 1.4)",
170
+ "loofah (~> 2.3)",
171
+ "crass (~> 1.0.2)"
172
+ ]
173
+ },
174
+ {
175
+ "name": "guard-rspec",
176
+ "total_dependencies": 21,
177
+ "first_level_dependencies": 3,
178
+ "top_level_dependencies": {},
179
+ "transitive_dependencies": [
180
+ "guard (~> 2.1)",
181
+ "guard-compat (~> 1.1)",
182
+ "rspec (>= 2.99.0, < 4.0)",
183
+ "formatador (>= 0.2.4)",
184
+ "listen (>= 2.7, < 4.0)",
185
+ "lumberjack (>= 1.0.12, < 2.0)",
186
+ "nenv (~> 0.1)",
187
+ "notiffany (~> 0.0)",
188
+ "pry (>= 0.13.0)",
189
+ "shellany (~> 0.0)",
190
+ "thor (>= 0.18.1)",
191
+ "rb-fsevent (~> 0.10, >= 0.10.3)",
192
+ "rb-inotify (~> 0.9, >= 0.9.10)",
193
+ "ffi (~> 1.0)",
194
+ "coderay (~> 1.1)",
195
+ "method_source (~> 1.0)",
196
+ "rspec-core (~> 3.12.0)",
197
+ "rspec-expectations (~> 3.12.0)",
198
+ "rspec-mocks (~> 3.12.0)",
199
+ "rspec-support (~> 3.12.0)",
200
+ "diff-lcs (>= 1.2.0, < 2.0)"
201
+ ]
202
+ },
203
+ {
204
+ "name": "coveralls",
205
+ "total_dependencies": 8,
206
+ "first_level_dependencies": 5,
207
+ "top_level_dependencies": {},
208
+ "transitive_dependencies": [
209
+ "json (>= 1.8, < 3)",
210
+ "simplecov (~> 0.16.1)",
211
+ "term-ansicolor (~> 1.3)",
212
+ "thor (>= 0.19.4, < 2.0)",
213
+ "tins (~> 1.6)",
214
+ "docile (~> 1.1)",
215
+ "simplecov-html (~> 0.10.0)",
216
+ "sync (>= 0)"
217
+ ]
218
+ },
219
+ {
220
+ "name": "pry-rails",
221
+ "total_dependencies": 3,
222
+ "first_level_dependencies": 1,
223
+ "top_level_dependencies": {},
224
+ "transitive_dependencies": [
225
+ "pry (>= 0.10.4)",
226
+ "coderay (~> 1.1)",
227
+ "method_source (~> 1.0)"
228
+ ]
229
+ },
230
+ {
231
+ "name": "pry",
232
+ "total_dependencies": 2,
233
+ "first_level_dependencies": 2,
234
+ "top_level_dependencies": {
235
+ "guard": "guard (2.18.0)",
236
+ "guard-rspec": "guard-rspec (4.7.3)",
237
+ "pry-rails": "pry-rails (0.3.9)"
238
+ },
239
+ "transitive_dependencies": [
240
+ "coderay (~> 1.1)",
241
+ "method_source (~> 1.0)"
242
+ ]
243
+ },
244
+ {
245
+ "name": "rspec_junit_formatter",
246
+ "total_dependencies": 2,
247
+ "first_level_dependencies": 1,
248
+ "top_level_dependencies": {},
249
+ "transitive_dependencies": [
250
+ "rspec-core (>= 2, < 4, != 2.12.0)",
251
+ "rspec-support (~> 3.12.0)"
252
+ ]
253
+ },
254
+ {
255
+ "name": "bundler",
256
+ "total_dependencies": 0,
257
+ "first_level_dependencies": 0,
258
+ "top_level_dependencies": {
259
+ "bundler-audit": "bundler-audit (0.9.1)",
260
+ "bundler-stats": "bundler-stats (2.3.0)",
261
+ "rails": "rails (6.1.7)",
262
+ "repo_analyzer": "repo_analyzer (1.3.0)"
263
+ },
264
+ "transitive_dependencies": []
265
+ },
266
+ {
267
+ "name": "sqlite3",
268
+ "total_dependencies": 0,
269
+ "first_level_dependencies": 0,
270
+ "top_level_dependencies": {},
271
+ "transitive_dependencies": []
272
+ }
273
+ ]
274
+ }
275
+ end
276
+
277
+ before do
278
+ allow(extractor).to receive(:`).with(
279
+ 'bundle exec bundle-stats stats -f json'
280
+ ).and_return(stats.to_json)
281
+ end
282
+
283
+ it { expect(extract[:bundler_stats_extractor]).to eq(stats.with_indifferent_access) }
284
+ end
285
+ end
@@ -0,0 +1,45 @@
1
+ require 'rails_helper'
2
+
3
+ describe RepoAnalyzer::FastererExtractor, repo_analyzer_extractor_helpers: true do
4
+ describe "#extract" do
5
+ let(:fasterer_result_content) do
6
+ <<~TEXT
7
+ \e[0;31;49mapp/extractors/repo_analyzer/github_extractor.rb:60\e[0m Don't rescue NoMethodError, rather check with respond_to?.
8
+
9
+ \e[0;31;49mapp/jobs/repo_analyzer/extract_project_info_job.rb:17\e[0m Calling blocks with call is slower than yielding.
10
+
11
+ \e[0;31;49mspec/dummy/config/puma.rb:14\e[0m Hash#fetch with second argument is slower than Hash#fetch with block.
12
+
13
+ \e[0;32;49m75 files inspected\e[0m, \e[0;31;49m3 offenses detected\e[0m
14
+ TEXT
15
+ end
16
+
17
+ before do
18
+ allow(OutputUtils).to receive(:with_captured_stdout).and_return(fasterer_result_content)
19
+ end
20
+
21
+ let(:expected) do
22
+ {
23
+ speedups: [
24
+ {
25
+ file_path: "app/extractors/repo_analyzer/github_extractor.rb",
26
+ line: "60",
27
+ message: "Don't rescue NoMethodError, rather check with respond_to?."
28
+ },
29
+ {
30
+ file_path: "app/jobs/repo_analyzer/extract_project_info_job.rb",
31
+ line: "17",
32
+ message: "Calling blocks with call is slower than yielding."
33
+ },
34
+ {
35
+ file_path: "spec/dummy/config/puma.rb",
36
+ line: "14",
37
+ message: "Hash#fetch with second argument is slower than Hash#fetch with block."
38
+ }
39
+ ]
40
+ }.with_indifferent_access
41
+ end
42
+
43
+ it { expect(extract[:fasterer_extractor]).to eq(expected) }
44
+ end
45
+ end
@@ -0,0 +1,76 @@
1
+ require 'rails_helper'
2
+
3
+ describe RepoAnalyzer::ReekExtractor, repo_analyzer_extractor_helpers: true do
4
+ describe "#extract" do
5
+ let(:reek_result_content) do
6
+ [
7
+ {
8
+ "context" => "ApplicationCable::Channel",
9
+ "lines" => [2],
10
+ "message" => "has no descriptive comment",
11
+ "smell_type" => "IrresponsibleModule",
12
+ "source" => "spec/assets/test_project/app/channels/application_cable/channel.rb",
13
+ "documentation_link" => "http://gh.com/reek/blob/v6.1.4/docs/Irresponsible-Module.md"
14
+ },
15
+ {
16
+ "context" => "ApplicationCable::Connection",
17
+ "lines" => [2],
18
+ "message" => "has no descriptive comment",
19
+ "smell_type" => "IrresponsibleModule",
20
+ "source" => "spec/assets/test_project/app/channels/application_cable/connection.rb",
21
+ "documentation_link" => "http://gh.com/reek/blob/v6.1.4/docs/Irresponsible-Module.md"
22
+ },
23
+ {
24
+ "context" => "AbastibleClient#parse_prices_by_type",
25
+ "lines" => [189],
26
+ "message" => "has the variable name 'e'",
27
+ "smell_type" => "UncommunicativeVariableName",
28
+ "source" => "spec/assets/test_project/app/clients/abastible_client.rb",
29
+ "name" => "e",
30
+ "documentation_link" => "http://gh.com/reek/blob/v6.1.4/docs/Uncommunicative-Variable-Name.md"
31
+ }
32
+ ].to_json
33
+ end
34
+
35
+ before do
36
+ allow(OutputUtils).to receive(:with_captured_stdout).and_return(reek_result_content)
37
+ end
38
+
39
+ let(:expected) do
40
+ {
41
+ "warnings" =>
42
+ {
43
+ "IrresponsibleModule" =>
44
+ [
45
+ {
46
+ "lines" => [2],
47
+ "message" => "has no descriptive comment",
48
+ "source" => "app/channels/application_cable/channel.rb",
49
+ "name" => nil,
50
+ "documentation_link" => "http://gh.com/reek/blob/v6.1.4/docs/Irresponsible-Module.md"
51
+ },
52
+ {
53
+ "lines" => [2],
54
+ "message" => "has no descriptive comment",
55
+ "source" => "app/channels/application_cable/connection.rb",
56
+ "name" => nil,
57
+ "documentation_link" => "http://gh.com/reek/blob/v6.1.4/docs/Irresponsible-Module.md"
58
+ }
59
+ ],
60
+ "UncommunicativeVariableName" =>
61
+ [
62
+ {
63
+ "lines" => [189],
64
+ "message" => "has the variable name 'e'",
65
+ "source" => "app/clients/abastible_client.rb",
66
+ "name" => "e",
67
+ "documentation_link" => "http://gh.com/reek/blob/v6.1.4/docs/Uncommunicative-Variable-Name.md"
68
+ }
69
+ ]
70
+ }
71
+ }
72
+ end
73
+
74
+ it { expect(extract[:reek_extractor]).to eq(expected) }
75
+ end
76
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: repo_analyzer
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Platanus
@@ -9,8 +9,36 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2023-04-04 00:00:00.000000000 Z
12
+ date: 2023-05-30 00:00:00.000000000 Z
13
13
  dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler-audit
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ">="
19
+ - !ruby/object:Gem::Version
20
+ version: '0'
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ version: '0'
28
+ - !ruby/object:Gem::Dependency
29
+ name: bundler-stats
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
14
42
  - !ruby/object:Gem::Dependency
15
43
  name: brakeman
16
44
  requirement: !ruby/object:Gem::Requirement
@@ -25,6 +53,34 @@ dependencies:
25
53
  - - ">="
26
54
  - !ruby/object:Gem::Version
27
55
  version: '0'
56
+ - !ruby/object:Gem::Dependency
57
+ name: faraday-retry
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ type: :runtime
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ - !ruby/object:Gem::Dependency
71
+ name: fasterer
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :runtime
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
28
84
  - !ruby/object:Gem::Dependency
29
85
  name: octokit
30
86
  requirement: !ruby/object:Gem::Requirement
@@ -67,6 +123,20 @@ dependencies:
67
123
  - - ">="
68
124
  - !ruby/object:Gem::Version
69
125
  version: '0'
126
+ - !ruby/object:Gem::Dependency
127
+ name: reek
128
+ requirement: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - ">="
131
+ - !ruby/object:Gem::Version
132
+ version: '0'
133
+ type: :runtime
134
+ prerelease: false
135
+ version_requirements: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - ">="
138
+ - !ruby/object:Gem::Version
139
+ version: '0'
70
140
  - !ruby/object:Gem::Dependency
71
141
  name: rubocop
72
142
  requirement: !ruby/object:Gem::Requirement
@@ -249,34 +319,6 @@ dependencies:
249
319
  - - ">="
250
320
  - !ruby/object:Gem::Version
251
321
  version: '0'
252
- - !ruby/object:Gem::Dependency
253
- name: rubocop
254
- requirement: !ruby/object:Gem::Requirement
255
- requirements:
256
- - - "~>"
257
- - !ruby/object:Gem::Version
258
- version: '1.9'
259
- type: :development
260
- prerelease: false
261
- version_requirements: !ruby/object:Gem::Requirement
262
- requirements:
263
- - - "~>"
264
- - !ruby/object:Gem::Version
265
- version: '1.9'
266
- - !ruby/object:Gem::Dependency
267
- name: rubocop-rails
268
- requirement: !ruby/object:Gem::Requirement
269
- requirements:
270
- - - ">="
271
- - !ruby/object:Gem::Version
272
- version: '0'
273
- type: :development
274
- prerelease: false
275
- version_requirements: !ruby/object:Gem::Requirement
276
- requirements:
277
- - - ">="
278
- - !ruby/object:Gem::Version
279
- version: '0'
280
322
  description: Rails engine to extract technical debt
281
323
  email:
282
324
  - rubygems@platan.us
@@ -305,13 +347,17 @@ files:
305
347
  - app/clients/repo_analyzer/github_client.rb
306
348
  - app/controllers/repo_analyzer/application_controller.rb
307
349
  - app/extractors/repo_analyzer/brakeman_extractor.rb
350
+ - app/extractors/repo_analyzer/bundler_audit_extractor.rb
351
+ - app/extractors/repo_analyzer/bundler_stats_extractor.rb
308
352
  - app/extractors/repo_analyzer/circleci_extractor.rb
353
+ - app/extractors/repo_analyzer/fasterer_extractor.rb
309
354
  - app/extractors/repo_analyzer/github_extractor.rb
310
355
  - app/extractors/repo_analyzer/power_types_extractor.rb
311
356
  - app/extractors/repo_analyzer/project_config_extractor.rb
312
357
  - app/extractors/repo_analyzer/project_info_extractor.rb
313
358
  - app/extractors/repo_analyzer/project_versions_extractor.rb
314
359
  - app/extractors/repo_analyzer/rails_best_practices_extractor.rb
360
+ - app/extractors/repo_analyzer/reek_extractor.rb
315
361
  - app/extractors/repo_analyzer/rubocop_extractor.rb
316
362
  - app/extractors/repo_analyzer/tests_info_extractor.rb
317
363
  - app/helpers/repo_analyzer/application_helper.rb
@@ -399,12 +445,16 @@ files:
399
445
  - spec/dummy/public/apple-touch-icon.png
400
446
  - spec/dummy/public/favicon.ico
401
447
  - spec/extractors/brakeman_extractor_spec.rb
448
+ - spec/extractors/bundler_audit_extractor_spec.rb
449
+ - spec/extractors/bundler_stats_extractor_spec.rb
402
450
  - spec/extractors/circleci_extractor_spec.rb
451
+ - spec/extractors/fasterer_extractor_spec.rb
403
452
  - spec/extractors/github_extractor_spec.rb
404
453
  - spec/extractors/power_types_extractor_spec.rb
405
454
  - spec/extractors/project_config_extractor_spec.rb
406
455
  - spec/extractors/project_versions_extractor_spec.rb
407
456
  - spec/extractors/rails_best_practices_extractor_spec.rb
457
+ - spec/extractors/reek_extractor_spec.rb
408
458
  - spec/extractors/rubocop_extractor_spec.rb
409
459
  - spec/extractors/tests_info_extractor_spec.rb
410
460
  - spec/fixtures/files/image.png
@@ -503,12 +553,16 @@ test_files:
503
553
  - spec/dummy/public/apple-touch-icon.png
504
554
  - spec/dummy/public/favicon.ico
505
555
  - spec/extractors/brakeman_extractor_spec.rb
556
+ - spec/extractors/bundler_audit_extractor_spec.rb
557
+ - spec/extractors/bundler_stats_extractor_spec.rb
506
558
  - spec/extractors/circleci_extractor_spec.rb
559
+ - spec/extractors/fasterer_extractor_spec.rb
507
560
  - spec/extractors/github_extractor_spec.rb
508
561
  - spec/extractors/power_types_extractor_spec.rb
509
562
  - spec/extractors/project_config_extractor_spec.rb
510
563
  - spec/extractors/project_versions_extractor_spec.rb
511
564
  - spec/extractors/rails_best_practices_extractor_spec.rb
565
+ - spec/extractors/reek_extractor_spec.rb
512
566
  - spec/extractors/rubocop_extractor_spec.rb
513
567
  - spec/extractors/tests_info_extractor_spec.rb
514
568
  - spec/fixtures/files/image.png