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
67 changes: 42 additions & 25 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
inherit_from: .rubocop_todo.yml

inherit_mode:
merge:
- Exclude
- Include

inherit_gem:
rubocop-gusto:
- config/default.yml

plugins:
- rubocop-sorbet
- rubocop-performance
- rubocop-gusto

AllCops:
TargetRubyVersion: 3.3
Expand All @@ -10,78 +20,85 @@ AllCops:
- bin/**/*
- vendor/**/*

Sorbet/StrictSigil:
Gemspec/RequireMFA:
Enabled: false

Layout/ExtraSpacing:
Enabled: true
Exclude:
- danger-packwerk.gemspec

Layout/LineLength:
Enabled: false

Layout/SpaceAroundOperators:
Enabled: true
Exclude:
- danger-packwerk.gemspec

Sorbet/ValidSigil:
Enabled: true

Gemspec/RequireMFA:
Lint/UnusedMethodArgument:
Enabled: false

Layout/LineLength:
Metrics/AbcSize:
Enabled: false

Metrics/BlockLength:
Enabled: false

Style/Documentation:
Metrics/ClassLength:
Enabled: false

Style/SignalException:
Metrics/CyclomaticComplexity:
Enabled: false

Style/MultilineBlockChain:
Metrics/MethodLength:
Enabled: false

Metrics/MethodLength:
Metrics/ModuleLength:
Enabled: false

Metrics/CyclomaticComplexity:
Metrics/ParameterLists:
Enabled: false

Metrics/ModuleLength:
Metrics/PerceivedComplexity:
Enabled: false

Metrics/ClassLength:
Naming/BlockForwarding:
Enabled: false

RSpec/NotToNot:
Enabled: true

Sorbet/FalseSigil:
Enabled: false

Lint/UnusedMethodArgument:
Sorbet/StrictSigil:
Enabled: false

Metrics/AbcSize:
Enabled: false
Sorbet/ValidSigil:
Enabled: true

Style/GuardClause:
Style/ArgumentsForwarding:
Enabled: false

Style/NumericPredicate:
Style/Documentation:
Enabled: false

Metrics/PerceivedComplexity:
Style/GuardClause:
Enabled: false

Metrics/ParameterLists:
Style/MultilineBlockChain:
Enabled: false

Style/SuperArguments:
Style/NumericPredicate:
Enabled: false

Style/ArgumentsForwarding:
Style/SignalException:
Enabled: false

Naming/BlockForwarding:
Style/StringLiterals:
Enabled: true
EnforcedStyle: double_quotes

Style/SuperArguments:
Enabled: false
75 changes: 75 additions & 0 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# This configuration was generated by
# `rubocop --auto-gen-config --exclude-limit 10000`
# on 2026-11-30 21:06:52 UTC using RuboCop version 1.92.1.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# Offense count: 1
# This cop supports unsafe autocorrection (--autocorrect-all).
Gusto/DescribedClassConstantReference:
Exclude:
- 'spec/query_packwerk/reference_spec.rb'

# Offense count: 12
Gusto/NoMetaprogramming:
Exclude:
- 'lib/query_packwerk/query_interface.rb'
- 'spec/query_packwerk/file_cache_spec.rb'
- 'spec/query_packwerk/pks_spec.rb'
- 'spec/query_packwerk/query_interface_spec.rb'
- 'spec/query_packwerk/reference_spec.rb'

# Offense count: 3
# This cop supports unsafe autocorrection (--autocorrect-all).
Gusto/RegexpBypass:
Exclude:
- 'lib/query_packwerk/constant_use.rb'
- 'lib/query_packwerk/pks.rb'

# Offense count: 7
# Configuration parameters: Prefixes, AllowedPatterns.
# Prefixes: when, with, without
RSpec/ContextWording:
Exclude:
- 'spec/query_packwerk/rule_rewriter_spec.rb'
- 'spec/support/pseudo_packs.rb'
- 'spec/support/referenced_packs.rb'

# Offense count: 3
RSpec/MultipleDescribes:
Exclude:
- 'spec/query_packwerk/package_spec.rb'
- 'spec/query_packwerk/violations_spec.rb'
- 'spec/query_packwerk_spec.rb'

