Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fatkodima/rubocop-disable_syntax
A RuboCop plugin that allows to disable some unfavorite ruby syntax, such as `unless`, safe navigation etc.
https://github.com/fatkodima/rubocop-disable_syntax
Last synced: about 1 month ago
JSON representation
A RuboCop plugin that allows to disable some unfavorite ruby syntax, such as `unless`, safe navigation etc.
- Host: GitHub
- URL: https://github.com/fatkodima/rubocop-disable_syntax
- Owner: fatkodima
- License: mit
- Created: 2023-09-26T09:30:41.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2023-10-13T11:08:38.000Z (about 1 year ago)
- Last Synced: 2024-04-14T10:48:12.592Z (9 months ago)
- Language: Ruby
- Size: 27.3 KB
- Stars: 21
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# rubocop-disable_syntax
[![Build Status](https://github.com/fatkodima/rubocop-disable_syntax/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/fatkodima/rubocop-disable_syntax/actions/workflows/ci.yml)
`rubocop-disable_syntax` is a [RuboCop](https://github.com/rubocop/rubocop) plugin that allows to disable some unfavorite ruby syntax such as `unless`, safe navigation etc.
## Requirements
- ruby 2.7+
- rubocop 1.50+## Installation
Add this line to your application's Gemfile:
```ruby
gem 'rubocop-disable_syntax', group: :development, require: false
```And then run:
```sh
$ bundle install
```## Usage
You need to tell RuboCop to load the `rubocop-disable_syntax` extension.
Put this into your `.rubocop.yml`.
```yaml
require:
- rubocop-disable_syntax
```All the ruby syntax features are enabled by default and so this gem acts as a no-op. You need to manually configure
which ruby features you want to disable:```yml
Style/DisableSyntax:
DisableSyntax:
- unless
- ternary
- safe_navigation
- endless_methods
- arguments_forwarding
- numbered_parameters
- pattern_matching
- shorthand_hash_syntax
- and_or_not
- until
- percent_literals
```* `unless` - no `unless` keyword
* `ternary` - no ternary operator (`condition ? foo : bar`)
* `safe_navigation` - no safe navigation operator (`&.`)
* `endless_methods` - no endless methods (`def foo = 1`)
* `arguments_forwarding` - no arguments forwarding (`foo(...)`, `foo(*)`, `foo(**)`, `foo(&)`)
* `numbered_parameters` - no numbered parameters (`foo.each { puts _1 }`)
* `pattern_matching` - no pattern matching
* `shorthand_hash_syntax` - no shorthand hash syntax (`{ x:, y: }`)
* `and_or_not` - no `and`/`or`/`not` keywords (should use `&&`/`||`/`!` instead)
* `until` - no `until` keyword
* `percent_literals` - no any `%` style literals (`%w[foo bar]`, `%i[foo bar]`, `%q("str")`, `%r{/regex/}`)## Development
After checking out the repo, run `bundle install` to install dependencies. Then, run `rake` to run the linter and tests.
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/fatkodima/rubocop-disable_syntax.
## License
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).