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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 53d3c586b21811a0a13b55a84253df3c26febb690ea9585b960c9c93d08a982e
4
- data.tar.gz: 00e2f95178bd563b816a8b961b25470115ad2d25249c5b0c9f2921cd23d6df74
3
+ metadata.gz: 39eccc2042bacc3bca61a4dc992aa38dcca8d7c734e0aa7661b4091e7e1cac2c
4
+ data.tar.gz: a8f61cd4628e3340e00a144958db6e0eacf60f1505043f6c21a7868a7e4ed664
5
5
  SHA512:
6
- metadata.gz: 5c5f2748fc138701c397c0952250f3a42a7f810e2830ba2421b7cfc526511bd31ad1f788ab7863ef86546848c8c18586d9e45feef025d14bdec12b232304a401
7
- data.tar.gz: 07c03a46b82ee6038f9ed5cdc7cb1358c58334a183827bb4b8908c2634a819aec88cc938dd451fc2b8182d734765dc284ce4059ea70d4e87a8b8b8e8ed3b98b6
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
- VERBS.include?(string) || VERBS.include?(short_string)
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 `loop`
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
- # add_column :languages, :items, :jsonb
21
+ # def change
22
+ # add_column :languages, :items, :jsonb
23
+ # end
22
24
  #
23
25
  # # good
24
- # add_column :languages,
25
- # :items,
26
- # :jsonb,
27
- # default: [],
28
- # comment: "Example: [{ 'name': 'ruby' }, { 'name': 'python' }]"
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 '#domain' do
12
- # context do
13
- # let(:url) { Url.new('http://www.some-site.com/some-page') }
14
- # it { expect(url.domain).to eq 'some-site.com' }
15
- # end
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
- # context do
18
- # let(:url) { Url.new('some-site.com') }
19
- # it { expect(url.domain).to eq 'some-site.com' }
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
@@ -1,5 +1,5 @@
1
1
  module Rubocop
2
2
  module Obsession
3
- VERSION = '0.1.7'
3
+ VERSION = '0.1.9'
4
4
  end
5
5
  end
@@ -1,5 +1,6 @@
1
1
  require 'active_support'
2
2
  require 'active_support/core_ext/object/blank'
3
+ require 'active_support/core_ext/string/inflections'
3
4
  require 'rubocop'
4
5
 
5
6
  require_relative 'cop/mixin/helpers'
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.7
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-03 00:00:00.000000000 Z
11
+ date: 2024-11-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport