rubocop-obsession 0.1.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.
Files changed (29) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE.txt +21 -0
  3. data/README.md +91 -0
  4. data/config/default.yml +163 -0
  5. data/lib/rubocop/cop/mixin/files/verbs.txt +8507 -0
  6. data/lib/rubocop/cop/mixin/helpers.rb +27 -0
  7. data/lib/rubocop/cop/obsession/graphql/mutation_name.rb +40 -0
  8. data/lib/rubocop/cop/obsession/method_order.rb +244 -0
  9. data/lib/rubocop/cop/obsession/no_break_or_next.rb +94 -0
  10. data/lib/rubocop/cop/obsession/no_paragraphs.rb +62 -0
  11. data/lib/rubocop/cop/obsession/no_todos.rb +26 -0
  12. data/lib/rubocop/cop/obsession/rails/callback_one_method.rb +35 -0
  13. data/lib/rubocop/cop/obsession/rails/fully_defined_json_field.rb +71 -0
  14. data/lib/rubocop/cop/obsession/rails/migration_belongs_to.rb +44 -0
  15. data/lib/rubocop/cop/obsession/rails/no_callback_conditions.rb +60 -0
  16. data/lib/rubocop/cop/obsession/rails/private_callback.rb +59 -0
  17. data/lib/rubocop/cop/obsession/rails/safety_assured_comment.rb +37 -0
  18. data/lib/rubocop/cop/obsession/rails/service_name.rb +82 -0
  19. data/lib/rubocop/cop/obsession/rails/service_perform_method.rb +57 -0
  20. data/lib/rubocop/cop/obsession/rails/short_after_commit.rb +90 -0
  21. data/lib/rubocop/cop/obsession/rails/short_validate.rb +36 -0
  22. data/lib/rubocop/cop/obsession/rails/validate_one_field.rb +33 -0
  23. data/lib/rubocop/cop/obsession/rails/validation_method_name.rb +32 -0
  24. data/lib/rubocop/cop/obsession/rspec/describe_public_method.rb +125 -0
  25. data/lib/rubocop/cop/obsession/rspec/empty_line_after_final_let.rb +36 -0
  26. data/lib/rubocop/cop/obsession/too_many_paragraphs.rb +56 -0
  27. data/lib/rubocop/obsession/version.rb +5 -0
  28. data/lib/rubocop/obsession.rb +9 -0
  29. metadata +100 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: a398487386fc743232d90d035d69d17ef394bd87f5c6b31062333c2f6f16dce7
4
+ data.tar.gz: cff18d09624eee51d93b07f88c1cfa5c056a538d2b56c3871be11d0f581646c3
5
+ SHA512:
6
+ metadata.gz: 6ffb7392aeb75c93dc6e74cbbe7071b6cc8b5b2144b51260f5438a2a9a3661b6f5f841c01ef219782993b935c05fe61c7bac9c824b7c81bd9969806a4a044b22
7
+ data.tar.gz: 4e6546861db7b072a29db94ab7f9dc6fb8fc731015e439ed4402ae56d1b36fd87bf144c464c77d5897268edc0025c3ff04ce78406bebf308c9cc8c81c9ea7927
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2024 Jerome Dalbert
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,91 @@
1
+ # Rubocop Obsession
2
+
3
+ A [RuboCop](https://github.com/rubocop/rubocop) extension that enforces a bunch
4
+ of best practices I have been obsessed with, such as making code read from
5
+ [top to bottom](lib/rubocop/cop/obsession/method_order.rb), or only unit
6
+ testing [public methods](lib/rubocop/cop/obsession/rspec/describe_public_method.rb).
7
+
8
+ ## Installation
9
+
10
+ Install the gem:
11
+
12
+ ```
13
+ gem install rubocop-obsession
14
+ ```
15
+
16
+ Or add this line to your Gemfile:
17
+
18
+ ```ruby
19
+ gem 'rubocop-obsession'
20
+ ```
21
+
22
+ and run `bundle install`.
23
+
24
+ ## Usage
25
+
26
+ You need to tell Rubocop to load the Obsession extension. There are three ways
27
+ to do this:
28
+
29
+ ### Rubocop configuration file
30
+
31
+ Put this into your `.rubocop.yml`.
32
+
33
+ ```yaml
34
+ require: rubocop-obsession
35
+ ```
36
+
37
+ Alternatively, use the following array notation when specifying multiple extensions.
38
+
39
+ ```yaml
40
+ require:
41
+ - rubocop-other-extension
42
+ - rubocop-obsession
43
+ ```
44
+
45
+ Now you can run `rubocop` and it will automatically load the Rubocop Obsession
46
+ cops together with the standard cops.
47
+
48
+ ### Command line
49
+
50
+ ```bash
51
+ rubocop --require rubocop-obsession
52
+ ```
53
+
54
+ ### Rake task
55
+
56
+ ```ruby
57
+ RuboCop::RakeTask.new do |task|
58
+ task.requires << 'rubocop-obsession'
59
+ end
60
+ ```
61
+
62
+ ## The cops
63
+
64
+ All cops are located under
65
+ [`lib/rubocop/cop/obsession`](lib/rubocop/cop/obsession), and contain examples
66
+ and documentation.
67
+
68
+ These cops are opinionated and can often feel like too much, that is why some
69
+ of them are disabled by default. They should not be treated as gospel, so do
70
+ not hesitate to enable or disable them!
71
+
72
+ I wrote them to scratch an itch I had at one point or another. Tastes change
73
+ with time, and I personally do not use some of them.
74
+
75
+ ## Development
76
+
77
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
78
+
79
+ 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).
80
+
81
+ ## Contributing
82
+
83
+ Bug reports and pull requests are welcome on GitHub at https://github.com/jeromedalbert/rubocop-obsession. 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/jeromedalbert/rubocop-obsession/blob/main/CODE_OF_CONDUCT.md).
84
+
85
+ ## License
86
+
87
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
88
+
89
+ ## Code of Conduct
90
+
91
+ Everyone interacting in the Rubocop::Obsession project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/jeromedalbert/rubocop-obsession/blob/main/CODE_OF_CONDUCT.md).
@@ -0,0 +1,163 @@
1
+ Obsession/MethodOrder:
2
+ Enabled: true
3
+ Obsession/NoBreakOrNext:
4
+ Enabled: false
5
+ Exclude:
6
+ - 'script/db/**/*'
7
+ Obsession/NoParagraphs:
8
+ Enabled: false
9
+ Exclude:
10
+ - 'db/migrate/*'
11
+ - 'spec/**/*'
12
+ Obsession/NoTodos:
13
+ Enabled: false
14
+ Obsession/TooManyParagraphs:
15
+ Enabled: false
16
+ Exclude:
17
+ - 'db/migrate/*'
18
+ - 'script/db/**/*'
19
+ - 'spec/**/*'
20
+
21
+ Obsession/Graphql/MutationName:
22
+ Enabled: true
23
+ Include:
24
+ - 'app/graphql/mutations/**/*'
25
+
26
+ Obsession/Rspec/DescribePublicMethod:
27
+ Enabled: true
28
+ Include:
29
+ - 'spec/**/*_spec.rb'
30
+ # Uncommenting this would mean adding rubocop-rspec as a gem dependency. Feels like too much for now.
31
+ # Obsession/Rspec/EmptyLineAfterFinalLet:
32
+ # Enabled: true
33
+ # Include:
34
+ # - 'spec/**/*'
35
+
36
+ Obsession/Rails/CallbackOneMethod:
37
+ Enabled: true
38
+ Include:
39
+ - 'app/models/**/*'
40
+ - 'app/controllers/**/*'
41
+ Obsession/Rails/FullyDefinedJsonField:
42
+ Enabled: true
43
+ Include:
44
+ - 'db/migrate/*'
45
+ Obsession/Rails/MigrationBelongsTo:
46
+ Enabled: true
47
+ Include:
48
+ - 'db/migrate/*'
49
+ Obsession/Rails/NoCallbackConditions:
50
+ Enabled: true
51
+ Include:
52
+ - 'app/models/**/*'
53
+ Obsession/Rails/PrivateCallback:
54
+ Enabled: true
55
+ Include:
56
+ - 'app/models/**/*'
57
+ - 'app/controllers/**/*'
58
+ Obsession/Rails/SafetyAssuredComment:
59
+ Enabled: false
60
+ Include:
61
+ - 'db/migrate/*'
62
+ Obsession/Rails/ServiceName:
63
+ Enabled: true
64
+ Include:
65
+ - 'app/services/**/*'
66
+ - 'app/jobs/**/*'
67
+ Exclude:
68
+ - 'app/jobs/application_job.rb'
69
+ - 'app/jobs/scheduled/scheduled_job.rb'
70
+ - '**/*events/**'
71
+ Obsession/Rails/ServicePerformMethod:
72
+ Enabled: true
73
+ Include:
74
+ - 'app/services/**/*'
75
+ Obsession/Rails/ShortAfterCommit:
76
+ Enabled: true
77
+ Include:
78
+ - 'app/models/**/*'
79
+ Obsession/Rails/ShortValidate:
80
+ Enabled: true
81
+ Include:
82
+ - 'app/models/**/*'
83
+ Obsession/Rails/ValidateOneField:
84
+ Enabled: true
85
+ Include:
86
+ - 'app/models/**/*'
87
+ Obsession/Rails/ValidationMethodName:
88
+ Enabled: true
89
+ Include:
90
+ - 'app/models/**/*'
91
+
92
+ Layout/ClassStructure:
93
+ Enabled: true
94
+ AutoCorrect: false
95
+ Categories:
96
+ module_inclusion:
97
+ - include
98
+ - prepend
99
+ - extend
100
+ attributes:
101
+ - attribute
102
+ - attr_reader
103
+ - attr_writer
104
+ - attr_accessor
105
+ - alias_attribute
106
+ - delegate
107
+ - enum
108
+ associations:
109
+ - belongs_to
110
+ - has_one
111
+ - has_many
112
+ - has_and_belongs_to_many
113
+ validations:
114
+ - validates
115
+ - validate
116
+ - validates_with
117
+ callbacks:
118
+ - before_validation
119
+ - before_save
120
+ - before_create
121
+ - before_destroy
122
+ - after_initialize
123
+ - after_create
124
+ - after_save
125
+ - after_destroy
126
+ - after_commit
127
+ - after_create_commit
128
+ - after_update_commit
129
+ - after_destroy_commit
130
+ - around_create
131
+ other_macros:
132
+ - devise
133
+ - acts_as_paranoid
134
+ - serialize
135
+ - has_paper_trail
136
+ - audited
137
+ scopes:
138
+ - default_scope
139
+ - scope
140
+ controller_actions:
141
+ - before_action
142
+ - skip_before_action
143
+ controller_rescue:
144
+ - rescue_from
145
+ ExpectedOrder:
146
+ - module_inclusion
147
+ - constants
148
+ - attributes
149
+ - enums
150
+ - associations
151
+ - validations
152
+ - callbacks
153
+ - other_macros
154
+ - scopes
155
+ - controller_macros
156
+ - controller_actions
157
+ - controller_action_caching
158
+ - controller_rescue
159
+ - class_methods
160
+ - initializer
161
+ - public_methods
162
+ - protected_methods
163
+ - private_methods