rake_check 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.cane +1 -0
- data/.gitignore +18 -0
- data/.rspec +2 -0
- data/.rvmrc +1 -0
- data/.travis.yml +3 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +32 -0
- data/Rakefile +3 -0
- data/lib/rake_check/cane_checker.rb +48 -0
- data/lib/rake_check/rbp_checker.rb +70 -0
- data/lib/rake_check/reek_checker.rb +47 -0
- data/lib/rake_check/rspec_checker.rb +70 -0
- data/lib/rake_check/tasks/check.rake +55 -0
- data/lib/rake_check/version.rb +7 -0
- data/lib/rake_check/yard_checker.rb +67 -0
- data/lib/rake_check.rb +8 -0
- data/rake_check.gemspec +26 -0
- data/spec/files/reek_output.yaml +36 -0
- data/spec/lib/rake_check/cane_checker_spec.rb +43 -0
- data/spec/lib/rake_check/rbp_checker_spec.rb +18 -0
- data/spec/lib/rake_check/reek_checker_spec.rb +18 -0
- data/spec/lib/rake_check/rspec_checker_spec.rb +45 -0
- data/spec/lib/rake_check/yard_checker_spec.rb +34 -0
- data/spec/spec_helper.rb +11 -0
- metadata +172 -0
data/.cane
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--style-measure 100
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rvmrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rvm use 1.9.3-p194@rake_check --create
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Dominik Masur
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# RakeCheck
|
2
|
+
|
3
|
+
Checking the Project for Code Smells and bad documentation
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'rake_check'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install rake_check
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
Put this in your Rakefile:
|
22
|
+
|
23
|
+
require 'rake_check'
|
24
|
+
load 'rake_check/tasks/check.rake'
|
25
|
+
|
26
|
+
## Contributing
|
27
|
+
|
28
|
+
1. Fork it
|
29
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
30
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
31
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
32
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'colored'
|
2
|
+
##
|
3
|
+
# CaneChecker checks the output code smells with cane
|
4
|
+
#
|
5
|
+
# @author dmasur
|
6
|
+
class CaneChecker
|
7
|
+
##
|
8
|
+
# Gives the Checkresult
|
9
|
+
#
|
10
|
+
# @return [Hash] Checkresult
|
11
|
+
# @author dmasur
|
12
|
+
def result
|
13
|
+
@shell_output = `cane`
|
14
|
+
{ :type => :cane, :check_output => @shell_output, :status => status }
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
##
|
19
|
+
# Gives the Check Status
|
20
|
+
#
|
21
|
+
# @return [String] Checkstatus
|
22
|
+
# @author dmasur
|
23
|
+
def status
|
24
|
+
@violations = @shell_output.scan(/\((\d*)\):/).flatten.map(&:to_i).
|
25
|
+
inject(0){ |sum, value| sum += value }
|
26
|
+
if @violations > 0
|
27
|
+
color_violations
|
28
|
+
"#{@violations} Style Violations"
|
29
|
+
elsif @shell_output.empty?
|
30
|
+
'OK'.green
|
31
|
+
else
|
32
|
+
'N/A'
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
##
|
37
|
+
# Color Code Validation Count
|
38
|
+
#
|
39
|
+
# @return [String] Colored Validation Count
|
40
|
+
# @author dmasur
|
41
|
+
def color_violations
|
42
|
+
color = case @violations
|
43
|
+
when 1..9 then :yellow
|
44
|
+
else :red
|
45
|
+
end
|
46
|
+
@violations = @violations.to_s.send color
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require 'colored'
|
2
|
+
##
|
3
|
+
# Check the output of rails best pratices gem
|
4
|
+
#
|
5
|
+
# @author dmasur
|
6
|
+
class RbpChecker
|
7
|
+
##
|
8
|
+
# Gives the Checkresult
|
9
|
+
#
|
10
|
+
# @return [Hash] Checkresult
|
11
|
+
# @author dmasur
|
12
|
+
def result
|
13
|
+
@shell_output = `rails_best_practices --silent --spec`
|
14
|
+
{:type => :rbp, :check_output => output, :status => status}
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
##
|
19
|
+
# Gives the Checkoutput
|
20
|
+
#
|
21
|
+
# @return [String] Checkoutput
|
22
|
+
# @author dmasur
|
23
|
+
def output
|
24
|
+
case state
|
25
|
+
when :good then ''
|
26
|
+
else
|
27
|
+
regexp = /Please go to .* to see more useful Rails Best Practices./
|
28
|
+
output_lines = @shell_output.gsub(regexp, '').split(/\n/)
|
29
|
+
(output_lines - ["\e[0m", "\e[32m", "\n"]).join("\n")
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
##
|
34
|
+
# Gives the Checkstatus
|
35
|
+
#
|
36
|
+
# @return [String] Checkstatus
|
37
|
+
# @author dmasur
|
38
|
+
def status
|
39
|
+
tmp_state = state
|
40
|
+
case tmp_state
|
41
|
+
when :good then 'OK'.green
|
42
|
+
when :error then 'N/A'
|
43
|
+
else error_message.red
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
##
|
48
|
+
# Gives the Error message
|
49
|
+
#
|
50
|
+
# @return [String] Errormessage
|
51
|
+
# @author dmasur
|
52
|
+
def error_message
|
53
|
+
warning_count = /Found (\d+) warnings/.match(@shell_output)[1]
|
54
|
+
"Found #{warning_count} warnings"
|
55
|
+
end
|
56
|
+
|
57
|
+
##
|
58
|
+
# Gives the Check state
|
59
|
+
#
|
60
|
+
# @return [Symbol] Checkstatus
|
61
|
+
# @author dmasur
|
62
|
+
def state
|
63
|
+
if @shell_output.include? 'No warning found. Cool!'
|
64
|
+
:good
|
65
|
+
elsif @shell_output =~ /Found \d+ warnings/
|
66
|
+
:failures
|
67
|
+
else :error
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'colored'
|
2
|
+
##
|
3
|
+
# ReekChecker checks the Output of reek for Code Smells
|
4
|
+
#
|
5
|
+
# @author dmasur
|
6
|
+
class ReekChecker
|
7
|
+
##
|
8
|
+
# Gives the Checkresult
|
9
|
+
#
|
10
|
+
# @return [Hash] Checkresult
|
11
|
+
# @author dmasur
|
12
|
+
def result
|
13
|
+
shell_output = `reek app lib -y 2>/dev/null`
|
14
|
+
@shell_output = shell_output.split("\n").
|
15
|
+
delete_if{|line| line.include?('already initialized constant') }.join("\n")
|
16
|
+
{:type => :reek, :check_output => output, :status => status}
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
# Gives the Check Status
|
21
|
+
#
|
22
|
+
# @return [String] Checkstatus
|
23
|
+
# @author dmasur
|
24
|
+
def status
|
25
|
+
if @shell_output.empty?
|
26
|
+
'OK'.green
|
27
|
+
elsif not @shell_output.include? '---'
|
28
|
+
'N/A'.red
|
29
|
+
else
|
30
|
+
error_count = YAML.parse(@shell_output).children.first.children.count
|
31
|
+
"#{error_count} Codesmell".yellow
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
##
|
36
|
+
# Gives the check output
|
37
|
+
#
|
38
|
+
# @return [String] Output
|
39
|
+
# @author dmasur
|
40
|
+
def output
|
41
|
+
unless @shell_output.include? '---'
|
42
|
+
@shell_output
|
43
|
+
else
|
44
|
+
''
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require 'colored'
|
2
|
+
##
|
3
|
+
# Check the Output of rspec and simplecov
|
4
|
+
#
|
5
|
+
# @author dmasur
|
6
|
+
class RspecChecker
|
7
|
+
##
|
8
|
+
# Gives the Result Hash
|
9
|
+
#
|
10
|
+
# @return [Hash] Checkresult
|
11
|
+
# @author dmasur
|
12
|
+
def result
|
13
|
+
@shell_output = `export COVERAGE=true; rspec spec; export COVERAGE=`
|
14
|
+
{:type => :rspec, :status => status + code_coverage, :check_output => output}
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
##
|
19
|
+
# Gives the Check Status
|
20
|
+
#
|
21
|
+
# @return [String] Checkstatus
|
22
|
+
# @author dmasur
|
23
|
+
def status
|
24
|
+
case @shell_output
|
25
|
+
when / 0 failures/
|
26
|
+
'OK'.green
|
27
|
+
when /failures?/
|
28
|
+
/\d+ failures?/.match(@shell_output)[0].red
|
29
|
+
else 'N/A'
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
##
|
34
|
+
# Gives the check output
|
35
|
+
#
|
36
|
+
# @return [String] Output
|
37
|
+
# @author dmasur
|
38
|
+
def output
|
39
|
+
case @shell_output
|
40
|
+
when / 0 failures/ then ''
|
41
|
+
else @shell_output
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
##
|
46
|
+
# Gives the check codecoverage
|
47
|
+
#
|
48
|
+
# @return [String] Codecoverage
|
49
|
+
def code_coverage
|
50
|
+
if @shell_output.include?('Coverage report generated')
|
51
|
+
@coverage = /LOC \((\d+\.\d+)%\) covered/.match(@shell_output)[1].to_f
|
52
|
+
color_coverage
|
53
|
+
" with #{@coverage} Code Coverage"
|
54
|
+
else
|
55
|
+
""
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
##
|
60
|
+
# Calculate the Codecoverage
|
61
|
+
#
|
62
|
+
# @return [String] Colored Codecoverage
|
63
|
+
def color_coverage
|
64
|
+
@coverage = case @coverage
|
65
|
+
when 0..60 then "#{@coverage}%".red
|
66
|
+
when 60..90 then "#{@coverage}%".yellow
|
67
|
+
when 90..100 then "#{@coverage}%".green
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
require 'rake_check/rbp_checker'
|
3
|
+
require 'rake_check/rspec_checker'
|
4
|
+
require 'rake_check/reek_checker'
|
5
|
+
require 'rake_check/yard_checker'
|
6
|
+
require 'rake_check/cane_checker'
|
7
|
+
##
|
8
|
+
# Do exakt what it is called
|
9
|
+
#
|
10
|
+
# @param [String] string The string to print
|
11
|
+
# @author dmasur
|
12
|
+
def puts_unless_empty string
|
13
|
+
puts string unless string.empty?
|
14
|
+
end
|
15
|
+
|
16
|
+
##
|
17
|
+
# Print the check results
|
18
|
+
#
|
19
|
+
# @param [Array / Hash] results Array of Results or Hashresult
|
20
|
+
# @author dmasur
|
21
|
+
def print_check_result results
|
22
|
+
print_outputs results
|
23
|
+
print_summary results
|
24
|
+
end
|
25
|
+
|
26
|
+
##
|
27
|
+
# Print Outputs of each result
|
28
|
+
#
|
29
|
+
# @author dmasur
|
30
|
+
def print_outputs results
|
31
|
+
results.each do |result|
|
32
|
+
puts_unless_empty result[:check_output]
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
##
|
37
|
+
# Print Summary of all Outputs
|
38
|
+
#
|
39
|
+
# @author dmasur
|
40
|
+
def print_summary results
|
41
|
+
results.each do |result|
|
42
|
+
type_name = result[:type].to_s
|
43
|
+
status = result[:status]
|
44
|
+
puts "puts #{type_name}:\t#{status}"
|
45
|
+
end
|
46
|
+
end
|
47
|
+
desc "Check Rails Best Practices and RSpec"
|
48
|
+
task :check do
|
49
|
+
rspec = RspecChecker.new.result
|
50
|
+
rbp = RbpChecker.new.result
|
51
|
+
yard = YardChecker.new.result
|
52
|
+
reek = ReekChecker.new.result
|
53
|
+
cane = CaneChecker.new.result
|
54
|
+
print_check_result [rspec, rbp, yard, reek, cane]
|
55
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require 'colored'
|
2
|
+
##
|
3
|
+
# YardChecker checks the output for undocumented classes and methods
|
4
|
+
#
|
5
|
+
# @author dmasur
|
6
|
+
class YardChecker
|
7
|
+
##
|
8
|
+
# Gives the Checkresult
|
9
|
+
#
|
10
|
+
# @return [Hash] Checkresult
|
11
|
+
# @author dmasur
|
12
|
+
def result
|
13
|
+
@shell_output = `yardoc`
|
14
|
+
{:type => :yard, :check_output => output, :status => status}
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
##
|
19
|
+
# Color the Coverage
|
20
|
+
#
|
21
|
+
# @return [String] colored Coverage
|
22
|
+
# @author dmasur
|
23
|
+
def color_coverage
|
24
|
+
@coverage = case @coverage
|
25
|
+
when 0..60 then "#{@coverage}%".red
|
26
|
+
when 60..90 then "#{@coverage}%".yellow
|
27
|
+
when 90..100 then "#{@coverage}%".green
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
##
|
32
|
+
# Parse the Code coverage
|
33
|
+
#
|
34
|
+
# @return [String] colored Codecoverage
|
35
|
+
# @author dmasur
|
36
|
+
def calc_yard_coverage
|
37
|
+
@coverage = /(\d+\.\d+)% documented/.match(@shell_output)[1].to_f
|
38
|
+
color_coverage
|
39
|
+
end
|
40
|
+
|
41
|
+
##
|
42
|
+
# Gives the Check Status
|
43
|
+
#
|
44
|
+
# @return [String] Checkstatus
|
45
|
+
# @author dmasur
|
46
|
+
def status
|
47
|
+
if @shell_output.include? 'documented'
|
48
|
+
calc_yard_coverage
|
49
|
+
"#{@coverage} documented"
|
50
|
+
else
|
51
|
+
'N/A'
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
##
|
56
|
+
# Gives the check output
|
57
|
+
#
|
58
|
+
# @return [String] Output
|
59
|
+
# @author dmasur
|
60
|
+
def output
|
61
|
+
if @shell_output.include? 'documented'
|
62
|
+
''
|
63
|
+
else
|
64
|
+
@shell_output
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
data/lib/rake_check.rb
ADDED
data/rake_check.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/rake_check/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Dominik Masur"]
|
6
|
+
gem.email = ["dominik.masur@googlemail.com"]
|
7
|
+
gem.description = %q{Checking the Project for Code Smells and bad documentation}
|
8
|
+
gem.summary = %q{Checking the Project for Code Smells and bad documentation}
|
9
|
+
gem.homepage = "https://github.com/TBAA/rake_check"
|
10
|
+
|
11
|
+
gem.files = `git ls-files`.split($\)
|
12
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
13
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
14
|
+
gem.name = "rake_check"
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.version = RakeCheck::VERSION
|
17
|
+
|
18
|
+
gem.add_dependency "rspec"
|
19
|
+
gem.add_dependency "colored"
|
20
|
+
gem.add_dependency "rake"
|
21
|
+
gem.add_dependency "reek"
|
22
|
+
gem.add_dependency "yard"
|
23
|
+
gem.add_dependency "rails_best_practices"
|
24
|
+
gem.add_dependency "cane"
|
25
|
+
gem.add_dependency 'redcarpet'
|
26
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
/Users/foo/.rvm/gems/ruby-1.9.3-p194/gems/ruby_parser-2.3.1/lib/ruby_parser_extras.rb:10: warning: already initialized constant ENC_NONE
|
2
|
+
/Users/foo/.rvm/gems/ruby-1.9.3-p194/gems/ruby_parser-2.3.1/lib/ruby_parser_extras.rb:11: warning: already initialized constant ENC_EUC
|
3
|
+
/Users/foo/.rvm/gems/ruby-1.9.3-p194/gems/ruby_parser-2.3.1/lib/ruby_parser_extras.rb:12: warning: already initialized constant ENC_SJIS
|
4
|
+
/Users/foo/.rvm/gems/ruby-1.9.3-p194/gems/ruby_parser-2.3.1/lib/ruby_parser_extras.rb:13: warning: already initialized constant ENC_UTF8
|
5
|
+
---
|
6
|
+
- !ruby/object:Reek::SmellWarning
|
7
|
+
smell:
|
8
|
+
class: Duplication
|
9
|
+
subclass: DuplicateMethodCall
|
10
|
+
message: calls "OK".green 5 times
|
11
|
+
call: ! '"OK".green'
|
12
|
+
occurrences: 5
|
13
|
+
status:
|
14
|
+
is_active: true
|
15
|
+
location:
|
16
|
+
context: ReekChecker#status
|
17
|
+
lines:
|
18
|
+
- 19
|
19
|
+
- 20
|
20
|
+
- 21
|
21
|
+
- 22
|
22
|
+
- 23
|
23
|
+
source: lib/rake_check/reek_checker.rb
|
24
|
+
- !ruby/object:Reek::SmellWarning
|
25
|
+
smell:
|
26
|
+
class: LongMethod
|
27
|
+
subclass: TooManyStatements
|
28
|
+
message: has approx 8 statements
|
29
|
+
statement_count: 8
|
30
|
+
status:
|
31
|
+
is_active: true
|
32
|
+
location:
|
33
|
+
context: ReekChecker#status
|
34
|
+
lines:
|
35
|
+
- 17
|
36
|
+
source: lib/rake_check/reek_checker.rb
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../../lib/rake_check/cane_checker')
|
2
|
+
|
3
|
+
describe CaneChecker do
|
4
|
+
it "gives N/A on Error" do
|
5
|
+
subject.stub('`' => 'Error')
|
6
|
+
subject.result.should == { type: :cane, check_output: 'Error', status: 'N/A' }
|
7
|
+
end
|
8
|
+
it "gives OK with no Errors" do
|
9
|
+
subject.stub('`' => '')
|
10
|
+
subject.result.should == { type: :cane,
|
11
|
+
check_output: '',
|
12
|
+
status: "\e[32mOK\e[0m" }
|
13
|
+
end
|
14
|
+
it "adds Class and Line violations" do
|
15
|
+
shell_output = "Lines violated style requirements (10):\nClasses are not documented (1):"
|
16
|
+
subject.stub('`' => shell_output)
|
17
|
+
subject.result.should == { type: :cane,
|
18
|
+
check_output: shell_output,
|
19
|
+
status: "\e[31m11\e[0m Style Violations" }
|
20
|
+
end
|
21
|
+
it "dont count other infos" do
|
22
|
+
shell_output = "Lines violated style requirements (1):
|
23
|
+
app/models/foo.rb:14 Line is >100 characters (115)"
|
24
|
+
subject.stub('`' => shell_output)
|
25
|
+
subject.result.should == { type: :cane,
|
26
|
+
check_output: shell_output,
|
27
|
+
status: "\e[33m1\e[0m Style Violations" }
|
28
|
+
end
|
29
|
+
it "is yellow under 10 Violations" do
|
30
|
+
shell_output = "Lines violated style requirements (10):"
|
31
|
+
subject.stub('`' => shell_output)
|
32
|
+
subject.result.should == { type: :cane,
|
33
|
+
check_output: shell_output,
|
34
|
+
status: "\e[31m10\e[0m Style Violations" }
|
35
|
+
end
|
36
|
+
it "is red under 10 Violations" do
|
37
|
+
shell_output = "Lines violated style requirements (9):"
|
38
|
+
subject.stub('`' => shell_output)
|
39
|
+
subject.result.should == { type: :cane,
|
40
|
+
check_output: shell_output,
|
41
|
+
status: "\e[33m9\e[0m Style Violations" }
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../../lib/rake_check/rbp_checker')
|
2
|
+
|
3
|
+
describe RbpChecker do
|
4
|
+
it "gives N/A on Error" do
|
5
|
+
subject.stub('`' => 'Error')
|
6
|
+
subject.result.should == { type: :rbp, check_output: 'Error', status: 'N/A' }
|
7
|
+
end
|
8
|
+
it "gives OK with no Errors" do
|
9
|
+
subject.stub('`' => 'No warning found. Cool!')
|
10
|
+
subject.result.should == { type: :rbp, check_output: '', status: "\e[32mOK\e[0m" }
|
11
|
+
end
|
12
|
+
it "gives warning message with Errors" do
|
13
|
+
subject.stub('`' => 'Found 1 warnings.')
|
14
|
+
subject.result.should == { type: :rbp,
|
15
|
+
check_output: 'Found 1 warnings.',
|
16
|
+
status: "\e[31mFound 1 warnings\e[0m" }
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../../lib/rake_check/reek_checker')
|
2
|
+
describe ReekChecker do
|
3
|
+
it "gives N/A on Error" do
|
4
|
+
require 'ruby_parser'
|
5
|
+
subject.stub('`' => 'Error')
|
6
|
+
subject.result.should == { type: :reek, check_output: 'Error', status: "\e[31mN/A\e[0m" }
|
7
|
+
end
|
8
|
+
it "gives OK on no Error" do
|
9
|
+
subject.stub('`' => 'warning: already initialized constant ENC_UTF8')
|
10
|
+
subject.result.should == { type: :reek, check_output: '', status: "\e[32mOK\e[0m" }
|
11
|
+
end
|
12
|
+
it "gives Error with on Codesmells" do
|
13
|
+
shell_output = File.read(File.expand_path(File.dirname(__FILE__) +
|
14
|
+
'/../../files/reek_output.yaml'))
|
15
|
+
subject.stub('`' => shell_output)
|
16
|
+
subject.result.should == { type: :reek, check_output: '', status: "\e[33m2 Codesmell\e[0m" }
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../../lib/rake_check/rspec_checker')
|
2
|
+
|
3
|
+
describe RspecChecker do
|
4
|
+
it "gives N/A on Error" do
|
5
|
+
subject.stub('`' => 'Error')
|
6
|
+
subject.result.should == { type: :rspec, check_output: 'Error', status: 'N/A' }
|
7
|
+
end
|
8
|
+
it "gives OK with no Errors" do
|
9
|
+
subject.stub('`' => '6 examples, 0 failures')
|
10
|
+
subject.result.should == { type: :rspec, check_output: '', status: "\e[32mOK\e[0m" }
|
11
|
+
end
|
12
|
+
it "gives warning message with Errors" do
|
13
|
+
subject.stub('`' => '6 examples, 3 failures')
|
14
|
+
subject.result.should == { type: :rspec, check_output: '6 examples, 3 failures',
|
15
|
+
status: "\e[31m3 failures\e[0m" }
|
16
|
+
end
|
17
|
+
it "gives warning message with one Error" do
|
18
|
+
subject.stub('`' => '6 examples, 1 failure')
|
19
|
+
subject.result.should == { type: :rspec, check_output: '6 examples, 1 failure',
|
20
|
+
status: "\e[31m1 failure\e[0m" }
|
21
|
+
end
|
22
|
+
describe "Code Coverage" do
|
23
|
+
it "is green over 90%" do
|
24
|
+
check_output = "6 examples, 0 failures
|
25
|
+
Coverage report generated for RSpec to /foo/bar/coverage. 38 / 38 LOC (93.90%) covered."
|
26
|
+
subject.stub('`' => check_output)
|
27
|
+
subject.result.should == { type: :rspec, check_output: '',
|
28
|
+
status: "\e[32mOK\e[0m with \e[32m93.9%\e[0m Code Coverage" }
|
29
|
+
end
|
30
|
+
it "is green over 70%" do
|
31
|
+
check_output = "6 examples, 0 failures
|
32
|
+
Coverage report generated for RSpec to /foo/bar/coverage. 38 / 38 LOC (73.90%) covered."
|
33
|
+
subject.stub('`' => check_output)
|
34
|
+
subject.result.should == { type: :rspec, check_output: '',
|
35
|
+
status: "\e[32mOK\e[0m with \e[33m73.9%\e[0m Code Coverage" }
|
36
|
+
end
|
37
|
+
it "is green over 10%" do
|
38
|
+
check_output = "6 examples, 0 failures
|
39
|
+
Coverage report generated for RSpec to /foo/bar/coverage. 38 / 38 LOC (13.90%) covered."
|
40
|
+
subject.stub('`' => check_output)
|
41
|
+
subject.result.should == { type: :rspec, check_output: '',
|
42
|
+
status: "\e[32mOK\e[0m with \e[31m13.9%\e[0m Code Coverage" }
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../../lib/rake_check/yard_checker')
|
2
|
+
|
3
|
+
describe YardChecker do
|
4
|
+
it "gives N/A on Error" do
|
5
|
+
subject.stub('`' => 'Error')
|
6
|
+
subject.result.should == { type: :yard, check_output: 'Error', status: 'N/A' }
|
7
|
+
end
|
8
|
+
it "gives OK with no Errors" do
|
9
|
+
subject.stub('`' => '100.00% documented')
|
10
|
+
subject.result.should == { type: :yard,
|
11
|
+
check_output: '',
|
12
|
+
status: "\e[32m100.0%\e[0m documented" }
|
13
|
+
end
|
14
|
+
describe "Code Coverage" do
|
15
|
+
it "is green over 90%" do
|
16
|
+
subject.stub('`' => "93.00% documented")
|
17
|
+
subject.result.should == { type: :yard,
|
18
|
+
check_output: '',
|
19
|
+
status: "\e[32m93.0%\e[0m documented" }
|
20
|
+
end
|
21
|
+
it "is green over 70%" do
|
22
|
+
subject.stub('`' => "73.00% documented")
|
23
|
+
subject.result.should == { type: :yard,
|
24
|
+
check_output: '',
|
25
|
+
status: "\e[33m73.0%\e[0m documented" }
|
26
|
+
end
|
27
|
+
it "is green over 10%" do
|
28
|
+
subject.stub('`' => "13.00% documented")
|
29
|
+
subject.result.should == { type: :yard,
|
30
|
+
check_output: '',
|
31
|
+
status: "\e[31m13.0%\e[0m documented" }
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
2
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
|
+
# Require this file using `require "spec_helper.rb"` to ensure that it is only
|
4
|
+
# loaded once.
|
5
|
+
#
|
6
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
7
|
+
RSpec.configure do |config|
|
8
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
9
|
+
config.run_all_when_everything_filtered = true
|
10
|
+
config.filter_run :focus
|
11
|
+
end
|
metadata
ADDED
@@ -0,0 +1,172 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rake_check
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Dominik Masur
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-05-02 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rspec
|
16
|
+
requirement: &70144098464480 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70144098464480
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: colored
|
27
|
+
requirement: &70144098463700 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70144098463700
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: rake
|
38
|
+
requirement: &70144098462760 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
type: :runtime
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70144098462760
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: reek
|
49
|
+
requirement: &70144098461880 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
type: :runtime
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *70144098461880
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: yard
|
60
|
+
requirement: &70144098461060 !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
type: :runtime
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: *70144098461060
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rails_best_practices
|
71
|
+
requirement: &70144098460120 !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ! '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
type: :runtime
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: *70144098460120
|
80
|
+
- !ruby/object:Gem::Dependency
|
81
|
+
name: cane
|
82
|
+
requirement: &70144098459640 !ruby/object:Gem::Requirement
|
83
|
+
none: false
|
84
|
+
requirements:
|
85
|
+
- - ! '>='
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
type: :runtime
|
89
|
+
prerelease: false
|
90
|
+
version_requirements: *70144098459640
|
91
|
+
- !ruby/object:Gem::Dependency
|
92
|
+
name: redcarpet
|
93
|
+
requirement: &70144098459200 !ruby/object:Gem::Requirement
|
94
|
+
none: false
|
95
|
+
requirements:
|
96
|
+
- - ! '>='
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
99
|
+
type: :runtime
|
100
|
+
prerelease: false
|
101
|
+
version_requirements: *70144098459200
|
102
|
+
description: Checking the Project for Code Smells and bad documentation
|
103
|
+
email:
|
104
|
+
- dominik.masur@googlemail.com
|
105
|
+
executables: []
|
106
|
+
extensions: []
|
107
|
+
extra_rdoc_files: []
|
108
|
+
files:
|
109
|
+
- .cane
|
110
|
+
- .gitignore
|
111
|
+
- .rspec
|
112
|
+
- .rvmrc
|
113
|
+
- .travis.yml
|
114
|
+
- Gemfile
|
115
|
+
- LICENSE
|
116
|
+
- README.md
|
117
|
+
- Rakefile
|
118
|
+
- lib/rake_check.rb
|
119
|
+
- lib/rake_check/cane_checker.rb
|
120
|
+
- lib/rake_check/rbp_checker.rb
|
121
|
+
- lib/rake_check/reek_checker.rb
|
122
|
+
- lib/rake_check/rspec_checker.rb
|
123
|
+
- lib/rake_check/tasks/check.rake
|
124
|
+
- lib/rake_check/version.rb
|
125
|
+
- lib/rake_check/yard_checker.rb
|
126
|
+
- rake_check.gemspec
|
127
|
+
- spec/files/reek_output.yaml
|
128
|
+
- spec/lib/rake_check/cane_checker_spec.rb
|
129
|
+
- spec/lib/rake_check/rbp_checker_spec.rb
|
130
|
+
- spec/lib/rake_check/reek_checker_spec.rb
|
131
|
+
- spec/lib/rake_check/rspec_checker_spec.rb
|
132
|
+
- spec/lib/rake_check/yard_checker_spec.rb
|
133
|
+
- spec/spec_helper.rb
|
134
|
+
homepage: https://github.com/TBAA/rake_check
|
135
|
+
licenses: []
|
136
|
+
post_install_message:
|
137
|
+
rdoc_options: []
|
138
|
+
require_paths:
|
139
|
+
- lib
|
140
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
141
|
+
none: false
|
142
|
+
requirements:
|
143
|
+
- - ! '>='
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
segments:
|
147
|
+
- 0
|
148
|
+
hash: 3943817759965377518
|
149
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
150
|
+
none: false
|
151
|
+
requirements:
|
152
|
+
- - ! '>='
|
153
|
+
- !ruby/object:Gem::Version
|
154
|
+
version: '0'
|
155
|
+
segments:
|
156
|
+
- 0
|
157
|
+
hash: 3943817759965377518
|
158
|
+
requirements: []
|
159
|
+
rubyforge_project:
|
160
|
+
rubygems_version: 1.8.10
|
161
|
+
signing_key:
|
162
|
+
specification_version: 3
|
163
|
+
summary: Checking the Project for Code Smells and bad documentation
|
164
|
+
test_files:
|
165
|
+
- spec/files/reek_output.yaml
|
166
|
+
- spec/lib/rake_check/cane_checker_spec.rb
|
167
|
+
- spec/lib/rake_check/rbp_checker_spec.rb
|
168
|
+
- spec/lib/rake_check/reek_checker_spec.rb
|
169
|
+
- spec/lib/rake_check/rspec_checker_spec.rb
|
170
|
+
- spec/lib/rake_check/yard_checker_spec.rb
|
171
|
+
- spec/spec_helper.rb
|
172
|
+
has_rdoc:
|