rubocop-obsession 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- 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: d393d8af056f32d108c9c0f272cf6a6ccf2158d33caf91a950ca317f9da2a9cb
|
4
|
+
data.tar.gz: 822e9f0697a1559eb91755d9f2702a9d121727c89e9715e9c48ab447ff702220
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9dc017470f824de21567bf7ec06ea9e372f5edc147932f715e8bdb3a8b60ef6cdfb1a84905b33c9ae0e340cf8515455e59374ec22121c6b4b36296204527918d
|
7
|
+
data.tar.gz: d4a5f84c5714d34ae2733e4f13fb58a089955d83c546ff411a34614bf2178a749f8acd1fc31bd4cbacb3d6fd5d85b24a0648fb7545f44a7a60110d1aa194494f
|
@@ -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.8
|
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
|