diff --git a/.rubocop.yml b/.rubocop.yml index a10e085..f9e12bb 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -8,11 +8,21 @@ # where the inspected file is and continue its way up to the root directory. # # See https://docs.rubocop.org/rubocop/configuration + +plugins: + - rubocop-rake + - rubocop-rspec + AllCops: NewCops: enable Exclude: - vendor/bundle/**/** - TargetRubyVersion: 2.6 + - bin/** + TargetRubyVersion: 3.2 + +Gemspec/DevelopmentDependencies: + Enabled: true + EnforcedStyle: Gemfile Metrics/ParameterLists: Enabled: false @@ -118,6 +128,11 @@ Style/AccessorGrouping: Style/HashSyntax: Enabled: false -Gemspec/DevelopmentDependencies: - Enabled: true - EnforcedStyle: gemspec +RSpec/MultipleExpectations: + Enabled: false + +RSpec/ExampleLength: + Enabled: false + +RSpec/ContextWording: + Enabled: false diff --git a/Gemfile b/Gemfile index 97fb145..0bee887 100644 --- a/Gemfile +++ b/Gemfile @@ -2,3 +2,12 @@ source 'https://rubygems.org' # Specify your gem's dependencies in code_teams.gemspec gemspec + +gem 'pry' +gem 'rake' +gem 'rspec', '~> 3.0' +gem 'rubocop' +gem 'rubocop-rake' +gem 'rubocop-rspec' +gem 'sorbet' +gem 'tapioca' diff --git a/Gemfile.lock b/Gemfile.lock index f9815ae..cc7ddc0 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -7,57 +7,102 @@ PATH GEM remote: https://rubygems.org/ specs: - ast (2.4.2) + ast (2.4.3) + benchmark (0.4.0) coderay (1.1.3) - diff-lcs (1.4.4) - json (2.6.3) - language_server-protocol (3.17.0.3) - method_source (1.0.0) - parallel (1.23.0) - parser (3.2.2.4) + diff-lcs (1.6.2) + erubi (1.13.1) + json (2.12.2) + language_server-protocol (3.17.0.5) + lint_roller (1.1.0) + logger (1.7.0) + method_source (1.1.0) + netrc (0.11.0) + parallel (1.27.0) + parser (3.3.8.0) ast (~> 2.4.1) racc - pry (0.14.1) + prism (1.4.0) + pry (0.15.2) coderay (~> 1.1) method_source (~> 1.0) - racc (1.7.3) + racc (1.8.1) rainbow (3.1.1) - rake (13.0.6) - regexp_parser (2.8.2) - rexml (3.2.6) - rspec (3.10.0) - rspec-core (~> 3.10.0) - rspec-expectations (~> 3.10.0) - rspec-mocks (~> 3.10.0) - rspec-core (3.10.1) - rspec-support (~> 3.10.0) - rspec-expectations (3.10.1) + rake (13.3.0) + rbi (0.3.3) + prism (~> 1.0) + rbs (>= 3.4.4) + sorbet-runtime (>= 0.5.9204) + rbs (3.9.4) + logger + regexp_parser (2.10.0) + rexml (3.4.1) + rspec (3.13.1) + rspec-core (~> 3.13.0) + rspec-expectations (~> 3.13.0) + rspec-mocks (~> 3.13.0) + rspec-core (3.13.4) + rspec-support (~> 3.13.0) + rspec-expectations (3.13.5) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.10.0) - rspec-mocks (3.10.2) + rspec-support (~> 3.13.0) + rspec-mocks (3.13.5) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.10.0) - rspec-support (3.10.2) - rubocop (1.57.2) + rspec-support (~> 3.13.0) + rspec-support (3.13.4) + rubocop (1.75.8) json (~> 2.3) - language_server-protocol (>= 3.17.0) + language_server-protocol (~> 3.17.0.2) + lint_roller (~> 1.1.0) parallel (~> 1.10) - parser (>= 3.2.2.4) + 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.28.1, < 2.0) + regexp_parser (>= 2.9.3, < 3.0) + rubocop-ast (>= 1.44.0, < 2.0) ruby-progressbar (~> 1.7) - unicode-display_width (>= 2.4.0, < 3.0) - rubocop-ast (1.30.0) - parser (>= 3.2.1.0) + unicode-display_width (>= 2.4.0, < 4.0) + rubocop-ast (1.44.1) + parser (>= 3.3.7.2) + prism (~> 1.4) + rubocop-rake (0.7.1) + lint_roller (~> 1.1) + rubocop (>= 1.72.1) + rubocop-rspec (3.6.0) + lint_roller (~> 1.1) + rubocop (~> 1.72, >= 1.72.1) ruby-progressbar (1.13.0) - sorbet (0.5.11122) - sorbet-static (= 0.5.11122) - sorbet-runtime (0.5.9976) - sorbet-static (0.5.11122-universal-darwin) - sorbet-static (0.5.11122-x86_64-linux) - unicode-display_width (2.5.0) + sorbet (0.5.12134) + sorbet-static (= 0.5.12134) + sorbet-runtime (0.5.12134) + sorbet-static (0.5.12134-universal-darwin) + sorbet-static-and-runtime (0.5.12134) + sorbet (= 0.5.12134) + sorbet-runtime (= 0.5.12134) + spoom (1.6.3) + erubi (>= 1.10.0) + prism (>= 0.28.0) + rbi (>= 0.3.3) + rexml (>= 3.2.6) + sorbet-static-and-runtime (>= 0.5.10187) + thor (>= 0.19.2) + tapioca (0.16.11) + benchmark + bundler (>= 2.2.25) + netrc (>= 0.11.0) + parallel (>= 1.21.0) + rbi (~> 0.2) + sorbet-static-and-runtime (>= 0.5.11087) + spoom (>= 1.2.0) + thor (>= 1.2.0) + yard-sorbet + thor (1.3.2) + unicode-display_width (3.1.4) + unicode-emoji (~> 4.0, >= 4.0.4) + unicode-emoji (4.0.4) + yard (0.9.37) + yard-sorbet (0.9.0) + sorbet-runtime + yard PLATFORMS universal-darwin @@ -69,7 +114,10 @@ DEPENDENCIES rake rspec (~> 3.0) rubocop + rubocop-rake + rubocop-rspec sorbet + tapioca BUNDLED WITH 2.4.7 diff --git a/bin/rubocop b/bin/rubocop new file mode 100755 index 0000000..369a05b --- /dev/null +++ b/bin/rubocop @@ -0,0 +1,27 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +# +# This file was generated by Bundler. +# +# The application 'rubocop' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__) + +bundle_binstub = File.expand_path("bundle", __dir__) + +if File.file?(bundle_binstub) + if File.read(bundle_binstub, 300).include?("This file was generated by Bundler") + load(bundle_binstub) + else + abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run. +Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.") + end +end + +require "rubygems" +require "bundler/setup" + +load Gem.bin_path("rubocop", "rubocop") diff --git a/bin/srb b/bin/srb new file mode 100755 index 0000000..324063c --- /dev/null +++ b/bin/srb @@ -0,0 +1,27 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +# +# This file was generated by Bundler. +# +# The application 'srb' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__) + +bundle_binstub = File.expand_path("bundle", __dir__) + +if File.file?(bundle_binstub) + if File.read(bundle_binstub, 300).include?("This file was generated by Bundler") + load(bundle_binstub) + else + abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run. +Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.") + end +end + +require "rubygems" +require "bundler/setup" + +load Gem.bin_path("sorbet", "srb") diff --git a/bin/srb-rbi b/bin/srb-rbi new file mode 100755 index 0000000..0bc5f70 --- /dev/null +++ b/bin/srb-rbi @@ -0,0 +1,27 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +# +# This file was generated by Bundler. +# +# The application 'srb-rbi' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__) + +bundle_binstub = File.expand_path("bundle", __dir__) + +if File.file?(bundle_binstub) + if File.read(bundle_binstub, 300).include?("This file was generated by Bundler") + load(bundle_binstub) + else + abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run. +Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.") + end +end + +require "rubygems" +require "bundler/setup" + +load Gem.bin_path("sorbet", "srb-rbi") diff --git a/code_teams.gemspec b/code_teams.gemspec index 2ffa2f4..533451e 100644 --- a/code_teams.gemspec +++ b/code_teams.gemspec @@ -20,13 +20,7 @@ Gem::Specification.new do |spec| spec.files = Dir['README.md', 'lib/**/*'] spec.require_paths = ['lib'] - spec.required_ruby_version = '>= 2.6' + spec.required_ruby_version = '>= 3.2' spec.add_dependency 'sorbet-runtime' - - spec.add_development_dependency 'pry' - spec.add_development_dependency 'rake' - spec.add_development_dependency 'rspec', '~> 3.0' - spec.add_development_dependency 'rubocop' - spec.add_development_dependency 'sorbet' end diff --git a/lib/code_teams.rb b/lib/code_teams.rb index 6663cf5..95d825c 100644 --- a/lib/code_teams.rb +++ b/lib/code_teams.rb @@ -3,7 +3,6 @@ # typed: strict require 'yaml' -require 'set' require 'pathname' require 'sorbet-runtime' require 'code_teams/plugin' diff --git a/sorbet/config b/sorbet/config index 534118e..b980aaf 100644 --- a/sorbet/config +++ b/sorbet/config @@ -1,3 +1,7 @@ --dir . --ignore=/vendor/bundle +--cache-dir=tmp/cache/sorbet +--ignore=tmp/ +--ignore=vendor/ +--ignore=spec/ diff --git a/spec/lib/plugin_spec.rb b/spec/lib/code_teams/plugin_spec.rb similarity index 100% rename from spec/lib/plugin_spec.rb rename to spec/lib/code_teams/plugin_spec.rb diff --git a/spec/lib/code_teams_spec.rb b/spec/lib/code_teams_spec.rb index 6ff41ee..ab18b93 100644 --- a/spec/lib/code_teams_spec.rb +++ b/spec/lib/code_teams_spec.rb @@ -7,20 +7,20 @@ before do write_file('config/teams/my_team.yml', team_yml) - CodeTeams.bust_caches! + described_class.bust_caches! allow(CodeTeams::Plugin).to receive(:registry).and_return({}) end describe '.all' do it 'correctly parses the team files' do - expect(CodeTeams.all.count).to eq 1 - team = CodeTeams.all.first + expect(described_class.all.count).to eq 1 + team = described_class.all.first expect(team.name).to eq 'My Team' expect(team.raw_hash['name']).to eq 'My Team' expect(team.config_yml).to eq 'config/teams/my_team.yml' end - context 'team YML has syntax errors' do + context 'if team YML has syntax errors' do let(:team_yml) do <<~YML.strip name =>>>asdfaf!!@#!@#@!syntax error My Team @@ -29,7 +29,7 @@ end it 'spits out a helpful error message' do - expect { CodeTeams.all }.to raise_error do |e| + expect { described_class.all }.to raise_error do |e| expect(e).to be_a CodeTeams::IncorrectPublicApiUsageError expect(e.message).to eq('The YML in config/teams/my_team.yml has a syntax error!') end @@ -38,7 +38,7 @@ end describe 'validation_errors' do - subject(:validation_errors) { CodeTeams.validation_errors(CodeTeams.all) } + subject(:validation_errors) { described_class.validation_errors(described_class.all) } context 'there is one definition for all teams' do it 'has no errors' do @@ -52,19 +52,15 @@ end it 'registers the team file as invalid' do - expect(validation_errors).to match_array( - [ - 'More than 1 definition for My Team found' - ] - ) + expect(validation_errors).to contain_exactly('More than 1 definition for My Team found') end end end describe '==' do it 'handles nil correctly' do - expect(CodeTeams.all.first == nil).to eq false # rubocop:disable Style/NilComparison - expect(CodeTeams.all.first.nil?).to eq false + expect(described_class.all.first == nil).to be false # rubocop:disable Style/NilComparison + expect(described_class.all.first.nil?).to be false end end end