synvert-core 1.33.0 → 1.33.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 279c659ed3a5da5cda7a67c95ef3cc74601d2f64d7dc70ae29431ef8ec4a9929
4
- data.tar.gz: 65caaa8ccc16f8789137b8269ad5ec45c6fe1c9d9198dc0b940b09ad3e3e06cd
3
+ metadata.gz: 6b61075876259ba185ddf48421d30e1d0dfb6cd92f447f31218581a555f69ef5
4
+ data.tar.gz: 9d7cd7d69f324e8c02d6c51014d8deb7524ca027b5b0099834953527d40d0da1
5
5
  SHA512:
6
- metadata.gz: f45bf64e55621191bfe3a17c689d337d0b25fd356217dd8965876540514bb4b5d04cabb25a834b0567dfba538c93095b12ba281cc02c90a596ec34f8b3dc9231
7
- data.tar.gz: 45c5c88b22be8e616cda46e518ee304333d3a8973f58b174182950eef2b958b16ed880311085cf63dc022fe79f8ec3e45fab3a32d23891db829dc5ba8066e075
6
+ metadata.gz: 56267c1b2d6955d040f38b211dfb058e59e66b3bf14a2d2072532e215be46427fbcac36b171da8058a95fc9d1a93fb4398d4b82989e46cc53e732b56c35f08f3
7
+ data.tar.gz: 1112d3c2985ad5b50a66f7210bd89c3fb512f13fc5710288591c6267dc320ac5a3e3746e6cfa66d08a4275bc21fd72428c260b431216d37efa57da1c3450bece
data/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 1.33.2 (2024-02-24)
4
+
5
+ * Reset `@warnings`, `@affected_files`, and `@test_results`
6
+ * Puts `Parser::SyntaxError` message only when `ENV[DEBUG]` is true
7
+ * Raise `ParserNotSupported` if parser is not supported
8
+
9
+ ## 1.33.1 (2024-02-23)
10
+
11
+ * Try 10 times at maximum when process
12
+
3
13
  ## 1.33.0 (2024-02-18)
4
14
 
5
15
  * Add `Configuration.respect_gitignore`
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- synvert-core (1.33.0)
4
+ synvert-core (1.33.2)
5
5
  activesupport (< 7.0.0)
6
6
  node_mutation (>= 1.23.2)
7
7
  node_query (>= 1.15.1)
@@ -16,7 +16,7 @@ PATH
16
16
  GEM
17
17
  remote: https://rubygems.org/
18
18
  specs:
19
- activesupport (6.1.7.6)
19
+ activesupport (6.1.7.7)
20
20
  concurrent-ruby (~> 1.0, >= 1.0.2)
21
21
  i18n (>= 1.6, < 2)
22
22
  minitest (>= 5.1)
@@ -52,7 +52,7 @@ GEM
52
52
  method_source (1.0.0)
53
53
  minitest (5.22.2)
54
54
  nenv (0.3.0)
55
- node_mutation (1.23.2)
55
+ node_mutation (1.23.3)
56
56
  node_query (1.15.1)
57
57
  notiffany (0.1.3)
58
58
  nenv (~> 0.1)
@@ -47,8 +47,9 @@ module Synvert::Core
47
47
  puts @file_path if Configuration.show_run_process
48
48
 
49
49
  absolute_file_path = File.join(Configuration.root_path, @file_path)
50
- # It keeps running until no conflict.
51
- loop do
50
+ # It keeps running until no conflict,
51
+ # it will try 10 times at maximum.
52
+ 10.times do
52
53
  source = read_source(absolute_file_path)
53
54
  encoded_source = Engine.encode(File.extname(file_path), source)
54
55
  @current_mutation = NodeMutation.new(source, adapter: @rewriter.parser)
@@ -67,8 +68,10 @@ module Synvert::Core
67
68
  end
68
69
  break unless result.conflicted?
69
70
  rescue Parser::SyntaxError => e
70
- puts "[Warn] file #{file_path} was not parsed correctly."
71
- puts e.message
71
+ if ENV['DEBUG'] == 'true'
72
+ puts "[Warn] file #{file_path} was not parsed correctly."
73
+ puts e.message
74
+ end
72
75
  break
73
76
  end
74
77
  end
@@ -94,8 +97,10 @@ module Synvert::Core
94
97
  result.file_path = file_path
95
98
  result
96
99
  rescue Parser::SyntaxError => e
97
- puts "[Warn] file #{file_path} was not parsed correctly."
98
- puts e.message
100
+ if ENV['DEBUG'] == 'true'
101
+ puts "[Warn] file #{file_path} was not parsed correctly."
102
+ puts e.message
103
+ end
99
104
  end
100
105
  end
101
106
 
@@ -497,8 +502,10 @@ module Synvert::Core
497
502
  parse_code_by_syntax_tree(file_path, encoded_source)
498
503
  when Synvert::PRISM_PARSER
499
504
  parse_code_by_prism(file_path, encoded_source)
500
- else
505
+ when Synvert::PARSER_PARSER
501
506
  parse_code_by_parser(file_path, encoded_source)
507
+ else
508
+ raise Errors::ParserNotSupported.new("Parser #{@rewriter.parser} not supported")
502
509
  end
503
510
  end
504
511
 
@@ -117,10 +117,8 @@ module Synvert::Core
117
117
  @block = block
118
118
  @helpers = []
119
119
  @sub_snippets = []
120
- @warnings = []
121
- @affected_files = Set.new
122
120
  @options = DEFAULT_OPTIONS.dup
123
- @test_results = Hash.new { |h, k| h[k] = [] }
121
+ reset
124
122
  self.class.register(@group, @name, self)
125
123
  end
126
124
 
@@ -184,6 +182,13 @@ module Synvert::Core
184
182
  @options[:parser]
185
183
  end
186
184
 
185
+ # Reset @warnings, @affected_files, and @test_results.
186
+ def reset
187
+ @warnings = []
188
+ @affected_files = Set.new
189
+ @test_results = Hash.new { |h, k| h[k] = [] }
190
+ end
191
+
187
192
  #######
188
193
  # DSL #
189
194
  #######
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Synvert
4
4
  module Core
5
- VERSION = '1.33.0'
5
+ VERSION = '1.33.2'
6
6
  end
7
7
  end
@@ -4,6 +4,19 @@ require 'spec_helper'
4
4
 
5
5
  module Synvert::Core
6
6
  RSpec.describe Rewriter do
7
+ describe '#reset' do
8
+ it 'resets warnings, affected_files, and test_results' do
9
+ rewriter = Rewriter.new 'group', 'name'
10
+ rewriter.instance_variable_set(:@warnings, ['warnings'])
11
+ rewriter.instance_variable_set(:@affected_files, ['files'])
12
+ rewriter.instance_variable_set(:@test_results, { foo: 'bar' })
13
+ rewriter.reset
14
+ expect(rewriter.warnings).to eq []
15
+ expect(rewriter.affected_files).to eq Set.new
16
+ expect(rewriter.test_results).to eq Hash.new
17
+ end
18
+ end
19
+
7
20
  describe '#configure' do
8
21
  it 'parses parser' do
9
22
  running_mutation_adapter = nil
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: synvert-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.33.0
4
+ version: 1.33.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Huang
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-02-18 00:00:00.000000000 Z
11
+ date: 2024-02-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport