pelusa 0.2.3 → 0.2.4

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.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- YjA3NTU1ZWZkNGViYTBmNTFhMmJmNGQ1MDZlNjQxNjcwYTJkMTA1ZQ==
5
- data.tar.gz: !binary |-
6
- NzEzMmJlNmE5N2ZhYTE3MjgyODMzMDgxMmEyMjYxMmFhYmZlZjBjOA==
7
- !binary "U0hBNTEy":
8
- metadata.gz: !binary |-
9
- MjFmZmQyNzRiZWI3YjU0ZjE1MTNkNjViMmE5YTFiMzEwMjhiYWU1MGNiMWVi
10
- YTI1ZDhiMjkwZjYyNjBhNGJhMThlOGQ0ZjE4M2FmMDBhZjhmNWQwMjRiNTBk
11
- ZDgwOGQ5NzAzZmFiNTdkOTMwMTBmNmNhMWUwMDc4ZjIyMmI0OTM=
12
- data.tar.gz: !binary |-
13
- ODI4ZGVkOWE5MTgzMzdiOWYyNmNmYzMxZTNkOTRhY2E4M2FjNGQyOTRlYTg4
14
- NDhmOTVkMWI0OWJkZTlmNjk3MjViNWEzMmUxYTRhMzMxNzQ5ZmY4ZWNjYTk5
15
- OWQxOGUzZjFjZTQyNmI1OWZkODE3YjRkODUwNDkzMzgzY2RjY2I=
2
+ SHA1:
3
+ metadata.gz: 113e730ed13c034f23af12fe5991429d700e4849
4
+ data.tar.gz: eb5bcf324e5fc9de0ae2ae3c1b0a4605699122ae
5
+ SHA512:
6
+ metadata.gz: 036db9f609c809992c3790b5988a3aa7ff5566d86cc6658cde3ba89af0884525a0f2e8268567d781be43ce034c4d09f366d50b6e6dcd1644be937c951def37e8
7
+ data.tar.gz: 948f926c35f9e580571db450b91c15103e1c6c106b0ab691efa1f7e93b58bdc9cdbed9f73c5c4d2b4713197295083b9e0d8791107c2335b2b73534e248b7ab7f
data/.gitignore CHANGED
@@ -3,3 +3,4 @@
3
3
  Gemfile.lock
