unparser 0.2.8 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +17 -0
  3. data/.rubocop.yml +1 -0
  4. data/Changelog.md +4 -0
  5. data/Gemfile +2 -0
  6. data/Gemfile.lock +70 -64
  7. data/Rakefile +1 -0
  8. data/bin/unparser +2 -0
  9. data/config/devtools.yml +1 -1
  10. data/config/flay.yml +1 -1
  11. data/config/reek.yml +136 -136
  12. data/config/rubocop.yml +14 -1
  13. data/lib/unparser.rb +2 -0
  14. data/lib/unparser/ast.rb +8 -6
  15. data/lib/unparser/ast/local_variable_scope.rb +3 -1
  16. data/lib/unparser/buffer.rb +5 -1
  17. data/lib/unparser/cli.rb +8 -1
  18. data/lib/unparser/cli/color.rb +2 -0
  19. data/lib/unparser/cli/differ.rb +2 -0
  20. data/lib/unparser/cli/source.rb +7 -1
  21. data/lib/unparser/comments.rb +5 -0
  22. data/lib/unparser/constants.rb +8 -6
  23. data/lib/unparser/dsl.rb +2 -0
  24. data/lib/unparser/emitter.rb +18 -9
  25. data/lib/unparser/emitter/alias.rb +2 -0
  26. data/lib/unparser/emitter/argument.rb +3 -0
  27. data/lib/unparser/emitter/assignment.rb +5 -2
  28. data/lib/unparser/emitter/begin.rb +3 -1
  29. data/lib/unparser/emitter/binary.rb +2 -0
  30. data/lib/unparser/emitter/block.rb +3 -0
  31. data/lib/unparser/emitter/case.rb +4 -0
  32. data/lib/unparser/emitter/cbase.rb +2 -0
  33. data/lib/unparser/emitter/class.rb +3 -0
  34. data/lib/unparser/emitter/def.rb +3 -0
  35. data/lib/unparser/emitter/defined.rb +2 -0
  36. data/lib/unparser/emitter/empty.rb +2 -0
  37. data/lib/unparser/emitter/ensure.rb +2 -0
  38. data/lib/unparser/emitter/flipflop.rb +2 -0
  39. data/lib/unparser/emitter/flow_modifier.rb +3 -1
  40. data/lib/unparser/emitter/for.rb +2 -0
  41. data/lib/unparser/emitter/hookexe.rb +2 -0
  42. data/lib/unparser/emitter/if.rb +5 -0
  43. data/lib/unparser/emitter/literal.rb +2 -0
  44. data/lib/unparser/emitter/literal/array.rb +5 -4
  45. data/lib/unparser/emitter/literal/dynamic.rb +2 -0
  46. data/lib/unparser/emitter/literal/dynamic_body.rb +2 -0
  47. data/lib/unparser/emitter/literal/execute_string.rb +2 -0
  48. data/lib/unparser/emitter/literal/hash.rb +3 -2
  49. data/lib/unparser/emitter/literal/primitive.rb +3 -1
  50. data/lib/unparser/emitter/literal/range.rb +2 -0
  51. data/lib/unparser/emitter/literal/regexp.rb +2 -0
  52. data/lib/unparser/emitter/literal/singleton.rb +2 -0
  53. data/lib/unparser/emitter/match.rb +2 -0
  54. data/lib/unparser/emitter/meta.rb +2 -0
  55. data/lib/unparser/emitter/module.rb +2 -0
  56. data/lib/unparser/emitter/op_assign.rb +2 -0
  57. data/lib/unparser/emitter/redo.rb +2 -0
  58. data/lib/unparser/emitter/repetition.rb +4 -1
  59. data/lib/unparser/emitter/resbody.rb +4 -24
  60. data/lib/unparser/emitter/rescue.rb +5 -2
  61. data/lib/unparser/emitter/retry.rb +2 -0
  62. data/lib/unparser/emitter/root.rb +2 -0
  63. data/lib/unparser/emitter/send.rb +3 -0
  64. data/lib/unparser/emitter/send/arguments.rb +2 -0
  65. data/lib/unparser/emitter/send/attribute_assignment.rb +2 -0
  66. data/lib/unparser/emitter/send/binary.rb +2 -0
  67. data/lib/unparser/emitter/send/conditional.rb +2 -0
  68. data/lib/unparser/emitter/send/index.rb +2 -0
  69. data/lib/unparser/emitter/send/regular.rb +3 -0
  70. data/lib/unparser/emitter/send/unary.rb +5 -3
  71. data/lib/unparser/emitter/splat.rb +2 -0
  72. data/lib/unparser/emitter/super.rb +2 -0
  73. data/lib/unparser/emitter/undef.rb +2 -0
  74. data/lib/unparser/emitter/variable.rb +3 -0
  75. data/lib/unparser/emitter/yield.rb +3 -0
  76. data/lib/unparser/finalize.rb +2 -0
  77. data/lib/unparser/node_helpers.rb +6 -0
  78. data/lib/unparser/preprocessor.rb +3 -0
  79. data/spec/integrations.yml +3 -1
  80. data/spec/unit/unparser_spec.rb +3 -7
  81. data/unparser.gemspec +3 -3
  82. metadata +6 -6
  83. data/circle.yml +0 -6
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Unparser
2
4
  class Emitter
