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
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ AllCops:
Exclude:
- vendor/bundle/**/**

require: rubocop-sorbet
plugins: rubocop-sorbet

Sorbet/StrictSigil:
Enabled: true
Expand Down
46 changes: 26 additions & 20 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ PATH
activesupport
base64
bigdecimal
lint_roller (~> 1.1)
packs-specification
parse_packwerk
rubocop (~> 1.0)
rubocop-sorbet (>= 0.8.4)
rubocop (~> 1.72)
rubocop-sorbet (>= 0.9.0)
sorbet-runtime

GEM
Expand All @@ -19,35 +20,36 @@ GEM
i18n (>= 1.6, < 2)
minitest (>= 5.1)
tzinfo (~> 2.0)
ast (2.4.2)
ast (2.4.3)
base64 (0.2.0)
bigdecimal (3.1.8)
concurrent-ruby (1.1.10)
diff-lcs (1.5.1)
erubi (1.13.0)
i18n (1.12.0)
concurrent-ruby (~> 1.0)
json (2.6.2)
json (2.10.2)
language_server-protocol (3.17.0.4)
lint_roller (1.1.0)
minitest (5.16.3)
netrc (0.11.0)
packs-specification (0.0.10)
sorbet-runtime
parallel (1.25.1)
parallel (1.26.3)
parse_packwerk (0.26.0)
bigdecimal
sorbet-runtime
parser (3.3.4.0)
parser (3.3.7.2)
ast (~> 2.4.1)
racc
prism (0.30.0)
racc (1.8.0)
racc (1.8.1)
rainbow (3.1.1)
rake (13.0.6)
rbi (0.1.14)
prism (>= 0.18.0, < 1.0.0)
sorbet-runtime (>= 0.5.9204)
regexp_parser (2.6.0)
rexml (3.2.5)
regexp_parser (2.10.0)
rspec (3.11.0)
rspec-core (~> 3.11.0)
rspec-expectations (~> 3.11.0)
Expand All @@ -61,25 +63,27 @@ GEM
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.11.0)
rspec-support (3.11.1)
rubocop (1.36.0)
rubocop (1.74.0)
json (~> 2.3)
language_server-protocol (~> 3.17.0.2)
lint_roller (~> 1.1.0)
parallel (~> 1.10)
parser (>= 3.1.2.1)
parser (>= 3.3.0.2)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.20.1, < 2.0)
regexp_parser (>= 2.9.3, < 3.0)
rubocop-ast (>= 1.38.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 3.0)
rubocop-ast (1.21.0)
parser (>= 3.1.1.0)
unicode-display_width (>= 2.4.0, < 4.0)
rubocop-ast (1.41.0)
parser (>= 3.3.7.2)
rubocop-extension-generator (0.5.1)
activesupport
bundler
rubocop (>= 1.22.0)
rubocop-sorbet (0.8.5)
rubocop-sorbet (0.9.0)
lint_roller (~> 1.1)
rubocop (>= 1)
ruby-progressbar (1.11.0)
ruby-progressbar (1.13.0)
sorbet (0.5.11492)
sorbet-static (= 0.5.11492)
sorbet-runtime (0.5.11492)
Expand All @@ -105,7 +109,9 @@ GEM
thor (1.3.1)
tzinfo (2.0.5)
concurrent-ruby (~> 1.0)
unicode-display_width (2.3.0)
unicode-display_width (3.1.4)
unicode-emoji (~> 4.0, >= 4.0.4)
unicode-emoji (4.0.4)
yard (0.9.36)
yard-sorbet (0.9.0)
sorbet-runtime
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,15 @@ You need to tell RuboCop to load the Packs extension. There are three ways to do
Put this into your `.rubocop.yml`:

```yaml
require:
plugins:
- rubocop-packs
```

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

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

## The Cops

