roodi 1.1.0 → 1.1.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/History.txt +16 -3
- data/README.txt +25 -9
- data/Rakefile +1 -1
- data/lib/roodi/checks/class_name_check.rb +2 -1
- data/lib/roodi/checks/method_name_check.rb +1 -1
- data/lib/roodi/core/parse_tree_runner.rb +7 -2
- data/lib/roodi/core/parser.rb +10 -0
- data/lib/roodi.rb +1 -1
- data/spec/checks/class_name_check_spec.rb +12 -0
- data/spec/checks/method_name_check_spec.rb +2 -2
- metadata +13 -3
data/History.txt
CHANGED
@@ -1,11 +1,24 @@
|
|
1
|
-
= 1.1.
|
1
|
+
= 1.1.1
|
2
|
+
|
3
|
+
* I'd initially published to Rubyforge under a 1.0.0 gem, and I've since tried to retrospectively fix up the version number system. It turns out that Rubyforge caches old gems permanently, so I have to re-start at a larger number again.
|
4
|
+
* class name check no longer gets confused about scoped class names like Module::Classname.
|
5
|
+
|
6
|
+
= 0.5
|
7
|
+
|
8
|
+
* expanded regex matching for method name check.
|
9
|
+
* suppressed noisy output from ParseTree using facets API.
|
10
|
+
* updated dependencies and version as a result of facets change.
|
11
|
+
* made Roodi tolerant of being asked to parse files which aren't really Ruby files.
|
12
|
+
* updated the documentation with usage examples.
|
13
|
+
|
14
|
+
= 0.4
|
2
15
|
|
3
16
|
* Added support back in for line numbers in error messages.
|
4
17
|
* Re-enabled MethodLineCountCheck as part of the default check set.
|
5
18
|
|
6
|
-
=
|
19
|
+
= 0.3
|
7
20
|
|
8
|
-
* First
|
21
|
+
* First version of Roodi to be published to Rubyforge.
|
9
22
|
|
10
23
|
= 0.2
|
11
24
|
|
data/README.txt
CHANGED
@@ -1,11 +1,35 @@
|
|
1
1
|
= roodi
|
2
2
|
|
3
|
-
* http://
|
3
|
+
* http://roodi.rubyforge.org
|
4
4
|
|
5
5
|
== DESCRIPTION:
|
6
6
|
|
7
7
|
Roodi stands for Ruby Object Oriented Design Inferometer. It parses your Ruby code and warns you about design issues you have based on the checks that is has configured.
|
8
8
|
|
9
|
+
== INSTALL:
|
10
|
+
|
11
|
+
* sudo gem install roodi
|
12
|
+
|
13
|
+
== SYNOPSIS:
|
14
|
+
|
15
|
+
To check one or more files using the default configuration that comes with Roodi, use:
|
16
|
+
roodi [patterns]
|
17
|
+
|
18
|
+
=== EXAMPLE USAGE
|
19
|
+
|
20
|
+
Check all ruby files in a rails app:
|
21
|
+
roodi "rails_app/**/*.rb"
|
22
|
+
|
23
|
+
Check one controller and one model file in a rails app:
|
24
|
+
roodi app/controller/sample_controller.rb app/models/sample.rb
|
25
|
+
|
26
|
+
Check one controller and all model files in a rails app:
|
27
|
+
roodi app/controller/sample_controller.rb "app/models/*.rb"
|
28
|
+
|
29
|
+
|
30
|
+
If you're writing a check, it is useful to see the structure of a file the way that Roodi tokenizes it (via ParesTree). Use:
|
31
|
+
roodi-describe [filename]
|
32
|
+
|
9
33
|
== SUPPORTED CHECKS:
|
10
34
|
|
11
35
|
* ClassNameCheck - Check that class names match convention.
|
@@ -16,14 +40,6 @@ Roodi stands for Ruby Object Oriented Design Inferometer. It parses your Ruby c
|
|
16
40
|
* MethodNameCheck - Check that method names match convention.
|
17
41
|
* MethodLineCountCheck - Check that the number of lines in a method is below the threshold.
|
18
42
|
|
19
|
-
== SYNOPSIS:
|
20
|
-
|
21
|
-
* TBD. See the Rakefile in this project for an example of how to get started if you're on the bleeding edge.
|
22
|
-
|
23
|
-
== INSTALL:
|
24
|
-
|
25
|
-
* sudo gem install roodi
|
26
|
-
|
27
43
|
== LICENSE:
|
28
44
|
|
29
45
|
(The MIT License)
|
data/Rakefile
CHANGED
@@ -8,8 +8,9 @@ module Roodi
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def evaluate(node)
|
11
|
+
class_name = node[1].class == Symbol ? node[1] : node[1].last
|
11
12
|
pattern = /^[A-Z][a-zA-Z0-9]*$/
|
12
|
-
add_error "Class name \"#{node[1]}\" should match pattern #{pattern.inspect}" unless
|
13
|
+
add_error "Class name \"#{node[1]}\" should match pattern #{pattern.inspect}" unless class_name.to_s =~ pattern
|
13
14
|
end
|
14
15
|
end
|
15
16
|
end
|
@@ -8,7 +8,7 @@ module Roodi
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def evaluate(node)
|
11
|
-
pattern = /^[
|
11
|
+
pattern = /^[_a-z<>=\[\]|+-\/\*`]+[_a-z0-9_<>=~@\[\]]*[=!\?]?$/
|
12
12
|
add_error "Method name \"#{node[1]}\" should match pattern #{pattern.inspect}" unless node[1].to_s =~ pattern
|
13
13
|
end
|
14
14
|
end
|
@@ -19,8 +19,13 @@ module Roodi
|
|
19
19
|
|
20
20
|
def check(filename, content)
|
21
21
|
@checks ||= load_checks
|
22
|
-
|
23
|
-
|
22
|
+
begin
|
23
|
+
node = @parser.parse(content, filename)
|
24
|
+
node.accept(IteratorVisitor.new(CheckingVisitor.new(@checks)))
|
25
|
+
rescue Exception => e
|
26
|
+
# puts e
|
27
|
+
puts "#{filename} looks like it's not a valid Ruby file. Skipping..."
|
28
|
+
end
|
24
29
|
end
|
25
30
|
|
26
31
|
def check_content(content)
|
data/lib/roodi/core/parser.rb
CHANGED
@@ -1,10 +1,20 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'parse_tree'
|
3
|
+
require 'facets'
|
4
|
+
|
3
5
|
|
4
6
|
module Roodi
|
5
7
|
module Core
|
6
8
|
class Parser
|
7
9
|
def parse(content, filename)
|
10
|
+
silence_stream(STDERR) do
|
11
|
+
return silent_parse(content, filename)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def silent_parse(content, filename)
|
8
18
|
@parser ||= ParseTree.new(true)
|
9
19
|
node = @parser.parse_tree_for_string(content, filename)
|
10
20
|
sexp = VisitableSexp.from_array node
|
data/lib/roodi.rb
CHANGED
@@ -14,6 +14,18 @@ describe Roodi::Checks::ClassNameCheck do
|
|
14
14
|
@roodi.errors.should be_empty
|
15
15
|
end
|
16
16
|
|
17
|
+
it "should be able to parse scoped class names" do
|
18
|
+
content = <<-END
|
19
|
+
class MyScope::GoodClassName
|
20
|
+
def method
|
21
|
+
end
|
22
|
+
end
|
23
|
+
END
|
24
|
+
# @roodi.print_content(content)
|
25
|
+
@roodi.check_content(content)
|
26
|
+
@roodi.errors.should be_empty
|
27
|
+
end
|
28
|
+
|
17
29
|
it "should reject class names with underscores" do
|
18
30
|
content = <<-END
|
19
31
|
class Bad_ClassName
|
@@ -147,7 +147,7 @@ describe Roodi::Checks::MethodNameCheck do
|
|
147
147
|
END
|
148
148
|
@roodi.check_content(content)
|
149
149
|
errors = @roodi.errors
|
150
|
-
errors.should_not be_empty
|
151
|
-
errors[0].should eql("dummy-file.rb:1 - Method name \"badMethodName\" should match pattern /^[
|
150
|
+
errors.should_not be_empty
|
151
|
+
errors[0].should eql("dummy-file.rb:1 - Method name \"badMethodName\" should match pattern /^[_a-z<>=\\[\\]|+-\\/\\*`]+[_a-z0-9_<>=~@\\[\\]]*[=!\\?]?$/")
|
152
152
|
end
|
153
153
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: roodi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marty Andrews
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-09-
|
12
|
+
date: 2008-09-11 00:00:00 +10:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -22,6 +22,16 @@ dependencies:
|
|
22
22
|
- !ruby/object:Gem::Version
|
23
23
|
version: "0"
|
24
24
|
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: facets
|
27
|
+
type: :runtime
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: "0"
|
34
|
+
version:
|
25
35
|
- !ruby/object:Gem::Dependency
|
26
36
|
name: hoe
|
27
37
|
type: :development
|
@@ -78,7 +88,7 @@ files:
|
|
78
88
|
- spec/checks/method_name_check_spec.rb
|
79
89
|
- spec/spec_helper.rb
|
80
90
|
has_rdoc: true
|
81
|
-
homepage: http://
|
91
|
+
homepage: http://roodi.rubyforge.org
|
82
92
|
post_install_message:
|
83
93
|
rdoc_options:
|
84
94
|
- --main
|