3
5
  class Send
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Unparser
2
4
  class Emitter
3
5
  class Send
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Unparser
2
4
  class Emitter
3
5
  class Send
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Unparser
2
4
  class Emitter
3
5
  class Send
@@ -27,6 +29,7 @@ module Unparser
27
29
  #
28
30
  def emit_receiver
29
31
  return unless first_child
32
+
30
33
  visit(receiver)
31
34
  write(T_DOT)
32
35
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Unparser
2
4
  class Emitter
3
5
  class Send
@@ -8,8 +10,8 @@ module Unparser
8
10
  private
9
11
 
10
12
  MAP = IceNine.deep_freeze(
11
- :'-@' => '-',
12
- :'+@' => '+'
13
+ '-@': '-',
14
+ '+@': '+'
13
15
  )
14
16
 
15
17
  # Perform dispatch
@@ -21,7 +23,7 @@ module Unparser
21
23
  def dispatch
22
24
  name = selector
23
25
  write(MAP.fetch(name, name).to_s)
24
- if receiver.type.equal?(:int) && selector.equal?(:'+@') && receiver.children.first > 0
26
+ if receiver.type.equal?(:int) && selector.equal?(:'+@')
25
27
  write('+')
26
28
  end
27
29
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Unparser
2
4
  class Emitter
3
5
  # Emitter for splats
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Unparser
2
4
  class Emitter
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Unparser
2
4
  class Emitter
3
5
  # Emitter for undef nodes
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Unparser
2
4
  class Emitter
3
5
 
@@ -52,6 +54,7 @@ module Unparser
52
54
  #
53
55
  def emit_scope
54
56
  return unless scope
57
+
55
58
  visit(scope)
56
59
  write(T_DCL) unless scope.type.equal?(:cbase)
57
60
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Unparser
2
4
  class Emitter
3
5
 
@@ -18,6 +20,7 @@ module Unparser
18
20
  def dispatch
19
21
  write(K_YIELD)
20
22
  return if children.empty?
23
+
21
24
  parentheses do
22
25
  delimited(children)
23
26
  end
@@ -1 +1,3 @@
1
+ # frozen_string_literal: true
2
+
1
3
  Unparser::Emitter::REGISTRY.freeze
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Unparser
2
4
  module NodeHelpers
3
5
 
@@ -9,6 +11,8 @@ module Unparser
9
11
  #
10
12
  # @api private
11
13
  #
14
+ # ignore :reek:UncommunicativeMethodName
15
+ # ignore :reek:UtilityFunction
12
16
  def s(type, *children)
13
17
  Parser::AST::Node.new(type, children)
14
18
  end
@@ -21,6 +25,8 @@ module Unparser
21
25
  #
22
26
  # @api private
23
27
  #
28
+ # ignore :reek:UncommunicativeMethodName
29
+ # ignore :reek:UtilityFunction
24
30
  def n(type, children = [])
25
31
  Parser::AST::Node.new(type, children)
26
32
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Unparser
2
4
  # Preprocessor to normalize AST generated by parser
3
5
  class Preprocessor
@@ -23,6 +25,7 @@ module Unparser
23
25
  #
24
26
  def self.run(node, parent_type = nil)
25
27
  return EMPTY if node.nil?
28
+
26
29
  REGISTRY.fetch(node.type, [Noop]).reduce(node) do |current, processor|
27
30
  processor.call(current, parent_type)
28
31
  end
@@ -57,9 +57,9 @@
57
57
  - core/string/shared/succ.rb
58
58
  - core/string/shared/to_sym.rb
59
59
  - core/string/squeeze_spec.rb
60
- - core/string/unpack/{b,c,h,m}_spec.rb
61
60
  - core/string/unpack/shared/float.rb
62
61
  - core/string/unpack/shared/integer.rb
62
+ - core/string/unpack/{b,c,h,m}_spec.rb
63
63
  - core/string/unpack/{u,w}_spec.rb
64
64
  - core/symbol/casecmp_spec.rb
65
65
  - core/time/_dump_spec.rb
@@ -69,6 +69,7 @@
69
69
  - language/for_spec.rb
70
70
  - language/regexp/encoding_spec.rb
71
71
  - language/regexp/escapes_spec.rb
