cane 2.4.0 → 2.5.0
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/HISTORY.md +5 -0
- data/README.md +5 -2
- data/cane.gemspec +1 -0
- data/lib/cane/doc_check.rb +22 -7
- data/lib/cane/style_check.rb +5 -3
- data/lib/cane/version.rb +1 -1
- data/spec/doc_check_spec.rb +26 -0
- data/spec/parser_spec.rb +2 -0
- data/spec/style_check_spec.rb +11 -0
- metadata +14 -39
data/HISTORY.md
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
# Cane History
|
2
2
|
|
3
|
+
## 2.5.0 - 17 November 2012 (628cc1e9)
|
4
|
+
|
5
|
+
* Feature: `--doc-exclude` option to exclude globs from documentation checks.
|
6
|
+
* Feature: `--style-exclude` supports globbing.
|
7
|
+
|
3
8
|
## 2.4.0 - 21 October 2012 (46949e77)
|
4
9
|
|
5
10
|
* Feature: Rake task can load configuration from a `.cane` file.
|
data/README.md
CHANGED
@@ -44,16 +44,19 @@ Customize behaviour with a wealth of options:
|
|
44
44
|
|
45
45
|
--style-glob GLOB Glob to run style checks over (default: {app,lib,spec}/**/*.rb)
|
46
46
|
--style-measure VALUE Max line length (default: 80)
|
47
|
-
--style-exclude
|
47
|
+
--style-exclude GLOB Exclude file or glob from style checking
|
48
48
|
--no-style Disable style checking
|
49
49
|
|
50
50
|
--doc-glob GLOB Glob to run doc checks over (default: {app,lib}/**/*.rb)
|
51
|
+
--doc-exclude GLOB Exclude file or glob from documentation checking
|
52
|
+
--no-readme Disable readme checking
|
51
53
|
--no-doc Disable documentation checking
|
52
54
|
|
53
|
-
--gte FILE,THRESHOLD
|
55
|
+
--gte FILE,THRESHOLD Check the number in FILE is >= to THRESHOLD (a number or another file name)
|
54
56
|
|
55
57
|
-f, --all FILE Apply all checks to given file
|
56
58
|
--max-violations VALUE Max allowed violations (default: 0)
|
59
|
+
--json Output as JSON
|
57
60
|
--parallel Use all processors. Slower on small projects, faster on large.
|
58
61
|
|
59
62
|
-v, --version Show version
|
data/cane.gemspec
CHANGED
data/lib/cane/doc_check.rb
CHANGED
@@ -14,12 +14,17 @@ module Cane
|
|
14
14
|
def self.name; "documentation checking"; end
|
15
15
|
def self.options
|
16
16
|
{
|
17
|
-
doc_glob:
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
17
|
+
doc_glob: ['Glob to run doc checks over',
|
18
|
+
default: '{app,lib}/**/*.rb',
|
19
|
+
variable: 'GLOB',
|
20
|
+
clobber: :no_doc],
|
21
|
+
doc_exclude: ['Exclude file or glob from documentation checking',
|
22
|
+
variable: 'GLOB',
|
23
|
+
type: Array,
|
24
|
+
default: [],
|
25
|
+
clobber: :no_doc],
|
26
|
+
no_readme: ['Disable readme checking', cast: ->(x) { !x }],
|
27
|
+
no_doc: ['Disable documentation checking', cast: ->(x) { !x }]
|
23
28
|
}
|
24
29
|
end
|
25
30
|
|
@@ -68,7 +73,7 @@ module Cane
|
|
68
73
|
end
|
69
74
|
|
70
75
|
def file_names
|
71
|
-
Dir[opts.fetch(:doc_glob)]
|
76
|
+
Dir[opts.fetch(:doc_glob)].reject { |file| excluded?(file) }
|
72
77
|
end
|
73
78
|
|
74
79
|
def class_definition?(line)
|
@@ -83,6 +88,16 @@ module Cane
|
|
83
88
|
line.match(/class\s+([^\s;]+)/)[1]
|
84
89
|
end
|
85
90
|
|
91
|
+
def exclusions
|
92
|
+
@exclusions ||= opts.fetch(:doc_exclude, []).flatten.map do |i|
|
93
|
+
Dir[i]
|
94
|
+
end.flatten.to_set
|
95
|
+
end
|
96
|
+
|
97
|
+
def excluded?(file)
|
98
|
+
exclusions.include?(file)
|
99
|
+
end
|
100
|
+
|
86
101
|
def worker
|
87
102
|
Cane.task_runner(opts)
|
88
103
|
end
|
data/lib/cane/style_check.rb
CHANGED
@@ -23,8 +23,8 @@ module Cane
|
|
23
23
|
default: 80,
|
24
24
|
cast: :to_i,
|
25
25
|
clobber: :no_style],
|
26
|
-
style_exclude: ['Exclude file from style checking',
|
27
|
-
variable: '
|
26
|
+
style_exclude: ['Exclude file or glob from style checking',
|
27
|
+
variable: 'GLOB',
|
28
28
|
type: Array,
|
29
29
|
default: [],
|
30
30
|
clobber: :no_style],
|
@@ -72,7 +72,9 @@ module Cane
|
|
72
72
|
end
|
73
73
|
|
74
74
|
def exclusions
|
75
|
-
@exclusions ||= opts.fetch(:style_exclude, []).flatten.
|
75
|
+
@exclusions ||= opts.fetch(:style_exclude, []).flatten.map do |i|
|
76
|
+
Dir[i]
|
77
|
+
end.flatten.to_set
|
76
78
|
end
|
77
79
|
|
78
80
|
def excluded?(file)
|
data/lib/cane/version.rb
CHANGED
data/spec/doc_check_spec.rb
CHANGED
@@ -71,4 +71,30 @@ class Doc; end
|
|
71
71
|
"Missing documentation", "No README found"
|
72
72
|
]
|
73
73
|
end
|
74
|
+
|
75
|
+
it 'skips declared exclusions' do
|
76
|
+
file_name = make_file <<-FILE.gsub /^\s{6}/, ''
|
77
|
+
class NeedsDocumentation
|
78
|
+
end
|
79
|
+
FILE
|
80
|
+
|
81
|
+
violations = check(file_name,
|
82
|
+
doc_exclude: [file_name]
|
83
|
+
).violations
|
84
|
+
|
85
|
+
violations.length.should == 0
|
86
|
+
end
|
87
|
+
|
88
|
+
it 'skips declared glob-based exclusions' do
|
89
|
+
file_name = make_file <<-FILE.gsub /^\s{6}/, ''
|
90
|
+
class NeedsDocumentation
|
91
|
+
end
|
92
|
+
FILE
|
93
|
+
|
94
|
+
violations = check(file_name,
|
95
|
+
doc_exclude: ["#{File.dirname(file_name)}/*"]
|
96
|
+
).violations
|
97
|
+
|
98
|
+
violations.length.should == 0
|
99
|
+
end
|
74
100
|
end
|
data/spec/parser_spec.rb
CHANGED
@@ -63,11 +63,13 @@ describe Cane::CLI::Parser do
|
|
63
63
|
it 'supports exclusions' do
|
64
64
|
options = [
|
65
65
|
"--abc-exclude", "Harness#complex_method",
|
66
|
+
"--doc-exclude", 'myfile',
|
66
67
|
"--style-exclude", 'myfile'
|
67
68
|
].join(' ')
|
68
69
|
|
69
70
|
_, result = run(options)
|
70
71
|
result[:abc_exclude].should == [['Harness#complex_method']]
|
72
|
+
result[:doc_exclude].should == [['myfile']]
|
71
73
|
result[:style_exclude].should == [['myfile']]
|
72
74
|
end
|
73
75
|
|
data/spec/style_check_spec.rb
CHANGED
@@ -33,6 +33,17 @@ describe Cane::StyleCheck do
|
|
33
33
|
violations.length.should == 0
|
34
34
|
end
|
35
35
|
|
36
|
+
it 'skips declared glob-based exclusions' do
|
37
|
+
file_name = make_file(ruby_with_style_issue)
|
38
|
+
|
39
|
+
violations = check(file_name,
|
40
|
+
style_measure: 80,
|
41
|
+
style_exclude: ["#{File.dirname(file_name)}/*"]
|
42
|
+
).violations
|
43
|
+
|
44
|
+
violations.length.should == 0
|
45
|
+
end
|
46
|
+
|
36
47
|
it 'does not include trailing new lines in the character count' do
|
37
48
|
file_name = make_file('#' * 80 + "\n" + '#' * 80)
|
38
49
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cane
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.5.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-11-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: parallel
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirement: &2156715960 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,15 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
25
|
-
none: false
|
26
|
-
requirements:
|
27
|
-
- - ! '>='
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: '0'
|
24
|
+
version_requirements: *2156715960
|
30
25
|
- !ruby/object:Gem::Dependency
|
31
26
|
name: rspec
|
32
|
-
requirement: !ruby/object:Gem::Requirement
|
27
|
+
requirement: &2156715440 !ruby/object:Gem::Requirement
|
33
28
|
none: false
|
34
29
|
requirements:
|
35
30
|
- - ~>
|
@@ -37,15 +32,10 @@ dependencies:
|
|
37
32
|
version: '2.0'
|
38
33
|
type: :development
|
39
34
|
prerelease: false
|
40
|
-
version_requirements:
|
41
|
-
none: false
|
42
|
-
requirements:
|
43
|
-
- - ~>
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
version: '2.0'
|
35
|
+
version_requirements: *2156715440
|
46
36
|
- !ruby/object:Gem::Dependency
|
47
37
|
name: rake
|
48
|
-
requirement: !ruby/object:Gem::Requirement
|
38
|
+
requirement: &2156715000 !ruby/object:Gem::Requirement
|
49
39
|
none: false
|
50
40
|
requirements:
|
51
41
|
- - ! '>='
|
@@ -53,15 +43,10 @@ dependencies:
|
|
53
43
|
version: '0'
|
54
44
|
type: :development
|
55
45
|
prerelease: false
|
56
|
-
version_requirements:
|
57
|
-
none: false
|
58
|
-
requirements:
|
59
|
-
- - ! '>='
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
46
|
+
version_requirements: *2156715000
|
62
47
|
- !ruby/object:Gem::Dependency
|
63
48
|
name: simplecov
|
64
|
-
requirement: !ruby/object:Gem::Requirement
|
49
|
+
requirement: &2156714520 !ruby/object:Gem::Requirement
|
65
50
|
none: false
|
66
51
|
requirements:
|
67
52
|
- - ! '>='
|
@@ -69,15 +54,10 @@ dependencies:
|
|
69
54
|
version: '0'
|
70
55
|
type: :development
|
71
56
|
prerelease: false
|
72
|
-
version_requirements:
|
73
|
-
none: false
|
74
|
-
requirements:
|
75
|
-
- - ! '>='
|
76
|
-
- !ruby/object:Gem::Version
|
77
|
-
version: '0'
|
57
|
+
version_requirements: *2156714520
|
78
58
|
- !ruby/object:Gem::Dependency
|
79
59
|
name: rspec-fire
|
80
|
-
requirement: !ruby/object:Gem::Requirement
|
60
|
+
requirement: &2156714100 !ruby/object:Gem::Requirement
|
81
61
|
none: false
|
82
62
|
requirements:
|
83
63
|
- - ! '>='
|
@@ -85,12 +65,7 @@ dependencies:
|
|
85
65
|
version: '0'
|
86
66
|
type: :development
|
87
67
|
prerelease: false
|
88
|
-
version_requirements:
|
89
|
-
none: false
|
90
|
-
requirements:
|
91
|
-
- - ! '>='
|
92
|
-
- !ruby/object:Gem::Version
|
93
|
-
version: '0'
|
68
|
+
version_requirements: *2156714100
|
94
69
|
description: Fails your build if code quality thresholds are not met
|
95
70
|
email:
|
96
71
|
- xavier@squareup.com
|
@@ -145,7 +120,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
145
120
|
requirements:
|
146
121
|
- - ! '>='
|
147
122
|
- !ruby/object:Gem::Version
|
148
|
-
version:
|
123
|
+
version: 1.9.0
|
149
124
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
150
125
|
none: false
|
151
126
|
requirements:
|
@@ -154,7 +129,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
154
129
|
version: '0'
|
155
130
|
requirements: []
|
156
131
|
rubyforge_project:
|
157
|
-
rubygems_version: 1.8.
|
132
|
+
rubygems_version: 1.8.6
|
158
133
|
signing_key:
|
159
134
|
specification_version: 3
|
160
135
|
summary: Fails your build if code quality thresholds are not met. Provides complexity
|