Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jeromedalbert/rubocop-obsession
RuboCop extension focused on higher-level concepts, like checking that code reads from top to bottom
https://github.com/jeromedalbert/rubocop-obsession
code-formatter linter rubocop ruby static-code-analysis
Last synced: about 18 hours ago
JSON representation
RuboCop extension focused on higher-level concepts, like checking that code reads from top to bottom
- Host: GitHub
- URL: https://github.com/jeromedalbert/rubocop-obsession
- Owner: jeromedalbert
- License: mit
- Created: 2024-10-20T23:50:08.000Z (18 days ago)
- Default Branch: main
- Last Pushed: 2024-11-01T04:33:14.000Z (7 days ago)
- Last Synced: 2024-11-01T09:58:25.880Z (7 days ago)
- Topics: code-formatter, linter, rubocop, ruby, static-code-analysis
- Language: Ruby
- Homepage: https://rubydoc.info/gems/rubocop-obsession
- Size: 70.3 KB
- Stars: 97
- Watchers: 1
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.txt
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Rubocop Obsession
A [RuboCop](https://github.com/rubocop/rubocop) extension that focuses on
higher-level concepts, like checking that code reads from
[top to bottom](lib/rubocop/cop/obsession/method_order.rb), or only unit
testing [public methods](lib/rubocop/cop/obsession/rspec/describe_public_method.rb).
There are some lower-level cops as well.Use the provided cops as is, or as inspiration to build custom cops aligned
with your project's best practices.Does your project have any cool custom cops that you think others might benefit
from? Then please open a PR!## Installation
Install the gem:
```
gem install rubocop-obsession
```Or add this line to your Gemfile:
```ruby
gem 'rubocop-obsession', require: false
```and run `bundle install`.
## Usage
You need to tell Rubocop to load the Obsession extension. There are three ways
to do this:### Rubocop configuration file
Put this into your `.rubocop.yml`.
```yaml
require: rubocop-obsession
```Alternatively, use the following array notation when specifying multiple extensions.
```yaml
require:
- rubocop-other-extension
- rubocop-obsession
```Now you can run `rubocop` and it will automatically load the Rubocop Obsession
cops together with the standard cops.### Command line
```bash
rubocop --require rubocop-obsession
```### Rake task
```ruby
RuboCop::RakeTask.new do |task|
task.requires << 'rubocop-obsession'
end
```## The cops
All cops are located under
[`lib/rubocop/cop/obsession`](lib/rubocop/cop/obsession), and contain examples
and documentation. Their default configuration is defined in
[`config/default.yml`](config/default.yml).These cops are opinionated and can feel like too much, that is why some of them
are disabled by default. Do not hesitate to enable or disable them as needed.I wrote them to scratch an itch I had at one point or another. Tastes change
with time, and I personally do not use some of them any more, but others might
find them useful.## Development
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.
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).
## Contributing
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).
## License
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
## Code of Conduct
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).