72
+ - language/source_encoding_spec.rb
72
73
  - language/string_spec.rb
73
74
  - library/digest/md5/shared/constants.rb
74
75
  - library/digest/md5/shared/sample.rb
@@ -83,3 +84,4 @@
83
84
  - library/stringscanner/shared/get_byte.rb
84
85
  - library/zlib/inflate/set_dictionary_spec.rb
85
86
  - optional/capi/integer_spec.rb
87
+ - security/cve_2010_1330_spec.rb
@@ -6,9 +6,7 @@ describe Unparser, mutant_expression: 'Unparser::Emitter*' do
6
6
  describe '.unparse' do
7
7
 
8
8
  RUBY_VERSION_PARSERS = IceNine.deep_freeze(
9
- '2.1' => Parser::Ruby21,
10
- '2.2' => Parser::Ruby22,
11
- '2.3' => Parser::Ruby23
9
+ '2.5' => Parser::Ruby25
12
10
  )
13
11
 
14
12
  RUBY_VERSIONS = RUBY_VERSION_PARSERS.keys.freeze
@@ -468,10 +466,8 @@ describe Unparser, mutant_expression: 'Unparser::Emitter*' do
468
466
  end
469
467
 
470
468
  context 'conditional send (csend)' do
471
- with_ruby_versions(beginning_at: '2.3') do
472
- assert_terminated 'a&.b'
473
- assert_terminated 'a&.b(c)'
474
- end
469
+ assert_terminated 'a&.b'
470
+ assert_terminated 'a&.b(c)'
475
471
  end
476
472
 
477
473
  context 'send' do
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |gem|
2
2
  gem.name = 'unparser'
3
- gem.version = '0.2.8'
3
+ gem.version = '0.3.0'
4
4
 
5
5
  gem.authors = ['Markus Schirp']
6
6
  gem.email = 'mbj@schirp-dso.com'
@@ -16,7 +16,7 @@ Gem::Specification.new do |gem|
16
16
  gem.extra_rdoc_files = %w[README.md]
17
17
  gem.executables = %w[unparser]
18
18
 
19
- gem.required_ruby_version = '>= 2.1'
19
+ gem.required_ruby_version = '>= 2.5'
20
20
 
21
21
  gem.add_dependency('abstract_type', '~> 0.0.7')
22
22
  gem.add_dependency('adamantium', '~> 0.2.0')
@@ -27,6 +27,6 @@ Gem::Specification.new do |gem|
27
27
  gem.add_dependency('procto', '~> 0.0.2')
28
28
 
29
29
  gem.add_development_dependency('anima', '~> 0.3.0')
30
- gem.add_development_dependency('devtools', '~> 0.1.3')
30
+ gem.add_development_dependency('devtools', '~> 0.1.21')
31
31
  gem.add_development_dependency('morpher', '~> 0.2.6')
32
32
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unparser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.8
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Markus Schirp
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-07-18 00:00:00.000000000 Z
11
+ date: 2018-11-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: abstract_type
@@ -134,14 +134,14 @@ dependencies:
134
134
  requirements:
135
135
  - - "~>"
136
136
  - !ruby/object:Gem::Version
137
- version: 0.1.3
137
+ version: 0.1.21
138
138
  type: :development
139
139
  prerelease: false
140
140
  version_requirements: !ruby/object:Gem::Requirement
141
141
  requirements:
142
142
  - - "~>"
143
143
  - !ruby/object:Gem::Version
144
- version: 0.1.3
144
+ version: 0.1.21
145
145
  - !ruby/object:Gem::Dependency
146
146
  name: morpher
147
147
  requirement: !ruby/object:Gem::Requirement
@@ -164,6 +164,7 @@ extensions: []
164
164
  extra_rdoc_files:
165
165
  - README.md
166
166
  files:
167
+ - ".circleci/config.yml"
167
168
  - ".gitignore"
168
169
  - ".rspec"
169
170
  - ".rubocop.yml"
@@ -174,7 +175,6 @@ files:
174
175
  - README.md
175
176
  - Rakefile
176
177
  - bin/unparser
177
- - circle.yml
178
178
  - config/devtools.yml
179
179
  - config/flay.yml
180
180
  - config/flog.yml
@@ -279,7 +279,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
279
279
  requirements:
280
280
  - - ">="
281
281
  - !ruby/object:Gem::Version
282
- version: '2.1'
282
+ version: '2.5'
283
283
  required_rubygems_version: !ruby/object:Gem::Requirement
284
284
  requirements:
285
285
  - - ">="
data/circle.yml DELETED
@@ -1,6 +0,0 @@
1
- machine:
2
- ruby:
3
- version: '2.2'
4
- test:
5
- override:
6
- - bundle exec rake ci