code_quality 0.1.8 → 0.1.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +1 -0
- data/lib/code_quality/version.rb +1 -1
- data/lib/tasks/code_quality.rake +50 -11
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4d634f37e3805714ba3225cbde5d3db73b7fcb469589c633e56ee11eabb0b7b5
|
4
|
+
data.tar.gz: 4986eb8f07b233f6bfa5b69e73218afa675c8340c4043f941d0866c7c7b877fa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2173a13b383cbf4f80b1c9dbf8f03d7ea6e13001ce9444e8a26eb6347d8d22a3ef920c3bef23f5f5929fcff03947123b5c37bb016d69bf094758f27acf16b488
|
7
|
+
data.tar.gz: 95733cc0481be5adec4bdb80d19b03ea3e5fda563b5272fd064c9b2d5ce9f7f7e6b01d69915c852cbee1cd45ad305ed99a5a5b6071f29f44d783719fd695bcde
|
data/Rakefile
CHANGED
data/lib/code_quality/version.rb
CHANGED
data/lib/tasks/code_quality.rake
CHANGED
@@ -12,17 +12,8 @@ namespace :code_quality do
|
|
12
12
|
|
13
13
|
# desc "generate a report index page"
|
14
14
|
task :generate_index => :helpers do
|
15
|
-
require "erb"
|
16
|
-
prepare_dir "tmp/code_quality"
|
17
|
-
gem_app_dir = File.expand_path("../../../app", __FILE__)
|
18
|
-
erb_file = "#{gem_app_dir}/views/code_quality/index.html.erb"
|
19
15
|
index_path = "tmp/code_quality/index.html"
|
20
|
-
|
21
|
-
# render view
|
22
|
-
erb = ERB.new(File.read(erb_file))
|
23
|
-
output = erb.result(binding)
|
24
|
-
|
25
|
-
File.open(index_path, 'w') {|f| f.write output }
|
16
|
+
generate_index index_path
|
26
17
|
# puts "Generate report index to #{index_path}"
|
27
18
|
show_in_browser File.realpath(index_path)
|
28
19
|
end
|
@@ -84,10 +75,44 @@ namespace :code_quality do
|
|
84
75
|
end
|
85
76
|
|
86
77
|
desc "code quality audit"
|
78
|
+
# e.g.: rake code_quality:quality_audit fail_fast=true
|
79
|
+
# options:
|
80
|
+
# fail_fast: to stop immediately if any audit task fails, by default fail_fast=false
|
81
|
+
# generate_index: generate a report index page to tmp/code_quality/quality_audit/index.html, by default generate_index=false
|
87
82
|
task :quality_audit => [:"quality_audit:default"] do; end
|
88
83
|
namespace :quality_audit do
|
89
84
|
# default tasks
|
90
|
-
task :default => [:
|
85
|
+
task :default => [:run_all, :resources] do; end
|
86
|
+
|
87
|
+
desc "run all audit tasks"
|
88
|
+
task :run_all => :helpers do
|
89
|
+
options = options_from_env(:fail_fast, :generate_index)
|
90
|
+
fail_fast = options.fetch(:fail_fast, "false")
|
91
|
+
generate_index = options.fetch(:generate_index, "false")
|
92
|
+
audit_tasks = [:rubycritic, :rubocop, :metric_fu]
|
93
|
+
exc = nil
|
94
|
+
audit_tasks.each do |task_name|
|
95
|
+
full_task_name = :"code_quality:quality_audit:#{task_name}"
|
96
|
+
begin
|
97
|
+
task = Rake::Task[full_task_name]
|
98
|
+
task.invoke
|
99
|
+
rescue SystemExit => exc
|
100
|
+
raise exc if fail_fast == "true"
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
# generate a report index page to tmp/code_quality/quality_audit/index.html
|
105
|
+
if options[:generate_index] == "true"
|
106
|
+
index_path = "tmp/code_quality/quality_audit/index.html"
|
107
|
+
@audit_tasks.each do |task_name, report|
|
108
|
+
report[:report_path].sub!("quality_audit/", "")
|
109
|
+
end
|
110
|
+
generate_index index_path
|
111
|
+
puts "Generate report index to #{index_path}"
|
112
|
+
end
|
113
|
+
|
114
|
+
audit_faild "" if exc
|
115
|
+
end
|
91
116
|
|
92
117
|
# desc "prepare dir"
|
93
118
|
task :prepare => :helpers do
|
@@ -332,6 +357,20 @@ namespace :code_quality do
|
|
332
357
|
def open_in_browser?
|
333
358
|
ENV["CI"].nil?
|
334
359
|
end
|
360
|
+
|
361
|
+
def generate_index(index_path)
|
362
|
+
require "erb"
|
363
|
+
prepare_dir "tmp/code_quality"
|
364
|
+
gem_app_dir = File.expand_path("../../../app", __FILE__)
|
365
|
+
erb_file = "#{gem_app_dir}/views/code_quality/index.html.erb"
|
366
|
+
|
367
|
+
# render view
|
368
|
+
@audit_tasks ||= []
|
369
|
+
erb = ERB.new(File.read(erb_file))
|
370
|
+
output = erb.result(binding)
|
371
|
+
|
372
|
+
File.open(index_path, 'w') {|f| f.write output }
|
373
|
+
end
|
335
374
|
end
|
336
375
|
|
337
376
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: code_quality
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- RainChen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-01-
|
11
|
+
date: 2018-01-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler-audit
|