fatkodima / rubocop-disable_syntax

A RuboCop plugin that allows to disable some unfavorite ruby syntax, such as `unless`, safe navigation etc.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

rubocop-disable_syntax

Build Status

rubocop-disable_syntax is a 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:

gem 'rubocop-disable_syntax', group: :development, require: false

And then run:

$ bundle install

Usage

You need to tell RuboCop to load the rubocop-disable_syntax extension.

Put this into your .rubocop.yml.

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:

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.

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.

About

A RuboCop plugin that allows to disable some unfavorite ruby syntax, such as `unless`, safe navigation etc.

License:MIT License


Languages

Language:Ruby 100.0%