rubocop-betterment 1.6.0 → 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5a8e6e836b70797730769203cc1f58e341cce95e
4
- data.tar.gz: d28f3bc8399c4778f7e29cf0815c44808951ede9
3
+ metadata.gz: fe0109185da03f1c923006903de0336b09941de2
4
+ data.tar.gz: f7ce1a98024ba65910f624b84d4e316f47975ed6
5
5
  SHA512:
6
- metadata.gz: 2b605a6a49483f80ae71a00540075adc516e4478c9bd4ff8f28e2b258201a484445044cf01953f36cd73c215b544abf40b99ac3a0c01bdd5f195d21602effb1d
7
- data.tar.gz: b8081a6defeb7207bd158934c762965be285e6db38b25cf620c956f0fe997875bdee136648760482dffa592ba38338194954ca095321fe409377fa56787e8bd6
6
+ metadata.gz: 60cffaab104cc7bcb8ac220073ed67a2c32b1f64758dafae509220ec6b213d40489a31c64c1a6bc0231242578a1fa1c70a8ef3288299d162f095b7c6ad6ed952
7
+ data.tar.gz: 08795fe114125cfa3dcc398756097394505393f85713be356847571608cf6e8612ff212e50541667bdc3688aed86643025948c83f80ff3706d35422b043deb1a
data/config/default.yml CHANGED
@@ -1,7 +1,8 @@
1
1
  # please keep this file alphabetically ordered!
2
2
 
3
- require: rubocop/cop/betterment
4
- require: rubocop-rspec
3
+ require:
4
+ - rubocop/cop/betterment.rb
5
+ - rubocop-rspec
5
6
 
6
7
  AllCops:
7
8
  Exclude:
@@ -17,6 +18,11 @@ AllCops:
17
18
  DisplayStyleGuide: true
18
19
  DisplayCopNames: true
19
20
 
21
+ Betterment/SitePrismLoaded:
22
+ Include:
23
+ - 'spec/features/**/*_spec.rb'
24
+ - 'spec/system/**/*_spec.rb'
25
+
20
26
  Capybara/FeatureMethods:
21
27
  Enabled: false
22
28
 
@@ -0,0 +1,25 @@
1
+ module RuboCop
2
+ module Cop
3
+ module Betterment
4
+ class SitePrismLoaded < Cop
5
+ MSG = 'Use `be_loaded` instead of `be_displayed`'.freeze
6
+
7
+ def_node_matcher :be_displayed_call?, <<-PATTERN
8
+ (send (send nil? :expect _) _ (send nil? :be_displayed))
9
+ PATTERN
10
+
11
+ def on_send(node)
12
+ return unless be_displayed_call?(node)
13
+
14
+ add_offense(node, location: node.children[2].loc.expression)
15
+ end
16
+
17
+ def autocorrect(node)
18
+ lambda do |corrector|
19
+ corrector.replace(node.children[2].loc.expression, 'be_loaded')
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -4,13 +4,14 @@ module RuboCop
4
4
  class Timeout < Cop
5
5
  MSG = 'Using Timeout.timeout without a custom exception can prevent rescue blocks from executing'.freeze
6
6
 
7
+ def_node_matcher :timeout_call?, <<-PATTERN
8
+ (send (const nil? :Timeout) :timeout _)
9
+ PATTERN
10
+
7
11
  def on_send(node)
8
- target_receiver = s(:const, nil, :Timeout)
9
- target_method = :timeout
12
+ return unless timeout_call?(node)
10
13
 
11
- if node.receiver == target_receiver && node.method_name == target_method && node.arguments.one?
12
- add_offense(node, location: node.source_range)
13
- end
14
+ add_offense(node)
14
15
  end
15
16
  end
16
17
  end
@@ -1,2 +1,4 @@
1
+ require 'rubocop'
1
2
  require 'rubocop/cop/betterment/timeout'
2
3
  require 'rubocop/cop/betterment/memoization_with_arguments'
4
+ require 'rubocop/cop/betterment/site_prism_loaded'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubocop-betterment
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.0
4
+ version: 1.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Development
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-12-20 00:00:00.000000000 Z
11
+ date: 2018-12-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubocop
@@ -92,6 +92,7 @@ files:
92
92
  - config/default.yml
93
93
  - lib/rubocop/cop/betterment.rb
94
94
  - lib/rubocop/cop/betterment/memoization_with_arguments.rb
95
+ - lib/rubocop/cop/betterment/site_prism_loaded.rb
95
96
  - lib/rubocop/cop/betterment/timeout.rb
96
97
  homepage:
97
98
  licenses: