codegram/pelusa — Issue #22: Analyzer is skipping Modules definitions
Author: mmullis
Created: 2012-03-01 04:25:11+00:00
State: open

Hi.
I think the analyzer is skipping over module definitions.
Below is a sample patch to include them however, it's not quite right.
The same checks get reported for all nested modules. Perhaps someone that knows the code can resolve that.
thanks,
michael.

diff --git a/lib/pelusa/analyzer.rb b/lib/pelusa/analyzer.rb
index a22302f..e1a7c22 100644
--- a/lib/pelusa/analyzer.rb
+++ b/lib/pelusa/analyzer.rb
@@ -39,7 +39,7 @@ module Pelusa
def extract_classes(ast)
classes = []
class_iterator = Iterator.new do |node|
- classes << node if node.is_a?(Rubinius::AST::Class)
+ classes << node if node.is_a?(Rubinius::AST::Class) || node.is_a?(Rubinius::AST::Module)
end
Array(ast).each(&class_iterator)
classes

=======
Example Source: module_sample.rb

module OuterModules
module InnerModule
def self.do_it(e, v, a_value, b_value)
puts "hello"
end
end
end

Without the patch,
RBXOPT=-X19 pelusa module_sample.rb
ϟ Pelusa ϟ
----------

With the patch:
RBXOPT=-X19 pelusa module_sample.rb
ϟ Pelusa ϟ
----------
module_sample.rb

class OuterModules
✿ Is below 50 lines ✓
✿ Uses less than 3 ivars ✓
✿ Respects Demeter law ✓
✿ Doesn't use more than one indentation level inside methods ✓
✿ Doesn't use else clauses ✓
✿ Doesn't use getters, setters or properties ✓
✿ Doesn't mix array instance variables with others ✓
✿ Uses descriptive names ✓
✿ Methods have short argument lists ✗
Methods with more than 3 arguments: do_it

class InnerModule
✿ Is below 50 lines ✓
✿ Uses less than 3 ivars ✓
✿ Respects Demeter law ✓
✿ Doesn't use more than one indentation level inside methods ✓
✿ Doesn't use else clauses ✓
✿ Doesn't use getters, setters or properties ✓
✿ Doesn't mix array instance variables with others ✓
✿ Uses descriptive names ✓
✿ Methods have short argument lists ✗
Methods with more than 3 arguments: do_it