rf-stylez 1.0.1 → 1.0.2
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 +4 -4
- data/lib/rf/stylez/update_check.rb +11 -10
- data/lib/rf/stylez/version.rb +1 -1
- data/lib/rf/stylez.rb +11 -10
- data/lib/rubocop/cop/lint/no_bang_state_machine_events.rb +3 -3
- data/lib/rubocop/cop/lint/no_grape_api.rb +2 -2
- data/lib/rubocop/cop/lint/no_http_party.rb +2 -2
- data/lib/rubocop/cop/lint/no_json.rb +2 -2
- data/lib/rubocop/cop/lint/no_untyped_raise.rb +2 -2
- data/lib/rubocop/cop/lint/no_vcr_recording.rb +4 -3
- data/lib/rubocop/cop/lint/obscure.rb +2 -2
- data/lib/rubocop/cop/lint/use_positive_int32_validator.rb +3 -3
- data/ruby/rubocop.yml +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6eab02f25e22ed5d7365687d436c5f7c6b7e8e036b9d41203b482cb945e573e9
|
4
|
+
data.tar.gz: b0a3163d0569cb82d9024902f2669b78be9bc6f0a8c6541e632212925e05a9ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7f8d14ce2b39e35025cb459371df3369e20e0a5120e29323dcd78acc51829a4fcfc1e4efabdb4ecb31d392235c96e23df40f7ef6314a0dd5beaa56b874c2aa8e
|
7
|
+
data.tar.gz: 012adcb6bdc628f820958909f86042a3a8d4e3863baee8afe070c29dfea9f550a1c2d23c90346a5660963fae813837cf5fbc38978361e88031b06a16f06069c3
|
@@ -1,32 +1,33 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
3
|
+
require "json"
|
4
|
+
require "net/http"
|
5
|
+
require "logger"
|
6
6
|
|
7
7
|
module Rf
|
8
8
|
module Stylez
|
9
|
+
# Check for updates to rf-stylez
|
9
10
|
module UpdateCheck
|
10
|
-
RUBYGEMS_URL = URI(
|
11
|
+
RUBYGEMS_URL = URI("https://rubygems.org/api/v1/gems/rf-stylez.json").freeze
|
11
12
|
|
12
13
|
def self.check
|
13
14
|
logger = Logger.new(STDOUT)
|
14
15
|
current_version = Gem::Version.new(VERSION)
|
15
16
|
|
16
17
|
remote_version = Gem::Version.new(
|
17
|
-
JSON.parse(Net::HTTP.get(RUBYGEMS_URL))[
|
18
|
+
JSON.parse(Net::HTTP.get(RUBYGEMS_URL))["version"] # rubocop:disable Lint/NoJSON
|
18
19
|
)
|
19
20
|
if current_version >= remote_version
|
20
|
-
logger.info(
|
21
|
-
logger.info(
|
21
|
+
logger.info("You are running latest rf-stylez ")
|
22
|
+
logger.info("(•_•) ( •_•)>⌐■-■ (⌐■_■)")
|
22
23
|
else
|
23
|
-
logger.warn(
|
24
|
+
logger.warn("RF Stylez is out of date!")
|
24
25
|
logger.warn("Newest version is: #{remote_version}")
|
25
26
|
logger.warn("You are running: #{current_version}")
|
26
|
-
logger.warn(
|
27
|
+
logger.warn("Please update: `gem update rf-stylez`")
|
27
28
|
end
|
28
29
|
rescue SocketError
|
29
|
-
logger.info(
|
30
|
+
logger.info("Offline, cannot check for rf-stylez updates")
|
30
31
|
end
|
31
32
|
end
|
32
33
|
end
|
data/lib/rf/stylez/version.rb
CHANGED
data/lib/rf/stylez.rb
CHANGED
@@ -1,17 +1,18 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
8
|
-
require
|
9
|
-
require
|
10
|
-
require
|
11
|
-
require
|
12
|
-
require
|
3
|
+
require "rf/stylez/version"
|
4
|
+
require "rf/stylez/update_check"
|
5
|
+
require "rubocop"
|
6
|
+
require "rubocop/cop/lint/no_json"
|
7
|
+
require "rubocop/cop/lint/no_http_party"
|
8
|
+
require "rubocop/cop/lint/obscure"
|
9
|
+
require "rubocop/cop/lint/no_grape_api"
|
10
|
+
require "rubocop/cop/lint/use_positive_int32_validator"
|
11
|
+
require "rubocop/cop/lint/no_untyped_raise"
|
12
|
+
require "rubocop/cop/lint/no_vcr_recording"
|
13
13
|
|
14
14
|
module Rf
|
15
|
+
# Stylez
|
15
16
|
module Stylez
|
16
17
|
def self.reek_config_path
|
17
18
|
File.expand_path("../../ruby/.reek.yml", __dir__)
|
@@ -18,10 +18,10 @@ module RuboCop
|
|
18
18
|
# end
|
19
19
|
# end
|
20
20
|
class NoBangStateMachineEvents < Cop
|
21
|
-
MSG =
|
21
|
+
MSG = "Event names ending with a `!` define `!`-ended methods that do not raise"
|
22
22
|
|
23
|
-
def_node_matcher :is_state_machine_event?,
|
24
|
-
def_node_matcher :is_state_machine?,
|
23
|
+
def_node_matcher :is_state_machine_event?, "(send nil? :event (sym $_))"
|
24
|
+
def_node_matcher :is_state_machine?, "(block (send nil? :state_machine ...) ...)"
|
25
25
|
|
26
26
|
def on_send(node)
|
27
27
|
return unless (event_name = is_state_machine_event?(node))
|
@@ -13,9 +13,9 @@ module RuboCop
|
|
13
13
|
# # good
|
14
14
|
# class Foo < Api::Base
|
15
15
|
class NoGrapeAPI < Cop
|
16
|
-
MSG =
|
16
|
+
MSG = "Prefer inheriting `Api::AuthBase` or `Api::Base` instead of `Grape::API`."
|
17
17
|
|
18
|
-
def_node_matcher :inherits_Grape_API?,
|
18
|
+
def_node_matcher :inherits_Grape_API?, "(class (const ...) (const (const nil? :Grape) :API) ...)"
|
19
19
|
|
20
20
|
def on_class(node)
|
21
21
|
return unless inherits_Grape_API?(node)
|
@@ -10,9 +10,9 @@ module RuboCop
|
|
10
10
|
# # good
|
11
11
|
# TimedRequest.get(...)
|
12
12
|
class NoHTTParty < Cop
|
13
|
-
MSG =
|
13
|
+
MSG = "Prefer `TimedRequest` instead of raw `HTTParty` calls."
|
14
14
|
|
15
|
-
def_node_matcher :is_HTTParty?,
|
15
|
+
def_node_matcher :is_HTTParty?, "(send (const nil? :HTTParty) ...)"
|
16
16
|
|
17
17
|
def on_send(node)
|
18
18
|
return unless is_HTTParty?(node)
|
@@ -11,9 +11,9 @@ module RuboCop
|
|
11
11
|
# MultiJson.load(...)
|
12
12
|
#
|
13
13
|
class NoJSON < Cop
|
14
|
-
MSG =
|
14
|
+
MSG = "Use `MultiJson` instead of `JSON`."
|
15
15
|
|
16
|
-
def_node_matcher :is_JSON?,
|
16
|
+
def_node_matcher :is_JSON?, "(const nil? :JSON)"
|
17
17
|
|
18
18
|
def on_const(node)
|
19
19
|
return unless is_JSON?(node)
|
@@ -11,9 +11,9 @@ module RuboCop
|
|
11
11
|
# raise ArgumentError, 'foo'
|
12
12
|
#
|
13
13
|
class NoUntypedRaise < Cop
|
14
|
-
MSG =
|
14
|
+
MSG = "Do not raise untyped exceptions, specify the error type so it can be rescued specifically."
|
15
15
|
|
16
|
-
def_node_matcher :is_untyped_raise?,
|
16
|
+
def_node_matcher :is_untyped_raise?, "(send nil? {:raise :fail} (str ...) ...)"
|
17
17
|
|
18
18
|
def on_send(node)
|
19
19
|
return unless is_untyped_raise?(node)
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
|
2
|
+
|
3
|
+
require "unparser"
|
3
4
|
|
4
5
|
module RuboCop
|
5
6
|
module Cop
|
@@ -15,7 +16,7 @@ module RuboCop
|
|
15
16
|
class NoVCRRecording < RuboCop::Cop::Base
|
16
17
|
extend AutoCorrector
|
17
18
|
|
18
|
-
MSG =
|
19
|
+
MSG = "Do not set :record option in VCR"
|
19
20
|
|
20
21
|
def_node_search :is_only_setting_record_option?, <<~PATTERN
|
21
22
|
(pair
|
@@ -48,7 +49,7 @@ module RuboCop
|
|
48
49
|
|
49
50
|
add_offense(node) do |corrector|
|
50
51
|
if is_only_setting_record_option?(node)
|
51
|
-
corrector.replace(node,
|
52
|
+
corrector.replace(node, "vcr: true")
|
52
53
|
elsif is_setting_record_option?(node)
|
53
54
|
corrector.replace(node, remove_record_option(node))
|
54
55
|
end
|
@@ -20,7 +20,7 @@ module RuboCop
|
|
20
20
|
#
|
21
21
|
# https://ruby-doc.org/core-2.4.0/String.html#method-i-25
|
22
22
|
class Obscure < Cop
|
23
|
-
MSG =
|
23
|
+
MSG = "Do not use the flipflop operator"
|
24
24
|
|
25
25
|
def_node_matcher :is_stringformat?, <<-PATTERN
|
26
26
|
(send {str dstr} $:% ...)
|
@@ -36,7 +36,7 @@ module RuboCop
|
|
36
36
|
|
37
37
|
def on_send(node)
|
38
38
|
return unless is_stringformat?(node)
|
39
|
-
add_offense(node, message:
|
39
|
+
add_offense(node, message: "Do not use String#%")
|
40
40
|
end
|
41
41
|
end
|
42
42
|
end
|
@@ -14,7 +14,7 @@ module RuboCop
|
|
14
14
|
# requires :id, type: Integer, positive_int32: true
|
15
15
|
# end
|
16
16
|
class UsePositiveInt32Validator < Cop
|
17
|
-
MSG =
|
17
|
+
MSG = "If this Integer maps to a postgres Integer column, validate with `positive_int32: true`"
|
18
18
|
|
19
19
|
# check if the param is `requires` / `optional`
|
20
20
|
def_node_search :find_params_hashes, <<~PATTERN
|
@@ -23,9 +23,9 @@ module RuboCop
|
|
23
23
|
$(hash ...) ...)
|
24
24
|
PATTERN
|
25
25
|
# check if hash contains `type: Integer`
|
26
|
-
def_node_search :is_type_integer?,
|
26
|
+
def_node_search :is_type_integer?, "(pair (sym :type) (const nil? :Integer))"
|
27
27
|
# check if the hash contains the `positive_int32` validator
|
28
|
-
def_node_search :validates_integer?,
|
28
|
+
def_node_search :validates_integer?, "(pair (sym :positive_int32) {{true false} (int _)})"
|
29
29
|
|
30
30
|
def on_block(node)
|
31
31
|
return unless (hash = find_params_hashes(node))
|
data/ruby/rubocop.yml
CHANGED