rubocop-yiffspace 0.0.1

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.
Files changed (47) hide show
  1. checksums.yaml +7 -0
  2. data/.idea/.gitignore +8 -0
  3. data/.idea/jsonSchemas.xml +25 -0
  4. data/.idea/misc.xml +4 -0
  5. data/.idea/modules.xml +8 -0
  6. data/.idea/rubocop-plugin.iml +65 -0
  7. data/.idea/vcs.xml +6 -0
  8. data/.rspec +3 -0
  9. data/.ruby-version +1 -0
  10. data/LICENSE.txt +21 -0
  11. data/README.md +39 -0
  12. data/Rakefile +33 -0
  13. data/config/custom.yml +17 -0
  14. data/config/default.yml +54 -0
  15. data/config/rails.yml +8 -0
  16. data/config/shared/bundler.yml +1 -0
  17. data/config/shared/gemspec.yml +1 -0
  18. data/config/shared/layout.yml +18 -0
  19. data/config/shared/lint.yml +4 -0
  20. data/config/shared/metrics.yml +35 -0
  21. data/config/shared/migration.yml +1 -0
  22. data/config/shared/naming.yml +7 -0
  23. data/config/shared/rails.yml +14 -0
  24. data/config/shared/security.yml +1 -0
  25. data/config/shared/style.yml +45 -0
  26. data/config/shared.yml +12 -0
  27. data/lib/rubocop/cop/mixin/active_record_helper.rb +18 -0
  28. data/lib/rubocop/cop/mixin/node_formatting_helper.rb +59 -0
  29. data/lib/rubocop/cop/yiff_space/belongs_to_user.rb +121 -0
  30. data/lib/rubocop/cop/yiff_space/belongs_to_user_invalid_ip.rb +107 -0
  31. data/lib/rubocop/cop/yiff_space/belongs_to_user_missing_ip.rb +105 -0
  32. data/lib/rubocop/cop/yiff_space/current_user_outside_of_requests.rb +194 -0
  33. data/lib/rubocop/cop/yiff_space/resolvable_user.rb +113 -0
  34. data/lib/rubocop/cop/yiff_space/user_to_id.rb +64 -0
  35. data/lib/rubocop/cop/yiffspace_cops.rb +10 -0
  36. data/lib/rubocop/yiff_space/plugin.rb +31 -0
  37. data/lib/rubocop/yiff_space/version.rb +7 -0
  38. data/lib/rubocop/yiff_space.rb +8 -0
  39. data/lib/rubocop-yiffspace.rb +9 -0
  40. data/spec/rubocop/cop/yiff_space/belongs_to_user_invalid_ip_spec.rb +109 -0
  41. data/spec/rubocop/cop/yiff_space/belongs_to_user_missing_ip_spec.rb +91 -0
  42. data/spec/rubocop/cop/yiff_space/belongs_to_user_spec.rb +158 -0
  43. data/spec/rubocop/cop/yiff_space/current_user_outside_of_requests_spec.rb +398 -0
  44. data/spec/rubocop/cop/yiff_space/resolvable_user_spec.rb +99 -0
  45. data/spec/rubocop/cop/yiff_space/user_to_id_spec.rb +67 -0
  46. data/spec/spec_helper.rb +20 -0
  47. metadata +118 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 5fd0dd0573dad1402eac1701714f78e98bafe2c40fd8b753f88776bbeae23ac4
