rubocop-teamtailor 0.1.0 → 0.3.0

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: 8ca3d5b8117d60d31717bc5e6d3c268e7138ec2734d247a02afef416ec445811
4
- data.tar.gz: 5094eb595da4608f50aba8f70d9c4f32b0aa0e94f23549b8fd295ff2067a7d8b
3
+ metadata.gz: a3415d0a918da6562c673c1113f17a517e8841834a7005efddd48931d2b7245d
4
+ data.tar.gz: c3cd2927bc900eef6a7e55c6e96ff90087c7473ac2ce22b4ce6091ce3ca55abd
5
5
  SHA512:
6
- metadata.gz: 342b844777a088abf662f4b4335c1d5e0f394ac97d73d9d2ea7746f4ad374146561f087f82feea447e414d4c4ee12fe10cda79f2fca0acc22cc91ba1867d29b3
7
- data.tar.gz: 790a00f4657f19e720564f3c14c7548999d27fa4cd3de9870735ed8667101e75a032a2086d9e19f3bee3f3e8d276264ee4628258a1a0fb7e0910471e96a700ee
6
+ metadata.gz: c3252311d281326157c2e70dce4ddf9cd7677baf442df466e4cde62e26784a632bcc7696fabd9bd279b743f1197f6823a0060af6d3acb9bab422408845a3454a
7
+ data.tar.gz: e7b64854a74e7ef40b9fe1e03c8ae9e9f732d55c942b55ad640b29f429cb62c5d4eb2d14237c6595d03f523229b4c0c40a05324edf96710d04967935e24e59ce
data/README.md CHANGED
@@ -6,15 +6,13 @@ Welcome to your new gem! In this directory, you'll find the files you need to be
6
6
 
7
7
  ## Installation
8
8
 
9
- TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
10
-
11
9
  Install the gem and add to the application's Gemfile by executing:
12
10
 
13
- $ bundle add UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG --require=false
11
+ $ bundle add rubocop-teamtailor --require=false
14
12
 
15
13
  If bundler is not being used to manage dependencies, install the gem by executing:
16
14
 
17
- $ gem install UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
15
+ $ gem install rubocop-teamtailor
18
16
 
19
17
  ## Usage
20
18
 
@@ -28,7 +26,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
28
26
 
29
27
  ## Contributing
30
28
 
31
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/rubocop-teamtailor. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/rubocop-teamtailor/blob/main/CODE_OF_CONDUCT.md).
29
+ Bug reports and pull requests are welcome on GitHub at https://github.com/teamtailor/rubocop-teamtailor. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/teamtailor/rubocop-teamtailor/blob/main/CODE_OF_CONDUCT.md).
32
30
 
33
31
  ## License
34
32
 
@@ -36,4 +34,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
36
34
 
37
35
  ## Code of Conduct
38
36
 
39
- Everyone interacting in the RuboCop::Teamtailor project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/rubocop-teamtailor/blob/main/CODE_OF_CONDUCT.md).
37
+ Everyone interacting in the RuboCop::Teamtailor project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/teamtailor/rubocop-teamtailor/blob/main/CODE_OF_CONDUCT.md).
data/config/default.yml CHANGED
@@ -1,6 +1,6 @@
1
1
  # Write it!
2
2
 
3
- Teamtailor/NoHasManyInActiveModelSerializer:
3
+ Teamtailor/NoEmbeddingsInActiveModelSerializer:
4
4
  Description: "TODO: Write a description of the cop."
5
5
  Enabled: true
6
6
  VersionAdded: "<<next>>"
@@ -3,11 +3,15 @@
3
3
  module RuboCop
4
4
  module Cop
5
5
  module Teamtailor
6
- class NoHasManyInActiveModelSerializer < Base
6
+ class NoEmbeddingsInActiveModelSerializer < Base
7
7
  MSG = "No embedding of records"
8
8
 
9
9
  def_node_matcher :no_has_many?, <<~PATTERN
10
- (send nil? :has_many ...)
10
+ (send nil? {:has_many | :has_one} ...)
11
+ PATTERN
12
+
13
+ def_node_matcher :no_embed?, <<~PATTERN
14
+ (sym {:embed | :embed_in_root})
11
15
  PATTERN
12
16
 
13
17
  def on_class(class_node)
@@ -17,8 +21,17 @@ module RuboCop
17
21
 
18
22
  private
19
23
 
24
+ def is_embedding?(node)
25
+ return true if no_embed?(node)
26
+
27
+ if node.respond_to?(:children)
28
+ return node.children.any? { |child| is_embedding?(child) }
29
+ end
30
+ false
31
+ end
32
+
20
33
  def check_children(node)
21
- if no_has_many?(node)
34
+ if no_has_many?(node) && is_embedding?(node)
22
35
  add_offense(node)
23
36
  end
24
37
 
@@ -1,3 +1,3 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "teamtailor/no_has_many_in_active_model_serializer"
3
+ require_relative "teamtailor/no_embeddings_in_active_model_serializer"
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RuboCop
4
4
  module Teamtailor
5
- VERSION = "0.1.0"
5
+ VERSION = "0.3.0"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubocop-teamtailor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonas Brusman
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-11-12 00:00:00.000000000 Z
11
+ date: 2025-08-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubocop
@@ -42,7 +42,7 @@ files:
42
42
  - Rakefile
43
43
  - config/default.yml
44
44
  - lib/rubocop-teamtailor.rb
45
- - lib/rubocop/cop/teamtailor/no_has_many_in_active_model_serializer.rb
45
+ - lib/rubocop/cop/teamtailor/no_embeddings_in_active_model_serializer.rb
46
46
  - lib/rubocop/cop/teamtailor_cops.rb
47
47
  - lib/rubocop/teamtailor.rb
48
48
  - lib/rubocop/teamtailor/inject.rb
@@ -69,7 +69,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
69
69
  - !ruby/object:Gem::Version
70
70
  version: '0'
71
71
  requirements: []
72
- rubygems_version: 3.4.10
72
+ rubygems_version: 3.5.22
73
73
  signing_key:
74
74
  specification_version: 4
75
75
  summary: Teamtailor's RuboCop cops