rubocop-obsession 0.1.7 → 0.1.9
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/rubocop/cop/mixin/helpers.rb +7 -3
- data/lib/rubocop/cop/obsession/no_break_or_next.rb +2 -2
- data/lib/rubocop/cop/obsession/no_todos.rb +13 -0
- data/lib/rubocop/cop/obsession/rails/fully_defined_json_field.rb +10 -6
- data/lib/rubocop/cop/obsession/rails/no_callback_conditions.rb +2 -0
- data/lib/rubocop/cop/obsession/rails/safety_assured_comment.rb +17 -0
- data/lib/rubocop/cop/obsession/rspec/empty_line_after_final_let.rb +10 -8
- data/lib/rubocop/obsession/version.rb +1 -1
- data/lib/rubocop/obsession.rb +1 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 39eccc2042bacc3bca61a4dc992aa38dcca8d7c734e0aa7661b4091e7e1cac2c
|
4
|
+
data.tar.gz: a8f61cd4628e3340e00a144958db6e0eacf60f1505043f6c21a7868a7e4ed664
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6fc06812358cdcd5b26c776dd964f5b341c02a70c4e8200f7542c75fe19026d913b6626c84da8af5a8b5c7cef6b3f36a8e6c4d80b367b664d769baa6ba8d92ca
|
7
|
+
data.tar.gz: d4367dd495d6e5848ad83122214be0a7b6af21dc4ea92278a0c5e97ccc4442a12f777a98838a231cc5336715e86c18de70ae8a86a99e5a04bc0f125f591ef472
|
@@ -3,8 +3,6 @@
|
|
3
3
|
module RuboCop
|
4
4
|
module Cop
|
5
5
|
module Helpers
|
6
|
-
VERBS = File.read("#{__dir__}/files/verbs.txt").split
|
7
|
-
|
8
6
|
def rails_callback?(callback)
|
9
7
|
return true if callback == 'validate'
|
10
8
|
|
@@ -20,7 +18,13 @@ module RuboCop
|
|
20
18
|
def verb?(string)
|
21
19
|
short_string = string[2..] if string.start_with?('re')
|
22
20
|
|
23
|
-
|
21
|
+
verbs.include?(string) || verbs.include?(short_string)
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def verbs
|
27
|
+
@@verbs ||= File.read("#{__dir__}/files/verbs.txt").split
|
24
28
|
end
|
25
29
|
end
|
26
30
|
end
|
@@ -11,8 +11,8 @@ module RuboCop
|
|
11
11
|
# - For small loops, you can just use normal conditions instead of `next`.
|
12
12
|
# `break` is allowed.
|
13
13
|
#
|
14
|
-
# Note: Sometimes loops can also be rethought, like transforming a
|
15
|
-
# + `break` into a `while`.
|
14
|
+
# Note: Sometimes loops can also be rethought, like transforming a
|
15
|
+
# `loop` + `break` into a `while`.
|
16
16
|
#
|
17
17
|
# @example
|
18
18
|
#
|
@@ -11,6 +11,19 @@ module RuboCop
|
|
11
11
|
# stale TODOs. Sometimes developers really mean to work on their TODOs
|
12
12
|
# soon, but then Product re-prioritizes their work, or the developer
|
13
13
|
# leaves the company, and never gets a chance to tackle them.
|
14
|
+
#
|
15
|
+
# @example
|
16
|
+
#
|
17
|
+
# # bad
|
18
|
+
# # TODO: remove this method when we ship the new signup flow
|
19
|
+
# def my_method
|
20
|
+
# ...
|
21
|
+
# end
|
22
|
+
#
|
23
|
+
# # good
|
24
|
+
# def my_method
|
25
|
+
# ...
|
26
|
+
# end
|
14
27
|
class NoTodos < Base
|
15
28
|
MSG = 'Avoid TODO comment, create a task in your project management tool instead.'
|
16
29
|
KEYWORD_REGEX = /(^|[^\w])(TODO|FIXME|OPTIMIZE|HACK)($|[^\w])/i
|
@@ -18,14 +18,18 @@ module RuboCop
|
|
18
18
|
# @example
|
19
19
|
#
|
20
20
|
# # bad
|
21
|
-
#
|
21
|
+
# def change
|
22
|
+
# add_column :languages, :items, :jsonb
|
23
|
+
# end
|
22
24
|
#
|
23
25
|
# # good
|
24
|
-
#
|
25
|
-
#
|
26
|
-
#
|
27
|
-
#
|
28
|
-
#
|
26
|
+
# def change
|
27
|
+
# add_column :languages,
|
28
|
+
# :items,
|
29
|
+
# :jsonb,
|
30
|
+
# default: [],
|
31
|
+
# comment: "Example: [{ 'name': 'ruby' }, { 'name': 'python' }]"
|
32
|
+
# end
|
29
33
|
class FullyDefinedJsonField < Base
|
30
34
|
def_node_matcher :json_field?, <<~PATTERN
|
31
35
|
(send nil? :add_column _ _ (sym {:json :jsonb}) ...)
|
@@ -19,12 +19,14 @@ module RuboCop
|
|
19
19
|
#
|
20
20
|
# # bad
|
21
21
|
# after_update_commit :crawl_rss, if: :rss_changed?
|
22
|
+
#
|
22
23
|
# def crawl_rss
|
23
24
|
# ...
|
24
25
|
# end
|
25
26
|
#
|
26
27
|
# # good
|
27
28
|
# after_update_commit :crawl_rss
|
29
|
+
#
|
28
30
|
# def crawl_rss
|
29
31
|
# return if !rss_changed?
|
30
32
|
# ...
|
@@ -13,6 +13,23 @@ module RuboCop
|
|
13
13
|
# of the DB migration. The reason should be detailed and reviewed by a
|
14
14
|
# knowledgeable PR reviewer. Failure to follow instructions may bring your
|
15
15
|
# app down.
|
16
|
+
#
|
17
|
+
# @example
|
18
|
+
#
|
19
|
+
# # bad
|
20
|
+
# class RemoveSourceUrlFromBlogPosts < ActiveRecord::Migration[8.0]
|
21
|
+
# def change
|
22
|
+
# safety_assured { remove_column :blog_posts, :source_url }
|
23
|
+
# end
|
24
|
+
# end
|
25
|
+
#
|
26
|
+
# # good
|
27
|
+
# class RemoveSourceUrlFromBlogPosts < ActiveRecord::Migration[8.0]
|
28
|
+
# # Safe because this column was ignored with self.ignored_columns in PR #1234
|
29
|
+
# def change
|
30
|
+
# safety_assured { remove_column :blog_posts, :source_url }
|
31
|
+
# end
|
32
|
+
# end
|
16
33
|
class SafetyAssuredComment < Base
|
17
34
|
MSG =
|
18
35
|
'Add `# Safe because <reason>` comment above safety_assured. ' \
|
@@ -8,15 +8,17 @@ if defined?(RuboCop::RSpec)
|
|
8
8
|
#
|
9
9
|
# @example
|
10
10
|
#
|
11
|
-
# describe
|
12
|
-
#
|
13
|
-
#
|
14
|
-
#
|
15
|
-
#
|
11
|
+
# describe Url do
|
12
|
+
# describe '#domain' do
|
13
|
+
# context do
|
14
|
+
# let(:url) { Url.new('http://www.some-site.com/some-page') }
|
15
|
+
# it { expect(url.domain).to eq 'some-site.com' }
|
16
|
+
# end
|
16
17
|
#
|
17
|
-
#
|
18
|
-
#
|
19
|
-
#
|
18
|
+
# context do
|
19
|
+
# let(:url) { Url.new('some-site.com') }
|
20
|
+
# it { expect(url.domain).to eq 'some-site.com' }
|
21
|
+
# end
|
20
22
|
# end
|
21
23
|
# end
|
22
24
|
class EmptyLineAfterFinalLet < RSpec::EmptyLineAfterFinalLet
|
data/lib/rubocop/obsession.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubocop-obsession
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jerome Dalbert
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-11-
|
11
|
+
date: 2024-11-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|