From bb1d9a65b360c4c8afa4d51ef528fd76831fc8db Mon Sep 17 00:00:00 2001 From: Prabodh Kumar Panda Date: Tue, 10 Feb 2026 20:57:26 +0530 Subject: [PATCH] Added how to disable rules --- README.md | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/README.md b/README.md index 4cd05d1..6c573d6 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,42 @@ After checking out the repo, run `bin/setup` to install dependencies. Then, run 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). +## Disabling Cops + +You can disable specific cops in several ways: + +### Disable a cop for a specific file + +Use inline comments at the top of the file: +```ruby +# rubocop:disable Neeto/DirectEnvAccess + +class ApiClient + def initialize + @api_key = ENV['API_KEY'] + end +end + +# rubocop:enable Neeto/DirectEnvAccess +``` + +### Disable a cop for a specific block + +Wrap the code with disable/enable comments: +```ruby +# rubocop:disable Neeto/DirectEnvAccess +api_key = ENV['API_KEY'] +secret = ENV['SECRET_TOKEN'] +# rubocop:enable Neeto/DirectEnvAccess +``` + +### Disable a cop for a single line + +Add an inline comment at the end of the line: +```ruby +api_key = ENV['API_KEY'] # rubocop:disable Neeto/DirectEnvAccess +``` + ## Contributing Bug reports and pull requests are welcome.