sandi_meter 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/README.md +1 -1
- data/bin/sandi_meter +47 -2
- data/lib/sandi_meter/loc_checker.rb +1 -1
- data/lib/sandi_meter/version.rb +1 -1
- data/spec/analyzer_spec.rb +18 -2
- data/spec/test_classes/12.rb +110 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NTkxMGM4NTg4OTVkNjY2MjkyNGZlNTg3YTM0YjdlMTFkNmJlZjcwZA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NTRkZDc2YzMzNDAzMDczM2ZlNTI1MTNmNjk4NGFhMGRiMmM3NDM1OA==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZWMwNTNhZTgyZjY0OGIyYmNmNjc2OTQ2ZWQyMTkzMGIyMjliOGVmNGFhOGQz
|
10
|
+
YmQ1NTU0NTA1ZTYwNmY2YmU5OGRmZmVjZDU0ZDgzYjg5MmE2MWY3MWEzM2Mx
|
11
|
+
MzZlNTI5ZmU3YTg2ZmY2ZWU5MWM3NzVkZjAyNWJhYjlmZDdiN2Y=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MDNiOGNlYjc3MjdjMmE4Njg2MWU4ODhmNmVjMTg1ODAyOTM5NTMwNTdjNmFk
|
14
|
+
ODczMjczNWMyMDZiZmUwY2FlYTJkYmY3MmM1OTA3YjVhZGU1NDA4M2UyZjk1
|
15
|
+
NTBjYTQ1NGMyMmJhMmY5YjU2NDM0ZWQ1NzQ1NWQwMjU5MWYyYjM=
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# SandiMeter
|
2
2
|
|
3
|
-
Static analysis tool for checking your Ruby code for [Sandi Metz'
|
3
|
+
Static analysis tool for checking your Ruby code for [Sandi Metz' four rules](http://robots.thoughtbot.com/post/50655960596/sandi-metz-rules-for-developers).
|
4
4
|
|
5
5
|
* 100 lines per class
|
6
6
|
* 5 lines per method
|
data/bin/sandi_meter
CHANGED
@@ -1,10 +1,55 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
+
require 'mixlib/cli'
|
3
4
|
require_relative '../lib/sandi_meter/file_scanner'
|
4
5
|
require_relative '../lib/sandi_meter/formatter'
|
5
6
|
|
6
|
-
|
7
|
-
|
7
|
+
class MyCLI
|
8
|
+
include Mixlib::CLI
|
9
|
+
|
10
|
+
option :path,
|
11
|
+
short: "-p PATH",
|
12
|
+
long: "--path PATH",
|
13
|
+
description: "Path to folder or file to analyze",
|
14
|
+
default: "."
|
15
|
+
|
16
|
+
option :log,
|
17
|
+
short: "-l",
|
18
|
+
long: "--log",
|
19
|
+
description: "Show syntax error and indentation log output",
|
20
|
+
boolean: true
|
21
|
+
|
22
|
+
option :help,
|
23
|
+
short: "-h",
|
24
|
+
long: "--help",
|
25
|
+
description: "Help",
|
26
|
+
on: :tail,
|
27
|
+
boolean: true,
|
28
|
+
show_options: true,
|
29
|
+
exit: 0
|
30
|
+
|
31
|
+
option :rules,
|
32
|
+
short: "-r",
|
33
|
+
long: "--rules",
|
34
|
+
description: "Show rules",
|
35
|
+
boolean: 0
|
36
|
+
end
|
37
|
+
|
38
|
+
cli = MyCLI.new
|
39
|
+
cli.parse_options
|
40
|
+
|
41
|
+
if cli.config[:rules]
|
42
|
+
puts %(
|
43
|
+
1. 100 lines per class
|
44
|
+
2. 5 lines per method
|
45
|
+
3. 4 params per method call (and don't even try cheating with hash params)
|
46
|
+
4. 1 instance variables per controller' action
|
47
|
+
)
|
48
|
+
exit 0
|
49
|
+
end
|
50
|
+
|
51
|
+
scanner = SandiMeter::FileScanner.new(cli.config[:log])
|
52
|
+
data = scanner.scan(cli.config[:path])
|
8
53
|
formatter = SandiMeter::Formatter.new
|
9
54
|
|
10
55
|
formatter.print_data(data)
|
data/lib/sandi_meter/version.rb
CHANGED
data/spec/analyzer_spec.rb
CHANGED
@@ -4,7 +4,7 @@ require_relative '../lib/sandi_meter/analyzer'
|
|
4
4
|
describe SandiMeter::Analyzer do
|
5
5
|
let(:analyzer) { SandiMeter::Analyzer.new }
|
6
6
|
|
7
|
-
describe 'finds properly
|
7
|
+
describe 'finds properly indented classes with lines' do
|
8
8
|
let(:test_class) { test_file_path(3) }
|
9
9
|
|
10
10
|
before do
|
@@ -44,7 +44,7 @@ describe SandiMeter::Analyzer do
|
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
|
-
describe 'finds properly
|
47
|
+
describe 'finds properly indented classes in one file' do
|
48
48
|
let(:test_class) { test_file_path(4) }
|
49
49
|
|
50
50
|
before do
|
@@ -160,4 +160,20 @@ describe SandiMeter::Analyzer do
|
|
160
160
|
analyzer.method_calls.should eq([[5, 3]])
|
161
161
|
end
|
162
162
|
end
|
163
|
+
|
164
|
+
describe 'empty lines inside class' do
|
165
|
+
let(:test_class) { test_file_path(12) }
|
166
|
+
|
167
|
+
before do
|
168
|
+
analyzer.analyze(test_class)
|
169
|
+
end
|
170
|
+
|
171
|
+
it 'are count for class definition' do
|
172
|
+
analyzer.classes.should eq([["Valera", 1, 109, false]])
|
173
|
+
end
|
174
|
+
|
175
|
+
it 'are count for method definition' do
|
176
|
+
analyzer.methods.should eq({"Valera"=>[["doodle", 2, 9, 0, false]]})
|
177
|
+
end
|
178
|
+
end
|
163
179
|
end
|
@@ -0,0 +1,110 @@
|
|
1
|
+
class Valera
|
2
|
+
def doodle
|
3
|
+
|
4
|
+
|
5
|
+
|
6
|
+
|
7
|
+
|
8
|
+
|
9
|
+
end
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
end
|
110
|
+
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sandi_meter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anatoli Makarevich
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-09-
|
11
|
+
date: 2013-09-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -65,6 +65,7 @@ files:
|
|
65
65
|
- spec/test_classes/1.rb
|
66
66
|
- spec/test_classes/10.rb
|
67
67
|
- spec/test_classes/11.rb
|
68
|
+
- spec/test_classes/12.rb
|
68
69
|
- spec/test_classes/2.rb
|
69
70
|
- spec/test_classes/3.rb
|
70
71
|
- spec/test_classes/4.rb
|