4
+ data.tar.gz: 15a05c4cfb067ea83ec47a355ca0270b6b1a3c93aa6c25786fbd508faca60d58
5
+ SHA512:
6
+ metadata.gz: d40713f1144504b174217b9e053507455914b16a453156f5df9342200733fa245e4395320e3a7954968d1458893b30d10b45bbb9a9d23145d8755155125bbcbe
7
+ data.tar.gz: 0f5087b8b4067b03830fd1a4631609648537175aad8be6e2b469185dc476b67e5a15743c9c1baed080a889c9792d348bba38047bccac748ece70053d07fcf25d
data/.idea/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ # Default ignored files
2
+ /shelf/
3
+ /workspace.xml
4
+ # Editor-based HTTP Client requests
5
+ /httpRequests/
6
+ # Datasource local storage ignored files
7
+ /dataSources/
8
+ /dataSources.local.xml
@@ -0,0 +1,25 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="JsonSchemaMappingsProjectConfiguration">
4
+ <state>
5
+ <map>
6
+ <entry key="Rubocop">
7
+ <value>
8
+ <SchemaInfo>
9
+ <option name="name" value="Rubocop" />
10
+ <option name="relativePathToSchema" value="https://www.rubyschema.org/rubocop.json" />
11
+ <option name="applicationDefined" value="true" />
12
+ <option name="patterns">
13
+ <list>
14
+ <Item>
15
+ <option name="path" value="config/shared.yml" />
16
+ </Item>
17
+ </list>
18
+ </option>
19
+ </SchemaInfo>
20
+ </value>
21
+ </entry>
22
+ </map>
23
+ </state>
24
+ </component>
25
+ </project>
data/.idea/misc.xml ADDED
@@ -0,0 +1,4 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectRootManager" version="2" project-jdk-name="Docker: e621" project-jdk-type="RUBY_SDK" />
4
+ </project>
data/.idea/modules.xml ADDED
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectModuleManager">
4
+ <modules>
5
+ <module fileurl="file://$PROJECT_DIR$/.idea/rubocop-plugin.iml" filepath="$PROJECT_DIR$/.idea/rubocop-plugin.iml" />
6
+ </modules>
7
+ </component>
8
+ </project>
@@ -0,0 +1,65 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <module type="RUBY_MODULE" version="4">
3
+ <component name="ModuleRunConfigurationManager">
4
+ <shared />
5
+ </component>
6
+ <component name="NewModuleRootManager">
7
+ <content url="file://$MODULE_DIR$">
8
+ <sourceFolder url="file://$MODULE_DIR$/features" isTestSource="true" />
9
+ <sourceFolder url="file://$MODULE_DIR$/spec" isTestSource="true" />
10
+ <sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
11
+ </content>
12
+ <orderEntry type="jdk" jdkName="rbenv: 3.4.1" jdkType="RUBY_SDK" />
13
+ <orderEntry type="sourceFolder" forTests="false" />
14
+ <orderEntry type="library" scope="PROVIDED" name="activesupport (v8.1.3, rbenv: 3.4.1) [gem]" level="application" />
15
+ <orderEntry type="library" scope="PROVIDED" name="ast (v2.4.3, rbenv: 3.4.1) [gem]" level="application" />
16
+ <orderEntry type="library" scope="PROVIDED" name="base64 (v0.3.0, rbenv: 3.4.1) [gem]" level="application" />
17
+ <orderEntry type="library" scope="PROVIDED" name="bigdecimal (v4.1.2, rbenv: 3.4.1) [gem]" level="application" />
18
+ <orderEntry type="library" scope="PROVIDED" name="bundler (v4.0.6, rbenv: 3.4.1) [gem]" level="application" />
19
+ <orderEntry type="library" scope="PROVIDED" name="concurrent-ruby (v1.3.6, rbenv: 3.4.1) [gem]" level="application" />
20
+ <orderEntry type="library" scope="PROVIDED" name="connection_pool (v3.0.2, rbenv: 3.4.1) [gem]" level="application" />
21
+ <orderEntry type="library" scope="PROVIDED" name="date (v3.5.1, rbenv: 3.4.1) [gem]" level="application" />
22
+ <orderEntry type="library" scope="PROVIDED" name="diff-lcs (v1.6.2, rbenv: 3.4.1) [gem]" level="application" />
23
+ <orderEntry type="library" scope="PROVIDED" name="drb (v2.2.3, rbenv: 3.4.1) [gem]" level="application" />
24
+ <orderEntry type="library" scope="PROVIDED" name="erb (v6.0.4, rbenv: 3.4.1) [gem]" level="application" />
25
+ <orderEntry type="library" scope="PROVIDED" name="i18n (v1.14.8, rbenv: 3.4.1) [gem]" level="application" />
26
+ <orderEntry type="library" scope="PROVIDED" name="io-console (v0.8.2, rbenv: 3.4.1) [gem]" level="application" />
27
+ <orderEntry type="library" scope="PROVIDED" name="irb (v1.18.0, rbenv: 3.4.1) [gem]" level="application" />
28
+ <orderEntry type="library" scope="PROVIDED" name="json (v2.19.5, rbenv: 3.4.1) [gem]" level="application" />
29
+ <orderEntry type="library" scope="PROVIDED" name="language_server-protocol (v3.17.0.5, rbenv: 3.4.1) [gem]" level="application" />
30
+ <orderEntry type="library" scope="PROVIDED" name="lint_roller (v1.1.0, rbenv: 3.4.1) [gem]" level="application" />
31
+ <orderEntry type="library" scope="PROVIDED" name="logger (v1.7.0, rbenv: 3.4.1) [gem]" level="application" />
32
+ <orderEntry type="library" scope="PROVIDED" name="minitest (v6.0.6, rbenv: 3.4.1) [gem]" level="application" />
33
+ <orderEntry type="library" scope="PROVIDED" name="parallel (v2.1.0, rbenv: 3.4.1) [gem]" level="application" />
34
+ <orderEntry type="library" scope="PROVIDED" name="parser (v3.3.11.1, rbenv: 3.4.1) [gem]" level="application" />
35
+ <orderEntry type="library" scope="PROVIDED" name="pp (v0.6.3, rbenv: 3.4.1) [gem]" level="application" />
36
+ <orderEntry type="library" scope="PROVIDED" name="prettyprint (v0.2.0, rbenv: 3.4.1) [gem]" level="application" />
37
+ <orderEntry type="library" scope="PROVIDED" name="prism (v1.9.0, rbenv: 3.4.1) [gem]" level="application" />
38
+ <orderEntry type="library" scope="PROVIDED" name="psych (v5.3.1, rbenv: 3.4.1) [gem]" level="application" />
39
+ <orderEntry type="library" scope="PROVIDED" name="racc (v1.8.1, rbenv: 3.4.1) [gem]" level="application" />
40
+ <orderEntry type="library" scope="PROVIDED" name="rack (v3.2.6, rbenv: 3.4.1) [gem]" level="application" />
41
+ <orderEntry type="library" scope="PROVIDED" name="rainbow (v3.1.1, rbenv: 3.4.1) [gem]" level="application" />
42
+ <orderEntry type="library" scope="PROVIDED" name="rake (v13.4.2, rbenv: 3.4.1) [gem]" level="application" />
43
+ <orderEntry type="library" scope="PROVIDED" name="rdoc (v7.2.0, rbenv: 3.4.1) [gem]" level="application" />
44
+ <orderEntry type="library" scope="PROVIDED" name="regexp_parser (v2.12.0, rbenv: 3.4.1) [gem]" level="application" />
45
+ <orderEntry type="library" scope="PROVIDED" name="reline (v0.6.3, rbenv: 3.4.1) [gem]" level="application" />
46
+ <orderEntry type="library" scope="PROVIDED" name="rspec (v3.13.2, rbenv: 3.4.1) [gem]" level="application" />
47
+ <orderEntry type="library" scope="PROVIDED" name="rspec-core (v3.13.6, rbenv: 3.4.1) [gem]" level="application" />
48
+ <orderEntry type="library" scope="PROVIDED" name="rspec-expectations (v3.13.5, rbenv: 3.4.1) [gem]" level="application" />
49
+ <orderEntry type="library" scope="PROVIDED" name="rspec-mocks (v3.13.8, rbenv: 3.4.1) [gem]" level="application" />
50
+ <orderEntry type="library" scope="PROVIDED" name="rspec-support (v3.13.7, rbenv: 3.4.1) [gem]" level="application" />
51
+ <orderEntry type="library" scope="PROVIDED" name="rubocop (v1.86.1, rbenv: 3.4.1) [gem]" level="application" />
52
+ <orderEntry type="library" scope="PROVIDED" name="rubocop-ast (v1.49.1, rbenv: 3.4.1) [gem]" level="application" />
53
+ <orderEntry type="library" scope="PROVIDED" name="rubocop-rails (v2.34.3, rbenv: 3.4.1) [gem]" level="application" />
54
+ <orderEntry type="library" scope="PROVIDED" name="rubocop-rake (v0.7.1, rbenv: 3.4.1) [gem]" level="application" />
55
+ <orderEntry type="library" scope="PROVIDED" name="rubocop-rspec (v3.9.0, rbenv: 3.4.1) [gem]" level="application" />
56
+ <orderEntry type="library" scope="PROVIDED" name="ruby-progressbar (v1.13.0, rbenv: 3.4.1) [gem]" level="application" />
57
+ <orderEntry type="library" scope="PROVIDED" name="securerandom (v0.4.1, rbenv: 3.4.1) [gem]" level="application" />
58
+ <orderEntry type="library" scope="PROVIDED" name="stringio (v3.2.0, rbenv: 3.4.1) [gem]" level="application" />
59
+ <orderEntry type="library" scope="PROVIDED" name="tsort (v0.2.0, rbenv: 3.4.1) [gem]" level="application" />
60
+ <orderEntry type="library" scope="PROVIDED" name="tzinfo (v2.0.6, rbenv: 3.4.1) [gem]" level="application" />
61
+ <orderEntry type="library" scope="PROVIDED" name="unicode-display_width (v3.2.0, rbenv: 3.4.1) [gem]" level="application" />
62
+ <orderEntry type="library" scope="PROVIDED" name="unicode-emoji (v4.2.0, rbenv: 3.4.1) [gem]" level="application" />
63
+ <orderEntry type="library" scope="PROVIDED" name="uri (v1.1.1, rbenv: 3.4.1) [gem]" level="application" />
64
+ </component>
65
+ </module>
data/.idea/vcs.xml ADDED
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="VcsDirectoryMappings">
4
+ <mapping directory="" vcs="Git" />
5
+ </component>
6
+ </project>
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 3.4.1
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2026 Donovan_DMC
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,39 @@
1
+ # RuboCop::Yiffspace
2
+
3
+ TODO: Delete this and the text below, and describe your gem
4
+
5
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/rubocop/yiffspace`. To experiment with that code, run `bin/console` for an interactive prompt.
6
+
7
+ ## Installation
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
+ Install the gem and add to the application's Gemfile by executing:
12
+
13
+ ```bash
14
+ bundle add UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG --require=false
15
+ ```
16
+
17
+ If bundler is not being used to manage dependencies, install the gem by executing:
18
+
19
+ ```bash
20
+ gem install UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
21
+ ```
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/DonovanDMC/rubocop-yiffspace.
36
+
37
+ ## License
38
+
39
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ require("bundler/gem_tasks")
4
+ require("rubocop/rake_task")
5
+
6
+ RuboCop::RakeTask.new
7
+
8
+ task(default: :rubocop)
9
+
10
+ require("rspec/core/rake_task")
11
+
12
+ RSpec::Core::RakeTask.new(:spec) do |spec|
13
+ spec.pattern = FileList["spec/**/*_spec.rb"]
14
+ end
15
+
16
+ desc("Generate a new cop with a template")
17
+ task(:new_cop, [:cop]) do |_task, args|
18
+ require("rubocop")
19
+
20
+ cop_name = args.fetch(:cop) do
21
+ warn("usage: bundle exec rake new_cop[Department/Name]")
22
+ exit!
23
+ end
24
+
25
+ generator = RuboCop::Cop::Generator.new(cop_name)
26
+
27
+ generator.write_source
28
+ generator.write_spec
29
+ generator.inject_require(root_file_path: "lib/rubocop/cop/yiffspace_cops.rb")
30
+ generator.inject_config(config_file_path: "config/default.yml")
31
+
32
+ puts(generator.todo)
33
+ end
data/config/custom.yml ADDED
@@ -0,0 +1,17 @@
1
+ YiffSpace/BelongsToUser:
2
+ Enabled: true
3
+
4
+ YiffSpace/BelongsToUserInvalidIp:
5
+ Enabled: true
6
+
7
+ YiffSpace/BelongsToUserMissingIp:
8
+ Enabled: true
9
+
10
+ YiffSpace/CurrentUserOutsideOfRequests:
11
+ Enabled: true
12
+
13
+ YiffSpace/ResolvableUser:
14
+ Enabled: true
15
+
16
+ YiffSpace/UserToID:
17
+ Enabled: true
@@ -0,0 +1,54 @@
1
+ # $schema: https://www.rubyschema.org/rubocop.json
2
+
3
+ YiffSpace/BelongsToUser:
4
+ Description: 'Enforces using `belongs_to_user` instead of `belongs_to` for User associations.'
5
+ Enabled: false
6
+ VersionAdded: '<<next>>'
7
+ SafeAutoCorrect: false
8
+ ClassName: User
9
+
10
+ YiffSpace/BelongsToUserInvalidIp:
11
+ Description: 'Detects `belongs_to_user` calls with an `ip:` option pointing to a non-existent database column.'
12
+ Enabled: false
13
+ VersionAdded: '<<next>>'
14
+ SafeAutoCorrect: false
15
+
16
+ YiffSpace/BelongsToUserMissingIp:
17
+ Description: 'Detects `belongs_to_user` calls missing `ip: true` when a corresponding `_ip_addr` column exists.'
18
+ Enabled: false
19
+ VersionAdded: '<<next>>'
20
+ SafeAutoCorrect: false
21
+
22
+ YiffSpace/CurrentUserOutsideOfRequests:
23
+ Description: 'Restricts use of `CurrentUser` to the request cycle (controllers, views, helpers, decorators).'
24
+ Enabled: false
25
+ VersionAdded: '<<next>>'
26
+ ClassName: CurrentUser
27
+ Exclude:
28
+ - app/views/**/*.erb
29
+ - app/controllers/**/*.rb
30
+ - app/helpers/**/*.rb
31
+ - app/presenters/**/*.rb
32
+ - app/decorators/**/*.rb
33
+ - app/inputs/**/*.rb
34
+ IgnoredMethodPatterns: []
35
+ IgnoredMethodPrefixes:
36
+ - apionly_
37
+ IgnoredMethodSuffixes:
38
+ - _current
39
+ - _current!
40
+ - _current?
41
+ IgnoredMethods:
42
+ - serializable_hash
43
+
44
+ YiffSpace/ResolvableUser:
45
+ Description: 'Suggests replacing `resolvable` with `belongs_to_user` when a corresponding `_id` column exists.'
46
+ Enabled: false
47
+ VersionAdded: '<<next>>'
48
+ SafeAutoCorrect: false
49
+
50
+ YiffSpace/UserToID:
51
+ Description: 'Enforces use of `u2id` instead of the `x.is_a?(User) ? x.id : x` ternary pattern.'
52
+ Enabled: false
53
+ VersionAdded: '<<next>>'
54
+ SafeAutoCorrect: false
data/config/rails.yml ADDED
@@ -0,0 +1,8 @@
1
+ # $schema: https://www.rubyschema.org/rubocop.json
2
+
3
+ plugins:
4
+ - rubocop-rails
5
+
6
+ inherit_from:
7
+ - ./shared.yml
8
+ - ./shared/rails.yml
@@ -0,0 +1 @@
1
+ # $schema: https://www.rubyschema.org/rubocop.json
@@ -0,0 +1 @@
1
+ # $schema: https://www.rubyschema.org/rubocop.json
@@ -0,0 +1,18 @@
1
+ # $schema: https://www.rubyschema.org/rubocop.json
2
+
3
+ Layout/FirstArrayElementIndentation:
4
+ EnforcedStyle: consistent
5
+
6
+ Layout/FirstHashElementIndentation:
7
+ EnforcedStyle: consistent
8
+
9
+ Lint/SymbolConversion:
10
+ EnforcedStyle: consistent
11
+
12
+ Layout/HashAlignment:
13
+ Enabled: true
14
+ EnforcedHashRocketStyle: table
15
+ EnforcedColonStyle: table
16
+
17
+ Layout/LineLength:
18
+ Enabled: false
@@ -0,0 +1,4 @@
1
+ # $schema: https://www.rubyschema.org/rubocop.json
2
+
3
+ Lint/SymbolConversion:
4
+ EnforcedStyle: consistent
@@ -0,0 +1,35 @@
1
+ # $schema: https://www.rubyschema.org/rubocop.json
2
+
3
+ Metrics/AbcSize:
4
+ Enabled: false
5
+
6
+ Metrics/BlockLength:
7
+ Enabled: true
8
+ Max: 50
9
+ CountAsOne:
10
+ - array
11
+ - hash
12
+ - heredoc
13
+
14
+ Metrics/ClassLength:
15
+ Enabled: false
16
+
17
+ Metrics/CyclomaticComplexity:
18
+ Enabled: false
19
+
20
+ Metrics/MethodLength:
21
+ Enabled: true
22
+ Max: 50
23
+ CountAsOne:
24
+ - array
25
+ - hash
26
+ - heredoc
27
+
28
+ Metrics/ModuleLength:
29
+ Enabled: false
30
+
31
+ Metrics/ParameterLists:
32
+ Enabled: false
33
+
34
+ Metrics/PerceivedComplexity:
35
+ Enabled: false
@@ -0,0 +1 @@
1
+ # $schema: https://www.rubyschema.org/rubocop.json
@@ -0,0 +1,7 @@
1
+ # $schema: https://www.rubyschema.org/rubocop.json
2
+
3
+ Naming/PredicatePrefix:
4
+ Enabled: false
5
+
6
+ Naming/MethodParameterName:
7
+ Enabled: false
@@ -0,0 +1,14 @@
1
+ # $schema: https://www.rubyschema.org/rubocop.json
2
+
3
+ Rails/HttpStatus:
4
+ EnforcedStyle: symbolic
5
+
6
+ Rails/I18nLocaleTexts:
7
+ Enabled: false
8
+
9
+ Rails/SkipsModelValidations:
10
+ Enabled: false
11
+
12
+ Rails/WhereExists:
13
+ Enabled: true
14
+ EnforcedStyle: where
@@ -0,0 +1 @@
1
+ # $schema: https://www.rubyschema.org/rubocop.json
@@ -0,0 +1,45 @@
1
+ # $schema: https://www.rubyschema.org/rubocop.json
2
+
3
+ Style/ConditionalAssignment:
4
+ Enabled: false
5
+
6
+ Style/Documentation:
7
+ Enabled: false
8
+
9
+ Style/DocumentationMethod:
10
+ Enabled: false
11
+
12
+ Style/FloatDivision:
13
+ Enabled: false
14
+
15
+ Style/HashSyntax:
16
+ EnforcedShorthandSyntax: never
17
+
18
+ Style/PerlBackrefs:
19
+ Enabled: false
20
+
21
+ Style/StringLiterals:
22
+ EnforcedStyle: double_quotes
23
+
24
+ Style/TrailingCommaInArguments:
25
+ EnforcedStyleForMultiline: comma
26
+
27
+ Style/TrailingCommaInArrayLiteral:
28
+ EnforcedStyleForMultiline: consistent_comma
29
+
30
+ Style/TrailingCommaInHashLiteral:
31
+ EnforcedStyleForMultiline: consistent_comma
32
+
33
+ Style/MethodCallWithArgsParentheses:
34
+ Enabled: true
35
+ IgnoreMacros: false
36
+
37
+ Lint/StructNewOverride:
38
+ Enabled: false
39
+
40
+ Style/SingleLineMethods:
41
+ Enabled: true
42
+ AllowIfMethodIsEmpty: true
43
+
44
+ Style/MultilineBlockChain:
45
+ Enabled: false
data/config/shared.yml ADDED
@@ -0,0 +1,12 @@
1
+ # $schema: https://www.rubyschema.org/rubocop.json
2
+
3
+ inherit_from:
4
+ - ./shared/bundler.yml
5
+ - ./shared/gemspec.yml
6
+ - ./shared/layout.yml
7
+ - ./shared/lint.yml
8
+ - ./shared/metrics.yml
9
+ - ./shared/migration.yml
10
+ - ./shared/naming.yml
11
+ - ./shared/security.yml
12
+ - ./shared/style.yml
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ begin
4
+ require("rubocop-rails")
5
+ rescue LoadError
6
+ module RuboCop
7
+ module Cop
8
+ module ActiveRecordHelper
9
+ # Stub used when rubocop-rails is not available.
10
+ # All schema-dependent cops guard on `return unless schema`, so
11
+ # returning nil here causes them to skip silently.
12
+ def schema
13
+ nil
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,59 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RuboCop
4
+ module Cop
5
+ module NodeFormattingHelper
6
+ # rubocop:disable Lint/BooleanSymbol -- No, no I do not want literal values for the keys
7
+ BASIC = {
8
+ true: true,
9
+ false: false,
10
+ nil: nil,
11
+ }.freeze
12
+ # rubocop:enable Lint/BooleanSymbol
13
+
14
+ def format_node(node, default = nil)
15
+ return default if node.nil?
16
+ return node.map { |n| format_node(n) } if node.is_a?(Array)
17
+
18
+ case node.type
19
+ when :sym, :str, :dstr, :int, :dsym, :float, :rational
20
+ format_literal(node)
21
+ when *BASIC.keys
22
+ get_basic(node)
23
+ when :pair
24
+ format_pair(node)
25
+ when :hash
26
+ format_hash(node)
27
+ when :lvar, :block
28
+ node.source
29
+ when :array
30
+ format_array(node)
31
+ else
32
+ raise(StandardError, "Don't know how to format #{node.type}")
33
+ end
34
+ end
35
+
36
+ private
37
+
38
+ def format_literal(node)
39
+ node.value
40
+ end
41
+
42
+ def get_basic(node)
43
+ BASIC[node.type]
44
+ end
45
+
46
+ def format_pair(node)
47
+ [format_node(node.key), format_node(node.value)]
48
+ end
49
+
50
+ def format_hash(node)
51
+ node.pairs.to_h { |pair| format_node(pair) }
52
+ end
53
+
54
+ def format_array(node)
55
+ node.children.map { |n| format_node(n) }
56
+ end
57
+ end
58
+ end
59
+ end