Last active
August 29, 2015 14:21
-
-
Save RGBD/0fc6e0377fdefbbf721b to your computer and use it in GitHub Desktop.
Test Parser and RuboCop
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rubocop -V: 0.31.0 (using Parser 2.2.2.2, running on ruby 2.2.1 x86_64-linux) | |
--------------------------------standalone_class-------------------------------- | |
# before class C | |
class C | |
def foo; end | |
end # end class C | |
----------------------------------associations---------------------------------- | |
(class | |
(const nil :C) nil | |
(def :foo | |
(args) nil)) | |
>>> 1: 0:# before class C | |
--------------------------------------cop--------------------------------------- | |
---------------------------------false_positive--------------------------------- | |
module M | |
# before class C | |
class C | |
def foo; end | |
end # end class C | |
end | |
----------------------------------associations---------------------------------- | |
(class | |
(const nil :C) nil | |
(def :foo | |
(args) nil)) | |
>>> 2: 2:# before class C | |
>>> 5: 6:# end class C | |
--------------------------------------cop--------------------------------------- | |
C: 3: 3: Missing top-level class documentation comment. | |
---------------------------------false_negative--------------------------------- | |
module M | |
class C | |
def foo | |
puts 'foo' | |
end | |
end | |
# assigned to class C, shouldn't it be the module comment? | |
end | |
----------------------------------associations---------------------------------- | |
(class | |
(const nil :C) nil | |
(def :foo | |
(args) | |
(send nil :puts | |
(str "foo")))) | |
>>> 7: 2:# assigned to class C, shouldn't it be the module comment? | |
--------------------------------------cop--------------------------------------- | |
-------------------------unoptimal_comment_association-------------------------- | |
# class C before --- C preceding | |
class C < A # C decoration comment | |
# foo method before --- foo method preceding | |
def foo # def C#foo --- decorating | |
puts 'foo' # puts 'foo' --- 'foo' decorating | |
# unrelated comment --- C#foo sparse | |
end # def C#foo end --- foo method decorating | |
def bar | |
puts 'bar' | |
end | |
# unrelated comment --- C sparse | |
end | |
----------------------------------associations---------------------------------- | |
(class | |
(const nil :C) | |
(const nil :A) | |
(begin | |
(def :foo | |
(args) | |
(send nil :puts | |
(str "foo"))) | |
(def :bar | |
(args) | |
(send nil :puts | |
(str "bar"))))) | |
>>> 1: 0:# class C before --- C preceding | |
(const nil :C) | |
>>> 2:12:# C decoration comment | |
(def :foo | |
(args) | |
(send nil :puts | |
(str "foo"))) | |
>>> 3: 2:# foo method before --- foo method preceding | |
>>> 4:10:# def C#foo --- decorating | |
(str "foo") | |
>>> 5:15:# puts 'foo' --- 'foo' decorating | |
(send nil :puts | |
(str "foo")) | |
>>> 6: 4:# unrelated comment --- C#foo sparse | |
(def :bar | |
(args) | |
(send nil :puts | |
(str "bar"))) | |
>>> 7: 6:# def C#foo end --- foo method decorating | |
(begin | |
(def :foo | |
(args) | |
(send nil :puts | |
(str "foo"))) | |
(def :bar | |
(args) | |
(send nil :puts | |
(str "bar")))) | |
>>>13: 2:# unrelated comment --- C sparse | |
--------------------------------------cop--------------------------------------- | |
----------------------------------huge_example---------------------------------- | |
# module M before | |
module M # module M | |
# class C before | |
class C # class C | |
def foo # def C#foo | |
puts 'foo' # puts 'foo' | |
end # def C#foo end | |
end # class end C | |
# middle comment belongs to next node | |
# class D before | |
class D # class D | |
def bar # def D#bar | |
puts 'bar' # puts 'bar' | |
# D#bar before end | |
end # def D#bar end | |
# class D before end | |
end # class D end | |
# module M before end comment | |
end | |
----------------------------------associations---------------------------------- | |
(module | |
(const nil :M) | |
(begin | |
(class | |
(const nil :C) nil | |
(def :foo | |
(args) | |
(send nil :puts | |
(str "foo")))) | |
(class | |
(const nil :D) nil | |
(def :bar | |
(args) | |
(send nil :puts | |
(str "bar")))))) | |
>>> 1: 0:# module M before | |
(const nil :M) | |
>>> 2: 9:# module M | |
(class | |
(const nil :C) nil | |
(def :foo | |
(args) | |
(send nil :puts | |
(str "foo")))) | |
>>> 3: 2:# class C before | |
(const nil :C) | |
>>> 4:10:# class C | |
(def :foo | |
(args) | |
(send nil :puts | |
(str "foo"))) | |
>>> 5:12:# def C#foo | |
>>> 7: 8:# def C#foo end | |
(str "foo") | |
>>> 6:17:# puts 'foo' | |
(class | |
(const nil :D) nil | |
(def :bar | |
(args) | |
(send nil :puts | |
(str "bar")))) | |
>>> 8: 6:# class end C | |
>>>10: 2:# middle comment belongs to next node | |
>>>12: 2:# class D before | |
(const nil :D) | |
>>>13:10:# class D | |
(def :bar | |
(args) | |
(send nil :puts | |
(str "bar"))) | |
>>>14:12:# def D#bar | |
>>>17: 8:# def D#bar end | |
>>>18: 4:# class D before end | |
(str "bar") | |
>>>15:17:# puts 'bar' | |
(send nil :puts | |
(str "bar")) | |
>>>16: 6:# D#bar before end | |
(begin | |
(class | |
(const nil :C) nil | |
(def :foo | |
(args) | |
(send nil :puts | |
(str "foo")))) | |
(class | |
(const nil :D) nil | |
(def :bar | |
(args) | |
(send nil :puts | |
(str "bar"))))) | |
>>>19: 6:# class D end | |
>>>21: 2:# module M before end comment | |
--------------------------------------cop--------------------------------------- | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rubocop -V: 0.31.0 (using Parser 2.2.2.2, running on ruby 2.2.1 x86_64-linux) | |
--------------------------------standalone_class-------------------------------- | |
# before class C | |
class C | |
def foo; end | |
end # end class C | |
----------------------------------associations---------------------------------- | |
(class | |
(const nil :C) nil | |
(def :foo | |
(args) nil)) | |
>>> 1: 0:# before class C | |
>>> 4: 4:# end class C | |
--------------------------------------cop--------------------------------------- | |
---------------------------------false_positive--------------------------------- | |
module M | |
# before class C | |
class C | |
def foo; end | |
end # end class C | |
end | |
----------------------------------associations---------------------------------- | |
(class | |
(const nil :C) nil | |
(def :foo | |
(args) nil)) | |
>>> 2: 2:# before class C | |
>>> 5: 6:# end class C | |
--------------------------------------cop--------------------------------------- | |
---------------------------------false_negative--------------------------------- | |
module M | |
class C | |
def foo | |
puts 'foo' | |
end | |
end | |
# assigned to class C, shouldn't it be the module comment? | |
end | |
----------------------------------associations---------------------------------- | |
(module | |
(const nil :M) | |
(class | |
(const nil :C) nil | |
(def :foo | |
(args) | |
(send nil :puts | |
(str "foo"))))) | |
>>> 7: 2:# assigned to class C, shouldn't it be the module comment? | |
--------------------------------------cop--------------------------------------- | |
C: 2: 3: Missing top-level class documentation comment. | |
-------------------------unoptimal_comment_association-------------------------- | |
# class C before --- C preceding | |
class C < A # C decoration comment | |
# foo method before --- foo method preceding | |
def foo # def C#foo --- decorating | |
puts 'foo' # puts 'foo' --- 'foo' decorating | |
# unrelated comment --- C#foo sparse | |
end # def C#foo end --- foo method decorating | |
def bar | |
puts 'bar' | |
end | |
# unrelated comment --- C sparse | |
end | |
----------------------------------associations---------------------------------- | |
(class | |
(const nil :C) | |
(const nil :A) | |
(begin | |
(def :foo | |
(args) | |
(send nil :puts | |
(str "foo"))) | |
(def :bar | |
(args) | |
(send nil :puts | |
(str "bar"))))) | |
>>> 1: 0:# class C before --- C preceding | |
>>>13: 2:# unrelated comment --- C sparse | |
(const nil :C) | |
>>> 2:12:# C decoration comment | |
(def :foo | |
(args) | |
(send nil :puts | |
(str "foo"))) | |
>>> 3: 2:# foo method before --- foo method preceding | |
>>> 4:10:# def C#foo --- decorating | |
>>> 6: 4:# unrelated comment --- C#foo sparse | |
>>> 7: 6:# def C#foo end --- foo method decorating | |
(str "foo") | |
>>> 5:15:# puts 'foo' --- 'foo' decorating | |
--------------------------------------cop--------------------------------------- | |
----------------------------------huge_example---------------------------------- | |
# module M before | |
module M # module M | |
# class C before | |
class C # class C | |
def foo # def C#foo | |
puts 'foo' # puts 'foo' | |
end # def C#foo end | |
end # class end C | |
# middle comment belongs to next node | |
# class D before | |
class D # class D | |
def bar # def D#bar | |
puts 'bar' # puts 'bar' | |
# D#bar before end | |
end # def D#bar end | |
# class D before end | |
end # class D end | |
# module M before end comment | |
end | |
----------------------------------associations---------------------------------- | |
(module | |
(const nil :M) | |
(begin | |
(class | |
(const nil :C) nil | |
(def :foo | |
(args) | |
(send nil :puts | |
(str "foo")))) | |
(class | |
(const nil :D) nil | |
(def :bar | |
(args) | |
(send nil :puts | |
(str "bar")))))) | |
>>> 1: 0:# module M before | |
>>>21: 2:# module M before end comment | |
(const nil :M) | |
>>> 2: 9:# module M | |
(class | |
(const nil :C) nil | |
(def :foo | |
(args) | |
(send nil :puts | |
(str "foo")))) | |
>>> 3: 2:# class C before | |
>>> 8: 6:# class end C | |
(const nil :C) | |
>>> 4:10:# class C | |
(def :foo | |
(args) | |
(send nil :puts | |
(str "foo"))) | |
>>> 5:12:# def C#foo | |
>>> 7: 8:# def C#foo end | |
(str "foo") | |
>>> 6:17:# puts 'foo' | |
(class | |
(const nil :D) nil | |
(def :bar | |
(args) | |
(send nil :puts | |
(str "bar")))) | |
>>>10: 2:# middle comment belongs to next node | |
>>>12: 2:# class D before | |
>>>18: 4:# class D before end | |
>>>19: 6:# class D end | |
(const nil :D) | |
>>>13:10:# class D | |
(def :bar | |
(args) | |
(send nil :puts | |
(str "bar"))) | |
>>>14:12:# def D#bar | |
>>>16: 6:# D#bar before end | |
>>>17: 8:# def D#bar end | |
(str "bar") | |
>>>15:17:# puts 'bar' | |
--------------------------------------cop--------------------------------------- | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rubocop -V: 0.31.0 (using Parser 2.2.2.2, running on ruby 2.2.1 x86_64-linux) | |
--------------------------------standalone_class-------------------------------- | |
# before class C | |
class C | |
def foo; end | |
end # end class C | |
----------------------------------associations---------------------------------- | |
(class | |
(const nil :C) nil | |
(def :foo | |
(args) nil)) | |
>>> 1: 0:# before class C | |
>>> 4: 4:# end class C | |
--------------------------------------cop--------------------------------------- | |
C: 2: 1: Missing top-level class documentation comment. | |
---------------------------------false_positive--------------------------------- | |
module M | |
# before class C | |
class C | |
def foo; end | |
end # end class C | |
end | |
----------------------------------associations---------------------------------- | |
(class | |
(const nil :C) nil | |
(def :foo | |
(args) nil)) | |
>>> 2: 2:# before class C | |
>>> 5: 6:# end class C | |
--------------------------------------cop--------------------------------------- | |
C: 3: 3: Missing top-level class documentation comment. | |
---------------------------------false_negative--------------------------------- | |
module M | |
class C | |
def foo | |
puts 'foo' | |
end | |
end | |
# assigned to class C, shouldn't it be the module comment? | |
end | |
----------------------------------associations---------------------------------- | |
(module | |
(const nil :M) | |
(class | |
(const nil :C) nil | |
(def :foo | |
(args) | |
(send nil :puts | |
(str "foo"))))) | |
>>> 7: 2:# assigned to class C, shouldn't it be the module comment? | |
--------------------------------------cop--------------------------------------- | |
C: 2: 3: Missing top-level class documentation comment. | |
-------------------------unoptimal_comment_association-------------------------- | |
# class C before --- C preceding | |
class C < A # C decoration comment | |
# foo method before --- foo method preceding | |
def foo # def C#foo --- decorating | |
puts 'foo' # puts 'foo' --- 'foo' decorating | |
# unrelated comment --- C#foo sparse | |
end # def C#foo end --- foo method decorating | |
def bar | |
puts 'bar' | |
end | |
# unrelated comment --- C sparse | |
end | |
----------------------------------associations---------------------------------- | |
(class | |
(const nil :C) | |
(const nil :A) | |
(begin | |
(def :foo | |
(args) | |
(send nil :puts | |
(str "foo"))) | |
(def :bar | |
(args) | |
(send nil :puts | |
(str "bar"))))) | |
>>> 1: 0:# class C before --- C preceding | |
>>>13: 2:# unrelated comment --- C sparse | |
(const nil :C) | |
>>> 2:12:# C decoration comment | |
(def :foo | |
(args) | |
(send nil :puts | |
(str "foo"))) | |
>>> 3: 2:# foo method before --- foo method preceding | |
>>> 4:10:# def C#foo --- decorating | |
>>> 6: 4:# unrelated comment --- C#foo sparse | |
>>> 7: 6:# def C#foo end --- foo method decorating | |
(str "foo") | |
>>> 5:15:# puts 'foo' --- 'foo' decorating | |
--------------------------------------cop--------------------------------------- | |
----------------------------------huge_example---------------------------------- | |
# module M before | |
module M # module M | |
# class C before | |
class C # class C | |
def foo # def C#foo | |
puts 'foo' # puts 'foo' | |
end # def C#foo end | |
end # class end C | |
# middle comment belongs to next node | |
# class D before | |
class D # class D | |
def bar # def D#bar | |
puts 'bar' # puts 'bar' | |
# D#bar before end | |
end # def D#bar end | |
# class D before end | |
end # class D end | |
# module M before end comment | |
end | |
----------------------------------associations---------------------------------- | |
(module | |
(const nil :M) | |
(begin | |
(class | |
(const nil :C) nil | |
(def :foo | |
(args) | |
(send nil :puts | |
(str "foo")))) | |
(class | |
(const nil :D) nil | |
(def :bar | |
(args) | |
(send nil :puts | |
(str "bar")))))) | |
>>> 1: 0:# module M before | |
>>>21: 2:# module M before end comment | |
(const nil :M) | |
>>> 2: 9:# module M | |
(class | |
(const nil :C) nil | |
(def :foo | |
(args) | |
(send nil :puts | |
(str "foo")))) | |
>>> 3: 2:# class C before | |
>>> 8: 6:# class end C | |
(const nil :C) | |
>>> 4:10:# class C | |
(def :foo | |
(args) | |
(send nil :puts | |
(str "foo"))) | |
>>> 5:12:# def C#foo | |
>>> 7: 8:# def C#foo end | |
(str "foo") | |
>>> 6:17:# puts 'foo' | |
(class | |
(const nil :D) nil | |
(def :bar | |
(args) | |
(send nil :puts | |
(str "bar")))) | |
>>>10: 2:# middle comment belongs to next node | |
>>>12: 2:# class D before | |
>>>18: 4:# class D before end | |
>>>19: 6:# class D end | |
(const nil :D) | |
>>>13:10:# class D | |
(def :bar | |
(args) | |
(send nil :puts | |
(str "bar"))) | |
>>>14:12:# def D#bar | |
>>>16: 6:# D#bar before end | |
>>>17: 8:# def D#bar end | |
(str "bar") | |
>>>15:17:# puts 'bar' | |
--------------------------------------cop--------------------------------------- | |
C: 4: 3: Missing top-level class documentation comment. | |
C: 13: 3: Missing top-level class documentation comment. | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rubocop -V: 0.31.0 (using Parser 2.2.2.2, running on ruby 2.2.1 x86_64-linux) | |
--------------------------------standalone_class-------------------------------- | |
# before class C | |
class C | |
def foo; end | |
end # end class C | |
----------------------------------associations---------------------------------- | |
(class | |
(const nil :C) nil | |
(def :foo | |
(args) nil)) | |
>>> 1: 0:# before class C | |
--------------------------------------cop--------------------------------------- | |
---------------------------------false_positive--------------------------------- | |
module M | |
# before class C | |
class C | |
def foo; end | |
end # end class C | |
end | |
----------------------------------associations---------------------------------- | |
(class | |
(const nil :C) nil | |
(def :foo | |
(args) nil)) | |
>>> 2: 2:# before class C | |
>>> 5: 6:# end class C | |
--------------------------------------cop--------------------------------------- | |
---------------------------------false_negative--------------------------------- | |
module M | |
class C | |
def foo | |
puts 'foo' | |
end | |
end | |
# assigned to class C, shouldn't it be the module comment? | |
end | |
----------------------------------associations---------------------------------- | |
(class | |
(const nil :C) nil | |
(def :foo | |
(args) | |
(send nil :puts | |
(str "foo")))) | |
>>> 7: 2:# assigned to class C, shouldn't it be the module comment? | |
--------------------------------------cop--------------------------------------- | |
C: 2: 3: Missing top-level class documentation comment. | |
-------------------------unoptimal_comment_association-------------------------- | |
# class C before --- C preceding | |
class C < A # C decoration comment | |
# foo method before --- foo method preceding | |
def foo # def C#foo --- decorating | |
puts 'foo' # puts 'foo' --- 'foo' decorating | |
# unrelated comment --- C#foo sparse | |
end # def C#foo end --- foo method decorating | |
def bar | |
puts 'bar' | |
end | |
# unrelated comment --- C sparse | |
end | |
----------------------------------associations---------------------------------- | |
(class | |
(const nil :C) | |
(const nil :A) | |
(begin | |
(def :foo | |
(args) | |
(send nil :puts | |
(str "foo"))) | |
(def :bar | |
(args) | |
(send nil :puts | |
(str "bar"))))) | |
>>> 1: 0:# class C before --- C preceding | |
(const nil :C) | |
>>> 2:12:# C decoration comment | |
(def :foo | |
(args) | |
(send nil :puts | |
(str "foo"))) | |
>>> 3: 2:# foo method before --- foo method preceding | |
>>> 4:10:# def C#foo --- decorating | |
(str "foo") | |
>>> 5:15:# puts 'foo' --- 'foo' decorating | |
(send nil :puts | |
(str "foo")) | |
>>> 6: 4:# unrelated comment --- C#foo sparse | |
(def :bar | |
(args) | |
(send nil :puts | |
(str "bar"))) | |
>>> 7: 6:# def C#foo end --- foo method decorating | |
(begin | |
(def :foo | |
(args) | |
(send nil :puts | |
(str "foo"))) | |
(def :bar | |
(args) | |
(send nil :puts | |
(str "bar")))) | |
>>>13: 2:# unrelated comment --- C sparse | |
--------------------------------------cop--------------------------------------- | |
----------------------------------huge_example---------------------------------- | |
# module M before | |
module M # module M | |
# class C before | |
class C # class C | |
def foo # def C#foo | |
puts 'foo' # puts 'foo' | |
end # def C#foo end | |
end # class end C | |
# middle comment belongs to next node | |
# class D before | |
class D # class D | |
def bar # def D#bar | |
puts 'bar' # puts 'bar' | |
# D#bar before end | |
end # def D#bar end | |
# class D before end | |
end # class D end | |
# module M before end comment | |
end | |
----------------------------------associations---------------------------------- | |
(module | |
(const nil :M) | |
(begin | |
(class | |
(const nil :C) nil | |
(def :foo | |
(args) | |
(send nil :puts | |
(str "foo")))) | |
(class | |
(const nil :D) nil | |
(def :bar | |
(args) | |
(send nil :puts | |
(str "bar")))))) | |
>>> 1: 0:# module M before | |
(const nil :M) | |
>>> 2: 9:# module M | |
(class | |
(const nil :C) nil | |
(def :foo | |
(args) | |
(send nil :puts | |
(str "foo")))) | |
>>> 3: 2:# class C before | |
(const nil :C) | |
>>> 4:10:# class C | |
(def :foo | |
(args) | |
(send nil :puts | |
(str "foo"))) | |
>>> 5:12:# def C#foo | |
>>> 7: 8:# def C#foo end | |
(str "foo") | |
>>> 6:17:# puts 'foo' | |
(class | |
(const nil :D) nil | |
(def :bar | |
(args) | |
(send nil :puts | |
(str "bar")))) | |
>>> 8: 6:# class end C | |
>>>10: 2:# middle comment belongs to next node | |
>>>12: 2:# class D before | |
(const nil :D) | |
>>>13:10:# class D | |
(def :bar | |
(args) | |
(send nil :puts | |
(str "bar"))) | |
>>>14:12:# def D#bar | |
>>>17: 8:# def D#bar end | |
>>>18: 4:# class D before end | |
(str "bar") | |
>>>15:17:# puts 'bar' | |
(send nil :puts | |
(str "bar")) | |
>>>16: 6:# D#bar before end | |
(begin | |
(class | |
(const nil :C) nil | |
(def :foo | |
(args) | |
(send nil :puts | |
(str "foo")))) | |
(class | |
(const nil :D) nil | |
(def :bar | |
(args) | |
(send nil :puts | |
(str "bar"))))) | |
>>>19: 6:# class D end | |
>>>21: 2:# module M before end comment | |
--------------------------------------cop--------------------------------------- | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module M | |
# top-level class documentation comment | |
class C | |
def foo; end | |
end # class ending comment, the troublemaker | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'pp' | |
require 'parser/current' | |
require 'rubocop' | |
puts 'rubocop -V: ' + `rubocop -V` | |
code = {} | |
code[:standalone_class] = <<-CODE | |
# before class C | |
class C | |
def foo; end | |
end # end class C | |
CODE | |
code[:false_positive] = <<-CODE | |
module M | |
# before class C | |
class C | |
def foo; end | |
end # end class C | |
end | |
CODE | |
code[:false_negative] = <<-CODE | |
module M | |
class C | |
def foo | |
puts 'foo' | |
end | |
end | |
# assigned to class C, shouldn't it be the module comment? | |
end | |
CODE | |
code[:unoptimal_comment_association] = <<-CODE | |
# class C before --- C preceding | |
class C < A # C decoration comment | |
# foo method before --- foo method preceding | |
def foo # def C#foo --- decorating | |
puts 'foo' # puts 'foo' --- 'foo' decorating | |
# unrelated comment --- C#foo sparse | |
end # def C#foo end --- foo method decorating | |
def bar | |
puts 'bar' | |
end | |
# unrelated comment --- C sparse | |
end | |
CODE | |
code[:huge_example] = <<-CODE | |
# module M before | |
module M # module M | |
# class C before | |
class C # class C | |
def foo # def C#foo | |
puts 'foo' # puts 'foo' | |
end # def C#foo end | |
end # class end C | |
# middle comment belongs to next node | |
# class D before | |
class D # class D | |
def bar # def D#bar | |
puts 'bar' # puts 'bar' | |
# D#bar before end | |
end # def D#bar end | |
# class D before end | |
end # class D end | |
# module M before end comment | |
end | |
CODE | |
def inspect_rubocop(source) | |
config = RuboCop::Config.new('Style/CommentAnnotation' => { | |
'Keywords' => %w(TODO FIXME OPTIMIZE HACK REVIEW) | |
}) | |
cop = RuboCop::Cop::Style::Documentation.new(config) | |
processed_source = RuboCop::ProcessedSource.new(source, nil) | |
fail 'Error parsing example code' unless processed_source.valid_syntax? | |
cop.investigate(processed_source) | |
cop.offenses.each do |offence| | |
puts offence | |
end | |
end | |
def inspect_parser(code) | |
ast, comments = Parser::CurrentRuby.parse_with_comments(code) | |
Parser::Source::Comment.associate_locations(ast, comments).each_pair do |k, v| | |
pp k.node | |
v.each do |c| | |
puts '>>>' + [c.loc.line, c.loc.column, c.text] | |
.map { |x| x.to_s.rjust(2) }.join(':') | |
end | |
end | |
end | |
code.each_pair do |name, source| | |
puts name.to_s.center(80, '-') | |
puts source | |
puts 'associations'.center(80, '-') | |
inspect_parser(source) | |
puts 'cop'.center(80, '-') | |
inspect_rubocop(source) | |
puts | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment