Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
inherit_from: .rubocop_todo.yml

require:
- rubocop/cop/internal_affairs
plugins:
- rubocop-internal_affairs
- rubocop-rake

require:
- rubocop-rspec

AllCops:
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## master (unreleased)

* [#58](https://github.com/rubocop/rubocop-rake/pull/58): Pluginfy RuboCop Rake. ([@koic][])
* [#57](https://github.com/rubocop/rubocop-rake/pull/57): Drop support Ruby 2.5 and 2.6 for runtime environment. ([@koic][])

## 0.6.0 (2021-06-29)
Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ gemspec

gem "rake", "~> 13.0"
gem 'rspec'
gem 'rubocop', '>= 0.76'
gem 'rubocop', '>= 1.72.1'
gem 'rubocop-rspec'
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,24 +31,27 @@ ways to do this:
Put this into your `.rubocop.yml`.

```yaml
require: rubocop-rake
plugins: rubocop-rake
```

Alternatively, use the following array notation when specifying multiple extensions.

```yaml
require:
plugins:
- rubocop-other-extension
- rubocop-rake
```

Now you can run `rubocop` and it will automatically load the RuboCop Rake
cops together with the standard cops.

> [!NOTE]
> The plugin system is supported in RuboCop 1.72+. In earlier versions, use `require` instead of `plugins`.

### Command line

```bash
rubocop --require rubocop-rake
rubocop --plugin rubocop-rake
```

### Rake task
Expand All @@ -57,7 +60,7 @@ rubocop --require rubocop-rake
require 'rubocop/rake_task'

RuboCop::RakeTask.new do |task|
task.requires << 'rubocop-rake'
task.plugins << 'rubocop-rake'
end
```

Expand All @@ -71,4 +74,3 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
## Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/rubocop/rubocop-rake.

4 changes: 1 addition & 3 deletions lib/rubocop-rake.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@

require_relative 'rubocop/rake'
require_relative 'rubocop/rake/version'
require_relative 'rubocop/rake/inject'

RuboCop::Rake::Inject.defaults!
require_relative 'rubocop/rake/plugin'

require_relative 'rubocop/cop/rake/helper/class_definition'
require_relative 'rubocop/cop/rake/helper/on_task'
Expand Down
6 changes: 0 additions & 6 deletions lib/rubocop/rake.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,5 @@ module RuboCop
# :nodoc:
module Rake
class Error < StandardError; end

PROJECT_ROOT = Pathname.new(__dir__).parent.parent.expand_path.freeze
CONFIG_DEFAULT = PROJECT_ROOT.join('config', 'default.yml').freeze
CONFIG = YAML.safe_load(CONFIG_DEFAULT.read).freeze

private_constant(:CONFIG_DEFAULT, :PROJECT_ROOT)
end
end
19 changes: 0 additions & 19 deletions lib/rubocop/rake/inject.rb

This file was deleted.

31 changes: 31 additions & 0 deletions lib/rubocop/rake/plugin.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# frozen_string_literal: true

require 'lint_roller'

module RuboCop
module Rake
# A plugin that integrates RuboCop Rake with RuboCop's plugin system.
class Plugin < LintRoller::Plugin
def about
LintRoller::About.new(
name: 'rubocop-rake',
version: Version::STRING,
homepage: 'https://github.com/rubocop/rubocop-rake',
description: 'A RuboCop plugin for Rake.',
)
end

def supported?(context)
context.engine == :rubocop
end

def rules(_context)
LintRoller::Rules.new(
type: :path,
config_format: :rubocop,
value: Pathname.new(__dir__).join('../../../config/default.yml'),
)
end
end
end
end
6 changes: 4 additions & 2 deletions rubocop-rake.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ Gem::Specification.new do |spec|
'homepage_uri' => spec.homepage,
'source_code_uri' => spec.homepage,
'changelog_uri' => "https://github.com/rubocop/rubocop-rake/blob/master/CHANGELOG.md",
'rubygems_mfa_required' => 'true'
'rubygems_mfa_required' => 'true',
'default_lint_roller_plugin' => 'RuboCop::Rake::Plugin'
}

# Specify which files should be added to the gem when it is released.
Expand All @@ -31,5 +32,6 @@ Gem::Specification.new do |spec|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
spec.require_paths = ["lib"]

spec.add_dependency 'rubocop', '~> 1.0'
spec.add_dependency 'lint_roller', '~> 1.1'
spec.add_dependency 'rubocop', '>= 1.72.1'
end
2 changes: 0 additions & 2 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
require 'rubocop/rspec/support'

RSpec.configure do |config|
config.include RuboCop::RSpec::ExpectOffense

config.disable_monkey_patching!
config.raise_errors_for_deprecations!
config.raise_on_warning = true
Expand Down