rubocop-openproject 0.1.0 → 0.2.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
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1b7762dbbe159ef129537b0da6ca121fde8f6417a92ae9d55acff9af82002456
|
|
4
|
+
data.tar.gz: f1193f7c4cf3b908b52a29649927a6e73a5f39376a79e69e0c0540461600ed01
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8d78e20f34afc1d1ac0ffcafa68a1a0953e49b7952d62e0ced2f78866500c43708294f5131796e0e2583c0aa0eab031fdfe818f063184313ef5747642ffcca21
|
|
7
|
+
data.tar.gz: 0d590796e0332ab1679f46062f967d4ab0bee76a97f7f7dc85617dc1186e60437e08071c4c1b6e6981a17fd2262e834fcd9294eb53c1751f9c31d81f1d85a5ff
|
data/CHANGELOG.md
CHANGED
data/config/default.yml
CHANGED
|
@@ -8,6 +8,11 @@ OpenProject/NoDoEndBlockWithRSpecCapybaraMatcherInExpect:
|
|
|
8
8
|
Enabled: true
|
|
9
9
|
VersionAdded: '0.1.0'
|
|
10
10
|
|
|
11
|
+
OpenProject/NoSleepInFeatureSpecs:
|
|
12
|
+
Description: 'Avoid using `sleep` greater than 1 second in feature specs.'
|
|
13
|
+
Enabled: true
|
|
14
|
+
VersionAdded: '0.1.0'
|
|
15
|
+
|
|
11
16
|
OpenProject/UseServiceResultFactoryMethods:
|
|
12
17
|
Description: 'Use ServiceResult factory methods instead of ServiceResult.new.'
|
|
13
18
|
Enabled: true
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module RuboCop
|
|
4
|
+
module Cop
|
|
5
|
+
module OpenProject
|
|
6
|
+
# Checks that feature specs do not use `sleep` greater than 1 second.
|
|
7
|
+
#
|
|
8
|
+
# Relying on `sleep` for synchronization reduces overall performance of
|
|
9
|
+
# the test suite. Consider using Capybara `have_*` matchers or
|
|
10
|
+
# rspec-wait `wait_for` method instead.
|
|
11
|
+
#
|
|
12
|
+
# @example
|
|
13
|
+
#
|
|
14
|
+
# # bad
|
|
15
|
+
# sleep 20
|
|
16
|
+
#
|
|
17
|
+
# # bad
|
|
18
|
+
# sleep 1.5
|
|
19
|
+
#
|
|
20
|
+
# # bad
|
|
21
|
+
# delay = 15
|
|
22
|
+
# sleep delay
|
|
23
|
+
#
|
|
24
|
+
# # good (use sparingly)
|
|
25
|
+
# sleep 1
|
|
26
|
+
#
|
|
27
|
+
# # good
|
|
28
|
+
# expect(page).not_to have_text("please wait")
|
|
29
|
+
#
|
|
30
|
+
# # good
|
|
31
|
+
# expect(page).to have_text("success")
|
|
32
|
+
#
|
|
33
|
+
# good
|
|
34
|
+
# wait_for { work_package.reload.subject }.to eq("Updated name")
|
|
35
|
+
class NoSleepInFeatureSpecs < Base
|
|
36
|
+
MSG = "Avoid using `sleep` greater than 1 second in feature specs. " \
|
|
37
|
+
"It will reduce overall performance of the test suite. " \
|
|
38
|
+
"Consider using Capybara `have_*` matchers or rspec-wait " \
|
|
39
|
+
"`wait_for` method instead."
|
|
40
|
+
|
|
41
|
+
def_node_matcher :on_sleep_call, "(send nil? :sleep $...)"
|
|
42
|
+
|
|
43
|
+
def on_send(node)
|
|
44
|
+
return unless feature_spec?(processed_source)
|
|
45
|
+
|
|
46
|
+
on_sleep_call(node) do |args|
|
|
47
|
+
add_offense(node, message: MSG) if sleeping_too_much?(args[0])
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
private
|
|
52
|
+
|
|
53
|
+
def sleeping_too_much?(arg)
|
|
54
|
+
return false if arg&.numeric_type? && arg.value.between?(0, 1)
|
|
55
|
+
|
|
56
|
+
true
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def feature_spec?(source)
|
|
60
|
+
source.file_path.include?("_spec.rb") && source.file_path.include?("features/")
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
@@ -3,3 +3,4 @@
|
|
|
3
3
|
require_relative "open_project/add_preview_for_view_component"
|
|
4
4
|
require_relative "open_project/no_do_end_block_with_rspec_capybara_matcher_in_expect"
|
|
5
5
|
require_relative "open_project/use_service_result_factory_methods"
|
|
6
|
+
require_relative "open_project/no_sleep_in_feature_specs"
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rubocop-openproject
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- OpenProject GmbH
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: exe
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date: 2024-
|
|
10
|
+
date: 2024-10-18 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: rubocop
|
|
@@ -41,6 +40,7 @@ files:
|
|
|
41
40
|
- lib/rubocop-openproject.rb
|
|
42
41
|
- lib/rubocop/cop/open_project/add_preview_for_view_component.rb
|
|
43
42
|
- lib/rubocop/cop/open_project/no_do_end_block_with_rspec_capybara_matcher_in_expect.rb
|
|
43
|
+
- lib/rubocop/cop/open_project/no_sleep_in_feature_specs.rb
|
|
44
44
|
- lib/rubocop/cop/open_project/use_service_result_factory_methods.rb
|
|
45
45
|
- lib/rubocop/cop/open_project_cops.rb
|
|
46
46
|
- lib/rubocop/open_project.rb
|
|
@@ -54,7 +54,6 @@ metadata:
|
|
|
54
54
|
source_code_uri: https://github.com/opf/rubocop-openproject
|
|
55
55
|
changelog_uri: https://github.com/opf/rubocop-openproject/blob/main/CHANGELOG.md
|
|
56
56
|
rubygems_mfa_required: 'true'
|
|
57
|
-
post_install_message:
|
|
58
57
|
rdoc_options: []
|
|
59
58
|
require_paths:
|
|
60
59
|
- lib
|
|
@@ -69,8 +68,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
69
68
|
- !ruby/object:Gem::Version
|
|
70
69
|
version: '0'
|
|
71
70
|
requirements: []
|
|
72
|
-
rubygems_version: 3.
|
|
73
|
-
signing_key:
|
|
71
|
+
rubygems_version: 3.6.0.dev
|
|
74
72
|
specification_version: 4
|
|
75
73
|
summary: RuboCop cops for OpenProject
|
|
76
74
|
test_files: []
|