code_quality 0.1.4 → 0.1.5

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
  SHA1:
3
- metadata.gz: 1e3a844a3e643f804b7d26ebdade9a3996b9c69d
4
- data.tar.gz: c8f60d29dffa58dccf7e27881e5520dd58b06abf
3
+ metadata.gz: 4753ee2f8d6753ecb8aa656ccbe13c1e1723f555
4
+ data.tar.gz: e49661a67fab0298bb6a86bc6c2d3344c2f5d0c1
5
5
  SHA512:
6
- metadata.gz: 7323fd69af310eb30abfedc3f939cc8f28abf40dae23d876c4f371b6476598db5e2357e5b7323f6944928b56ccf874e48a5c98c645f90e1f861070234b1d59e8
7
- data.tar.gz: aa3d23b5d413330119b9501e3f86fa25b4c00a930e45fe06b98a1bacca945587ed74032cf677ebfe0191c288db8e17cb105b60afa96140c7df4acde5ac5269bf
6
+ metadata.gz: f3f208d3a980688ac3a9a51d450ef2153341904dd78e7ed03ff8324ba1631f97524271933e0de6f11ed44770e0852c8788218acdc74c14df60180944361d82b1
7
+ data.tar.gz: 1a217e7da64454c3d6341ecd00c5fd6a278bed1c5ed66b06d23bf3ef275c84e9307f08e9d79ef491812aa6e7b513aadc05095b313e8b9521a1eb77ab5f64972b
data/README.md CHANGED
@@ -2,6 +2,9 @@
2
2
 
3
3
  Run code quality and security audit report with one rake task as `rake code_quality`.
4
4
 
5
+ [![Gem Version](https://badge.fury.io/rb/code_quality.svg)](https://badge.fury.io/rb/code_quality)
6
+ [![Build Status](https://travis-ci.org/rainchen/code_quality.svg)](https://travis-ci.org/rainchen/code_quality)
7
+
5
8
  ## Principle
6
9
 
7
10
  > If you can’t measure it, you can’t improve it.
data/app/readme ADDED
@@ -0,0 +1 @@
1
+ keeping an "app" dir for brakeman "Please supply the path to a Rails application."
data/code_quality.gemspec CHANGED
@@ -26,7 +26,7 @@ Gem::Specification.new do |spec|
26
26
  spec.add_dependency "rubycritic", "~> 3.3.0"
27
27
  spec.add_dependency "rubocop", "~> 0.52.0"
28
28
  spec.add_dependency "rubocop-github", "~> 0.8.1"
29
- spec.add_dependency "code_metric_fu", "~> 4.14.3"
29
+ spec.add_dependency "code_metric_fu", "~> 4.14.4"
30
30
 
31
31
  spec.add_development_dependency "bundler", "~> 1.16"
32
32
  spec.add_development_dependency "rake", "~> 10.0"
data/lib/code_quality.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  require "code_quality/version"
2
- require "code_quality/railtie"# if defined?(Rails)
2
+ require "code_quality/railtie" if defined?(Rails)
3
3
 
4
4
  module CodeQuality
5
5
  end
@@ -1,3 +1,3 @@
1
1
  module CodeQuality
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.5"
3
3
  end
@@ -38,6 +38,7 @@ namespace :code_quality do
38
38
 
39
39
  desc "brakeman"
40
40
  task :brakeman => :prepare do
41
+ require 'json'
41
42
  run_audit "Brakeman audit - checks Ruby on Rails applications for security vulnerabilities" do
42
43
  `brakeman -o #{report_dir}/brakeman-report.txt -o #{report_dir}/brakeman-report.json`
43
44
  puts `cat #{report_dir}/brakeman-report.txt`
@@ -83,8 +84,10 @@ namespace :code_quality do
83
84
  task :rubycritic => :prepare do
84
85
  options = options_from_env(:lowest_score)
85
86
  run_audit "Rubycritic - static analysis gems such as Reek, Flay and Flog to provide a quality report of your Ruby code." do
86
- report = `rubycritic -p #{report_dir}/rubycritic app lib`
87
+ report = `rubycritic -p #{report_dir}/rubycritic app lib --no-browser`
87
88
  puts report
89
+ report_path = "#{report_dir}/rubycritic/overview.html"
90
+ show_in_browser File.realpath(report_path)
88
91
 
89
92
  # if config lowest_score then audit it with report score
90
93
  if options[:lowest_score]
@@ -184,6 +187,7 @@ namespace :code_quality do
184
187
  # audit report result
185
188
  report_result_path = "tmp/metric_fu/report.yml"
186
189
  if File.exists? report_result_path
190
+ require 'yaml'
187
191
  report_result = YAML.load_file(report_result_path)
188
192
  # if config #{metric}_max_offenses then audit it with report result
189
193
  audit_failures = []
@@ -229,6 +233,7 @@ namespace :code_quality do
229
233
  end
230
234
 
231
235
  def realtime(&block)
236
+ require 'benchmark'
232
237
  realtime = Benchmark.realtime do
233
238
  block.call
234
239
  end.round
@@ -260,7 +265,8 @@ namespace :code_quality do
260
265
 
261
266
  # e.g.: options_from_env(:a, :b) => {:a => ..., :b => ... }
262
267
  def options_from_env(*keys)
263
- ENV.to_h.slice(*keys.map(&:to_s)).symbolize_keys!
268
+ # ENV.to_h.slice(*keys.map(&:to_s)).symbolize_keys! # using ActiveSupport
269
+ ENV.to_h.inject({}) { |opts, (k, v)| keys.include?(k.to_sym) ? opts.merge({k.to_sym => v}) : opts }
264
270
  end
265
271
 
266
272
  # set text color, background color using ANSI escape sequences, e.g.:
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
4
+ version: 0.1.5
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-13 00:00:00.000000000 Z
11
+ date: 2018-01-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler-audit
@@ -86,14 +86,14 @@ dependencies:
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: 4.14.3
89
+ version: 4.14.4
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: 4.14.3
96
+ version: 4.14.4
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: bundler
99
99
  requirement: !ruby/object:Gem::Requirement
@@ -150,6 +150,7 @@ files:
150
150
  - LICENSE.txt
151
151
  - README.md
152
152
  - Rakefile
153
+ - app/readme
153
154
  - bin/console
154
155
  - bin/setup
155
156
  - code_quality.gemspec