<commit_before>= Extensions

It's possible to extend RuboCop with custom (third-party) cops and formatters.

== Loading Extensions

Besides the `--require` command line option you can also specify ruby
files that should be loaded with the optional `require` directive in the
`.rubocop.yml` file:

[source,yaml]
----
require:
 - ../my/custom/file.rb
 - rubocop-extension
----

NOTE: The paths are directly passed to `Kernel.require`. If your
extension file is not in `$LOAD_PATH`, you need to specify the path as
relative path prefixed with `./` explicitly or absolute path. Paths
starting with a `.` are resolved relative to `.rubocop.yml`.

== Extension Suggestions

Depending on what gems you have in your bundle, RuboCop might suggest extensions
that can be added to provide further functionality. For instance, if you are using
`rspec` without the corresponding `rubocop-rspec` extension, RuboCop will suggest
enabling it.

This message can be disabled by adding the following to your configuration:

[source,yaml]
----
AllCops:
  SuggestExtensions: false
----

You can also opt-out of suggestions for a particular extension library as so (unspecified
extensions will continue to be notified, as appropriate):

[source,yaml]
----
AllCops:
  SuggestExtensions:
    rubocop-rake: false
----

== Custom Cops

You can configure the custom cops in your `.rubocop.yml` just like any
other cop.

=== Writing your own Cops

If you'd like to create an extension gem, you can use https://github.com/rubocop/rubocop-extension-generator[rubocop-extension-generator].

See xref:development.adoc[development] to learn how to implement a cop.

=== Cop Extensions

The main RuboCop gem focuses on the core Ruby language and doesn't
include functionality related to any external Ruby libraries/frameworks.
There are, however, many RuboCop extensions dedicated to those and
a few of them are maintained by RuboCop's Core Team.

==== Official Extensions

* https://github.com/rubocop/rubocop-performance[rubocop-performance] -
Performance optimization analysis
* https://github.com/rubocop/rubocop-rails[rubocop-rails] -
Rails-specific analysis
* https://github.com/rubocop/rubocop-rspec[rubocop-rspec] -
RSpec-specific analysis
* https://github.com/rubocop/rubocop-minitest[rubocop-minitest] -
Minitest-specific analysis
* https://github.com/rubocop/rubocop-rake[rubocop-rake] -
Rake-specific analysis
* https://github.com/rubocop/rubocop-sequel[rubocop-sequel] -
Code style checking for Sequel gem

==== Third-party Extensions

* https://github.com/covermymeds/rubocop-thread_safety[rubocop-thread_safety] -
Thread-safety analysis
* https://github.com/milch/rubocop-require_tools[rubocop-require_tools] -
Dynamic analysis for missing `require` statements
* https://github.com/puppetlabs/rubocop-i18n[rubocop-i18n] -
i18n wrapper function analysis (`gettext` and `rails-i18n`)
* https://github.com/chef/cookstyle[cookstyle] -
Custom cops and config defaults for Chef Infra Cookbooks
* https://github.com/utkarsh2102/rubocop-packaging[rubocop-packaging] -
Upstream best practices and coding conventions for downstream (e.g. Debian packages) compatibility.
* https://github.com/Shopify/rubocop-sorbet[rubocop-sorbet]
Sorbet-specific analysis
* https://github.com/DmitryTsepelev/rubocop-graphql[rubocop-graphql] -<commit_msg>RuboCop::ThreadSafety moved into the RuboCop org<commit_after>= Extensions

It's possible to extend RuboCop with custom (third-party) cops and formatters.

== Loading Extensions

Besides the `--require` command line option you can also specify ruby
files that should be loaded with the optional `require` directive in the
`.rubocop.yml` file:

[source,yaml]
----
require:
 - ../my/custom/file.rb
 - rubocop-extension
----

NOTE: The paths are directly passed to `Kernel.require`. If your
extension file is not in `$LOAD_PATH`, you need to specify the path as
relative path prefixed with `./` explicitly or absolute path. Paths
starting with a `.` are resolved relative to `.rubocop.yml`.

== Extension Suggestions

Depending on what gems you have in your bundle, RuboCop might suggest extensions
that can be added to provide further functionality. For instance, if you are using
`rspec` without the corresponding `rubocop-rspec` extension, RuboCop will suggest
enabling it.

This message can be disabled by adding the following to your configuration:

[source,yaml]
----
AllCops:
  SuggestExtensions: false
----

You can also opt-out of suggestions for a particular extension library as so (unspecified
extensions will continue to be notified, as appropriate):

[source,yaml]
----
AllCops:
  SuggestExtensions:
    rubocop-rake: false
----

== Custom Cops

You can configure the custom cops in your `.rubocop.yml` just like any
other cop.

=== Writing your own Cops

If you'd like to create an extension gem, you can use https://github.com/rubocop/rubocop-extension-generator[rubocop-extension-generator].

See xref:development.adoc[development] to learn how to implement a cop.

=== Cop Extensions

The main RuboCop gem focuses on the core Ruby language and doesn't
include functionality related to any external Ruby libraries/frameworks.
There are, however, many RuboCop extensions dedicated to those and
a few of them are maintained by RuboCop's Core Team.

==== Official Extensions

* https://github.com/rubocop/rubocop-performance[rubocop-performance] -
Performance optimization analysis
* https://github.com/rubocop/rubocop-rails[rubocop-rails] -
Rails-specific analysis
* https://github.com/rubocop/rubocop-rspec[rubocop-rspec] -
RSpec-specific analysis
* https://github.com/rubocop/rubocop-minitest[rubocop-minitest] -
Minitest-specific analysis
* https://github.com/rubocop/rubocop-rake[rubocop-rake] -
Rake-specific analysis
* https://github.com/rubocop/rubocop-sequel[rubocop-sequel] -
Code style checking for Sequel gem
* https://github.com/rubocop/rubocop-thread_safety[rubocop-thread_safety] -
Thread-safety analysis

==== Third-party Extensions

* https://github.com/milch/rubocop-require_tools[rubocop-require_tools] -
Dynamic analysis for missing `require` statements
* https://github.com/puppetlabs/rubocop-i18n[rubocop-i18n] -
i18n wrapper function analysis (`gettext` and `rails-i18n`)
* https://github.com/chef/cookstyle[cookstyle] -
Custom cops and config defaults for Chef Infra Cookbooks
* https://github.com/utkarsh2102/rubocop-packaging[rubocop-packaging] -
Upstream best practices and coding conventions for downstream (e.g. Debian packages) compatibility.
* https://github.com/Shopify/rubocop-sorbet[rubocop-sorbet]
Sorbet-specific analysis
* https://github.com/DmitryTsepelev/rubocop-graphql[rubocop-graphql] -
{'fraction_non_alphanumeric': 0.10049646457048292, 'fraction_numerical': 0.0036106514216939973, 'mean_word_length': 4.721170395869191, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 28, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3733436', 'n_tokens_mistral': 2089, 'n_tokens_neox': 2000, 'n_words': 649}