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 +4 -4
- data/README.md +1 -1
- data/lib/rubocop/cop/rails/time_zone.rb +15 -2
- data/lib/rubocop/rails/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 492db5e3433993952c5b4b1df25b1a5b1a43531603eee5295d2c48f8d705b2c3
|
4
|
+
data.tar.gz: 33d65e499186e463cf38b03397510fded02216053078289c639e80077c731b50
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 61cede5d16b9e4ec2451035108c7bf9e51ddf257ae2bc637d57827bc6eb16d4cb6e3408535ed4b47e39dbccbbc20ff881a076847e5e541980479ecb8867f10bb
|
7
|
+
data.tar.gz: e80b95b67271d8e7708a0da90550afe30678dfb52ca20edd4e094ef21f414759ce5e09f141f83e34f9f0af0a3bb10d23982ca70e531ee57f88e1ffecad44d15c
|
data/README.md
CHANGED
@@ -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
|
-
|
79
|
-
|
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)
|
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.
|
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-
|
13
|
+
date: 2019-07-13 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rack
|