roodi 3.1.0 → 3.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/History.txt +5 -0
- data/lib/roodi/checks/abc_metric_method_check.rb +6 -9
- data/lib/roodi/checks/check.rb +2 -2
- data/lib/roodi/checks/method_name_check.rb +3 -3
- data/lib/roodi/core/parser.rb +7 -8
- data/lib/roodi/core/runner.rb +1 -1
- data/lib/roodi/core/visitable_sexp.rb +2 -3
- data/lib/roodi/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 791b4df2f1296693e2b3bb3eff9ca6f20e5f42f3
|
4
|
+
data.tar.gz: 3c6cc32ae0aae19f77615c293f59f331d209a076
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cc7d87be26ee71b755ca594122c0fcb95321dd223d16c7c3ea3b0d88756b7d667a6d99b82338f6a36e21df30cc1ecf61c2b9d01496774abcd18c05a15f041090
|
7
|
+
data.tar.gz: e400fb3c7e4a3b66d8992ef43e18b881ddff25d4a51e49da8c000a491ebe15fc365432db646761d7ddcdcf7b9713189fdd374877385903a1262eed8ee95e61a3
|
data/History.txt
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
= 3.1.1
|
2
|
+
* Merge pull request #23 from metricfu/remove_rubygems_require
|
3
|
+
* Fix ruby warnings
|
4
|
+
* Remove unnecessary require of rubygems
|
5
|
+
|
1
6
|
= 3.1.0
|
2
7
|
* Loosen ruby_parser version dependency (PR from Benjamin Fleischer)
|
3
8
|
* Files that can't be parsed are no longer silently skipped
|
@@ -35,23 +35,20 @@ module Roodi
|
|
35
35
|
private
|
36
36
|
|
37
37
|
def count_assignments(node)
|
38
|
-
count = 0
|
39
|
-
|
40
|
-
node.children.each {|node| count += count_assignments(node)}
|
38
|
+
count = assignment?(node) ? 1 : 0
|
39
|
+
node.children.each {|child_node| count += count_assignments(child_node)}
|
41
40
|
count
|
42
41
|
end
|
43
42
|
|
44
43
|
def count_branches(node)
|
45
|
-
count = 0
|
46
|
-
|
47
|
-
node.children.each {|node| count += count_branches(node)}
|
44
|
+
count = branch?(node) ? 1 : 0
|
45
|
+
node.children.each {|child_node| count += count_branches(child_node)}
|
48
46
|
count
|
49
47
|
end
|
50
48
|
|
51
49
|
def count_conditionals(node)
|
52
|
-
count = 0
|
53
|
-
|
54
|
-
node.children.each {|node| count += count_conditionals(node)}
|
50
|
+
count = conditional?(node) ? 1 : 0
|
51
|
+
node.children.each {|child_node| count += count_conditionals(child_node)}
|
55
52
|
count
|
56
53
|
end
|
57
54
|
|
data/lib/roodi/checks/check.rb
CHANGED
@@ -28,8 +28,8 @@ module Roodi
|
|
28
28
|
NODE_TYPES.each do |node|
|
29
29
|
start_node_method = "evaluate_start_#{node}"
|
30
30
|
end_node_method = "evaluate_end_#{node}"
|
31
|
-
define_method(start_node_method) { |
|
32
|
-
define_method(end_node_method) { |
|
31
|
+
define_method(start_node_method) { |start_node| return } unless self.respond_to?(start_node_method)
|
32
|
+
define_method(end_node_method) { |end_node| return } unless self.respond_to?(end_node_method)
|
33
33
|
end
|
34
34
|
|
35
35
|
def position(offset = 0)
|
@@ -3,17 +3,17 @@ require 'roodi/checks/name_check'
|
|
3
3
|
module Roodi
|
4
4
|
module Checks
|
5
5
|
# Checks a method name to make sure it matches the specified pattern.
|
6
|
-
#
|
6
|
+
#
|
7
7
|
# Keeping to a consistent nameing convention makes your code easier to read.
|
8
8
|
class MethodNameCheck < NameCheck
|
9
9
|
|
10
10
|
DEFAULT_PATTERN = /^[_a-z<>=\[|+-\/\*`]+[_a-z0-9_<>=~@\[\]]*[=!\?]?$/
|
11
|
-
|
11
|
+
|
12
12
|
def initialize
|
13
13
|
super()
|
14
14
|
self.pattern = DEFAULT_PATTERN
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
17
|
def interesting_nodes
|
18
18
|
[:defn]
|
19
19
|
end
|
data/lib/roodi/core/parser.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
require 'rubygems'
|
2
1
|
require 'ruby_parser'
|
3
2
|
require 'rbconfig'
|
4
3
|
|
@@ -6,13 +5,13 @@ module Roodi
|
|
6
5
|
module Core
|
7
6
|
class Parser
|
8
7
|
def parse(content, filename)
|
9
|
-
silence_stream(STDERR) do
|
8
|
+
silence_stream(STDERR) do
|
10
9
|
return silent_parse(content, filename)
|
11
10
|
end
|
12
11
|
end
|
13
|
-
|
12
|
+
|
14
13
|
private
|
15
|
-
|
14
|
+
|
16
15
|
def silence_stream(stream)
|
17
16
|
old_stream = stream.dup
|
18
17
|
stream.reopen(null_stream_output)
|
@@ -21,16 +20,16 @@ module Roodi
|
|
21
20
|
ensure
|
22
21
|
stream.reopen(old_stream)
|
23
22
|
end
|
24
|
-
|
23
|
+
|
25
24
|
def silent_parse(content, filename)
|
26
25
|
@parser ||= RubyParser.new
|
27
26
|
@parser.parse(content, filename)
|
28
27
|
end
|
29
|
-
|
28
|
+
|
30
29
|
def null_stream_output
|
31
30
|
null_output_for_platform(RbConfig::CONFIG['host_os'])
|
32
31
|
end
|
33
|
-
|
32
|
+
|
34
33
|
def null_output_for_platform(host_os)
|
35
34
|
case host_os
|
36
35
|
when windows_host_os_matcher
|
@@ -39,7 +38,7 @@ module Roodi
|
|
39
38
|
'/dev/null'
|
40
39
|
end
|
41
40
|
end
|
42
|
-
|
41
|
+
|
43
42
|
def windows_host_os_matcher
|
44
43
|
/mingw|mswin32|cygwin/o
|
45
44
|
end
|
data/lib/roodi/core/runner.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
require 'rubygems'
|
2
1
|
require 'sexp'
|
3
2
|
|
4
3
|
class Sexp
|
@@ -13,11 +12,11 @@ class Sexp
|
|
13
12
|
def children
|
14
13
|
find_all { | sexp | Sexp === sexp }
|
15
14
|
end
|
16
|
-
|
15
|
+
|
17
16
|
def is_language_node?
|
18
17
|
first.class == Symbol
|
19
18
|
end
|
20
|
-
|
19
|
+
|
21
20
|
def visitable_children
|
22
21
|
parent = is_language_node? ? sexp_body : self
|
23
22
|
parent.children
|
data/lib/roodi/version.rb
CHANGED
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: 3.1.
|
4
|
+
version: 3.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marty Andrews
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-08-
|
12
|
+
date: 2013-08-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: ruby_parser
|