rufo 0.3.1 → 0.4.0

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
- SHA1:
3
- metadata.gz: 6403e7160a1d00c65b0562de144fe3aebf112a7e
4
- data.tar.gz: d175a0ae7c46af1e5ebdfa7b4db59e324af1fdf3
2
+ SHA256:
3
+ metadata.gz: 882bdf48ef5e72a77d7971ee7569d8f9b8e70269c6c61a87bb73791a17634b8e
4
+ data.tar.gz: df6f5f5b21ad982b68bb21cb092d06eae0b9f1bdaebcbbd22711b490b9d41eb6
5
5
  SHA512:
6
- metadata.gz: 8664f038f6bb0f10e60a7e84278bcfd91ae6205d71b7e73b50dfdaf39145664c8300e2b10cfe0eddb2551eb2fd81e81e6a50ae9a6e5de3f6c1500f51ea155c18
7
- data.tar.gz: 4d6390b9b88aeb21d97090326b9ae2eb923fdb299b658209efaf30f21b0830bc37778ced67811d550eaedc3c9f9125618b6f88e4ac2287db3e5c67e6caf66c86
6
+ metadata.gz: c4fdfc5b81de84282a471532d222fdf5b233a88d04c1ac5f8fa542e15b480264be269c5dcbf03d2bdea192739b5ca7b6c01fb96a95695b341211bff81f36ac90
7
+ data.tar.gz: 6bb2aa7c349e41503634d7a891047a401f9ebb8fe8f574c9f894bdcc5fd5c6cbf45aa16cc327b69227630c143e8e5b82e7edd141749dda5b423c4d2572791a9c
@@ -2,14 +2,13 @@ sudo: false
2
2
  language: ruby
3
3
  cache: bundler
4
4
  rvm:
5
- - 2.5.0
6
- - 2.4.2
7
- - 2.3.5
8
- - 2.2.8
5
+ - 2.5.1
6
+ - 2.4.4
7
+ - 2.3.7
9
8
  - ruby-head
10
9
  matrix:
11
10
  allow_failures:
12
11
  - rvm: ruby-head
13
- before_install: gem install bundler -v 1.16.1
12
+ before_install: gem install bundler -v 1.16.2
14
13
  script:
15
14
  - bundle exec rake ci
