sevencop 0.26.0 → 0.26.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: 9b03712edc9d72494a99f77fe83b616b83314f1b72347dd96fbe30d3ecb66508
4
- data.tar.gz: bf06a9f54c5dfea1d64c357d70e14287b389efe7f26474c87355e38ab7bc5736
3
+ metadata.gz: 7ae1550d29e9e7aeb18b9f63d2e8f167ef5a7d871f2e953551e7be6c86038430
4
+ data.tar.gz: fba303001375952d8f8f1e3de021a9a5b155adc79440bb526342391c81be2a9b
5
5
  SHA512:
6
- metadata.gz: 260701a809a5b831e985ff159550b62bec1e0801c80dbfd7ed79a55ab9297307512116c6cc96161bdf374a8afcd350ea993543b335d5621f296d5d2bbdc451d1
7
- data.tar.gz: 894f7f028033cf169c1f5576b29418245dfbe052f6e088e5f5a021c040fef68ab9784f969a98c17287ebbfe5832d79f2d107fd932b5d1f0953c04c07d8f6f07a
6
+ metadata.gz: a32371dd923b0922ae7072b11d6917cf876eec46061a3fe0a7229a5bac2713d77b66f75ef7259f15838173d20dbd7f039dcb4af0ce0c456216091906eda7f6c4
7
+ data.tar.gz: a5cece615fd407987d77a5e7d5db08ef78c816a07c3330da17fdd5d778552dfd4ff1d249d044b95540ce06a04b873623853b42a5e466bbe4d389fb284784f75a
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sevencop (0.26.0)
4
+ sevencop (0.26.1)
5
5
  activesupport
6
6
  rubocop
7
7
 
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'set'
4
+
3
5
  module RuboCop
4
6
  module Cop
5
7
  module Sevencop
@@ -425,10 +427,9 @@ module RuboCop
425
427
  )
426
428
  corrector.replace(
427
429
  node,
428
- format(
429
- '%<time>s.%<helper_method_name>s',
430
- helper_method_name: helper_method_name_for_comparison(node),
431
- time: find_comparison_subject_to_time_current(node).source
430
+ format_to_method_call(
431
+ method: helper_method_name_for_comparison(node),
432
+ receiver: find_comparison_subject_to_time_current(node)
432
433
  )
433
434
  )
434
435
  end
@@ -444,10 +445,9 @@ module RuboCop
444
445
  )
445
446
  corrector.replace(
446
447
  node,
447
- format(
448
- '%<duration>s.%<helper_method_name>s',
449
- duration: node.first_argument.source,
450
- helper_method_name: helper_method_name
448
+ format_to_method_call(
449
+ method: helper_method_name,
450
+ receiver: node.first_argument
451
451
  )
452
452
  )
453
453
  end
@@ -465,10 +465,9 @@ module RuboCop
465
465
  )
466
466
  corrector.replace(
467
467
  node,
468
- format(
469
- '%<date>s.%<helper_method_name>s',
470
- date: find_equality_subject_to_date_with(node, date_method_name).source,
471
- helper_method_name: helper_method_name
468
+ format_to_method_call(
469
+ method: helper_method_name,
470
+ receiver: find_equality_subject_to_date_with(node, date_method_name)
472
471
  )
473
472
  )
474
473
  end
@@ -736,6 +735,18 @@ module RuboCop
736
735
  end
737
736
  end
738
737
 
738
+ # @param receiver [RuboCop::AST::Node]
739
+ # @param method [String]
740
+ # @return [String]
741
+ def format_to_method_call(
742
+ method:,
743
+ receiver:
744
+ )
745
+ receiver_source = receiver.source
746
+ receiver_source = "(#{receiver_source})" if receiver.operator_method?
747
+ [receiver_source, method].join('.')
748
+ end
749
+
739
750
  # @param node [RuboCop::AST::SendNode]
740
751
  # @return [Symbol]
741
752
  def helper_method_name_for_comparison(node)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Sevencop
4
- VERSION = '0.26.0'
4
+ VERSION = '0.26.1'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sevencop
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.26.0
4
+ version: 0.26.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryo Nakamura