Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop Ruby 2.7 and other updates #282

Merged
merged 17 commits into from
Feb 25, 2024
Merged
9 changes: 0 additions & 9 deletions .editorconfig

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
ruby-version: ['2.7', '3.0', '3.1', '3.2', '3.3']
ruby-version: ['3.0', '3.1', '3.2', '3.3']
steps:
- uses: actions/checkout@v4
- name: Set up Ruby
Expand Down
31 changes: 31 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: check-added-large-files
args: [--maxkb=2000]
- id: check-case-conflict
- id: check-executables-have-shebangs
- id: check-json
- id: check-merge-conflict
- id: check-shebang-scripts-are-executable
- id: check-toml
- id: check-vcs-permalinks
exclude: sorbet/rbi/annotations
- id: detect-private-key
- id: end-of-file-fixer
- id: forbid-submodules
- id: mixed-line-ending
- id: sort-simple-yaml
- id: trailing-whitespace
- repo: https://github.com/crate-ci/typos
rev: v1.18.2
hooks:
- id: typos
args: [--exclude=sorbet/rbi/gems, --force-exclude]
- repo: https://github.com/adrienverge/yamllint
rev: v1.35.0
hooks:
- id: yamllint
args: [--strict]
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ require:

AllCops:
NewCops: enable
TargetRubyVersion: 2.7
TargetRubyVersion: 3.0

Layout/ClassStructure:
Enabled: true
Expand Down
1 change: 0 additions & 1 deletion .yamllint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@ extends: default

ignore: |
/vendor/bundle/
/.rubocop_todo.yml
8 changes: 6 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@

### Bug Fixes

