rubocop-rake 0.6.0 → 0.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a878d5ccc2eec701b39d7d2ee54cbee2eeafc822d0fdd9ebb1bd24174f62eb6e
4
- data.tar.gz: 137d23f7a93f25c027872cff22cca183e87b3c57a34b63a970a6687101a2ea69
3
+ metadata.gz: 73918e72f7bf532b0f7135573441db1a9ef24e238643fc17ea994590f66324f6
4
+ data.tar.gz: fb2e221a24d9137951a0a44da94c321640014a76d4c7708c64a98b881152174d
5
5
  SHA512:
6
- metadata.gz: 67ef6e06e7704cac677af3256d2a14c15729b521a2873d971bf0339eed83bdb04019ea7302cc35b8a461469c52c77382da35d2fca1e7d022cd471a10a832bfa4
7
- data.tar.gz: 111a3788568c30c1588e4aa4108cce2c5d8a4eae21d9f11d897f19fa44495486933edbd8ca0945d63b8daefcc1551e74e69197a02c7006c1f1bf0f57da79f9fa
6
+ metadata.gz: '038cf12d0dfc8ab1961ab51a8cb6338cd8b2eca829a2c31c356fc93934cc36c27ec7877c092068ed2f6b3da5cdb32b63a055328440606ae5e04749eaab3dd35a'
7
+ data.tar.gz: bb96859209d55b15b99ff079870d7845dc06b572623c497227f1ef1562cf507be2960eb1e2c180cf937584210ef3af9483636b825660a87356c213e7285248b3
@@ -0,0 +1,34 @@
1
+ name: CI
2
+
3
+ on:
4
+ pull_request:
5
+ push:
6
+ branches:
7
+ - master
8
+
9
+ concurrency:
10
+ group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
11
+ cancel-in-progress: true
12
+
13
+ jobs:
14
+ main:
15
+ runs-on: ubuntu-latest
16
+ strategy:
17
+ fail-fast: false
18
+ matrix:
19
+ ruby:
20
+ - "2.7"
21
+ - "3.0"
22
+ - "3.1"
23
+ - "3.2"
24
+ - "3.3"
25
+ - "3.4"
26
+ - ruby-head
27
+ name: "Ruby ${{ matrix.ruby }}: spec"
28
+ steps:
29
+ - uses: actions/checkout@v4
30
+ - uses: ruby/setup-ruby@v1
31
+ with:
32
+ ruby-version: "${{ matrix.ruby }}"
33
+ bundler-cache: true
34
+ - run: bundle exec rake
data/.rubocop.yml CHANGED
@@ -1,16 +1,22 @@
1
1
  inherit_from: .rubocop_todo.yml
2
2
 
3
- require:
4
- - rubocop/cop/internal_affairs
3
+ plugins:
4
+ - rubocop-internal_affairs
5
5
  - rubocop-rake
6
+
7
+ require:
6
8
  - rubocop-rspec
7
9
 
8
10
  AllCops:
9
- TargetRubyVersion: 2.5
11
+ NewCops: enable
12
+ TargetRubyVersion: 2.7
10
13
 
11
14
  InternalAffairs/NodeMatcherDirective:
12
15
  Enabled: false
13
16
 
17
+ InternalAffairs/OnSendWithoutOnCSend:
18
+ Enabled: false
19
+
14
20
  Layout/LineLength:
15
21
  Enabled: false
16
22
 
@@ -43,14 +49,16 @@ Style/PercentLiteralDelimiters:
43
49
  Style/TrailingCommaInArguments:
44
50
  EnforcedStyleForMultiline: comma
45
51
 
46
- RSpec/ExampleLength:
47
- Enabled: false
48
-
49
52
  Naming/FileName:
50
53
  Exclude:
51
54
  - 'lib/rubocop-rake.rb'
52
55
 
