ezcater_rubocop 1.3.0 → 1.4.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: caa54b1bc5ab26cb7d499ac8b61e01aeb94bb82de6a7de5c125cbc4a1f4c3c0a
4
- data.tar.gz: 4af52c423b5e171436383e3ee85bbfdd72ef1a80e0de7f519a88e44cf21a20ab
3
+ metadata.gz: 59363f6017a9e7c83ac703824a241234009c10ded26a608b576342dcae476beb
4
+ data.tar.gz: 70ede1534ff0563c74b4c221053a9f97fccf6af899291a39e6ec366aa20fec48
5
5
  SHA512:
6
- metadata.gz: 7cc9e1d28ef7cb67418d65e16e17e5d43c850c76d3b417a4a264c30a80cb43d648ed0204441e5f612b2719daf241fea818e2aace75338106c16910345137ec56
7
- data.tar.gz: 1760b6cdc245067c9d46d6ea9574b1bce15c7c2c1e0dc1b59d53f733a20ac36db2cf137697754f21992d0a76e3dc2dcfba4d11b8fa15b358b5df324523175d9f
6
+ metadata.gz: 8fd92f50f269a93990759237b7260d1872675297ed80d37dfca8bdaac2ce9be26280663a69c3ad3beefa54010ca7b0b64d5b128a6c53bcdee7b164adc98f214c
7
+ data.tar.gz: a4a660828cd2df9b9c86313fc8f763f9aa127746fa2bd80ab52f7c4262bd0317b282e5aa6b95b128ea9691fb9f9abb38fb510e23f269a44c975e4340b245d997
@@ -6,6 +6,9 @@ This gem is moving onto its own [Semantic Versioning](https://semver.org/) schem
6
6
 
7
7
  Prior to v1.0.0 this gem was versioned based on the `MAJOR`.`MINOR` version of RuboCop. The first release of the ezcater_rubocop gem was `v0.49.0`.
8
8
 
9
+ ## v1.4.0
10
+ - Add `Ezcater/RubyTimeout` cop.
11
+
9
12
  ## v1.3.0
10
13
  - Add `Ezcater/GraphqlFieldsNaming` cop.
11
14
 
@@ -51,3 +51,7 @@ Ezcater/StyleDig:
51
51
  Description: 'Recommend `dig` for deeply nested access.'
52
52
  Enabled: true
53
53
  AutoCorrect: false
54
+
55
+ Ezcater/RubyTimeout:
56
+ Description: 'Disallow use of `Timeout.timeout` because it is unsafe and can cause unexpected behavior.'
57
+ Enabled: true
@@ -47,7 +47,7 @@ Gem::Specification.new do |spec|
47
47
  spec.add_development_dependency "rake", "~> 12.3"
48
48
  spec.add_development_dependency "rspec", "~> 3.0"
49
49
  spec.add_development_dependency "rspec_junit_formatter"
50
- spec.add_development_dependency "simplecov"
50
+ spec.add_development_dependency "simplecov", "< 0.18.0"
51
51
 
52
52
  spec.add_runtime_dependency "parser", "!= 2.5.1.1"
53
53
  spec.add_runtime_dependency "rubocop", "~> 0.61.1"
@@ -18,6 +18,7 @@ require "rubocop/cop/ezcater/direct_env_check"
18
18
  require "rubocop/cop/ezcater/graphql_fields_naming"
19
19
  require "rubocop/cop/ezcater/rails_configuration"
20
20
  require "rubocop/cop/ezcater/rails_env"
21
+ require "rubocop/cop/ezcater/ruby_timeout"
21
22
  require "rubocop/cop/ezcater/rails_top_level_sql_execute"
22
23
  require "rubocop/cop/ezcater/require_gql_error_helpers"
23
24
  require "rubocop/cop/ezcater/rspec_match_ordered_array"
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EzcaterRubocop
4
- VERSION = "1.3.0"
4
+ VERSION = "1.4.0"
5
5
  end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RuboCop
4
+ module Cop
5
+ module Ezcater
6
+ # Don't use Timeout.timeout because it can cause transient errors
7
+ #
8
+ # @example
9
+ # # bad
10
+ # Timeout.timeout(5) do
11
+ # ...
12
+ # end
13
+ #
14
+ # # good
15
+ # expiry_time = Time.current + 5.seconds
16
+ # while Time.current < expiry_time
17
+ # ...
18
+ # end
19
+ #
20
+ class RubyTimeout < Cop
21
+ MSG = <<~END_MESSAGE.split("\n").join(" ")
22
+ `Timeout.timeout` is unsafe. Find an alternative to achieve the same goal.
23
+ Ex. Use the timeout capabilities of a networking library.
24
+ Ex. Iterate and check runtime after each iteration.
25
+ END_MESSAGE
26
+
27
+ def_node_matcher "timeout", <<-PATTERN
28
+ (send (const _ :Timeout) :timeout)
29
+ PATTERN
30
+
31
+ def on_send(node)
32
+ timeout(node) do
33
+ add_offense(node, location: :expression, message: MSG)
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ezcater_rubocop
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ezCater, Inc
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-01-22 00:00:00.000000000 Z
11
+ date: 2020-03-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -84,16 +84,16 @@ dependencies:
84
84
  name: simplecov
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ">="
87
+ - - "<"
88
88
  - !ruby/object:Gem::Version
89
- version: '0'
89
+ version: 0.18.0
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ">="
94
+ - - "<"
95
95
  - !ruby/object:Gem::Version
96
- version: '0'
96
+ version: 0.18.0
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: parser
99
99
  requirement: !ruby/object:Gem::Requirement
@@ -169,6 +169,7 @@ files:
169
169
  - lib/rubocop/cop/ezcater/rspec_require_browser_mock.rb
170
170
  - lib/rubocop/cop/ezcater/rspec_require_feature_flag_mock.rb
171
171
  - lib/rubocop/cop/ezcater/rspec_require_http_status_matcher.rb
172
+ - lib/rubocop/cop/ezcater/ruby_timeout.rb
172
173
  - lib/rubocop/cop/ezcater/style_dig.rb
173
174
  - lib/rubocop/rspec/language/each_selector.rb
174
175
  homepage: https://github.com/ezcater/ezcater_rubocop
@@ -191,8 +192,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
191
192
  - !ruby/object:Gem::Version
192
193
  version: '0'
193
194
  requirements: []
194
- rubyforge_project:
195
- rubygems_version: 2.7.6
195
+ rubygems_version: 3.0.3
196
196
  signing_key:
197
197
  specification_version: 4
198
198
  summary: ezCater custom cops and shared configuration