rf-stylez 1.0.1 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- 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/rails/rubocop.yml +15 -0
- data/rf-stylez.gemspec +8 -8
- data/ruby/rubocop.yml +1 -1
- metadata +19 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 635ce26c463a5d16254a7ab7370d7795db7d003781688309788066aeba2ade69
|
4
|
+
data.tar.gz: 78d49dbdd04b273f8e4eb09a67b0740d9de0eef1b742068a157ea2f37784fe48
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1d352f55a2beb9f4664a6689e3b8ffac5e084f84af4d490f26fe863ed9343f3a1a9015ad2457d5204c2a1169b8e387efaf4f9759face0f1640f5f31e9557fa0f
|
7
|
+
data.tar.gz: 75788254d6173f0c4c1ba772eb60aab22b8a8dccd904152ee1f5cca31475875adcd0d7f53765544ae25c1d38002f5210045b685afb2d3625d726cef7d2acba16
|
@@ -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/rails/rubocop.yml
CHANGED
@@ -1 +1,16 @@
|
|
1
1
|
require: rubocop-rails
|
2
|
+
|
3
|
+
Rails/AddColumnIndex:
|
4
|
+
Enabled: true
|
5
|
+
Rails/DuplicateAssociation:
|
6
|
+
Enabled: true
|
7
|
+
Rails/Presence:
|
8
|
+
Enabled: true
|
9
|
+
Rails/Present:
|
10
|
+
Enabled: true
|
11
|
+
Rails/ReversibleMigration:
|
12
|
+
Enabled: true
|
13
|
+
Rails/ReversibleMigrationMethodDefinition:
|
14
|
+
Enabled: true
|
15
|
+
Rails/TransactionExitStatement:
|
16
|
+
Enabled: true
|
data/rf-stylez.gemspec
CHANGED
@@ -21,18 +21,18 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.executables = ["rf-stylez"]
|
22
22
|
spec.require_paths = ["lib"]
|
23
23
|
|
24
|
-
spec.add_runtime_dependency "rubocop", "1.
|
25
|
-
spec.add_runtime_dependency "rubocop-rails", "2.
|
26
|
-
spec.add_runtime_dependency "rubocop-rspec", "2.
|
27
|
-
spec.add_runtime_dependency "reek", "~> 6.
|
28
|
-
spec.add_runtime_dependency "get_env", "~> 0.2.
|
24
|
+
spec.add_runtime_dependency "rubocop", "1.59.0"
|
25
|
+
spec.add_runtime_dependency "rubocop-rails", "2.23.1"
|
26
|
+
spec.add_runtime_dependency "rubocop-rspec", "2.26.1"
|
27
|
+
spec.add_runtime_dependency "reek", "~> 6.2"
|
28
|
+
spec.add_runtime_dependency "get_env", "~> 0.2.1"
|
29
29
|
spec.add_runtime_dependency "unparser", "~> 0.6"
|
30
|
-
spec.add_runtime_dependency "pronto", "~> 0.11.
|
30
|
+
spec.add_runtime_dependency "pronto", "~> 0.11.2"
|
31
31
|
spec.add_runtime_dependency "pronto-rubocop", "~> 0.11.5"
|
32
32
|
|
33
33
|
spec.add_development_dependency "bundler", "~> 2.4"
|
34
|
-
spec.add_development_dependency "rake", "~> 13.
|
35
|
-
spec.add_development_dependency "rspec", ">= 3.
|
34
|
+
spec.add_development_dependency "rake", "~> 13.1"
|
35
|
+
spec.add_development_dependency "rspec", ">= 3.12"
|
36
36
|
spec.add_development_dependency "byebug"
|
37
37
|
spec.add_development_dependency "rspec_junit_formatter"
|
38
38
|
end
|
data/ruby/rubocop.yml
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rf-stylez
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Emanuel Evans
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-01-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubocop
|
@@ -16,70 +16,70 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 1.
|
19
|
+
version: 1.59.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 1.
|
26
|
+
version: 1.59.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rubocop-rails
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - '='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 2.
|
33
|
+
version: 2.23.1
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - '='
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 2.
|
40
|
+
version: 2.23.1
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rubocop-rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - '='
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 2.
|
47
|
+
version: 2.26.1
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - '='
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 2.
|
54
|
+
version: 2.26.1
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: reek
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '6.
|
61
|
+
version: '6.2'
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '6.
|
68
|
+
version: '6.2'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: get_env
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 0.2.
|
75
|
+
version: 0.2.1
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: 0.2.
|
82
|
+
version: 0.2.1
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: unparser
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -100,14 +100,14 @@ dependencies:
|
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: 0.11.
|
103
|
+
version: 0.11.2
|
104
104
|
type: :runtime
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: 0.11.
|
110
|
+
version: 0.11.2
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: pronto-rubocop
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -142,28 +142,28 @@ dependencies:
|
|
142
142
|
requirements:
|
143
143
|
- - "~>"
|
144
144
|
- !ruby/object:Gem::Version
|
145
|
-
version: '13.
|
145
|
+
version: '13.1'
|
146
146
|
type: :development
|
147
147
|
prerelease: false
|
148
148
|
version_requirements: !ruby/object:Gem::Requirement
|
149
149
|
requirements:
|
150
150
|
- - "~>"
|
151
151
|
- !ruby/object:Gem::Version
|
152
|
-
version: '13.
|
152
|
+
version: '13.1'
|
153
153
|
- !ruby/object:Gem::Dependency
|
154
154
|
name: rspec
|
155
155
|
requirement: !ruby/object:Gem::Requirement
|
156
156
|
requirements:
|
157
157
|
- - ">="
|
158
158
|
- !ruby/object:Gem::Version
|
159
|
-
version: '3.
|
159
|
+
version: '3.12'
|
160
160
|
type: :development
|
161
161
|
prerelease: false
|
162
162
|
version_requirements: !ruby/object:Gem::Requirement
|
163
163
|
requirements:
|
164
164
|
- - ">="
|
165
165
|
- !ruby/object:Gem::Version
|
166
|
-
version: '3.
|
166
|
+
version: '3.12'
|
167
167
|
- !ruby/object:Gem::Dependency
|
168
168
|
name: byebug
|
169
169
|
requirement: !ruby/object:Gem::Requirement
|
@@ -248,7 +248,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
248
248
|
- !ruby/object:Gem::Version
|
249
249
|
version: '0'
|
250
250
|
requirements: []
|
251
|
-
rubygems_version: 3.4.
|
251
|
+
rubygems_version: 3.4.19
|
252
252
|
signing_key:
|
253
253
|
specification_version: 4
|
254
254
|
summary: Styles for Rainforest code
|