53
- # This disabling is a workaround for https://github.com/rubocop-hq/rubocop-rspec/issues/1068.
54
- # The cop has been disabled because FactoryBot is not used in this repository.
55
- RSpec/FactoryBot/CreateList:
56
+ RSpec:
57
+ Language:
58
+ Expectations:
59
+ - expect_correction
60
+ - expect_no_offenses
61
+ - expect_offense
62
+
63
+ RSpec/ExampleLength:
56
64
  Enabled: false
data/CHANGELOG.md CHANGED
@@ -2,6 +2,22 @@
2
2
 
3
3
  ## master (unreleased)
4
4
 
5
+ ## 0.7.1 (2025-02-16)
6
+
7
+ ### Bug fixes
8
+
9
+ * [#59](https://github.com/rubocop/rubocop-rake/pull/59): Fix incorrect plugin version when displaing `rubocop -V`. ([@koic][])
10
+
11
+ ## 0.7.0 (2025-02-16)
12
+
13
+ ### New features
14
+
15
+ * [#58](https://github.com/rubocop/rubocop-rake/pull/58): Pluginfy RuboCop Rake. ([@koic][])
16
+
17
+ ### Changes
18
+
19
+ * [#57](https://github.com/rubocop/rubocop-rake/pull/57): Drop support Ruby 2.5 and 2.6 for runtime environment. ([@koic][])
20
+
5
21
  ## 0.6.0 (2021-06-29)
6
22
 
7
23
  ### Changes
data/Gemfile CHANGED
@@ -5,7 +5,7 @@ source "https://rubygems.org"
5
5
  # Specify your gem's dependencies in rubocop-rake.gemspec
6
6
  gemspec
7
7
 
8
- gem "rake", "~> 12.0"
8
+ gem "rake", "~> 13.0"
9
9
  gem 'rspec'
10
- gem 'rubocop', '>= 0.76'
10
+ gem 'rubocop', '>= 1.72.1'
11
11
  gem 'rubocop-rspec'
data/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  [![Gem Version](https://badge.fury.io/rb/rubocop-rake.svg)](https://rubygems.org/gems/rubocop-rake)
2
- [![CircleCI](https://circleci.com/gh/rubocop/rubocop-rake.svg?style=svg)](https://circleci.com/gh/rubocop/rubocop-rake)
2
+ ![CI](https://github.com/rubocop/rubocop-rake/workflows/main.yml/badge.svg)
3
3
 
4
4
  # RuboCop Rake
5
5
 
@@ -23,12 +23,48 @@ Or install it yourself as:
23
23
 
24
24
  ## Usage
25
25
 
26
+ You need to tell RuboCop to load the Rake extension. There are three
27
+ ways to do this:
28
+
29
+ ### RuboCop configuration file
30
+
26
31
  Put this into your `.rubocop.yml`.
27
32
 
28
33
  ```yaml
29
- require: rubocop-rake
34
+ plugins: rubocop-rake
35
+ ```
36
+
37
+ Alternatively, use the following array notation when specifying multiple extensions.
38
+
39
+ ```yaml
40
+ plugins:
41
+ - rubocop-other-extension
42
+ - rubocop-rake
43
+ ```
44
+
45
+ Now you can run `rubocop` and it will automatically load the RuboCop Rake
46
+ cops together with the standard cops.
47
+
48
+ > [!NOTE]
49
+ > The plugin system is supported in RuboCop 1.72+. In earlier versions, use `require` instead of `plugins`.
50
+
51
+ ### Command line
52
+
53
+ ```bash
54
+ rubocop --plugin rubocop-rake
30
55
  ```
31
56
 
57
+ ### Rake task
58
+
59
+ ```ruby
60
+ require 'rubocop/rake_task'
61
+
62
+ RuboCop::RakeTask.new do |task|
63
+ task.plugins << 'rubocop-rake'
64
+ end
65
+ ```
66
+
67
+
32
68
  ## Development
33
69
 
34
70
  After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -38,4 +74,3 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
38
74
  ## Contributing
39
75
 
40
76
  Bug reports and pull requests are welcome on GitHub at https://github.com/rubocop/rubocop-rake.
41
-
@@ -3,7 +3,7 @@
3
3
  module RuboCop
4
4
  module Cop
5
5
  module Rake
6
- # This cop detects class or module definition in a task or namespace,
6
+ # Detects class or module definition in a task or namespace,
7
7
  # because it is defined to the top level.
8
8
  # It is confusing because the scope looks in the task or namespace,
9
9
  # but actually it is defined to the top level.
@@ -74,7 +74,7 @@ module RuboCop
74
74
  end
75
75
 
76
76
  private def can_insert_desc_to?(parent)
77
- parent.begin_type? || parent.block_type? || parent.kwbegin_type?
77
+ parent.type?(:begin, :block, :kwbegin)
78
78
  end
79
79
  end
80
80
  end
@@ -74,7 +74,7 @@ module RuboCop
74
74
  end
75
75
 
76
76
  def source_location(node)
77
- range = node.location.expression
77
+ range = node.source_range
78
78
  path = smart_path(range.source_buffer.name)
79
79
  "#{path}:#{range.line}"
80
80
  end
@@ -73,7 +73,7 @@ module RuboCop
73
73
  end
74
74
 
75
75
  def source_location(node)
76
- range = node.location.expression
76
+ range = node.source_range
77
77
  path = smart_path(range.source_buffer.name)
78
78
  "#{path}:#{range.line}"
79
79
  end
@@ -7,6 +7,8 @@ module RuboCop
7
7
  module OnTask
8
8
  extend NodePattern::Macros
9
9
 
10
+ RESTRICT_ON_SEND = %i[task].freeze
11
+
10
12
  def_node_matcher :task?, <<~PATTERN
11
13
  (send nil? :task ...)
12
14
  PATTERN
@@ -8,7 +8,7 @@ module RuboCop
8
8
  extend self
9
9
 
10
10
  def task_name(node)
11
- first_arg = node.arguments[0]
11
+ first_arg = node.first_argument
12
12
  case first_arg&.type
13
13
  when :sym, :str
14
14
  first_arg.value.to_sym
@@ -3,7 +3,7 @@
3
3
  module RuboCop
4
4
  module Cop
5
5
  module Rake
6
- # This cop detects method definition in a task or namespace,
6
+ # Detects method definition in a task or namespace,
7
7
  # because it is defined to the top level.
8
8
  # It is confusing because the scope looks in the task or namespace,
9
9
  # but actually it is defined to the top level.
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'lint_roller'
4
+
5
+ module RuboCop
6
+ module Rake
7
+ # A plugin that integrates RuboCop Rake with RuboCop's plugin system.
8
+ class Plugin < LintRoller::Plugin
9
+ def about
10
+ LintRoller::About.new(
11
+ name: 'rubocop-rake',
12
+ version: VERSION,
13
+ homepage: 'https://github.com/rubocop/rubocop-rake',
14
+ description: 'A RuboCop plugin for Rake.',
15
+ )
16
+ end
17
+
18
+ def supported?(context)
19
+ context.engine == :rubocop
20
+ end
21
+
22
+ def rules(_context)
23
+ LintRoller::Rules.new(
24
+ type: :path,
25
+ config_format: :rubocop,
26
+ value: Pathname.new(__dir__).join('../../../config/default.yml'),
27
+ )
28
+ end
29
+ end
30
+ end
31
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RuboCop
4
4
  module Rake
5
- VERSION = "0.6.0"
5
+ VERSION = "0.7.1"
6
6
  end
7
7
  end
data/lib/rubocop/rake.rb CHANGED
@@ -6,11 +6,5 @@ module RuboCop
6
6
  # :nodoc:
7
7
  module Rake
8
8
  class Error < StandardError; end
9
-
10
- PROJECT_ROOT = Pathname.new(__dir__).parent.parent.expand_path.freeze
11
- CONFIG_DEFAULT = PROJECT_ROOT.join('config', 'default.yml').freeze
12
- CONFIG = YAML.safe_load(CONFIG_DEFAULT.read).freeze
13
-
14
- private_constant(:CONFIG_DEFAULT, :PROJECT_ROOT)
15
9
  end
16
10
  end
data/lib/rubocop-rake.rb CHANGED
@@ -4,9 +4,7 @@ require 'rubocop'
4
4
 
5
5
  require_relative 'rubocop/rake'
6
6
  require_relative 'rubocop/rake/version'
7
- require_relative 'rubocop/rake/inject'
8
-
9
- RuboCop::Rake::Inject.defaults!
7
+ require_relative 'rubocop/rake/plugin'
10
8
 
11
9
  require_relative 'rubocop/cop/rake/helper/class_definition'
12
10
  require_relative 'rubocop/cop/rake/helper/on_task'
data/rubocop-rake.gemspec CHANGED
@@ -11,14 +11,17 @@ Gem::Specification.new do |spec|
11
11
  spec.summary = %q{A RuboCop plugin for Rake}
12
12
  spec.description = %q{A RuboCop plugin for Rake}
13
13
  spec.homepage = "https://github.com/rubocop/rubocop-rake"
14
- spec.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
14
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.7.0")
15
15
  spec.licenses = ['MIT']
16
16
 
17
- spec.metadata["allowed_push_host"] = "https://rubygems.org"
18
-
19
- spec.metadata["homepage_uri"] = spec.homepage
20
- spec.metadata["source_code_uri"] = spec.homepage
21
- spec.metadata["changelog_uri"] = "https://github.com/rubocop/rubocop-rake/blob/master/CHANGELOG.md"
17
+ spec.metadata = {
18
+ 'allowed_push_host' => 'https://rubygems.org',
19
+ 'homepage_uri' => spec.homepage,
20
+ 'source_code_uri' => spec.homepage,
21
+ 'changelog_uri' => "https://github.com/rubocop/rubocop-rake/blob/master/CHANGELOG.md",
22
+ 'rubygems_mfa_required' => 'true',
23
+ 'default_lint_roller_plugin' => 'RuboCop::Rake::Plugin'
24
+ }
22
25
 
23
26
  # Specify which files should be added to the gem when it is released.
24
27
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
@@ -29,5 +32,6 @@ Gem::Specification.new do |spec|
29
32
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
30
33
  spec.require_paths = ["lib"]
31
34
 
32
- spec.add_runtime_dependency 'rubocop', '~> 1.0'
35
+ spec.add_dependency 'lint_roller', '~> 1.1'
36
+ spec.add_dependency 'rubocop', '>= 1.72.1'
33
37
  end
metadata CHANGED
@@ -1,29 +1,42 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubocop-rake
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Masataka Pocke Kuwabara
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2021-06-28 00:00:00.000000000 Z
10
+ date: 2025-02-16 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
- name: rubocop
13
+ name: lint_roller
15
14
  requirement: !ruby/object:Gem::Requirement
16
15
  requirements:
17
16
  - - "~>"
18
17
  - !ruby/object:Gem::Version
19
- version: '1.0'
18
+ version: '1.1'
20
19
  type: :runtime
21
20
  prerelease: false
22
21
  version_requirements: !ruby/object:Gem::Requirement
23
22
  requirements:
24
23
  - - "~>"
25
24
  - !ruby/object:Gem::Version
26
- version: '1.0'
25
+ version: '1.1'
26
+ - !ruby/object:Gem::Dependency
27
+ name: rubocop
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 1.72.1
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: 1.72.1
27
40
  description: A RuboCop plugin for Rake
28
41
  email:
29
42
  - kuwabara@pocke.me
@@ -31,7 +44,7 @@ executables: []
31
44
  extensions: []
32
45
  extra_rdoc_files: []
33
46
  files:
34
- - ".circleci/config.yml"
47
+ - ".github/workflows/main.yml"
35
48
  - ".gitignore"
36
49
  - ".rspec"
37
50
  - ".rubocop.yml"
@@ -57,7 +70,7 @@ files:
57
70
  - lib/rubocop/cop/rake/method_definition_in_task.rb
58
71
  - lib/rubocop/cop/rake_cops.rb
59
72
  - lib/rubocop/rake.rb
60
- - lib/rubocop/rake/inject.rb
73
+ - lib/rubocop/rake/plugin.rb
61
74
  - lib/rubocop/rake/version.rb
62
75
  - rubocop-rake.gemspec
63
76
  homepage: https://github.com/rubocop/rubocop-rake
@@ -68,7 +81,8 @@ metadata:
68
81
  homepage_uri: https://github.com/rubocop/rubocop-rake
69
82
  source_code_uri: https://github.com/rubocop/rubocop-rake
70
83
  changelog_uri: https://github.com/rubocop/rubocop-rake/blob/master/CHANGELOG.md
71
- post_install_message:
84
+ rubygems_mfa_required: 'true'
85
+ default_lint_roller_plugin: RuboCop::Rake::Plugin
72
86
  rdoc_options: []
73
87
  require_paths:
74
88
  - lib
@@ -76,15 +90,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
76
90
  requirements:
77
91
  - - ">="
78
92
  - !ruby/object:Gem::Version
79
- version: 2.5.0
93
+ version: 2.7.0
80
94
  required_rubygems_version: !ruby/object:Gem::Requirement
81
95
  requirements:
82
96
  - - ">="
83
97
  - !ruby/object:Gem::Version
84
98
  version: '0'
85
99
  requirements: []
86
- rubygems_version: 3.2.13
87
- signing_key:
100
+ rubygems_version: 3.7.0.dev
88
101
  specification_version: 4
89
102
  summary: A RuboCop plugin for Rake
90
103
  test_files: []
data/.circleci/config.yml DELETED
@@ -1,44 +0,0 @@
1
- version: 2
2
-
3
- steps: &steps
4
- steps:
5
- - checkout
6
- - run: bundle install
7
- - run: bundle exec rake
8
-
9
- jobs:
10
-
11
- ruby-2.5:
12
- docker:
13
- - image: circleci/ruby:2.5
14
- <<: *steps
15
-
16
- ruby-2.6:
17
- docker:
18
- - image: circleci/ruby:2.6
19
- <<: *steps
20
-
21
- ruby-2.7:
22
- docker:
23
- - image: circleci/ruby:2.7
24
- <<: *steps
25
-
26
- ruby-3.0:
27
- docker:
28
- - image: circleci/ruby:3.0
29
- <<: *steps
30
-
31
- ruby-head:
32
- docker:
33
- - image: rubocophq/circleci-ruby-snapshot:latest
34
- <<: *steps
35
-
36
- workflows:
37
- version: 2
38
- build:
39
- jobs:
40
- - ruby-2.5
41
- - ruby-2.6
42
- - ruby-2.7
43
- - ruby-3.0
44
- - ruby-head
@@ -1,20 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # The original code is from https://github.com/rubocop/rubocop-rspec/blob/master/lib/rubocop/rspec/inject.rb
4
- # See https://github.com/rubocop/rubocop-rspec/blob/master/MIT-LICENSE.md
5
- module RuboCop
6
- module Rake
7
- # Because RuboCop doesn't yet support plugins, we have to monkey patch in a
8
- # bit of our configuration.
9
- module Inject
10
- def self.defaults!
11
- path = CONFIG_DEFAULT.to_s
12
- hash = ConfigLoader.send(:load_yaml_configuration, path)
13
- config = Config.new(hash, path)
14
- puts "configuration from #{path}" if ConfigLoader.debug?
15
- config = ConfigLoader.merge_with_default(config, path)
16
- ConfigLoader.instance_variable_set(:@default_configuration, config)
17
- end
18
- end
19
- end
20
- end