# Offense count: 2
RSpec/RepeatedDescription:
Exclude:
- 'spec/query_packwerk/file_cache_spec.rb'

# Offense count: 6
RSpec/RepeatedExampleGroupDescription:
Exclude:
- 'spec/query_packwerk/package_spec.rb'
- 'spec/query_packwerk/violations_spec.rb'
- 'spec/query_packwerk_spec.rb'

# Offense count: 6
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: AutocorrectToRBS.
Sorbet/ForbidTUnsafe:
Exclude:
- 'lib/query_packwerk/constant_use.rb'
- 'lib/query_packwerk/constant_uses.rb'
- 'lib/query_packwerk/package.rb'
- 'lib/query_packwerk/query_interface.rb'

# Offense count: 1
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: EnforcedStyle, Autocorrect.
# SupportedStyles: module_function, extend_self, forbidden
Style/ModuleFunction:
Exclude:
- 'lib/query_packwerk.rb'
25 changes: 13 additions & 12 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
# frozen_string_literal: true

source 'https://rubygems.org'
source "https://rubygems.org"

# Specify your gem's dependencies in query_packwerk.gemspec
gemspec

gem 'irb'
gem 'pry'
gem "irb"
gem "pry"

gem 'packs-specification'
gem "packs-specification"

gem 'rake', '~> 13.4'
gem 'rspec', '~> 3.13'
gem "rake", "~> 13.4"
gem "rspec", "~> 3.13"

gem 'rubocop', '~> 1.92'
gem 'rubocop-performance', '~> 1.27'
gem 'rubocop-sorbet', '~> 0.17'
gem "rubocop", "~> 1.92"
gem "rubocop-gusto", require: false
gem "rubocop-performance", "~> 1.27"
gem "rubocop-sorbet", "~> 0.17"

gem 'sorbet'
gem 'tapioca'
gem "sorbet"
gem "tapioca"

# Unreleased fix for parsing `...` params (Shopify/rbi#625), needed by tapioca's RBS rewriter on herb 0.11
gem 'rbi', github: 'Shopify/rbi'
gem "rbi", github: "Shopify/rbi"
21 changes: 21 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ GEM
smart_properties
bigdecimal (4.1.3)
builder (3.3.0)
code_teams (1.3.1)
sorbet-runtime
coderay (1.1.3)
concurrent-ruby (1.3.8)
connection_pool (3.0.2)
Expand Down Expand Up @@ -178,10 +180,26 @@ GEM
rubocop-ast (1.50.0)
parser (>= 3.3.7.2)
prism (~> 1.7)
rubocop-gusto (11.12.0)
code_teams
lint_roller
rubocop (>= 1.76)
rubocop-performance
rubocop-rake
rubocop-rspec
rubocop-sorbet (>= 0.13.0)
smart_todo
thor
rubocop-performance (1.27.0)
lint_roller (~> 1.1)
rubocop (>= 1.89.0, < 2.0)
rubocop-ast (>= 1.47.1, < 2.0)
rubocop-rake (0.7.1)
lint_roller (~> 1.1)
rubocop (>= 1.72.1)
rubocop-rspec (3.11.0)
lint_roller (~> 1.1)
rubocop (~> 1.92)
rubocop-sorbet (0.17.2)
rbi (~> 0.4, >= 0.4.3)
rbs (>= 4.1.1)
Expand All @@ -193,6 +211,8 @@ GEM
rubydex (0.4.1-x86_64-linux)
securerandom (0.4.1)
smart_properties (1.17.0)
smart_todo (1.11.0)
prism (~> 1.0)
sorbet (0.6.13593)
sorbet-static (= 0.6.13593)
sorbet-runtime (0.6.13593)
Expand Down Expand Up @@ -252,6 +272,7 @@ DEPENDENCIES
rbi!
rspec (~> 3.13)
rubocop (~> 1.92)
rubocop-gusto
rubocop-performance (~> 1.27)
rubocop-sorbet (~> 0.17)
sorbet
Expand Down
8 changes: 4 additions & 4 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# frozen_string_literal: true