@@ -6,6 +6,24 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ### Fixed
10
+
11
+ ### Added
12
+
13
+ ## [0.4.0] - 2018-08-09
14
+
15
+ ### Fixed
16
+ - Fix Bug: Rufo breaks HEREDOC syntax. (issue [#88](https://github.com/ruby-formatter/rufo/issues/88)). This fixes heredoc within parens formatting causing bad formatting and subsequent syntax error.
17
+ - Fix Bug: formatter.rb:3700:in `block in adjust_other_alignments': undefined method `[]' for nil:NilClass (NoMethodError) (issue [#87](https://github.com/ruby-formatter/rufo/issues/87)). Check alignment target exists.
18
+ - Fix Bug: Rufo keeps switching formatting on same file every time it runs (issue [#86](https://github.com/ruby-formatter/rufo/issues/86)). Avoids re-indenting nested literal indents.
19
+
20
+ ### Added
21
+ - Allow for simpler else_body node to suit new Ripper style in 2.6.0
22
+ - Allow new Ripper node :excessed_comma in block parsing
23
+ - Allow :bodystmt in lambda nodes to suit Ripper format in 2.6.0
24
+ - Drop support for ruby 2.2
25
+ - Set minimum required ruby version. As rufo is not tested on unsupported versions it may (and is known to) break code.
26
+
9
27
  ## [0.3.1] - 2018-04-12
10
28
 
11
29
  ### Fixed
data/README.md CHANGED
@@ -12,7 +12,7 @@ Unlike the best known Ruby formatter [RuboCop](https://github.com/bbatsov/ruboco
12
12
 
13
13
  RuboCop does much more than just format code though, so feel free to run them both!
14
14
 
15
- Rufo supports all Ruby versions >= 2.2.4, but works most reliably with >= 2.3.**5** / >= 2.4.**2**, due to a bug in Ruby's Ripper parser.
15
+ Rufo supports all Ruby versions >= 2.3.**5** / >= 2.4.**2**, due to a bug in Ruby's Ripper parser.
16
16
 
17
17
  ## Installation
18
18
 
@@ -113,8 +113,8 @@ Rufo Warning!
113
113
  end
114
114
 
115
115
  def backported_version
116
- return "2.3.5" if RUBY_VERSION[0..2] == "2.3"
117
- "2.4.2"
116
+ return "2.3.7" if RUBY_VERSION[0..2] == "2.3"
117
+ "2.4.4"
118
118
  end
119
119
 
120
120
  def format_file(filename)
@@ -1547,6 +1547,7 @@ class Rufo::Formatter
1547
1547
 
1548
1548
  def visit_bodystmt(node)
1549
1549
  # [:bodystmt, body, rescue_body, else_body, ensure_body]
1550
+ # [:bodystmt, [[:@int, "1", [2, 1]]], nil, [[:@int, "2", [4, 1]]], nil] (2.6.0)
1550
1551
  _, body, rescue_body, else_body, ensure_body = node
1551
1552
 
1552
1553
  inside_type_body = @inside_type_body
@@ -1585,9 +1586,11 @@ class Rufo::Formatter
1585
1586
 
1586
1587
  if else_body
1587
1588
  # [:else, body]
1589
+ # [[:@int, "2", [4, 1]]] (2.6.0)
1588
1590
  write_indent
1589
1591
  consume_keyword "else"
1590
- indent_body else_body[1]
1592
+ else_body = else_body[1] if else_body[0] == :else
1593
+ indent_body else_body
1591
1594
  end
1592
1595
 
1593
1596
  if ensure_body
@@ -2077,11 +2080,13 @@ class Rufo::Formatter
2077
2080
  consume_token :on_lparen
2078
2081
  skip_space_or_newline
2079
2082
 
2083
+ heredoc = current_token_kind == :on_heredoc_beg
2080
2084
  if exps
2081
2085
  visit_exps to_ary(exps), with_lines: false
2082
2086
  end
2083
2087
 
2084
2088
  skip_space_or_newline
2089
+ write "\n" if heredoc
2085
2090
  consume_token :on_rparen
2086
2091
  end
2087
2092
 
@@ -2111,8 +2116,9 @@ class Rufo::Formatter
2111
2116
  end
2112
2117
 
2113
2118
  if rest_param
2114
- # check for trailing , |x, |
2115
- if rest_param == 0
2119
+ # check for trailing , |x, | (may be [:excessed_comma] in 2.6.0)
2120
+ case rest_param
2121
+ when 0, [:excessed_comma]
2116
2122
  write_params_comma
2117
2123
  else
2118
2124
  # [:rest_param, [:@ident, "x", [1, 15]]]
@@ -2524,8 +2530,11 @@ class Rufo::Formatter
2524
2530
 
2525
2531
  def visit_lambda(node)
2526
2532
  # [:lambda, [:params, nil, nil, nil, nil, nil, nil, nil], [[:void_stmt]]]
2533
+ # [:lambda, [:params, nil, nil, nil, nil, nil, nil, nil], [[:@int, "1", [2, 2]], [:@int, "2", [3, 2]]]]
2534
+ # [:lambda, [:params, nil, nil, nil, nil, nil, nil, nil], [:bodystmt, [[:@int, "1", [2, 2]], [:@int, "2", [3, 2]]], nil, nil, nil]] (on 2.6.0)
2527
2535
  _, params, body = node
2528
2536
 
2537
+ body = body[1] if body[0] == :bodystmt
2529
2538
  check :on_tlambda
2530
2539
  write "->"
2531
2540
  next_token
@@ -3728,14 +3737,18 @@ class Rufo::Formatter
3728
3737
 
3729
3738
  lines = @output.lines
3730
3739
 
3740
+ modified_lines = []
3731
3741
  @literal_indents.each do |first_line, last_line, indent|
3732
3742
  (first_line + 1..last_line).each do |line|
3733
3743
  next if @unmodifiable_string_lines[line]
3734
3744
 
3735
3745
  current_line = lines[line]
3736
3746
  current_line = "#{" " * indent}#{current_line}"
3737
- lines[line] = current_line
3738
- adjust_other_alignments nil, line, 0, indent
3747
+ unless modified_lines[line]
3748
+ modified_lines[line] = current_line
3749
+ lines[line] = current_line
3750
+ adjust_other_alignments nil, line, 0, indent
3751
+ end
3739
3752
  end
3740
3753
  end
3741
3754
 
@@ -3803,7 +3816,7 @@ class Rufo::Formatter
3803
3816
  next if adjustment_column <= column
3804
3817
  next if scope == key
3805
3818
 
3806
- target[index][1] += offset
3819
+ target[index][1] += offset if target[index]
3807
3820
  end
3808
3821
  end
3809
3822
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Rufo
4
- VERSION = "0.3.1"
4
+ VERSION = "0.4.0"
5
5
  end
@@ -20,6 +20,7 @@ Gem::Specification.new do |spec|
20
20
  spec.bindir = "exe"
21
21
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
22
  spec.require_paths = ["lib"]
23
+ spec.required_ruby_version = '>= 2.3.5'
23
24
 
24
25
  spec.add_development_dependency "bundler", "~> 1.15"
25
26
  spec.add_development_dependency "rake", "~> 10.0"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rufo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ary Borenszweig
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-04-12 00:00:00.000000000 Z
11
+ date: 2018-08-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -113,7 +113,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
113
113
  requirements:
114
114
  - - ">="
115
115
  - !ruby/object:Gem::Version
116
- version: '0'
116
+ version: 2.3.5
117
117
  required_rubygems_version: !ruby/object:Gem::Requirement
118
118
  requirements:
119
119
  - - ">="
@@ -121,7 +121,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
121
121
  version: '0'
122
122
  requirements: []
123
123
  rubyforge_project:
124
- rubygems_version: 2.6.13
124
+ rubygems_version: 2.7.3
125
125
  signing_key:
126
126
  specification_version: 4
127
127
  summary: Ruby code formatter