4
4
  pkg/*
5
5
  .rbx
6
+ .ruby-version
@@ -1,4 +1,2 @@
1
- env:
2
- - RBXOPT=-X19
3
1
  rvm:
4
- - rbx
2
+ - rbx-2.2.6
data/Gemfile CHANGED
@@ -3,5 +3,5 @@ source "http://rubygems.org"
3
3
  # Specify your gem's dependencies in pelusa.gemspec
4
4
  gemspec
5
5
  gem 'rake'
6
-
6
+ gem 'rubinius-melbourne'
7
7
  gem 'minitest'
data/bin/pelusa CHANGED
@@ -1,12 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
  $:.unshift(File.dirname(__FILE__) + '/../lib')
3
3
 
4
- warning = %q{Pelusa needs Rubinius to run in 1.9 mode.
5
- Please either `export RBXOPT=-X19` before running it or compile Rubinius with
6
- 1.9 support enabled by default.}
7
-
8
- abort warning unless Rubinius.ruby19?
9
-
10
4
  require 'pelusa'
11
5
 
12
6
  cli = Pelusa::Cli.new(ARGV)
@@ -39,12 +39,12 @@ module Pelusa
39
39
  # Returns an Array of Class nodes.
40
40
  def extract_classes(ast)
41
41
  classes = []
42
- if ast.is_a?(Rubinius::AST::Class) || ast.is_a?(Rubinius::AST::Module)
42
+ if ast.is_a?(Rubinius::ToolSets::Runtime::ToolSet::AST::Class) || ast.is_a?(Rubinius::ToolSets::Runtime::ToolSet::AST::Module)
43
43
  classes << ast
44
44
  end
45
45
 
46
46
  ast.walk do |continue, node|
47
- if node.is_a?(Rubinius::AST::Class) || node.is_a?(Rubinius::AST::Module)
47
+ if node.is_a?(Rubinius::ToolSets::Runtime::ToolSet::AST::Class) || node.is_a?(Rubinius::ToolSets::Runtime::ToolSet::AST::Module)
48
48
  classes << node
49
49
  end
50
50
  true
@@ -16,7 +16,7 @@ class Pelusa::ClassAnalyzer
16
16
 
17
17
  # Public: Returns the type of container being examined (class or module).
18
18
  def type
19
- @klass.is_a?(Rubinius::AST::Class) ? "class" : "module"
19
+ @klass.is_a?(Rubinius::ToolSets::Runtime::ToolSet::AST::Class) ? "class" : "module"
20
20
  end
21
21
 
22
22
  # Public: Analyzes a class with a series of lints.
@@ -23,7 +23,7 @@ module Pelusa
23
23
 
24
24
  def iterate_lines!(klass)
25
25
  ClassAnalyzer.walk(klass) do |node|
26
- if node.is_a?(Rubinius::AST::Case)
26
+ if node.is_a?(Rubinius::ToolSets::Runtime::ToolSet::AST::Case)
27
27
  @violations << node.line
28
28
  end
29
29
  end
@@ -28,9 +28,9 @@ module Pelusa
28
28
  array_values = {}
29
29
 
30
30
  ClassAnalyzer.walk(klass) do |node|
31
- if node.is_a?(Rubinius::AST::InstanceVariableAssignment) &&
32
- (node.value.is_a?(Rubinius::AST::ArrayLiteral) ||
33
- node.value.is_a?(Rubinius::AST::EmptyArray))
31
+ if node.is_a?(Rubinius::ToolSets::Runtime::ToolSet::AST::InstanceVariableAssignment) &&
32
+ (node.value.is_a?(Rubinius::ToolSets::Runtime::ToolSet::AST::ArrayLiteral) ||
33
+ node.value.is_a?(Rubinius::ToolSets::Runtime::ToolSet::AST::EmptyArray))
34
34
  array_assignments[node] = true
35
35
  array_values[node.name] = true
36
36
  end
@@ -41,10 +41,10 @@ module Pelusa
41
41
  # if this is where we assign the node for the first time, good
42
42
  unless array_assignments[node]
43
43
  # otherwise, if it's an instance variable assignment, verboten!
44
- if node.is_a?(Rubinius::AST::InstanceVariableAssignment)
44
+ if node.is_a?(Rubinius::ToolSets::Runtime::ToolSet::AST::InstanceVariableAssignment)
45
45
  @violations << node.line
46
46
  # or if we access any other ivars
47
- elsif node.is_a?(Rubinius::AST::InstanceVariableAccess) &&
47
+ elsif node.is_a?(Rubinius::ToolSets::Runtime::ToolSet::AST::InstanceVariableAccess) &&
48
48
  !array_values[node.name]
49
49
  @violations << node.line
50
50
  end
@@ -23,7 +23,7 @@ module Pelusa
23
23
 
24
24
  def iterate_lines!(klass)
25
25
  ClassAnalyzer.walk(klass) do |node|
26
- if node.is_a?(Rubinius::AST::Send) && node.receiver.is_a?(Rubinius::AST::Send)
26
+ if node.is_a?(Rubinius::ToolSets::Runtime::ToolSet::AST::Send) && node.receiver.is_a?(Rubinius::ToolSets::Runtime::ToolSet::AST::Send)
27
27
  @violations << node.line unless white_listed?(node.receiver.name)
28
28
  end
29
29
  end
@@ -23,9 +23,9 @@ module Pelusa
23
23
 
24
24
  def iterate_lines!(klass)
25
25
  ClassAnalyzer.walk(klass) do |node|
26
- if node.is_a?(Rubinius::AST::If)
27
- has_body = node.body && !node.body.is_a?(Rubinius::AST::NilLiteral)
28
- has_else = node.else && !node.else.is_a?(Rubinius::AST::NilLiteral)
26
+ if node.is_a?(Rubinius::ToolSets::Runtime::ToolSet::AST::If)
27
+ has_body = node.body && !node.body.is_a?(Rubinius::ToolSets::Runtime::ToolSet::AST::NilLiteral)
28
+ has_else = node.else && !node.else.is_a?(Rubinius::ToolSets::Runtime::ToolSet::AST::NilLiteral)
29
29
 
30
30
  if has_body && has_else
31
31
  @violations << node.else.line
@@ -32,7 +32,7 @@ module Pelusa
32
32
  end
33
33
 
34
34
  def eval_violation?(node)
35
- node.is_a?(Rubinius::AST::SendWithArguments) && node.name == :eval && node.receiver.is_a?(Rubinius::AST::Self)
35
+ node.is_a?(Rubinius::ToolSets::Runtime::ToolSet::AST::SendWithArguments) && node.name == :eval && node.receiver.is_a?(Rubinius::ToolSets::Runtime::ToolSet::AST::Self)
36
36
  end
37
37
 
38
38
  end
@@ -26,7 +26,7 @@ module Pelusa
26
26
  # contain > 1 indentation levels
27
27
  # this method totally fails the IndentationLevel level lint :P
28
28
  ClassAnalyzer.walk(klass) do |node|
29
- if node.is_a?(Rubinius::AST::Define)
29
+ if node.is_a?(Rubinius::ToolSets::Runtime::ToolSet::AST::Define)
30
30
  # we're inside a method body, so see if we indent anywhere
31
31
  ClassAnalyzer.walk(node) do |inner_node|
32
32
  if inner_body = get_body_from_node[inner_node]
@@ -53,7 +53,7 @@ module Pelusa
53
53
 
54
54
  def get_body_from_node
55
55
  lambda do |node|
56
- if node.respond_to?(:body) && !node.body.is_a?(Rubinius::AST::NilLiteral)
56
+ if node.respond_to?(:body) && !node.body.is_a?(Rubinius::ToolSets::Runtime::ToolSet::AST::NilLiteral)
57
57
  node.body
58
58
  elsif node.respond_to?(:else)
59
59
  node.else
@@ -27,7 +27,7 @@ module Pelusa
27
27
 
28
28
  def iterate_lines!(klass)
29
29
  ClassAnalyzer.walk(klass) do |node|
30
- if node.is_a?(Rubinius::AST::InstanceVariableAccess) || node.is_a?(Rubinius::AST::InstanceVariableAssignment)
30
+ if node.is_a?(Rubinius::ToolSets::Runtime::ToolSet::AST::InstanceVariableAccess) || node.is_a?(Rubinius::ToolSets::Runtime::ToolSet::AST::InstanceVariableAssignment)
31
31
  @ivars << node.name
32
32
  end
33
33
  end
@@ -27,7 +27,7 @@ module Pelusa
27
27
 
28
28
  def iterate_lines!(klass)
29
29
  ClassAnalyzer.walk(klass) do |node|
30
- if node.is_a?(Rubinius::AST::Define) && node.arguments.total_args > limit
30
+ if node.is_a?(Rubinius::ToolSets::Runtime::ToolSet::AST::Define) && node.arguments.total_args > limit
31
31
  @violations << node.name
32
32
  end
33
33
  end
@@ -23,7 +23,7 @@ module Pelusa
23
23
 
24
24
  def iterate_lines!(klass)
25
25
  ClassAnalyzer.walk(klass) do |node|
26
- if node.is_a?(Rubinius::AST::Send)
26
+ if node.is_a?(Rubinius::ToolSets::Runtime::ToolSet::AST::Send)
27
27
  if [:attr_accessor, :attr_writer, :attr_reader].include? node.name
28
28
  @violations << node.line
29
29
  end
@@ -36,7 +36,7 @@ module Pelusa
36
36
  #
37
37
  # Returns a Rubinius::Melbourne parser.
38
38
  def parser
39
- Rubinius::Melbourne19
39
+ ::Rubinius::ToolSets.current::ToolSet::Melbourne
40
40
  end
41
41
  end
42
42
  end
@@ -1,3 +1,3 @@
1
1
  module Pelusa
2
- VERSION = "0.2.3"
2
+ VERSION = "0.2.4"
3
3
  end
@@ -5,7 +5,7 @@ module Pelusa
5
5
  describe '#analyze' do
6
6
  describe 'with a multi-expression AST' do
7
7
  before do
8
- @ast = """
8
+ @ast = Pelusa.to_ast """
9
9
  class Foo
10
10
  def bar
11
11
  123
@@ -23,7 +23,7 @@ module Pelusa
23
23
  2.7
24
24
  end
25
25
  end
26
- """.to_ast
26
+ """
27
27
 
28
28
  lints = stub
29
29
  @analyzer = Analyzer.new([Lint::LineRestriction], RubyReporter, "foo.rb")
@@ -40,13 +40,13 @@ module Pelusa
40
40
 
41
41
  describe 'with a single-expression AST' do
42
42
  before do
43
- @ast = """
43
+ @ast = Pelusa.to_ast """
44
44
  class Foo
45
45
  def bar
46
46
  123
47
47
  end
48
48
  end
49
- """.to_ast
49
+ """
50
50
 
51
51
  lints = stub
52
52
  @analyzer = Analyzer.new([Lint::LineRestriction], RubyReporter, "foo.rb")
@@ -25,13 +25,13 @@ module Pelusa
25
25
  describe "#type" do
26
26
  it "returns the type module for modules" do
27
27
  # hacky!
28
- @klass.stubs(:is_a?).with(Rubinius::AST::Class).returns(true)
28
+ @klass.stubs(:is_a?).with(Rubinius::ToolSets::Runtime::ToolSet::AST::Class).returns(true)
29
29
  @analyzer.type.must_equal "class"
30
30
  end
31
31
 
32
32
  it "returns the type module for modules" do
33
33
  # hacky!
34
- @klass.stubs(:is_a?).with(Rubinius::AST::Class).returns(false)
34
+ @klass.stubs(:is_a?).with(Rubinius::ToolSets::Runtime::ToolSet::AST::Class).returns(false)
35
35
  @analyzer.type.must_equal "module"
36
36
  end
37
37
  end
@@ -10,12 +10,12 @@ module Pelusa
10
10
  describe '#check' do
11
11
  describe 'when the class does not use switch statements' do
12
12
  it 'returns a SuccessAnalysis' do
13
- klass = """
13
+ klass = Pelusa.to_ast """
14
14
  class Foo
15
15
  def initialize
16
16
  return nil
17
17
  end
18
- end""".to_ast
18
+ end"""
19
19
 
20
20
  analysis = @lint.check(klass)
21
21
  analysis.successful?.must_equal true
@@ -24,14 +24,14 @@ module Pelusa
24
24
 
25
25
  describe 'when the class uses case statements' do
26
26
  it 'returns a FailureAnalysis' do
27
- klass = """
27
+ klass = Pelusa.to_ast """
28
28
  class Foo
29
29
  def initialize
30
30
  case foo
31
31
  when bar
32
32
  end
33
33
  end
34
- end""".to_ast
34
+ end"""
35
35
 
36
36
  analysis = @lint.check(klass)
37
37
  analysis.failed?.must_equal true
@@ -10,12 +10,12 @@ module Pelusa
10
10
  describe '#check' do
11
11
  describe 'when the class is not a collection wrapper with more instance variables' do
12
12
  it 'returns a SuccessAnalysis' do
13
- klass = """
13
+ klass = Pelusa.to_ast """
14
14
  class Foo
15
15
  def initialize
16
16
  @things = []
17
17
  end
18
- end""".to_ast
18
+ end"""
19
19
 
20
20
  analysis = @lint.check(klass)
21
21
  analysis.successful?.must_equal true
@@ -24,12 +24,12 @@ module Pelusa
24
24
 
25
25
  describe 'when the class has no ivars' do
26
26
  it 'returns a SuccessAnalysis' do
27
- klass = """
27
+ klass = Pelusa.to_ast """
28
28
  class Foo
29
29
  def initialize
30
30
  things = []
31
31
  end
32
- end""".to_ast
32
+ end"""
33
33
 
34
34
  analysis = @lint.check(klass)
35
35
  analysis.successful?.must_equal true
@@ -38,13 +38,13 @@ module Pelusa
38
38
 
39
39
  describe 'when the class mixes collection ivars with others' do
40
40
  it 'returns a FailureAnalysis' do
41
- klass = """
41
+ klass = Pelusa.to_ast """
42
42
  class Foo
43
43
  def initialize
44
44
  @things = []
45
45
  @foo = 'bar'
46
46
  end
47
- end""".to_ast
47
+ end"""
48
48
 
49
49
  analysis = @lint.check(klass)
50
50
  analysis.failed?.must_equal true
@@ -53,13 +53,13 @@ module Pelusa
53
53
 
54
54
  describe 'when the class has multiple array assignments' do
55
55
  it 'returns a FailureAnalysis' do
56
- klass = """
56
+ klass = Pelusa.to_ast """
57
57
  class Foo
58
58
  def initialize
59
59
  @things = []
60
60
  @foos = []
61
61
  end
62
- end""".to_ast
62
+ end"""
63
63
 
64
64
  analysis = @lint.check(klass)
65
65
  analysis.failed?.must_equal false
@@ -68,14 +68,14 @@ module Pelusa
68
68
 
69
69
  describe 'when the class has multiple array and other assignments' do
70
70
  it 'returns a FailureAnalysis' do
71
- klass = """
71
+ klass = Pelusa.to_ast """
72
72
  class Foo
73
73
  def initialize
74
74
  @things = []
75
75
  @foos = []
76
76
  @foo = 'bar'
77
77
  end
78
- end""".to_ast
78
+ end"""
79
79
 
80
80
  analysis = @lint.check(klass)
81
81
  analysis.failed?.must_equal true
@@ -10,13 +10,13 @@ module Pelusa
10
10
  describe '#check' do
11
11
  describe 'when the class respects Demeter law' do
12
12
  it 'returns a SuccessAnalysis' do
13
- klass = """
13
+ klass = Pelusa.to_ast """
14
14
  class Foo
15
15
  def initialize
16
16
  foo = 'hey'.upcase
17
17
  foo.downcase
18
18
  end
19
- end""".to_ast
19
+ end"""
20
20
 
21
21
  analysis = @lint.check(klass)
22
22
  analysis.successful?.must_equal true
@@ -25,12 +25,12 @@ module Pelusa
25
25
 
26
26
  describe 'when the class does not respect Demeter law' do
27
27
  it 'returns a FailureAnalysis' do
28
- klass = """
28
+ klass = Pelusa.to_ast """
29
29
  class Foo
30
30
  def initialize
31
31
  foo = 'hey'.upcase.downcase
32
32
  end
33
- end""".to_ast
33
+ end"""
34
34
 
35
35
  analysis = @lint.check(klass)
36
36
  analysis.failed?.must_equal true
@@ -39,12 +39,12 @@ module Pelusa
39
39
 
40
40
  describe 'when instantiating a class' do
41
41
  it 'returns a SuccessAnalysis' do
42
- klass = """
42
+ klass = Pelusa.to_ast """
43
43
  class Foo
44
44
  def execute
45
45
  Bar.new.execute
46
46
  end
47
- end""".to_ast
47
+ end"""
48
48
 
49
49
  analysis = @lint.check(klass)
50
50
  analysis.successful?.must_equal true
@@ -53,36 +53,36 @@ module Pelusa
53
53
 
54
54
  describe 'when chaining whitelisted operations' do
55
55
  it 'returns a SuccessAnalysis for chained operations from Enumerable' do
56
- klass = """
56
+ klass = Pelusa.to_ast """
57
57
  class Foo
58
58
  def execute
59
59
  [1,2,3].map(&:object_id).each {|i| i}
60
60
  end
61
- end""".to_ast
61
+ end"""
62
62
 
63
63
  analysis = @lint.check(klass)
64
64
  analysis.successful?.must_equal true
65
65
  end
66
66
 
67
67
  it 'returns a SuccessAnalysis when chaining methods from Fixnum' do
68
- klass = """
68
+ klass = Pelusa.to_ast """
69
69
  class Foo
70
70
  def execute
71
71
  1 + 2 + 3 + 4
72
72
  end
73
- end""".to_ast
73
+ end"""
74
74
 
75
75
  analysis = @lint.check(klass)
76
76
  analysis.successful?.must_equal true
77
77
  end
78
78
 
79
79
  it 'returns a SuccessAnalysis for chained operations from Object' do
80
- klass = """
80
+ klass = Pelusa.to_ast """
81
81
  class Foo
82
82
  def execute
83
83
  Object.new.to_s.inspect
84
84
  end
85
- end""".to_ast
85
+ end"""
86
86
 
87
87
  analysis = @lint.check(klass)
88
88
  analysis.successful?.must_equal true
@@ -93,12 +93,12 @@ module Pelusa
93
93
  {"whitelist" => "Object, Kernel, Hash, Enumerable"}
94
94
  )
95
95
 
96
- klass = """
96
+ klass = Pelusa.to_ast """
97
97
  class Foo
98
98
  def execute
99
99
  {'a' => 2}.merge.each_pair {|k, v|}
100
100
  end
101
- end""".to_ast
101
+ end"""
102
102
 
103
103
  analysis = @lint.check(klass)
104
104
  analysis.successful?.must_equal true
@@ -111,24 +111,24 @@ module Pelusa
111
111
  {"allow_conversions" => true}
112
112
  )
113
113
 
114
- klass = """
114
+ klass = Pelusa.to_ast """
115
115
  class Foo
116
116
  def execute
117
117
  {'a' => 2}.merge({}).to_hash.as_json
118
118
  end
119
- end""".to_ast
119
+ end"""
120
120
 
121
121
  analysis = @lint.check(klass)
122
122
  analysis.successful?.must_equal true
123
123
  end
124
124
 
125
125
  it 'returns a FailureAnalysis for conversions if not allowed' do
126
- klass = """
126
+ klass = Pelusa.to_ast """
127
127
  class Foo
128
128
  def execute
129
129
  {'a' => 2}.merge({}).to_hash
130
130
  end
131
- end""".to_ast
131
+ end"""
132
132
 
133
133
  analysis = @lint.check(klass)
134
134
  analysis.successful?.must_equal false
@@ -10,7 +10,7 @@ module Pelusa
10
10
  describe '#check' do
11
11
  describe 'when the class does not use else clauses' do
12
12
  it 'returns a SuccessAnalysis' do
13
- klass = """
13
+ klass = Pelusa.to_ast """
14
14
  class Foo
15
15
  def initialize
16
16
  if 3
@@ -20,7 +20,7 @@ module Pelusa
20
20
  3
21
21
  end
22
22
  end
23
- end""".to_ast
23
+ end"""
24
24
 
25
25
  analysis = @lint.check(klass)
26
26
  analysis.successful?.must_equal true
@@ -29,7 +29,7 @@ module Pelusa
29
29
 
30
30
  describe 'when the class uses else clauses' do
31
31
  it 'returns a FailureAnalysis' do
32
- klass = """
32
+ klass = Pelusa.to_ast """
33
33
  class Foo
34
34
  def initialize
35
35
  if 3
@@ -38,7 +38,7 @@ module Pelusa
38
38
  9
39
39
  end
40
40
  end
41
- end""".to_ast
41
+ end"""
42
42
 
43
43
  analysis = @lint.check(klass)
44
44
  analysis.failed?.must_equal true
@@ -16,7 +16,7 @@ class WithoutEval
16
16
  end
17
17
  end
18
18
  RUBY
19
- klass = klass_str.to_ast
19
+ klass = Pelusa.to_ast klass_str
20
20
  analysis = @lint.check(klass)
21
21
  analysis.successful?.must_equal true
22
22
  end
@@ -31,7 +31,7 @@ class WithEval
31
31
  end
32
32
  end
33
33
  RUBY
34
- klass = klass_str.to_ast
34
+ klass = Pelusa.to_ast klass_str
35
35
  analysis = @lint.check(klass)
36
36
  analysis.failed?.must_equal true
37
37
  end
@@ -47,7 +47,7 @@ class WithEvalUse
47
47
  end
48
48
  end
49
49
  RUBY
50
- klass = klass_str.to_ast
50
+ klass = Pelusa.to_ast klass_str
51
51
  analysis = @lint.check(klass)
52
52
  analysis.successful?.must_equal true
53
53
  end
@@ -10,14 +10,14 @@ module Pelusa
10
10
  describe '#check' do
11
11
  describe 'when the class has one method with one or less indentation levels' do
12
12
  it 'returns a SuccessAnalysis' do
13
- klass = """
13
+ klass = Pelusa.to_ast """
14
14
  class Foo
15
15
  def initialize
16
16
  if 9
17
17
  3
18
18
  end
19
19
  end
20
- end""".to_ast
20
+ end"""
21
21
 
22
22
  analysis = @lint.check(klass)
23
23
  analysis.successful?.must_equal true
@@ -26,7 +26,7 @@ module Pelusa
26
26
 
27
27
  describe 'when the class has one method with more than one indentation level' do
28
28
  it 'returns a FailureAnalysis' do
29
- klass = """
29
+ klass = Pelusa.to_ast """
30
30
  class Foo
31
31
  def initialize
32
32
  if 9
@@ -35,7 +35,7 @@ module Pelusa
35
35
  end
36
36
  end
37
37
  end
38
- end""".to_ast
38
+ end"""
39
39
 
40
40
  analysis = @lint.check(klass)
41
41
  analysis.failed?.must_equal true
@@ -44,7 +44,7 @@ module Pelusa
44
44
 
45
45
  describe "when there is method which produces nested list" do
46
46
  it 'returns a FailureAnalysis' do
47
- klass = """
47
+ klass = Pelusa.to_ast """
48
48
  class Foo
49
49
  def initialize
50
50
  if test
@@ -55,7 +55,7 @@ module Pelusa
55
55
  ]
56
56
  end
57
57
  end
58
- end""".to_ast
58
+ end"""
59
59
 
60
60
  analysis = @lint.check klass
61
61
  analysis.failed?.must_equal true
@@ -10,13 +10,13 @@ module Pelusa
10
10
  describe '#check' do
11
11
  describe 'when the class uses less than 3 ivars' do
12
12
  it 'returns a SuccessAnalysis' do
13
- klass = """
13
+ klass = Pelusa.to_ast """
14
14
  class Foo
15
15
  def initialize
16
16
  @foo = 1
17
17
  @bar = 2
18
18
  end
19
- end""".to_ast
19
+ end"""
20
20
 
21
21
  analysis = @lint.check(klass)
22
22
  analysis.successful?.must_equal true
@@ -25,14 +25,14 @@ module Pelusa
25
25
 
26
26
  describe 'when the class has more than 50 lines' do
27
27
  it 'returns a FailureAnalysis' do
28
- klass = """
28
+ klass = Pelusa.to_ast """
29
29
  class Foo
30
30
  def initialize
31
31
  @foo = 1
32
32
  @bar = 2
33
33
  @baz = 3
34
34
  end
35
- end""".to_ast
35
+ end"""
36
36
 
37
37
  analysis = @lint.check(klass)
38
38
  analysis.failed?.must_equal true
@@ -10,11 +10,11 @@ module Pelusa
10
10
  describe '#check' do
11
11
  describe 'when the class has less than 50 lines' do
12
12
  it 'returns a SuccessAnalysis' do
13
- klass = """
13
+ klass = Pelusa.to_ast """
14
14
  class Foo
15
15
  attr_accessor :foo
16
16
  attr_accessor :bar
17
- end""".to_ast
17
+ end"""
18
18
 
19
19
  analysis = @lint.check(klass)
20
20
  analysis.successful?.must_equal true
@@ -23,12 +23,12 @@ module Pelusa
23
23
 
24
24
  describe 'when the class has more than 50 lines' do
25
25
  it 'returns a FailureAnalysis' do
26
- klass = """
26
+ klass = Pelusa.to_ast """
27
27
  class Foo
28
28
  attr_accessor :foo
29
29
  #{"\n" * 80}
30
30
  attr_accessor :bar
31
- end""".to_ast
31
+ end"""
32
32
 
33
33
  analysis = @lint.check(klass)
34
34
  analysis.failed?.must_equal true
@@ -10,12 +10,12 @@ module Pelusa
10
10
  describe '#check' do
11
11
  describe 'when the class contains no long identifiers' do
12
12
  it 'returns a SuccessAnalysis' do
13
- klass = """
13
+ klass = Pelusa.to_ast """
14
14
  class Foo
15
15
  def initialize
16
16
  not_long_identifier = nil
17
17
  end
18
- end""".to_ast
18
+ end"""
19
19
 
20
20
  analysis = @lint.check(klass)
21
21
  analysis.successful?.must_equal true
@@ -24,12 +24,12 @@ module Pelusa
24
24
 
25
25
  describe 'when the class contains a long identifier' do
26
26
  it 'returns a FailureAnalysis' do
27
- klass = """
27
+ klass = Pelusa.to_ast """
28
28
  class Foo
29
29
  def initialize
30
30
  it_is_long_identifier = nil
31
31
  end
32
- end""".to_ast
32
+ end"""
33
33
 
34
34
  analysis = @lint.check(klass)
35
35
  analysis.failed?.must_equal true
@@ -10,7 +10,7 @@ module Pelusa
10
10
  describe '#check' do
11
11
  describe 'when the class contains only method definitions with a small number of arguments' do
12
12
  it 'returns a SuccessAnalysis' do
13
- klass = """
13
+ klass = Pelusa.to_ast """
14
14
  class Foo
15
15
  def bar(dog)
16
16
  return dog
@@ -21,7 +21,7 @@ module Pelusa
21
21
  def bam(dog, cat, fish)
22
22
  return dog + cat + fish
23
23
  end
24
- end""".to_ast
24
+ end"""
25
25
 
26
26
  analysis = @lint.check(klass)
27
27
  analysis.successful?.must_equal true
@@ -30,12 +30,12 @@ module Pelusa
30
30
 
31
31
  describe 'when the class contains a method definition with many arguments' do
32
32
  it 'returns a FailureAnalysis' do
33
- klass = """
33
+ klass = Pelusa.to_ast """
34
34
  class Foo
35
35
  def bar(dog, cat, fish, lobster)
36
36
  x = 2
37
37
  end
38
- end""".to_ast
38
+ end"""
39
39
 
40
40
  analysis = @lint.check(klass)
41
41
  analysis.failed?.must_equal true
@@ -10,7 +10,7 @@ module Pelusa
10
10
  describe '#check' do
11
11
  describe 'when the class does not use getters, setters or properties' do
12
12
  it 'returns a SuccessAnalysis' do
13
- klass = """
13
+ klass = Pelusa.to_ast """
14
14
  class Foo
15
15
  def initialize
16
16
  @name = 'john'
@@ -19,7 +19,7 @@ module Pelusa
19
19
  def name
20
20
  @name
21
21
  end
22
- end""".to_ast
22
+ end"""
23
23
 
24
24
  analysis = @lint.check(klass)
25
25
  analysis.successful?.must_equal true
@@ -28,11 +28,11 @@ module Pelusa
28
28
 
29
29
  describe 'when the class uses getters, setters or properties' do
30
30
  it 'returns a FailureAnalysis' do
31
- klass = """
31
+ klass = Pelusa.to_ast """
32
32
  class Foo
33
33
  attr_accessor :name
34
34
  attr_reader :foo
35
- end""".to_ast
35
+ end"""
36
36
 
37
37
  analysis = @lint.check(klass)
38
38
  analysis.failed?.must_equal true
@@ -10,12 +10,12 @@ module Pelusa
10
10
  describe '#check' do
11
11
  describe 'when the class contains no short identifiers' do
12
12
  it 'returns a SuccessAnalysis' do
13
- klass = """
13
+ klass = Pelusa.to_ast """
14
14
  class Foo
15
15
  def initialize
16
16
  foo = 3
17
17
  end
18
- end""".to_ast
18
+ end"""
19
19
 
20
20
  analysis = @lint.check(klass)
21
21
  analysis.successful?.must_equal true
@@ -24,13 +24,13 @@ module Pelusa
24
24
 
25
25
  describe 'when the class contains short identifier from reserved list' do
26
26
  it 'returns a SuccessAnalysis' do
27
- klass = """
27
+ klass = Pelusa.to_ast """
28
28
  class Foo
29
29
  def initialize
30
30
  id = 2
31
31
  pp id
32
32
  end
33
- end""".to_ast
33
+ end"""
34
34
 
35
35
  analysis = @lint.check(klass)
36
36
  analysis.successful?.must_equal true
@@ -39,12 +39,12 @@ module Pelusa
39
39
 
40
40
  describe 'when the class contains a short identifier' do
41
41
  it 'returns a FailureAnalysis' do
42
- klass = """
42
+ klass = Pelusa.to_ast """
43
43
  class Foo
44
44
  def initialize
45
45
  x = 2
46
46
  end
47
- end""".to_ast
47
+ end"""
48
48
 
49
49
  analysis = @lint.check(klass)
50
50
  analysis.failed?.must_equal true
@@ -5,3 +5,9 @@ require 'mocha/setup'
5
5
  require 'pelusa'
6
6
 
7
7
  FIXTURES_PATH = File.dirname(__FILE__) + '/fixtures'
8
+
9
+ module Pelusa
10
+ def self.to_ast(string)
11
+ ::Rubinius::ToolSets.current::ToolSet::Melbourne.parse_string(string)
12
+ end
13
+ end
metadata CHANGED
@@ -1,31 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pelusa
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josep M. Bach
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-19 00:00:00.000000000 Z
11
+ date: 2015-01-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
+ name: mocha
14
15
  requirement: !ruby/object:Gem::Requirement
15
16
  requirements:
16
- - - ! '>='
17
+ - - ">="
17
18
  - !ruby/object:Gem::Version
18
- version: !binary |-
19
- MA==
20
- name: mocha
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
21
22
  version_requirements: !ruby/object:Gem::Requirement
22
23
  requirements:
23
- - - ! '>='
24
+ - - ">="
24
25
  - !ruby/object:Gem::Version
25
- version: !binary |-
26
- MA==
27
- prerelease: false
28
- type: :development
26
+ version: '0'
29
27
  description: Static analysis Lint-type tool to improve your OO Ruby code
30
28
  email:
31
29
  - josep.m.bach@gmail.com
@@ -34,10 +32,10 @@ executables:
34
32
  extensions: []
35
33
  extra_rdoc_files: []
36
34
  files:
37
- - .gitignore
38
- - .pelusa.yml
39
- - .rvmrc
40
- - .travis.yml
35
+ - ".gitignore"
36
+ - ".pelusa.yml"
37
+ - ".rvmrc"
38
+ - ".travis.yml"
41
39
  - Gemfile
42
40
  - Rakefile
43
41
  - Readme.md
@@ -99,31 +97,26 @@ require_paths:
99
97
  - lib
100
98
  required_ruby_version: !ruby/object:Gem::Requirement
101
99
  requirements:
102
- - - ! '>='
100
+ - - ">="
103
101
  - !ruby/object:Gem::Version
104
- version: !binary |-
105
- MA==
102
+ version: '0'
106
103
  required_rubygems_version: !ruby/object:Gem::Requirement
107
104
  requirements:
108
- - - ! '>='
105
+ - - ">="
109
106
  - !ruby/object:Gem::Version
110
- version: !binary |-
111
- MA==
107
+ version: '0'
112
108
  requirements: []
113
109
  rubyforge_project: pelusa
114
- rubygems_version: 2.0.6
110
+ rubygems_version: 2.2.2
115
111
  signing_key:
116
112
  specification_version: 4
117
113
  summary: Static analysis Lint-type tool to improve your OO Ruby code
118
114
  test_files:
119
- - test/pelusa_test.rb
120
- - test/test_helper.rb
121
115
  - test/pelusa/analysis_test.rb
122
116
  - test/pelusa/analyzer_test.rb
123
117
  - test/pelusa/class_analyzer_test.rb
124
118
  - test/pelusa/cli_test.rb
125
119
  - test/pelusa/configuration_test.rb
126
- - test/pelusa/runner_test.rb
127
120
  - test/pelusa/lint/case_statements_test.rb
128
121
  - test/pelusa/lint/collection_wrappers_test.rb
129
122
  - test/pelusa/lint/demeter_law_test.rb
@@ -137,3 +130,6 @@ test_files:
137
130
  - test/pelusa/lint/properties_test.rb
138
131
  - test/pelusa/lint/short_identifiers_test.rb
139
132
  - test/pelusa/reporters/ruby_reporter_test.rb
133
+ - test/pelusa/runner_test.rb
134
+ - test/pelusa_test.rb
135
+ - test/test_helper.rb