mavenlint 1.2.1 → 1.3.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: 882e8d33124b9ee52b9217164397280aa6cd66c9
4
- data.tar.gz: 72741abfa7c50f4d25796611cc1a2f7173fd6c32
3
+ metadata.gz: dcfc99e4f4f3972ef1b8f710e2f038061810051d
4
+ data.tar.gz: 6fecb9a506040fdc6242c96dde6f719f7f778a9d
5
5
  SHA512:
6
- metadata.gz: b22956d519f95a4ffb3fdae9a25c83718f072e6c26e1c2c4f9fa68b2d457fe7b6a4b85f14c3f29b2f083767e2774639cdf6068340c045c6b292ba0b1fa449307
7
- data.tar.gz: a377001f38dd395d3116ac2596810a6bf8cdb90be8058a0df4420d1e98b294b0ba8fd492621d72fe847a2a2294a76f7a0bb2c9cb7e4b232e3ee40d3dd9c46d6c
6
+ metadata.gz: 3035ed08d6026916007c04c77978c75465d26de511ccf4737c403524fef221acbcbf8343d577978d8df30329989239a82b715e36e26d3072fb0270802dbc7ae9
7
+ data.tar.gz: 55cdf4ed75294698ee27061f7777f54191adbaf3f5e500be35a8b70f24ba0a8402e2c12a94ff0f8c60f911468227b8bbd34a5ffb035077ae5cf3be4c16ee8a24
data/lib/mavenlint.rb CHANGED
@@ -1,2 +1,3 @@
1
- require 'rubocop/cop/mavenlint/unsafe-mass-assignment'
2
- require 'rubocop/cop/mavenlint/use-application-record'
1
+ require 'rubocop/cop/mavenlint/unsafe_mass_assignment'
2
+ require 'rubocop/cop/mavenlint/use_application_record'
3
+ require 'rubocop/cop/mavenlint/use_fast_capybara_matchers'
@@ -15,7 +15,7 @@ module RuboCop
15
15
  # or updated through a publicly accessible endpoint, because the associated model isn't
16
16
  # necessarily loaded and ran through security checks.
17
17
  class UnsafeMassAssignment < RuboCop::Cop::Cop
18
- MSG = "Do not allow mass-assignment of foreign key columns. See http://bit.ly/2IjZco0".freeze
18
+ MSG = "Do not allow mass-assignment of foreign key columns. See https://github.com/mavenlink/welcome/wiki/Lint-Errors#unsafemassassignment".freeze
19
19
 
20
20
  def on_send(node)
21
21
  return unless node.command?(:attr_accessible)
@@ -0,0 +1,46 @@
1
+ require 'rubocop'
2
+
3
+ module RuboCop
4
+ module Cop
5
+ module Mavenlint
6
+ # Identify usages of `to_not` with a Capybara matcher, which will be really slow.
7
+ #
8
+ # For example
9
+ #
10
+ # expect(page).to_not have_text('Hi')
11
+ #
12
+ # Writing an assertion this way will first try to find the text 'Hi'. If not present,
13
+ # Capybara will wait for the full timeout (often 30 seconds) before then inverting with
14
+ # `to_not` and passing.
15
+ #
16
+ # Instead, we should do something like:
17
+ #
18
+ # expect(page).to have_no_text('Hi')
19
+ #
20
+ # Which will pass as soon as the text is not detected without any timeout.
21
+ class UseFastCapybaraMatchers < RuboCop::Cop::Cop
22
+ MSG = 'Use a `to have_no_*` selector. See https://github.com/mavenlink/welcome/wiki/Lint-Errors#usefastcapybaramatchers'.freeze
23
+ CAPYBARA_MATCHERS = %i(have_button have_checked_field have_content have_css have_field have_link have_select have_selector have_table have_text have_unchecked_field have_xpath)
24
+
25
+ def_node_matcher :slow_capybara_matcher?, <<~PATTERN
26
+ (send
27
+ (send nil? :expect _)
28
+ :to_not
29
+ (send nil? #capybara? ...))
30
+ PATTERN
31
+
32
+ def on_send(node)
33
+ return unless slow_capybara_matcher?(node)
34
+
35
+ add_offense(node)
36
+ end
37
+
38
+ private
39
+
40
+ def capybara?(symbol)
41
+ CAPYBARA_MATCHERS.include?(symbol)
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
data/rubocop.yml CHANGED
@@ -56,3 +56,9 @@ Layout/EmptyLinesAroundMethodBody:
56
56
  # Ensure that two spaces are used for indentation.
57
57
  Layout/IndentationWidth:
58
58
  Enabled: true
59
+
60
+ # Only run our Capybara checks in directories that will have Capybara tests.
61
+ Mavenlint/UseFastCapybaraMatchers:
62
+ Include:
63
+ - spec/selenium/**/*.rb
64
+ - spec/features/**/*.rb
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mavenlint
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mavenlnk
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-05-07 00:00:00.000000000 Z
11
+ date: 2018-09-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -60,8 +60,9 @@ extensions: []
60
60
  extra_rdoc_files: []
61
61
  files:
62
62
  - lib/mavenlint.rb
63
- - lib/rubocop/cop/mavenlint/unsafe-mass-assignment.rb
64
- - lib/rubocop/cop/mavenlint/use-application-record.rb
63
+ - lib/rubocop/cop/mavenlint/unsafe_mass_assignment.rb
64
+ - lib/rubocop/cop/mavenlint/use_application_record.rb
65
+ - lib/rubocop/cop/mavenlint/use_fast_capybara_matchers.rb
65
66
  - rubocop.yml
66
67
  homepage: https://github.com/mavenlink/mavenlint
67
68
  licenses: