rubocop-rails 2.2.0 → 2.2.1

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: ad71070534d738a411a8cff630f6631592c3f704bddf47d11a014c3721a88cc0
4
- data.tar.gz: 07646afb945a609a7b6e498d4df6399f85b5c4e54e5f3a91ae27b375e798787d
3
+ metadata.gz: 492db5e3433993952c5b4b1df25b1a5b1a43531603eee5295d2c48f8d705b2c3
4
+ data.tar.gz: 33d65e499186e463cf38b03397510fded02216053078289c639e80077c731b50
5
5
  SHA512:
6
- metadata.gz: 0460ef0f52a504e1c7e49f25542f563697005f57a72d92d3542c63927b6579c23ab1ce38cc5fb501b6ec4a3b60fc057756ee8ec8fb2a169a5fe85c51d87b71c2
7
- data.tar.gz: 98982bc1c50a9336ea2a51f5911fc2edfaf1630c706998d8c1cd78cac42d51716627a475e2a3fc4ed5d315a290f43bc659c3c72cc6ebebec7eee023931a789a9
6
+ metadata.gz: 61cede5d16b9e4ec2451035108c7bf9e51ddf257ae2bc637d57827bc6eb16d4cb6e3408535ed4b47e39dbccbbc20ff881a076847e5e541980479ecb8867f10bb
7
+ data.tar.gz: e80b95b67271d8e7708a0da90550afe30678dfb52ca20edd4e094ef21f414759ce5e09f141f83e34f9f0af0a3bb10d23982ca70e531ee57f88e1ffecad44d15c
data/README.md CHANGED
@@ -48,7 +48,7 @@ cops together with the standard cops.
48
48
  ### Command line
49
49
 
50
50
  ```sh
51
- rubocop --require rubocop-rails --rails
51
+ rubocop --require rubocop-rails
52
52
  ```
53
53
 
54
54
  Note: `--rails` option is required while `rubocop` command supports `--rails` option.
@@ -75,10 +75,15 @@ module RuboCop
75
75
  lambda do |corrector|
76
76
  # add `.zone`: `Time.at` => `Time.zone.at`
77
77
  corrector.insert_after(node.children[0].source_range, '.zone')
78
- # replace `Time.zone.current` => `Time.zone.now`
79
- if node.method_name == :current
78
+
79
+ case node.method_name
80
+ when :current
81
+ # replace `Time.zone.current` => `Time.zone.now`
80
82
  corrector.replace(node.loc.selector, 'now')
83
+ when :new
84
+ autocorrect_time_new(node, corrector)
81
85
  end
86
+
82
87
  # prefer `Time` over `DateTime` class
83
88
  if strict?
84
89
  corrector.replace(node.children.first.source_range, 'Time')
@@ -89,6 +94,14 @@ module RuboCop
89
94
 
90
95
  private
91
96
 
97
+ def autocorrect_time_new(node, corrector)
98
+ if node.arguments?
99
+ corrector.replace(node.loc.selector, 'local')
100
+ else
101
+ corrector.replace(node.loc.selector, 'now')
102
+ end
103
+ end
104
+
92
105
  # remove redundant `.in_time_zone` from `Time.zone.now.in_time_zone`
93
106
  def remove_redundant_in_time_zone(corrector, node)
94
107
  time_methods_called = extract_method_chain(node)
@@ -4,7 +4,7 @@ module RuboCop
4
4
  module Rails
5
5
  # This module holds the RuboCop Rails version information.
6
6
  module Version
7
- STRING = '2.2.0'
7
+ STRING = '2.2.1'
8
8
  end
9
9
  end
10
10
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubocop-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 2.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bozhidar Batsov
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2019-07-06 00:00:00.000000000 Z
13
+ date: 2019-07-13 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rack