quality_meter 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +3 -0
- data/Rakefile +34 -0
- data/app/assets/javascripts/quality_meter/jquery-v1.11.2.js +4 -0
- data/app/assets/javascripts/quality_meter/quality_meter.js +312 -0
- data/app/assets/stylesheets/quality_meter/quality_meter.css +229 -0
- data/app/controllers/quality_meter/report_controller.rb +35 -0
- data/app/views/quality_meter/report/index.html.erb +276 -0
- data/config/routes.rb +4 -0
- data/lib/quality_meter.rb +170 -0
- data/lib/quality_meter/engine.rb +5 -0
- data/lib/quality_meter/string.rb +7 -0
- data/lib/quality_meter/templates/summary_report.html.erb +248 -0
- data/lib/quality_meter/version.rb +3 -0
- data/lib/tasks/quality_meter_tasks.rake +97 -0
- metadata +128 -0
@@ -0,0 +1,248 @@
|
|
1
|
+
<!DOCTYPE HTML SYSTEM>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
5
|
+
<title>Application Report</title>
|
6
|
+
<style>
|
7
|
+
/* CSS style used for HTML reports */
|
8
|
+
body {
|
9
|
+
font-family: sans-serif;
|
10
|
+
color: #161616;
|
11
|
+
width: 70%;
|
12
|
+
margin: auto;
|
13
|
+
}
|
14
|
+
th {
|
15
|
+
/*background-color: #980905;*/
|
16
|
+
/*border-bottom: 5px solid #530200;*/
|
17
|
+
/*color: white;*/
|
18
|
+
font-size: 11pt;
|
19
|
+
padding: 1px 8px 1px 8px;
|
20
|
+
}
|
21
|
+
|
22
|
+
td {
|
23
|
+
border-bottom: 2px solid white;
|
24
|
+
font-family: monospace;
|
25
|
+
padding: 5px 8px 1px 8px;
|
26
|
+
}
|
27
|
+
|
28
|
+
table {
|
29
|
+
/*background-color: #FCF4D4;*/
|
30
|
+
border-collapse: collapse;
|
31
|
+
/*color: black;*/
|
32
|
+
}
|
33
|
+
|
34
|
+
tr.first {
|
35
|
+
border-top: 1px solid #7ecc54;
|
36
|
+
padding-top: 2px;
|
37
|
+
}
|
38
|
+
|
39
|
+
table{
|
40
|
+
width: 100%;
|
41
|
+
border: 1px;
|
42
|
+
border-color: black;
|
43
|
+
}
|
44
|
+
th, td{
|
45
|
+
width: 33.33%;
|
46
|
+
}
|
47
|
+
|
48
|
+
.pie1 .title {
|
49
|
+
position: relative;
|
50
|
+
bottom: -40px;
|
51
|
+
text-align: top;
|
52
|
+
width: 50%;
|
53
|
+
}
|
54
|
+
|
55
|
+
.content {
|
56
|
+
width: 100px;
|
57
|
+
height: 100px;
|
58
|
+
border-radius: 50%;
|
59
|
+
background-color: #fff;
|
60
|
+
position: absolute;
|
61
|
+
top: 20px;
|
62
|
+
left: 20px;
|
63
|
+
line-height: 100px;
|
64
|
+
font-family: arial, sans-serif;
|
65
|
+
font-size: 35px;
|
66
|
+
text-align: center;
|
67
|
+
z-index: 2;
|
68
|
+
}
|
69
|
+
.content span {
|
70
|
+
opacity: 0;
|
71
|
+
animation: load-content 1s;
|
72
|
+
animation-fill-mode: forwards;
|
73
|
+
animation-delay: 0.6s;
|
74
|
+
-webkit-animation: load-content 3s;
|
75
|
+
-webkit-animation-fill-mode: forwards;
|
76
|
+
-webkit-animation-delay: 0.6s;
|
77
|
+
}
|
78
|
+
@keyframes load-content {
|
79
|
+
from {
|
80
|
+
opacity: 0;
|
81
|
+
}
|
82
|
+
to {
|
83
|
+
opacity: 5;
|
84
|
+
}
|
85
|
+
}
|
86
|
+
@-webkit-keyframes load-content {
|
87
|
+
from {
|
88
|
+
opacity: 0;
|
89
|
+
}
|
90
|
+
to {
|
91
|
+
opacity: 1;
|
92
|
+
}
|
93
|
+
}
|
94
|
+
|
95
|
+
.pie {
|
96
|
+
width:200px;
|
97
|
+
height:200px;
|
98
|
+
-moz-border-radius:100px;
|
99
|
+
-webkit-border-radius:100px;
|
100
|
+
border-radius:100px;
|
101
|
+
position:relative;
|
102
|
+
}
|
103
|
+
</style>
|
104
|
+
</head>
|
105
|
+
<body>
|
106
|
+
<table width="70%" margin="auto" border="1%">
|
107
|
+
<tr>
|
108
|
+
<th>
|
109
|
+
<h3>Security Warnings ss</h3>
|
110
|
+
<div class="pie" style="<%= if @brakeman_warnings.count > @security_warnings then "background-color:red;" else "background-color:green;" end %>">
|
111
|
+
<div class="title"></div>
|
112
|
+
<div class="outer-right mask" id= "10deg"></div>
|
113
|
+
<div class="inner-right"></div>
|
114
|
+
|
115
|
+
<div class="outer-left mask">
|
116
|
+
<div class="inner-left"></div>
|
117
|
+
</div>
|
118
|
+
<div class="content">
|
119
|
+
<span><%= @brakeman_warnings.count %></span>
|
120
|
+
</div>
|
121
|
+
</div><p></p>
|
122
|
+
<a href="<%= @app_root %>/report.html" target="_blank">Report</a>
|
123
|
+
</th>
|
124
|
+
|
125
|
+
<th>
|
126
|
+
<h3>Rails Best Practise</h3>
|
127
|
+
<div class="pie" style="<%= if @rails_best_practices_info.first['rails_best_practices'] > @rails_best_practices then "background-color:red;" else "background-color:green;" end %>">
|
128
|
+
<div class="title"></div>
|
129
|
+
<div class="outer-right mask" id= "10deg">
|
130
|
+
<!-- <div class="inner-right"></div> -->
|
131
|
+
</div>
|
132
|
+
|
133
|
+
<div class="outer-left mask">
|
134
|
+
<div class="inner-left"></div>
|
135
|
+
</div>
|
136
|
+
<div class="content">
|
137
|
+
<span><%= @rails_best_practices_info.first['rails_best_practices'] %></span>
|
138
|
+
</div>
|
139
|
+
</div>
|
140
|
+
<p></p>
|
141
|
+
<a href="<%= @app_root %>/tmp/metric_fu/output/rails_best_practices.html" target="_blank">Report</a>
|
142
|
+
</th>
|
143
|
+
|
144
|
+
<th>
|
145
|
+
<h3>Flog</h3>
|
146
|
+
<div class="pie" style="<%= if @flog_info.first['flog'] > @flog_complexity then "background-color:red;" else "background-color:green;" end %>">
|
147
|
+
<div class="title"></div>
|
148
|
+
<div class="outer-right mask" id= "10deg">
|
149
|
+
<div class="inner-right"></div>
|
150
|
+
</div>
|
151
|
+
|
152
|
+
<div class="outer-left mask">
|
153
|
+
<div class="inner-left"></div>
|
154
|
+
</div>
|
155
|
+
<div class="content">
|
156
|
+
<span><%= @flog_info.first['flog'] %></span>
|
157
|
+
</div>
|
158
|
+
</div><p></p>
|
159
|
+
<a href="<%= @app_root %>/tmp/metric_fu/output/flog.html" target="_blank">Report</a>
|
160
|
+
</th>
|
161
|
+
|
162
|
+
<th>
|
163
|
+
<h3>Stat</h3>
|
164
|
+
<div class="pie" style="<%= if @stats_info.first['stats'] > @stats_ratio then "background-color:red;" else "background-color:green;" end %>">
|
165
|
+
<div class="title"></div>
|
166
|
+
<div class="outer-right mask" id= "10deg">
|
167
|
+
<div class="inner-right"></div>
|
168
|
+
</div>
|
169
|
+
|
170
|
+
<div class="outer-left mask">
|
171
|
+
<div class="inner-left"></div>
|
172
|
+
</div>
|
173
|
+
<div class="content">
|
174
|
+
<span><%= @stats_info.first['stats'] %></span>
|
175
|
+
</div>
|
176
|
+
</div><p></p>
|
177
|
+
<a href="<%= @app_root %>/tmp/metric_fu/output/stats.html" target="_blank">Report</a>
|
178
|
+
</th>
|
179
|
+
</tr>
|
180
|
+
</table>
|
181
|
+
<p></p>
|
182
|
+
|
183
|
+
<h2>Security Warnings</h2>
|
184
|
+
<table style="background-color: pink;">
|
185
|
+
<tr>
|
186
|
+
<th>Type</th>
|
187
|
+
<th>File</th>
|
188
|
+
<th>Message</th>
|
189
|
+
</tr>
|
190
|
+
|
191
|
+
<% @brakeman_warnings.each do |warning| %>
|
192
|
+
<tr>
|
193
|
+
<td><h4><%= warning['warning_type'] %></h4></td>
|
194
|
+
<td><%= warning['file'] %></td>
|
195
|
+
<td><%= warning['message'] %></td>
|
196
|
+
</tr>
|
197
|
+
<% end %>
|
198
|
+
</table>
|
199
|
+
<p></p>
|
200
|
+
|
201
|
+
<table width="80%">
|
202
|
+
<tr>
|
203
|
+
<th><div id="lineCanvas" style="position:absolute;height:300px;width:300px;"></div></th>
|
204
|
+
<th><div id="line1Canvas" style=" position:absolute;height:300px;width:300px;"></div></th>
|
205
|
+
<th><div id="line2Canvas" style="position:absolute;height:300px;width:300px;"></div></th>
|
206
|
+
<th><div id="line3Canvas" style="position:absolute;height:300px;width:300px;"></div></th>
|
207
|
+
</tr>
|
208
|
+
</table>
|
209
|
+
|
210
|
+
<script type="text/javascript">
|
211
|
+
var g = new line_graph();
|
212
|
+
g.add('c1', 140);
|
213
|
+
g.add('c2', 90);
|
214
|
+
g.add('c3', 100);
|
215
|
+
g.add('c4', 54);
|
216
|
+
g.add('c5', 0);
|
217
|
+
|
218
|
+
var m = new line_graph();
|
219
|
+
m.add('c1', 200);
|
220
|
+
m.add('c2', 100);
|
221
|
+
m.add('c3', 9000);
|
222
|
+
m.add('c4', 8000);
|
223
|
+
m.add('c5', 70);
|
224
|
+
|
225
|
+
var n = new line_graph();
|
226
|
+
n.add('c1', 200);
|
227
|
+
n.add('c2', 105);
|
228
|
+
n.add('c3', 90);
|
229
|
+
n.add('c4', 35);
|
230
|
+
n.add('c5', 10);
|
231
|
+
|
232
|
+
var q = new line_graph();
|
233
|
+
q.add('c1', 20);
|
234
|
+
q.add('c2', 18);
|
235
|
+
q.add('c3', 15);
|
236
|
+
q.add('c4', 4);
|
237
|
+
q.add('c5', 1);
|
238
|
+
|
239
|
+
g.render("lineCanvas", "flog Graph");
|
240
|
+
m.render("line1Canvas", "Rails best practise Graph");
|
241
|
+
n.render("line2Canvas", "Rails best practise Graph");
|
242
|
+
q.render("line3Canvas", "flog Grap");
|
243
|
+
</script>
|
244
|
+
|
245
|
+
<h2><%= "Generated on #{Time.now}" %></h2>
|
246
|
+
<%#= @previous_reports %>
|
247
|
+
</body>
|
248
|
+
</html>
|
@@ -0,0 +1,97 @@
|
|
1
|
+
require 'erb'
|
2
|
+
require 'quality_meter/string'
|
3
|
+
require 'terminal-table'
|
4
|
+
|
5
|
+
namespace :quality_meter do
|
6
|
+
desc "Run brakeman and metric_fu to generate report of code"
|
7
|
+
|
8
|
+
###This will run command to generate brakeman and matric fu report ###
|
9
|
+
task :generate_report do
|
10
|
+
puts "*** run brakeman ***"
|
11
|
+
system "brakeman -o report.html -o report.json"
|
12
|
+
|
13
|
+
puts "*** run metric_fu ***"
|
14
|
+
system "metric_fu --out #{Rails.root}/public/metric_fu "
|
15
|
+
end
|
16
|
+
|
17
|
+
task :add_command_in_post_commit do
|
18
|
+
### Asked user to add rake command inside git post commit file , Task will run in each eommit
|
19
|
+
STDOUT.puts "Write Y to add rake qmeter:run command to 'post commit', it will run when you commit the code".reverse_color
|
20
|
+
input = STDIN.gets.strip
|
21
|
+
if input == 'y' || input == 'Y'
|
22
|
+
File.open('.git/hooks/post-commit', 'a') do |f|
|
23
|
+
f.puts "rake qmeter:run"
|
24
|
+
end
|
25
|
+
system "chmod +x .git/hooks/post-commit"
|
26
|
+
else
|
27
|
+
STDOUT.puts "You can add it in next time"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
### *** ###
|
32
|
+
task :run do
|
33
|
+
if File.directory?('.git') && File.exists?('.git/config')
|
34
|
+
### this will check git post commit has rake command or not
|
35
|
+
if File.file?('.git/hooks/post-commit')
|
36
|
+
file = File.read(".git/hooks/post-commit").include?('rake qmeter:run')
|
37
|
+
if !file = File.read(".git/hooks/post-commit").include?('rake qmeter:run')
|
38
|
+
Rake::Task["qmeter:add_command_in_post_commit"].execute
|
39
|
+
end
|
40
|
+
else
|
41
|
+
Rake::Task["qmeter:add_command_in_post_commit"].execute
|
42
|
+
end
|
43
|
+
|
44
|
+
###This always executes the task, but it doesn't execute its dependencies
|
45
|
+
Rake::Task["qmeter:generate_report"].execute
|
46
|
+
### *** ###
|
47
|
+
extend Qmeter
|
48
|
+
self.generate_final_report
|
49
|
+
puts "======= Saving Current Analysis Details ======="
|
50
|
+
self.save_report
|
51
|
+
# Initialize JavaScript and CoffeeScript functionality
|
52
|
+
initialize_javascript_coffeescript_report unless File.exist?("#{Rails.root}/config/js_cs_config/js_error_list.txt")
|
53
|
+
|
54
|
+
rows = []
|
55
|
+
rows << ['Security Warning', @warnings_count]
|
56
|
+
rows << ['Flog', @flog_average_complexity]
|
57
|
+
rows << ['Stats', @stats_code_to_test_ratio]
|
58
|
+
rows << ['Rails Best Practices', @rails_best_practices_total]
|
59
|
+
table = Terminal::Table.new :title => "Qmeter Analysis", :headings => ['Type', 'Number'], :rows => rows, :style => {:width => 80}
|
60
|
+
puts table
|
61
|
+
|
62
|
+
puts "======= Please visit localhost:3000/qmeter for detailed report ======="
|
63
|
+
else
|
64
|
+
puts "======= Please Initialize git first =======".bold.green.bg_red
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
# This will append Files/Folders in .gitignore file
|
69
|
+
task :gitignore do
|
70
|
+
add_to_gitignore("qmeter.csv")
|
71
|
+
add_to_gitignore("report.json")
|
72
|
+
add_to_gitignore("report.html")
|
73
|
+
add_to_gitignore("public/metric_fu")
|
74
|
+
add_to_gitignore("config/js_cs_config")
|
75
|
+
end
|
76
|
+
|
77
|
+
def add_to_gitignore(file_folder)
|
78
|
+
resource = file_folder.to_s
|
79
|
+
unless File.read('.gitignore').include?(resource)
|
80
|
+
gitignore_file = File.open('.gitignore', 'a')
|
81
|
+
gitignore_file.puts(resource)
|
82
|
+
gitignore_file.close_write
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
def initialize_javascript_coffeescript_report
|
87
|
+
puts "======= Initializing for JavsScript CoffeeScript reports =======".reverse_color
|
88
|
+
open("#{Rails.root}/Gemfile", 'a') { |f| f.puts "gem 'jshint'" } unless (File.read('Gemfile').include?("gem 'jshint'") || File.read('Gemfile').include?('gem "jshint"'))
|
89
|
+
open("#{Rails.root}/Gemfile", 'a') { |f| f.puts "gem 'coffeelint'" } unless (File.read('Gemfile').include?("gem 'coffeelint'") || File.read('Gemfile').include?('gem "coffeelint"'))
|
90
|
+
system('bundle')
|
91
|
+
system('mkdir config/js_cs_config') unless File.directory?("#{Rails.root}/config/js_cs_config")
|
92
|
+
File.open("config/js_cs_config/coffeelint.json", 'w') do |f|
|
93
|
+
f.write('{ "max_line_length": { "value": 120 }, "no_tabs": { "level": "ignore" } }')
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
end
|
metadata
ADDED
@@ -0,0 +1,128 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: quality_meter
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Arpit Vaishnav
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-05-27 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.8'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.8'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: brakeman
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.3'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.3'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: metric_fu
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '4.12'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '4.12'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: terminal-table
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '1.5'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '1.5'
|
83
|
+
description: QualityMeter is a common platform for rails application quality controll.
|
84
|
+
email:
|
85
|
+
- arpitvaishnav@gmail.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- MIT-LICENSE
|
91
|
+
- README.rdoc
|
92
|
+
- Rakefile
|
93
|
+
- app/assets/javascripts/quality_meter/jquery-v1.11.2.js
|
94
|
+
- app/assets/javascripts/quality_meter/quality_meter.js
|
95
|
+
- app/assets/stylesheets/quality_meter/quality_meter.css
|
96
|
+
- app/controllers/quality_meter/report_controller.rb
|
97
|
+
- app/views/quality_meter/report/index.html.erb
|
98
|
+
- config/routes.rb
|
99
|
+
- lib/quality_meter.rb
|
100
|
+
- lib/quality_meter/engine.rb
|
101
|
+
- lib/quality_meter/string.rb
|
102
|
+
- lib/quality_meter/templates/summary_report.html.erb
|
103
|
+
- lib/quality_meter/version.rb
|
104
|
+
- lib/tasks/quality_meter_tasks.rake
|
105
|
+
homepage: https://github.com/arpitvaishnav/quality_meter
|
106
|
+
licenses: []
|
107
|
+
metadata: {}
|
108
|
+
post_install_message:
|
109
|
+
rdoc_options: []
|
110
|
+
require_paths:
|
111
|
+
- lib
|
112
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - ">="
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '0'
|
117
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
118
|
+
requirements:
|
119
|
+
- - ">="
|
120
|
+
- !ruby/object:Gem::Version
|
121
|
+
version: '0'
|
122
|
+
requirements: []
|
123
|
+
rubyforge_project:
|
124
|
+
rubygems_version: 2.4.8
|
125
|
+
signing_key:
|
126
|
+
specification_version: 4
|
127
|
+
summary: QualityMeter for applications in Rails.
|
128
|
+
test_files: []
|