All cops are located under [`lib/rubocop/cop/packs`](lib/rubocop/cop/packs), and contain examples/documentation.
Expand Down
5 changes: 2 additions & 3 deletions lib/rubocop-packs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@
require 'packs-specification'

require_relative 'rubocop/packs'
require_relative 'rubocop/packs/inject'
require_relative 'rubocop/packs/version'
require_relative 'rubocop/packs/plugin'
require_relative 'rubocop/packwerk_lite'

require 'rubocop/cop/packs/root_namespace_is_pack_name'
require 'rubocop/cop/packs/typed_public_apis'
require 'rubocop/cop/packs/class_methods_as_public_apis'
require 'rubocop/cop/packs/documented_public_apis'

RuboCop::Packs::Inject.defaults!
5 changes: 0 additions & 5 deletions lib/rubocop/packs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@ module RuboCop
module Packs
extend T::Sig

PROJECT_ROOT = T.let(Pathname.new(__dir__).parent.parent.expand_path.freeze, Pathname)
CONFIG_DEFAULT = T.let(PROJECT_ROOT.join('config', 'default.yml').freeze, Pathname)

private_constant(:CONFIG_DEFAULT, :PROJECT_ROOT)

sig { void }
def self.bust_cache!
config.bust_cache!
Expand Down
24 changes: 0 additions & 24 deletions lib/rubocop/packs/inject.rb

This file was deleted.

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

require 'lint_roller'

module RuboCop
module Packs
# A plugin that integrates rubocop-packs with RuboCop's plugin system.
class Plugin < LintRoller::Plugin
def about
LintRoller::About.new(
name: 'rubocop-packs',
version: VERSION,
homepage: 'https://github.com/rubyatscale/rubocop-packs',
description: 'A collection of Rubocop rules for gradually modularizing a ruby codebase'
)
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
8 changes: 8 additions & 0 deletions lib/rubocop/packs/version.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# typed: false
# frozen_string_literal: true

module RuboCop
module Packs
VERSION = '0.0.45'
end
end
10 changes: 7 additions & 3 deletions rubocop-packs.gemspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
require_relative 'lib/rubocop/packs/version'

Gem::Specification.new do |spec|
spec.name = 'rubocop-packs'
spec.version = '0.0.45'
spec.version = RuboCop::Packs::VERSION
spec.authors = ['Gusto Engineers']
spec.email = ['dev@gusto.com']
spec.summary = 'A collection of Rubocop rules for gradually modularizing a ruby codebase'
Expand All @@ -13,6 +15,7 @@ Gem::Specification.new do |spec|
spec.metadata['source_code_uri'] = 'https://github.com/rubyatscale/rubocop-packs'
spec.metadata['changelog_uri'] = 'https://github.com/rubyatscale/rubocop-packs/releases'
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
spec.metadata['default_lint_roller_plugin'] = 'RuboCop::Packs::Plugin'
else
raise 'RubyGems 2.0 or newer is required to protect against ' \
'public gem pushes.'
Expand All @@ -26,10 +29,11 @@ Gem::Specification.new do |spec|
spec.add_dependency 'activesupport'
spec.add_dependency 'base64'
spec.add_dependency 'bigdecimal'
spec.add_dependency 'lint_roller', '~> 1.1'
spec.add_dependency 'packs-specification'
spec.add_dependency 'parse_packwerk'
spec.add_dependency 'rubocop', '~> 1.0'
spec.add_dependency 'rubocop-sorbet', '>= 0.8.4'
spec.add_dependency 'rubocop', '~> 1.72'
spec.add_dependency 'rubocop-sorbet', '>= 0.9.0'
spec.add_dependency 'sorbet-runtime'

spec.add_development_dependency 'bundler', '~> 2.2.16'
Expand Down
2 changes: 0 additions & 2 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
c.syntax = :expect
end

config.include RuboCop::RSpec::ExpectOffense

config.around do |example|
ParsePackwerk.bust_cache!
RuboCop::Packs.bust_cache!
Expand Down
Loading