* Fix syntax of order-dependent lists
* [Fix](https://github.com/dduugg/yard-sorbet/commit/f44388b) syntax of order-dependent lists

### Changes

* [#282](https://github.com/dduugg/yard-sorbet/issues/282) Increase minimum required ruby version to `3.0`

## 0.8.1 (2023-04-03)

Expand All @@ -31,7 +35,7 @@

### Changes

* Increase minimum required ruby version to `2.7.0`
* Increase minimum required ruby version to `2.7`

## 0.6.1 (2021-11-01)

Expand Down
9 changes: 4 additions & 5 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,15 @@ source 'https://rubygems.org'

gemspec

gem 'pry-byebug', '~> 3.10'
gem 'rake', '~> 13.1.0'
gem 'redcarpet', '~> 3.6.0'
gem 'rspec', '~> 3.12.0'
gem 'rubocop', '~> 1.59.0'
gem 'rspec', '~> 3.13.0'
gem 'rubocop', '~> 1.60.2'
gem 'rubocop-packaging', '~> 0.5.2'
gem 'rubocop-performance', '~> 1.20.1'
gem 'rubocop-rake', '~> 0.6.0'
gem 'rubocop-rspec', '~> 2.25.0'
gem 'rubocop-rspec', '~> 2.26.1'
gem 'rubocop-sorbet', '~> 0.7.6'
gem 'simplecov-cobertura', '~> 2.1.0'
gem 'sorbet', '~> 0.5.11164'
gem 'tapioca', '~> 0.11.8'
gem 'tapioca', '~> 0.12.0'
112 changes: 52 additions & 60 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9,53 +9,45 @@ GEM
remote: https://rubygems.org/
specs:
ast (2.4.2)
byebug (11.1.3)
coderay (1.1.3)
diff-lcs (1.5.0)
diff-lcs (1.5.1)
docile (1.4.0)
erubi (1.12.0)
json (2.7.1)
language_server-protocol (3.17.0.3)
method_source (1.0.0)
netrc (0.11.0)
parallel (1.24.0)
parser (3.2.2.4)
parser (3.3.0.5)
ast (~> 2.4.1)
racc
pry (0.14.1)
coderay (~> 1.1)
method_source (~> 1.0)
pry-byebug (3.10.1)
byebug (~> 11.0)
pry (>= 0.13, < 0.15)
prettier_print (1.2.1)
prism (0.24.0)
racc (1.7.3)
rainbow (3.1.1)
rake (13.1.0)
rbi (0.0.17)
ast
parser (>= 3.0.0)
rbi (0.1.9)
prism (>= 0.18.0, < 0.25)
sorbet-runtime (>= 0.5.9204)
unparser (>= 0.5.6)
redcarpet (3.6.0)
regexp_parser (2.8.3)
regexp_parser (2.9.0)
rexml (3.2.6)
rspec (3.12.0)
rspec-core (~> 3.12.0)
rspec-expectations (~> 3.12.0)
rspec-mocks (~> 3.12.0)
rspec-core (3.12.0)
rspec-support (~> 3.12.0)
rspec-expectations (3.12.0)
rspec (3.13.0)
rspec-core (~> 3.13.0)
rspec-expectations (~> 3.13.0)
rspec-mocks (~> 3.13.0)
rspec-core (3.13.0)
rspec-support (~> 3.13.0)
rspec-expectations (3.13.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.12.0)
rspec-mocks (3.12.0)
rspec-support (~> 3.13.0)
rspec-mocks (3.13.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.12.0)
rspec-support (3.12.0)
rubocop (1.59.0)
rspec-support (~> 3.13.0)
rspec-support (3.13.0)
rubocop (1.60.2)
json (~> 2.3)
language_server-protocol (>= 3.17.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)
Expand All @@ -64,25 +56,25 @@ GEM
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.30.0)
parser (>= 3.2.1.0)
rubocop-capybara (2.19.0)
rubocop-capybara (2.20.0)
rubocop (~> 1.41)
rubocop-factory_bot (2.25.1)
rubocop (~> 1.41)
rubocop-factory_bot (2.24.0)
rubocop (~> 1.33)
rubocop-packaging (0.5.2)
rubocop (>= 1.33, < 2.0)
rubocop-performance (1.20.1)
rubocop-performance (1.20.2)
rubocop (>= 1.48.1, < 2.0)
rubocop-ast (>= 1.30.0, < 2.0)
rubocop-rake (0.6.0)
rubocop (~> 1.0)
rubocop-rspec (2.25.0)
rubocop-rspec (2.26.1)
rubocop (~> 1.40)
rubocop-capybara (~> 2.17)
rubocop-factory_bot (~> 2.22)
rubocop-sorbet (0.7.6)
rubocop-sorbet (0.7.7)
rubocop (>= 0.90.0)
ruby-progressbar (1.13.0)
simplecov (0.21.2)
simplecov (0.22.0)
docile (~> 1.1)
simplecov-html (~> 0.11)
simplecov_json_formatter (~> 0.1)
Expand All @@ -91,54 +83,54 @@ GEM
simplecov (~> 0.19)
simplecov-html (0.12.3)
simplecov_json_formatter (0.1.4)
sorbet (0.5.11164)
sorbet-static (= 0.5.11164)
sorbet-runtime (0.5.11164)
sorbet-static (0.5.11164-universal-darwin)
sorbet-static (0.5.11164-x86_64-linux)
sorbet-static-and-runtime (0.5.11164)
sorbet (= 0.5.11164)
sorbet-runtime (= 0.5.11164)
spoom (1.2.1)
sorbet (>= 0.5.10187)
sorbet-runtime (>= 0.5.9204)
sorbet (0.5.11262)
sorbet-static (= 0.5.11262)
sorbet-runtime (0.5.11262)
sorbet-static (0.5.11262-universal-darwin)
sorbet-static (0.5.11262-x86_64-linux)
sorbet-static-and-runtime (0.5.11262)
sorbet (= 0.5.11262)
sorbet-runtime (= 0.5.11262)
spoom (1.2.4)
erubi (>= 1.10.0)
sorbet-static-and-runtime (>= 0.5.10187)
syntax_tree (>= 6.1.1)
thor (>= 0.19.2)
tapioca (0.11.8)
syntax_tree (6.2.0)
prettier_print (>= 1.2.0)
tapioca (0.12.0)
bundler (>= 2.2.25)
netrc (>= 0.11.0)
parallel (>= 1.21.0)
rbi (~> 0.0.0, >= 0.0.16)
sorbet-static-and-runtime (>= 0.5.10187)
rbi (>= 0.1.4, < 0.2)
sorbet-static-and-runtime (>= 0.5.10820)
spoom (~> 1.2.0, >= 1.2.0)
thor (>= 1.2.0)
yard-sorbet
thor (1.2.2)
thor (1.3.0)
unicode-display_width (2.5.0)
unparser (0.6.8)
diff-lcs (~> 1.3)
parser (>= 3.2.0)
yard (0.9.34)

PLATFORMS
arm64-darwin-21
arm64-darwin-23
x86_64-darwin-21
x86_64-linux

DEPENDENCIES
pry-byebug (~> 3.10)
rake (~> 13.1.0)
redcarpet (~> 3.6.0)
rspec (~> 3.12.0)
rubocop (~> 1.59.0)
rspec (~> 3.13.0)
rubocop (~> 1.60.2)
rubocop-packaging (~> 0.5.2)
rubocop-performance (~> 1.20.1)
rubocop-rake (~> 0.6.0)
rubocop-rspec (~> 2.25.0)
rubocop-rspec (~> 2.26.1)
rubocop-sorbet (~> 0.7.6)
simplecov-cobertura (~> 2.1.0)
sorbet (~> 0.5.11164)
tapioca (~> 0.11.8)
tapioca (~> 0.12.0)
yard-sorbet!

BUNDLED WITH
2.3.13
2.3.7
9 changes: 5 additions & 4 deletions bin/console
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
# frozen_string_literal: true

require 'bundler/setup'
require 'pry-byebug'
require 'irb'
require 'yard-sorbet'

# Use `Bundler.require(:development)` to add >1s of latency but enjoy access to dev dependencies
Bundler.require
# To require all gems in the Gemfile:
# Bundler.require

Pry.start
IRB.start(__FILE__)
4 changes: 1 addition & 3 deletions lib/yard-sorbet/directives.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ def self.extract_directives(docstring)
end

sig { params(docstring: String, directives: T::Array[String]).void }
def self.add_directives(docstring, directives)
directives.each { docstring.concat("\n#{_1}") }
end
def self.add_directives(docstring, directives) = directives.each { docstring.concat("\n#{_1}") }
end
end
2 changes: 1 addition & 1 deletion lib/yard-sorbet/handlers/abstract_dsl_handler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class AbstractDSLHandler < YARD::Handlers::Ruby::Base
# The `@abstract` tag template
TAG_TEXT = 'Subclasses must implement the `abstract` methods below.'
# Extra text for class namespaces
CLASS_TAG_TEXT = T.let("It cannot be directly instantiated. #{TAG_TEXT}", String)
CLASS_TAG_TEXT = T.let("It cannot be directly instantiated. #{TAG_TEXT}".freeze, String)

sig { void }
def process
Expand Down
4 changes: 1 addition & 3 deletions lib/yard-sorbet/handlers/enums_handler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ def process
private

sig { params(node: YARD::Parser::Ruby::AstNode).returns(T::Boolean) }
def const_assign_node?(node)
node.type == :assign && node[0][0].type == :const
end
def const_assign_node?(node) = node.type == :assign && node[0][0].type == :const
end
end
end
4 changes: 1 addition & 3 deletions lib/yard-sorbet/handlers/mixes_in_class_methods_handler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ class MixesInClassMethodsHandler < YARD::Handlers::Ruby::Base
@@mix_in_class_methods = T.let({}, T::Hash[String, T::Array[String]]) # rubocop:disable Style/ClassVars

sig { params(code_obj: String).returns(T.nilable(T::Array[String])) }
def self.mixed_in_class_methods(code_obj)
@@mix_in_class_methods[code_obj]
end
def self.mixed_in_class_methods(code_obj) = @@mix_in_class_methods[code_obj]

sig { void }
def process
Expand Down
6 changes: 2 additions & 4 deletions lib/yard-sorbet/handlers/sig_handler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,13 @@ def merged_into_attr?(attr_node)
attrs = namespace.attributes[scope][names[0]]
return false if attrs.nil? || attrs.empty?

document_attr_methods(attrs.values.compact)
document_attrs(attrs.values.compact)
attr_node.docstring = nil
true
end

sig { params(method_objects: T::Array[YARD::CodeObjects::MethodObject]).void }
def document_attr_methods(method_objects)
method_objects.each { parse_node(_1, _1.docstring, include_params: false) }
end
def document_attrs(method_objects) = method_objects.each { parse_node(_1, _1.docstring, include_params: false) }

sig { params(attach_to: Documentable, docstring: T.nilable(String), include_params: T::Boolean).void }
def parse_node(attach_to, docstring, include_params: true)
Expand Down
12 changes: 3 additions & 9 deletions lib/yard-sorbet/handlers/struct_prop_handler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,11 @@ def decorate_object(object, prop)
end

sig { returns(T::Boolean) }
def immutable?
statement.method_name(true) == :const || kw_arg('immutable:') == 'true'
end
def immutable? = statement.method_name(true) == :const || kw_arg('immutable:') == 'true'

# @return the value passed to the keyword argument, or nil
sig { params(kwd: String).returns(T.nilable(String)) }
def kw_arg(kwd)
params[2]&.find { _1[0].source == kwd }&.[](1)&.source
end
def kw_arg(kwd) = params[2]&.find { _1[0].source == kwd }&.[](1)&.source

sig { params(name: String).returns(TStructProp) }
def make_prop(name)
Expand All @@ -57,9 +53,7 @@ def make_prop(name)
end

sig { returns(T::Array[YARD::Parser::Ruby::AstNode]) }
def params
@params ||= T.let(statement.parameters(false), T.nilable(T::Array[YARD::Parser::Ruby::AstNode]))
end
def params = @params ||= T.let(statement.parameters(false), T.nilable(T::Array[YARD::Parser::Ruby::AstNode]))

# Register the field explicitly as an attribute.
sig { params(object: YARD::CodeObjects::MethodObject, name: String).void }
Expand Down
Loading
Loading