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
23 changes: 19 additions & 4 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
9 changes: 9 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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'
124 changes: 86 additions & 38 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -69,7 +114,10 @@ DEPENDENCIES
rake
rspec (~> 3.0)
rubocop
rubocop-rake
rubocop-rspec
sorbet
tapioca

BUNDLED WITH
2.4.7
27 changes: 27 additions & 0 deletions bin/rubocop
Original file line number Diff line number Diff line change
@@ -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")
27 changes: 27 additions & 0 deletions bin/srb
Original file line number Diff line number Diff line change
@@ -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")
27 changes: 27 additions & 0 deletions bin/srb-rbi
Original file line number Diff line number Diff line change
@@ -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")
8 changes: 1 addition & 7 deletions code_teams.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 0 additions & 1 deletion lib/code_teams.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# typed: strict

require 'yaml'
require 'set'
require 'pathname'
require 'sorbet-runtime'
require 'code_teams/plugin'
Expand Down
4 changes: 4 additions & 0 deletions sorbet/config
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
--dir
.
--ignore=/vendor/bundle
--cache-dir=tmp/cache/sorbet
--ignore=tmp/
--ignore=vendor/
--ignore=spec/
File renamed without changes.
22 changes: 9 additions & 13 deletions spec/lib/code_teams_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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