require 'bundler/gem_tasks'
require 'rspec/core/rake_task'
require "bundler/gem_tasks"
require "rspec/core/rake_task"

RSpec::Core::RakeTask.new(:spec)

require 'rubocop/rake_task'
require "rubocop/rake_task"

RuboCop::RakeTask.new

task default: %i[spec rubocop]
task default: %i(spec rubocop)
4 changes: 2 additions & 2 deletions exe/query_packwerk
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

require 'query_packwerk'
require 'query_packwerk/cli'
require "query_packwerk"
require "query_packwerk/cli"

QueryPackwerk::CLI.start
44 changes: 22 additions & 22 deletions lib/query_packwerk.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# typed: strict
# frozen_string_literal: true

require 'sorbet-runtime'
require 'herb'
require 'parse_packwerk'
require 'rubocop'
require "sorbet-runtime"
require "herb"
require "parse_packwerk"
require "rubocop"

# QueryPackwerk is a tool for querying Packwerk violations.
#
Expand All @@ -14,21 +14,21 @@
#
# See also: https://github.com/rubyatscale/parse_packwerk
module QueryPackwerk
autoload :Console, 'query_packwerk/console'
autoload :ConsoleHelpers, 'query_packwerk/console_helpers'
autoload :QueryInterface, 'query_packwerk/query_interface'
autoload :ConstantUse, 'query_packwerk/constant_use'
autoload :ConstantUses, 'query_packwerk/constant_uses'
autoload :Violations, 'query_packwerk/violations'
autoload :Violation, 'query_packwerk/violation'
autoload :References, 'query_packwerk/references'
autoload :Reference, 'query_packwerk/reference'
autoload :Pks, 'query_packwerk/pks'
autoload :Packages, 'query_packwerk/packages'
autoload :Package, 'query_packwerk/package'
autoload :RuleRewriter, 'query_packwerk/rule_rewriter'
autoload :FileCache, 'query_packwerk/file_cache'
autoload :Version, 'query_packwerk/version'
autoload :Console, "query_packwerk/console"
autoload :ConsoleHelpers, "query_packwerk/console_helpers"
autoload :QueryInterface, "query_packwerk/query_interface"
autoload :ConstantUse, "query_packwerk/constant_use"
autoload :ConstantUses, "query_packwerk/constant_uses"
autoload :Violations, "query_packwerk/violations"
autoload :Violation, "query_packwerk/violation"
autoload :References, "query_packwerk/references"
autoload :Reference, "query_packwerk/reference"
autoload :Pks, "query_packwerk/pks"
autoload :Packages, "query_packwerk/packages"
autoload :Package, "query_packwerk/package"
autoload :RuleRewriter, "query_packwerk/rule_rewriter"
autoload :FileCache, "query_packwerk/file_cache"
autoload :Version, "query_packwerk/version"

extend T::Sig

Expand Down Expand Up @@ -62,7 +62,7 @@ def violation_sources_for(pack_name)
# Get how often the violations occurred
sig { params(pack_name: String, threshold: Integer).returns(T::Hash[String, T::Hash[String, Integer]]) }
def violation_counts_for(pack_name, threshold: 0)
violations_for(pack_name).source_counts(threshold: threshold)
violations_for(pack_name).source_counts(threshold:)
end

# Get the 'shape' of all violations (how other packages access this package)
Expand All @@ -74,13 +74,13 @@ def anonymous_violation_sources_for(pack_name)
# Get how often each 'shape' of violation occurs (counts of how other packages access this package)
sig { params(pack_name: String, threshold: Integer).returns(T::Hash[String, T::Hash[String, Integer]]) }
def anonymous_violation_counts_for(pack_name, threshold: 0)
violations_for(pack_name).anonymous_source_counts(threshold: threshold)
violations_for(pack_name).anonymous_source_counts(threshold:)
end

# Get which packages consume code from this package (who depends on this package)
sig { params(pack_name: String, threshold: Integer).returns(T::Hash[String, Integer]) }
def consumers(pack_name, threshold: 0)
violations_for(pack_name).consumers(threshold: threshold)
violations_for(pack_name).consumers(threshold:)
end

# Get all references from other packages to this package's constants, whether
Expand Down
Loading