From 76f5249daeda88d995a2a19b8fd935d02244679f Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Fri, 13 Jun 2025 07:11:25 -0400 Subject: [PATCH 001/400] Add RuboCop workflow --- .github/workflows/rubocop.yml | 39 +++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 .github/workflows/rubocop.yml diff --git a/.github/workflows/rubocop.yml b/.github/workflows/rubocop.yml new file mode 100644 index 000000000..760e6890c --- /dev/null +++ b/.github/workflows/rubocop.yml @@ -0,0 +1,39 @@ +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. +# This workflow will download a prebuilt Ruby version, install dependencies and run tests with rspec. +# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby + +name: RuboCop + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +permissions: + contents: read + +jobs: + test: + + runs-on: ubuntu-latest + strategy: + matrix: + ruby-version: '3.0' + + steps: + - uses: actions/checkout@v3 + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby-version }} + bundler-cache: false + + - name: Install gems + run: bundle install + + - name: Run RuboCop + run: bundle exec rubocop From 1849b925c2317fc1af52bd506f7a1b6b845a8b12 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Fri, 13 Jun 2025 08:25:30 -0400 Subject: [PATCH 002/400] Add RuboCop workflow --- .github/workflows/rubocop.yml | 3 +- .rubocop.yml | 36 + .rubocop_todo.yml | 1727 +++++++++++++++++++++++++++++++++ lib/.rubocop.yml | 22 - solargraph.gemspec | 4 +- 5 files changed, 1768 insertions(+), 24 deletions(-) create mode 100644 .rubocop.yml create mode 100644 .rubocop_todo.yml delete mode 100644 lib/.rubocop.yml diff --git a/.github/workflows/rubocop.yml b/.github/workflows/rubocop.yml index 760e6890c..5d55e4a20 100644 --- a/.github/workflows/rubocop.yml +++ b/.github/workflows/rubocop.yml @@ -36,4 +36,5 @@ jobs: run: bundle install - name: Run RuboCop - run: bundle exec rubocop + # Use -c flag so we ignore config files used within rubocop-related fixtures + run: bundle exec rubocop -c .rubocop.yml diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 000000000..198447e83 --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,36 @@ +--- +inherit_from: .rubocop_todo.yml + +# The behavior of RuboCop can be controlled via the .rubocop.yml +# configuration file. It makes it possible to enable/disable +# certain cops (checks) and to alter their behavior if they accept +# any parameters. The file can be placed either in your home +# directory or in some project directory. +# +# RuboCop will start looking for the configuration file in the directory +# where the inspected file is and continue its way up to the root directory. +# +# See https://docs.rubocop.org/rubocop/configuration +AllCops: + NewCops: enable + Exclude: + - "spec/fixtures/rubocop-validation-error/.*" + - "spec/fixtures/rubocop-validation-error/*" + - "spec/fixtures/rubocop-unused-variable-error/.*" + - "spec/fixtures/rubocop-unused-variable-error/*" + - "spec/fixtures/rubocop-subfolder-configuration/.*" + - "spec/fixtures/rubocop-subfolder-configuration/*" + TargetRubyVersion: 3.0 + +Style/MethodDefParentheses: + EnforcedStyle: require_no_parentheses + +Layout/EmptyLineAfterGuardClause: + Enabled: false + +Metrics/MethodLength: + Max: 25 + +plugins: + - rubocop-rspec + - rubocop-rake diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml new file mode 100644 index 000000000..2f0e023a3 --- /dev/null +++ b/.rubocop_todo.yml @@ -0,0 +1,1727 @@ +# This configuration was generated by +# `rubocop --auto-gen-config` +# on 2025-06-13 12:23:43 UTC using RuboCop version 1.76.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: 20 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: Include. +# Include: **/*.gemspec +Gemspec/AddRuntimeDependency: + Exclude: + - 'solargraph.gemspec' + +# Offense count: 2 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: Severity, Include. +# Include: **/*.gemspec +Gemspec/DeprecatedAttributeAssignment: + Exclude: + - 'solargraph.gemspec' + - 'spec/fixtures/rdoc-lib/rdoc-lib.gemspec' + +# Offense count: 7 +# Configuration parameters: EnforcedStyle, AllowedGems, Include. +# SupportedStyles: Gemfile, gems.rb, gemspec +# Include: **/*.gemspec, **/Gemfile, **/gems.rb +Gemspec/DevelopmentDependencies: + Exclude: + - 'solargraph.gemspec' + +# Offense count: 3 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: Severity, Include. +# Include: **/*.gemspec +Gemspec/RequireMFA: + Exclude: + - 'solargraph.gemspec' + - 'spec/fixtures/rdoc-lib/rdoc-lib.gemspec' + - 'spec/fixtures/rubocop-custom-version/specifications/rubocop-0.0.0.gemspec' + +# Offense count: 3 +# Configuration parameters: Severity, Include. +# Include: **/*.gemspec +Gemspec/RequiredRubyVersion: + Exclude: + - 'spec/fixtures/rdoc-lib/rdoc-lib.gemspec' + - 'spec/fixtures/rubocop-custom-version/specifications/rubocop-0.0.0.gemspec' + - 'spec/fixtures/vendored/vendor/do_not_use.gemspec' + +# Offense count: 5 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle, IndentationWidth. +# SupportedStyles: with_first_argument, with_fixed_indentation +Layout/ArgumentAlignment: + Exclude: + - 'lib/solargraph/pin/callable.rb' + - 'spec/source/source_chainer_spec.rb' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyleAlignWith. +# SupportedStylesAlignWith: either, start_of_block, start_of_line +Layout/BlockAlignment: + Exclude: + - 'spec/source_map/mapper_spec.rb' + +# Offense count: 8 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AllowForAlignment. +Layout/CommentIndentation: + Exclude: + - 'lib/solargraph/api_map.rb' + - 'lib/solargraph/language_server/host.rb' + - 'lib/solargraph/parser/parser_gem/node_methods.rb' + - 'lib/solargraph/source_map/mapper.rb' + +# Offense count: 22 +# This cop supports safe autocorrection (--autocorrect). +Layout/ElseAlignment: + Enabled: false + +# Offense count: 2 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EmptyLineBetweenMethodDefs, EmptyLineBetweenClassDefs, EmptyLineBetweenModuleDefs, DefLikeMacros, AllowAdjacentOneLineDefs, NumberOfEmptyLines. +Layout/EmptyLineBetweenDefs: + Exclude: + - 'lib/solargraph/language_server/message/initialize.rb' + - 'lib/solargraph/pin/delegated_method.rb' + +# Offense count: 8 +# This cop supports safe autocorrection (--autocorrect). +Layout/EmptyLines: + Exclude: + - 'lib/solargraph/bench.rb' + - 'lib/solargraph/complex_type/unique_type.rb' + - 'lib/solargraph/convention.rb' + - 'lib/solargraph/language_server/message/extended/check_gem_version.rb' + - 'lib/solargraph/language_server/message/initialize.rb' + - 'lib/solargraph/pin/delegated_method.rb' + - 'spec/pin/parameter_spec.rb' + - 'spec/pin/symbol_spec.rb' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines +Layout/EmptyLinesAroundModuleBody: + Exclude: + - 'lib/solargraph/api_map/source_to_yard.rb' + +# Offense count: 22 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyleAlignWith, Severity. +# SupportedStylesAlignWith: keyword, variable, start_of_line +Layout/EndAlignment: + Enabled: false + +# Offense count: 4 +# Configuration parameters: EnforcedStyle. +# SupportedStyles: native, lf, crlf +Layout/EndOfLine: + Exclude: + - 'Gemfile' + - 'Rakefile' + - 'lib/solargraph/source/encoding_fixes.rb' + - 'solargraph.gemspec' + +# Offense count: 3 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AllowForAlignment, AllowBeforeTrailingComments, ForceEqualSignAlignment. +Layout/ExtraSpacing: + Exclude: + - 'lib/solargraph/parser/parser_gem/node_processors/opasgn_node.rb' + - 'lib/solargraph/rbs_map/conversions.rb' + - 'lib/solargraph/type_checker.rb' + +# Offense count: 2 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle, IndentationWidth. +# SupportedStyles: consistent, consistent_relative_to_receiver, special_for_inner_method_call, special_for_inner_method_call_in_parentheses +Layout/FirstArgumentIndentation: + Exclude: + - 'lib/solargraph/parser/parser_gem/node_processors/args_node.rb' + - 'spec/source/source_chainer_spec.rb' + +# Offense count: 18 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle, IndentationWidth. +# SupportedStyles: special_inside_parentheses, consistent, align_brackets +Layout/FirstArrayElementIndentation: + Exclude: + - 'lib/solargraph/source.rb' + - 'spec/diagnostics/update_errors_spec.rb' + - 'spec/source/cursor_spec.rb' + - 'spec/source/source_chainer_spec.rb' + - 'spec/source_spec.rb' + +# Offense count: 63 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle, IndentationWidth. +# SupportedStyles: special_inside_parentheses, consistent, align_braces +Layout/FirstHashElementIndentation: + Exclude: + - 'lib/solargraph/language_server/message/extended/check_gem_version.rb' + - 'lib/solargraph/language_server/message/extended/document_gems.rb' + - 'lib/solargraph/language_server/message/text_document/completion.rb' + - 'lib/solargraph/language_server/message/text_document/rename.rb' + - 'lib/solargraph/language_server/message/text_document/signature_help.rb' + - 'spec/language_server/host_spec.rb' + - 'spec/language_server/message/completion_item/resolve_spec.rb' + - 'spec/language_server/message/initialize_spec.rb' + - 'spec/language_server/message/text_document/definition_spec.rb' + - 'spec/language_server/message/text_document/formatting_spec.rb' + - 'spec/language_server/message/text_document/hover_spec.rb' + - 'spec/language_server/message/text_document/rename_spec.rb' + - 'spec/language_server/message/text_document/type_definition_spec.rb' + - 'spec/language_server/message/workspace/did_change_watched_files_spec.rb' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AllowMultipleStyles, EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle. +# SupportedHashRocketStyles: key, separator, table +# SupportedColonStyles: key, separator, table +# SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit +Layout/HashAlignment: + Exclude: + - 'lib/solargraph/workspace/config.rb' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +Layout/HeredocIndentation: + Exclude: + - 'spec/yard_map/mapper/to_method_spec.rb' + +# Offense count: 24 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: Width, AllowedPatterns. +Layout/IndentationWidth: + Enabled: false + +# Offense count: 5 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AllowDoxygenCommentStyle, AllowGemfileRubyComment, AllowRBSInlineAnnotation, AllowSteepAnnotation. +Layout/LeadingCommentSpace: + Exclude: + - 'lib/solargraph/complex_type.rb' + - 'lib/solargraph/rbs_map/conversions.rb' + - 'lib/solargraph/source/chain/call.rb' + - 'lib/solargraph/source_map/clip.rb' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: space, no_space +Layout/LineContinuationSpacing: + Exclude: + - 'lib/solargraph/diagnostics/rubocop_helpers.rb' + +# Offense count: 3 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: symmetrical, new_line, same_line +Layout/MultilineMethodCallBraceLayout: + Exclude: + - 'lib/solargraph/parser/parser_gem/node_processors/send_node.rb' + - 'spec/source/source_chainer_spec.rb' + +# Offense count: 12 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle, IndentationWidth. +# SupportedStyles: aligned, indented, indented_relative_to_receiver +Layout/MultilineMethodCallIndentation: + Exclude: + - 'lib/solargraph/api_map.rb' + - 'lib/solargraph/diagnostics/type_check.rb' + - 'lib/solargraph/language_server/message/completion_item/resolve.rb' + - 'lib/solargraph/language_server/message/text_document/hover.rb' + - 'lib/solargraph/library.rb' + - 'lib/solargraph/pin/search.rb' + - 'lib/solargraph/type_checker.rb' + +# Offense count: 3 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle, IndentationWidth. +# SupportedStyles: aligned, indented +Layout/MultilineOperationIndentation: + Exclude: + - 'lib/solargraph/language_server/host/dispatch.rb' + - 'lib/solargraph/source.rb' + +# Offense count: 6 +# This cop supports safe autocorrection (--autocorrect). +Layout/SpaceAfterComma: + Exclude: + - 'spec/source/cursor_spec.rb' + +# Offense count: 27 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AllowForAlignment, EnforcedStyleForExponentOperator, EnforcedStyleForRationalLiterals. +# SupportedStylesForExponentOperator: space, no_space +# SupportedStylesForRationalLiterals: space, no_space +Layout/SpaceAroundOperators: + Exclude: + - 'lib/solargraph/library.rb' + - 'lib/solargraph/parser/parser_gem/node_methods.rb' + - 'lib/solargraph/source.rb' + - 'lib/solargraph/source/change.rb' + - 'lib/solargraph/source/cursor.rb' + - 'lib/solargraph/source/source_chainer.rb' + - 'lib/solargraph/source_map/clip.rb' + - 'lib/solargraph/workspace/config.rb' + - 'spec/library_spec.rb' + - 'spec/yard_map/mapper_spec.rb' + +# Offense count: 112 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces. +# SupportedStyles: space, no_space +# SupportedStylesForEmptyBraces: space, no_space +Layout/SpaceBeforeBlockBraces: + Enabled: false + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +Layout/SpaceBeforeComma: + Exclude: + - 'spec/source/cursor_spec.rb' + +# Offense count: 189 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters. +# SupportedStyles: space, no_space +# SupportedStylesForEmptyBraces: space, no_space +Layout/SpaceInsideBlockBraces: + Enabled: false + +# Offense count: 26 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces. +# SupportedStyles: space, no_space, compact +# SupportedStylesForEmptyBraces: space, no_space +Layout/SpaceInsideHashLiteralBraces: + Exclude: + - 'lib/solargraph/language_server/message/extended/document.rb' + - 'lib/solargraph/language_server/message/extended/search.rb' + - 'lib/solargraph/language_server/message/initialize.rb' + - 'lib/solargraph/workspace/config.rb' + - 'spec/complex_type_spec.rb' + - 'spec/language_server/host/message_worker_spec.rb' + - 'spec/language_server/message/extended/check_gem_version_spec.rb' + +# Offense count: 2 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: space, compact, no_space +Layout/SpaceInsideParens: + Exclude: + - 'lib/solargraph/pin/namespace.rb' + - 'lib/solargraph/source_map.rb' + +# Offense count: 4 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AllowInHeredoc. +Layout/TrailingWhitespace: + Exclude: + - 'lib/solargraph/language_server/message/client/register_capability.rb' + - 'spec/api_map/config_spec.rb' + - 'spec/convention_spec.rb' + - 'spec/source_map/clip_spec.rb' + +# Offense count: 2 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AllowedMethods, AllowedPatterns. +Lint/AmbiguousBlockAssociation: + Exclude: + - 'lib/solargraph/api_map.rb' + - 'lib/solargraph/language_server/host.rb' + +# Offense count: 15 +# This cop supports safe autocorrection (--autocorrect). +Lint/AmbiguousOperator: + Exclude: + - 'lib/solargraph/api_map.rb' + - 'lib/solargraph/complex_type.rb' + - 'lib/solargraph/language_server/message/workspace/did_change_watched_files.rb' + - 'lib/solargraph/parser/parser_gem/class_methods.rb' + - 'lib/solargraph/pin/constant.rb' + - 'lib/solargraph/pin/method.rb' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +Lint/AmbiguousOperatorPrecedence: + Exclude: + - 'lib/solargraph/source.rb' + +# Offense count: 1 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: AllowSafeAssignment. +Lint/AssignmentInCondition: + Exclude: + - 'lib/solargraph/library.rb' + +# Offense count: 3 +Lint/BinaryOperatorWithIdenticalOperands: + Exclude: + - 'lib/solargraph/api_map/source_to_yard.rb' + +# Offense count: 5 +# This cop supports unsafe autocorrection (--autocorrect-all). +Lint/BooleanSymbol: + Exclude: + - 'lib/solargraph/convention/struct_definition/struct_definition_node.rb' + - 'lib/solargraph/parser/parser_gem/node_methods.rb' + - 'lib/solargraph/source/chain/literal.rb' + +# Offense count: 1 +# Configuration parameters: AllowedMethods. +# AllowedMethods: enums +Lint/ConstantDefinitionInBlock: + Exclude: + - 'spec/complex_type_spec.rb' + +# Offense count: 6 +# Configuration parameters: IgnoreLiteralBranches, IgnoreConstantBranches, IgnoreDuplicateElseBranch. +Lint/DuplicateBranch: + Exclude: + - 'lib/solargraph/complex_type/type_methods.rb' + - 'lib/solargraph/parser/parser_gem/node_chainer.rb' + - 'lib/solargraph/rbs_map/conversions.rb' + +# Offense count: 5 +Lint/DuplicateMethods: + Exclude: + - 'lib/solargraph/complex_type.rb' + - 'lib/solargraph/location.rb' + - 'lib/solargraph/pin/method.rb' + - 'lib/solargraph/source/chain/link.rb' + +# Offense count: 1 +# Configuration parameters: AllowComments, AllowEmptyLambdas. +Lint/EmptyBlock: + Exclude: + - 'spec/convention_spec.rb' + +# Offense count: 5 +# Configuration parameters: AllowComments. +Lint/EmptyClass: + Exclude: + - 'spec/fixtures/workspace-with-gemfile/lib/other.rb' + - 'spec/fixtures/workspace/lib/other.rb' + - 'spec/fixtures/workspace/lib/something.rb' + - 'spec/fixtures/workspace_folders/folder1/app.rb' + - 'spec/fixtures/workspace_folders/folder2/app.rb' + +# Offense count: 2 +# Configuration parameters: AllowComments. +Lint/EmptyFile: + Exclude: + - 'spec/fixtures/rubocop-subfolder-configuration/folder1/folder2/test.rb' + - 'spec/fixtures/vendored/vendor/do_not_use.gemspec' + +# Offense count: 6 +# This cop supports unsafe autocorrection (--autocorrect-all). +Lint/InterpolationCheck: + Exclude: + - 'spec/complex_type_spec.rb' + - 'spec/parser/node_methods_spec.rb' + - 'spec/source/chain_spec.rb' + - 'spec/source/cursor_spec.rb' + +# Offense count: 5 +# Configuration parameters: AllowedParentClasses. +Lint/MissingSuper: + Exclude: + - 'lib/solargraph/source/chain/call.rb' + - 'lib/solargraph/source/chain/constant.rb' + - 'lib/solargraph/source/chain/if.rb' + - 'lib/solargraph/source/chain/literal.rb' + - 'lib/solargraph/source/chain/or.rb' + +# Offense count: 4 +# This cop supports safe autocorrection (--autocorrect). +Lint/ParenthesesAsGroupedExpression: + Exclude: + - 'lib/solargraph/parser/parser_gem/node_chainer.rb' + - 'spec/complex_type_spec.rb' + - 'spec/language_server/host_spec.rb' + - 'spec/source_map/clip_spec.rb' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +Lint/RedundantRequireStatement: + Exclude: + - 'spec/language_server/protocol_spec.rb' + +# Offense count: 2 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: AllowedMethods. +# AllowedMethods: instance_of?, kind_of?, is_a?, eql?, respond_to?, equal? +Lint/RedundantSafeNavigation: + Exclude: + - 'lib/solargraph/api_map/source_to_yard.rb' + - 'lib/solargraph/rbs_map.rb' + +# Offense count: 6 +# This cop supports safe autocorrection (--autocorrect). +Lint/RedundantStringCoercion: + Exclude: + - 'lib/solargraph/parser/parser_gem/node_chainer.rb' + - 'lib/solargraph/pin/conversions.rb' + - 'lib/solargraph/pin/method.rb' + - 'lib/solargraph/pin/namespace.rb' + - 'lib/solargraph/rbs_map/conversions.rb' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +Lint/RedundantWithIndex: + Exclude: + - 'lib/solargraph/language_server/message/completion_item/resolve.rb' + +# Offense count: 1 +# Configuration parameters: AllowComments, AllowNil. +Lint/SuppressedException: + Exclude: + - 'Rakefile' + +# Offense count: 1 +# Configuration parameters: AllowKeywordBlockArguments. +Lint/UnderscorePrefixedVariableName: + Exclude: + - 'lib/solargraph/library.rb' + +# Offense count: 2 +# Configuration parameters: Methods. +Lint/UnexpectedBlockArity: + Exclude: + - 'lib/solargraph/language_server/message/completion_item/resolve.rb' + - 'lib/solargraph/type_checker.rb' + +# Offense count: 4 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AutoCorrect, IgnoreEmptyBlocks, AllowUnusedKeywordArguments. +Lint/UnusedBlockArgument: + Exclude: + - 'lib/solargraph/language_server/message/workspace/did_change_workspace_folders.rb' + - 'lib/solargraph/logging.rb' + - 'spec/language_server/transport/data_reader_spec.rb' + +# Offense count: 35 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AutoCorrect, AllowUnusedKeywordArguments, IgnoreEmptyMethods, IgnoreNotImplementedMethods, NotImplementedExceptions. +# NotImplementedExceptions: NotImplementedError +Lint/UnusedMethodArgument: + Enabled: false + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AutoCorrect, ContextCreatingMethods, MethodCreatingMethods. +Lint/UselessAccessModifier: + Exclude: + - 'lib/solargraph/api_map.rb' + +# Offense count: 32 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AutoCorrect. +Lint/UselessAssignment: + Enabled: false + +# Offense count: 1 +Lint/UselessConstantScoping: + Exclude: + - 'lib/solargraph/rbs_map/conversions.rb' + +# Offense count: 1 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: AutoCorrect. +Lint/UselessMethodDefinition: + Exclude: + - 'lib/solargraph/pin/signature.rb' + +# Offense count: 209 +# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes. +Metrics/AbcSize: + Max: 200 + +# Offense count: 11 +# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns, inherit_mode. +# AllowedMethods: refine +Metrics/BlockLength: + Max: 54 + +# Offense count: 13 +# Configuration parameters: CountBlocks, CountModifierForms. +Metrics/BlockNesting: + Max: 6 + +# Offense count: 27 +# Configuration parameters: CountComments, CountAsOne. +Metrics/ClassLength: + Max: 541 + +# Offense count: 97 +# Configuration parameters: AllowedMethods, AllowedPatterns. +Metrics/CyclomaticComplexity: + Max: 42 + +# Offense count: 47 +# Configuration parameters: CountComments, Max, CountAsOne, AllowedMethods, AllowedPatterns. +Metrics/MethodLength: + Enabled: false + +# Offense count: 4 +# Configuration parameters: CountComments, CountAsOne. +Metrics/ModuleLength: + Max: 458 + +# Offense count: 13 +# Configuration parameters: CountKeywordArgs. +Metrics/ParameterLists: + Max: 9 + MaxOptionalParameters: 5 + +# Offense count: 82 +# Configuration parameters: AllowedMethods, AllowedPatterns. +Metrics/PerceivedComplexity: + Max: 47 + +# Offense count: 5 +Naming/AccessorMethodName: + Exclude: + - 'lib/solargraph/api_map.rb' + - 'lib/solargraph/api_map/store.rb' + - 'lib/solargraph/language_server/message/base.rb' + +# Offense count: 1 +# Configuration parameters: AsciiConstants. +Naming/AsciiIdentifiers: + Exclude: + - 'spec/fixtures/unicode.rb' + +# Offense count: 1 +# Configuration parameters: ForbiddenDelimiters. +# ForbiddenDelimiters: (?i-mx:(^|\s)(EO[A-Z]{1}|END)(\s|$)) +Naming/HeredocDelimiterNaming: + Exclude: + - 'spec/yard_map/mapper/to_method_spec.rb' + +# Offense count: 5 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: EnforcedStyleForLeadingUnderscores. +# SupportedStylesForLeadingUnderscores: disallowed, required, optional +Naming/MemoizedInstanceVariableName: + Exclude: + - 'lib/solargraph/complex_type/type_methods.rb' + - 'lib/solargraph/convention/gemfile.rb' + - 'lib/solargraph/convention/gemspec.rb' + - 'lib/solargraph/convention/rakefile.rb' + - 'lib/solargraph/workspace.rb' + +# Offense count: 16 +# Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames. +# AllowedNames: as, at, by, cc, db, id, if, in, io, ip, of, on, os, pp, to +Naming/MethodParameterName: + Exclude: + - 'lib/solargraph/parser/parser_gem/node_chainer.rb' + - 'lib/solargraph/pin/base.rb' + - 'lib/solargraph/range.rb' + - 'lib/solargraph/source.rb' + - 'lib/solargraph/yard_map/mapper/to_method.rb' + - 'lib/solargraph/yard_map/to_method.rb' + +# Offense count: 17 +# Configuration parameters: Mode, AllowedMethods. +# AllowedMethods: call +Naming/PredicateMethod: + Exclude: + - 'lib/solargraph/api_map/store.rb' + - 'lib/solargraph/doc_map.rb' + - 'lib/solargraph/language_server/progress.rb' + - 'lib/solargraph/library.rb' + - 'lib/solargraph/parser/parser_gem/node_processors/send_node.rb' + - 'lib/solargraph/pin/base.rb' + - 'lib/solargraph/pin/base_variable.rb' + - 'lib/solargraph/pin/local_variable.rb' + - 'lib/solargraph/pin/method.rb' + - 'lib/solargraph/pin/parameter.rb' + - 'lib/solargraph/source_map.rb' + - 'lib/solargraph/workspace.rb' + +# Offense count: 4 +# Configuration parameters: NamePrefix, ForbiddenPrefixes, AllowedMethods, MethodDefinitionMacros, UseSorbetSigs. +# NamePrefix: is_, has_, have_, does_ +# ForbiddenPrefixes: is_, has_, have_, does_ +# AllowedMethods: is_a? +# MethodDefinitionMacros: define_method, define_singleton_method +Naming/PredicatePrefix: + Exclude: + - 'spec/**/*' + - 'lib/solargraph/api_map.rb' + - 'lib/solargraph/language_server/host.rb' + - 'lib/solargraph/parser/parser_gem/class_methods.rb' + - 'lib/solargraph/workspace.rb' + +# Offense count: 1 +# Configuration parameters: EnforcedStyle, AllowedIdentifiers, AllowedPatterns, ForbiddenIdentifiers, ForbiddenPatterns. +# SupportedStyles: snake_case, camelCase +Naming/VariableName: + Exclude: + - 'spec/fixtures/unicode.rb' + +# Offense count: 3 +RSpec/Be: + Exclude: + - 'spec/rbs_map/stdlib_map_spec.rb' + - 'spec/rbs_map_spec.rb' + - 'spec/source/source_chainer_spec.rb' + +# Offense count: 5 +# This cop supports unsafe autocorrection (--autocorrect-all). +RSpec/BeEq: + Exclude: + - 'spec/complex_type_spec.rb' + - 'spec/pin/base_spec.rb' + - 'spec/pin/method_spec.rb' + +# Offense count: 7 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: be, be_nil +RSpec/BeNil: + Exclude: + - 'spec/api_map/source_to_yard_spec.rb' + - 'spec/language_server/host_spec.rb' + +# Offense count: 5 +RSpec/BeforeAfterAll: + Exclude: + - '**/spec/spec_helper.rb' + - '**/spec/rails_helper.rb' + - '**/spec/support/**/*.rb' + - 'spec/api_map_spec.rb' + - 'spec/doc_map_spec.rb' + - 'spec/language_server/host/dispatch_spec.rb' + - 'spec/language_server/protocol_spec.rb' + +# Offense count: 14 +# Configuration parameters: Prefixes, AllowedPatterns. +# Prefixes: when, with, without +RSpec/ContextWording: + Exclude: + - 'spec/complex_type_spec.rb' + - 'spec/library_spec.rb' + - 'spec/pin/method_spec.rb' + - 'spec/pin/parameter_spec.rb' + - 'spec/pin/symbol_spec.rb' + - 'spec/type_checker/levels/normal_spec.rb' + - 'spec/type_checker/levels/strict_spec.rb' + - 'spec/type_checker/levels/strong_spec.rb' + - 'spec/type_checker/levels/typed_spec.rb' + +# Offense count: 1 +# Configuration parameters: IgnoredMetadata. +RSpec/DescribeClass: + Exclude: + - '**/spec/features/**/*' + - '**/spec/requests/**/*' + - '**/spec/routing/**/*' + - '**/spec/system/**/*' + - '**/spec/views/**/*' + - 'spec/source_map/node_processor_spec.rb' + +# Offense count: 493 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: SkipBlocks, EnforcedStyle, OnlyStaticConstants. +# SupportedStyles: described_class, explicit +RSpec/DescribedClass: + Enabled: false + +# Offense count: 1 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: AutoCorrect. +RSpec/EmptyExampleGroup: + Exclude: + - 'spec/convention_spec.rb' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +RSpec/EmptyLineAfterFinalLet: + Exclude: + - 'spec/workspace/config_spec.rb' + +# Offense count: 914 +# Configuration parameters: CountAsOne. +RSpec/ExampleLength: + Max: 59 + +# Offense count: 4 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: CustomTransform, IgnoredWords, DisallowedExamples. +# DisallowedExamples: works +RSpec/ExampleWording: + Exclude: + - 'spec/pin/base_spec.rb' + - 'spec/pin/method_spec.rb' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +RSpec/ExcessiveDocstringSpacing: + Exclude: + - 'spec/source/chain/call_spec.rb' + +# Offense count: 5 +# This cop supports safe autocorrection (--autocorrect). +RSpec/ExpectActual: + Exclude: + - '**/spec/routing/**/*' + - 'spec/rbs_map/stdlib_map_spec.rb' + - 'spec/source_map/mapper_spec.rb' + +# Offense count: 13 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: implicit, each, example +RSpec/HookArgument: + Exclude: + - 'spec/api_map/config_spec.rb' + - 'spec/diagnostics/require_not_found_spec.rb' + - 'spec/language_server/host/dispatch_spec.rb' + - 'spec/language_server/host_spec.rb' + - 'spec/language_server/message/extended/check_gem_version_spec.rb' + - 'spec/language_server/protocol_spec.rb' + - 'spec/workspace/config_spec.rb' + - 'spec/workspace_spec.rb' + +# Offense count: 246 +# Configuration parameters: AssignmentOnly. +RSpec/InstanceVariable: + Exclude: + - 'spec/api_map/config_spec.rb' + - 'spec/api_map_spec.rb' + - 'spec/diagnostics/require_not_found_spec.rb' + - 'spec/language_server/host/dispatch_spec.rb' + - 'spec/language_server/host_spec.rb' + - 'spec/language_server/protocol_spec.rb' + +# Offense count: 1 +RSpec/LeakyConstantDeclaration: + Exclude: + - 'spec/complex_type_spec.rb' + +# Offense count: 3 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AutoCorrect. +RSpec/LetBeforeExamples: + Exclude: + - 'spec/complex_type_spec.rb' + +# Offense count: 3 +# Configuration parameters: . +# SupportedStyles: have_received, receive +RSpec/MessageSpies: + EnforcedStyle: receive + +# Offense count: 2 +RSpec/MissingExampleGroupArgument: + Exclude: + - 'spec/diagnostics/rubocop_helpers_spec.rb' + +# Offense count: 466 +RSpec/MultipleExpectations: + Max: 14 + +# Offense count: 8 +# Configuration parameters: AllowedPatterns. +# AllowedPatterns: ^expect_, ^assert_ +RSpec/NoExpectationExample: + Exclude: + - 'spec/language_server/protocol_spec.rb' + - 'spec/parser/node_methods_spec.rb' + - 'spec/pin/block_spec.rb' + - 'spec/pin/method_spec.rb' + - 'spec/source/chain/call_spec.rb' + - 'spec/type_checker/checks_spec.rb' + - 'spec/type_checker/levels/typed_spec.rb' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: not_to, to_not +RSpec/NotToNot: + Exclude: + - 'spec/rbs_map/core_map_spec.rb' + +# Offense count: 33 +RSpec/PendingWithoutReason: + Exclude: + - 'spec/api_map_spec.rb' + - 'spec/complex_type_spec.rb' + - 'spec/parser/node_chainer_spec.rb' + - 'spec/parser/node_methods_spec.rb' + - 'spec/pin/method_spec.rb' + - 'spec/rbs_map/core_map_spec.rb' + - 'spec/source/chain/call_spec.rb' + - 'spec/source/chain_spec.rb' + - 'spec/source_map/clip_spec.rb' + - 'spec/type_checker/levels/strict_spec.rb' + - 'spec/yard_map/mapper/to_method_spec.rb' + +# Offense count: 3 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: Strict, EnforcedStyle, AllowedExplicitMatchers. +# SupportedStyles: inflected, explicit +RSpec/PredicateMatcher: + Exclude: + - 'spec/language_server/message/workspace/did_change_configuration_spec.rb' + - 'spec/source_spec.rb' + +# Offense count: 3 +# This cop supports unsafe autocorrection (--autocorrect-all). +RSpec/ReceiveMessages: + Exclude: + - 'spec/language_server/host_spec.rb' + +# Offense count: 1 +RSpec/RemoveConst: + Exclude: + - 'spec/diagnostics/rubocop_helpers_spec.rb' + +# Offense count: 46 +RSpec/RepeatedDescription: + Exclude: + - 'spec/api_map_spec.rb' + - 'spec/language_server/protocol_spec.rb' + - 'spec/parser/node_methods_spec.rb' + - 'spec/source/chain/call_spec.rb' + - 'spec/source/source_chainer_spec.rb' + - 'spec/source_map/clip_spec.rb' + - 'spec/source_map/mapper_spec.rb' + - 'spec/type_checker/levels/normal_spec.rb' + - 'spec/type_checker/levels/strict_spec.rb' + +# Offense count: 28 +RSpec/RepeatedExample: + Exclude: + - 'spec/api_map_spec.rb' + - 'spec/parser/node_methods_spec.rb' + - 'spec/source/cursor_spec.rb' + - 'spec/source_map/clip_spec.rb' + - 'spec/type_checker/levels/strict_spec.rb' + +# Offense count: 2 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AutoCorrect. +RSpec/ScatteredLet: + Exclude: + - 'spec/complex_type_spec.rb' + +# Offense count: 87 +# Configuration parameters: Include, CustomTransform, IgnoreMethods, IgnoreMetadata. +# Include: **/*_spec.rb +RSpec/SpecFilePathFormat: + Enabled: false + +# Offense count: 1 +RSpec/StubbedMock: + Exclude: + - 'spec/language_server/host/message_worker_spec.rb' + +# Offense count: 24 +# Configuration parameters: IgnoreNameless, IgnoreSymbolicNames. +RSpec/VerifiedDoubles: + Exclude: + - 'spec/complex_type_spec.rb' + - 'spec/language_server/host/diagnoser_spec.rb' + - 'spec/language_server/host/message_worker_spec.rb' + - 'spec/language_server/host_spec.rb' + - 'spec/language_server/message/completion_item/resolve_spec.rb' + - 'spec/language_server/message/extended/check_gem_version_spec.rb' + - 'spec/language_server/message/text_document/formatting_spec.rb' + - 'spec/language_server/message/workspace/did_change_watched_files_spec.rb' + - 'spec/language_server/protocol_spec.rb' + - 'spec/source/chain/class_variable_spec.rb' + - 'spec/source/cursor_spec.rb' + - 'spec/source/source_chainer_spec.rb' + - 'spec/workspace_spec.rb' + +# Offense count: 1 +Security/MarshalLoad: + Exclude: + - 'lib/solargraph/cache.rb' + +# Offense count: 12 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: EnforcedStyle, AllowModifiersOnSymbols, AllowModifiersOnAttrs, AllowModifiersOnAliasMethod. +# SupportedStyles: inline, group +Style/AccessModifierDeclarations: + Exclude: + - 'lib/solargraph/api_map.rb' + - 'lib/solargraph/complex_type.rb' + - 'lib/solargraph/complex_type/unique_type.rb' + - 'lib/solargraph/location.rb' + - 'lib/solargraph/position.rb' + - 'lib/solargraph/range.rb' + - 'lib/solargraph/source/chain.rb' + - 'lib/solargraph/source/chain/call.rb' + - 'lib/solargraph/source/chain/hash.rb' + - 'lib/solargraph/source/chain/if.rb' + - 'lib/solargraph/source/chain/link.rb' + - 'lib/solargraph/source/chain/literal.rb' + +# Offense count: 9 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: separated, grouped +Style/AccessorGrouping: + Exclude: + - 'lib/solargraph/parser/flow_sensitive_typing.rb' + - 'lib/solargraph/pin/callable.rb' + - 'lib/solargraph/pin/method.rb' + +# Offense count: 39 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: always, conditionals +Style/AndOr: + Exclude: + - 'lib/solargraph/api_map/source_to_yard.rb' + - 'lib/solargraph/complex_type/unique_type.rb' + - 'lib/solargraph/language_server/message/base.rb' + - 'lib/solargraph/page.rb' + - 'lib/solargraph/parser/parser_gem/node_methods.rb' + - 'lib/solargraph/pin/method.rb' + - 'lib/solargraph/pin/parameter.rb' + - 'lib/solargraph/position.rb' + - 'lib/solargraph/source/change.rb' + - 'lib/solargraph/source/cursor.rb' + - 'lib/solargraph/source/source_chainer.rb' + - 'lib/solargraph/source/updater.rb' + - 'lib/solargraph/workspace.rb' + - 'lib/solargraph/yard_map/mapper.rb' + +# Offense count: 4 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AllowOnlyRestArgument, UseAnonymousForwarding, RedundantRestArgumentNames, RedundantKeywordRestArgumentNames, RedundantBlockArgumentNames. +# RedundantRestArgumentNames: args, arguments +# RedundantKeywordRestArgumentNames: kwargs, options, opts +# RedundantBlockArgumentNames: blk, block, proc +Style/ArgumentsForwarding: + Exclude: + - 'lib/solargraph/api_map.rb' + - 'lib/solargraph/complex_type.rb' + +# Offense count: 61 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle, ProceduralMethods, FunctionalMethods, AllowedMethods, AllowedPatterns, AllowBracesOnProceduralOneLiners, BracesRequiredMethods. +# SupportedStyles: line_count_based, semantic, braces_for_chaining, always_braces +# ProceduralMethods: benchmark, bm, bmbm, create, each_with_object, measure, new, realtime, tap, with_object +# FunctionalMethods: let, let!, subject, watch +# AllowedMethods: lambda, proc, it +Style/BlockDelimiters: + Enabled: false + +# Offense count: 7 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: MinBranchesCount. +Style/CaseLikeIf: + Exclude: + - 'lib/solargraph/language_server/message/workspace/did_change_watched_files.rb' + - 'lib/solargraph/parser/parser_gem/node_methods.rb' + - 'lib/solargraph/pin/parameter.rb' + - 'lib/solargraph/rbs_map/conversions.rb' + - 'lib/solargraph/source/source_chainer.rb' + - 'lib/solargraph/yard_map/mapper.rb' + +# Offense count: 11 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: EnforcedStyle, EnforcedStyleForClasses, EnforcedStyleForModules. +# SupportedStyles: nested, compact +# SupportedStylesForClasses: ~, nested, compact +# SupportedStylesForModules: ~, nested, compact +Style/ClassAndModuleChildren: + Exclude: + - 'lib/solargraph/language_server/message/text_document/definition.rb' + - 'lib/solargraph/language_server/message/text_document/document_highlight.rb' + - 'lib/solargraph/language_server/message/text_document/document_symbol.rb' + - 'lib/solargraph/language_server/message/text_document/prepare_rename.rb' + - 'lib/solargraph/language_server/message/text_document/references.rb' + - 'lib/solargraph/language_server/message/text_document/rename.rb' + - 'lib/solargraph/language_server/message/text_document/type_definition.rb' + - 'lib/solargraph/language_server/message/workspace/did_change_configuration.rb' + - 'lib/solargraph/language_server/message/workspace/did_change_watched_files.rb' + - 'lib/solargraph/language_server/message/workspace/did_change_workspace_folders.rb' + - 'lib/solargraph/language_server/message/workspace/workspace_symbol.rb' + +# Offense count: 2 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: AllowedMethods, AllowedPatterns. +# AllowedMethods: ==, equal?, eql? +Style/ClassEqualityComparison: + Exclude: + - 'lib/solargraph/pin/base.rb' + +# Offense count: 13 +Style/ClassVars: + Exclude: + - 'lib/solargraph/api_map.rb' + - 'lib/solargraph/convention.rb' + - 'lib/solargraph/logging.rb' + - 'lib/solargraph/parser/node_processor.rb' + - 'lib/solargraph/rbs_map.rb' + - 'lib/solargraph/source/chain.rb' + +# Offense count: 2 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: AllowedReceivers. +Style/CollectionCompact: + Exclude: + - 'lib/solargraph/pin/constant.rb' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +Style/ColonMethodCall: + Exclude: + - 'spec/type_checker_spec.rb' + +# Offense count: 1 +# This cop supports unsafe autocorrection (--autocorrect-all). +Style/CombinableLoops: + Exclude: + - 'lib/solargraph/pin/parameter.rb' + +# Offense count: 1 +# This cop supports unsafe autocorrection (--autocorrect-all). +Style/ConcatArrayLiterals: + Exclude: + - 'lib/solargraph/parser/parser_gem/node_processors/sclass_node.rb' + +# Offense count: 4 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle, SingleLineConditionsOnly, IncludeTernaryExpressions. +# SupportedStyles: assign_to_condition, assign_inside_condition +Style/ConditionalAssignment: + Exclude: + - 'lib/solargraph/api_map/source_to_yard.rb' + - 'lib/solargraph/parser/parser_gem/node_processors/defs_node.rb' + - 'lib/solargraph/source/chain/call.rb' + +# Offense count: 140 +# Configuration parameters: AllowedConstants. +Style/Documentation: + Enabled: false + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +Style/EmptyLambdaParameter: + Exclude: + - 'spec/rbs_map/core_map_spec.rb' + +# Offense count: 4 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AutoCorrect, EnforcedStyle. +# SupportedStyles: compact, expanded +Style/EmptyMethod: + Exclude: + - 'lib/solargraph/language_server/message/client/register_capability.rb' + - 'spec/fixtures/formattable.rb' + - 'spec/fixtures/rdoc-lib/lib/example.rb' + - 'spec/fixtures/workspace-with-gemfile/lib/thing.rb' + +# Offense count: 5 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: trailing_conditional, ternary +Style/EmptyStringInsideInterpolation: + Exclude: + - 'lib/solargraph/library.rb' + - 'lib/solargraph/pin/documenting.rb' + - 'lib/solargraph/shell.rb' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +Style/ExpandPathArguments: + Exclude: + - 'solargraph.gemspec' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AllowedVars. +Style/FetchEnvVar: + Exclude: + - 'spec/api_map/config_spec.rb' + +# Offense count: 2 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: left_coerce, right_coerce, single_coerce, fdiv +Style/FloatDivision: + Exclude: + - 'lib/solargraph/library.rb' + - 'lib/solargraph/pin/search.rb' + +# Offense count: 126 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: always, always_true, never +Style/FrozenStringLiteralComment: + Enabled: false + +# Offense count: 8 +# This cop supports unsafe autocorrection (--autocorrect-all). +Style/GlobalStdStream: + Exclude: + - 'lib/solargraph/logging.rb' + - 'lib/solargraph/shell.rb' + - 'spec/logging_spec.rb' + +# Offense count: 11 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: MinBodyLength, AllowConsecutiveConditionals. +Style/GuardClause: + Exclude: + - 'lib/solargraph/api_map.rb' + - 'lib/solargraph/library.rb' + - 'lib/solargraph/parser/parser_gem/node_processors/send_node.rb' + - 'lib/solargraph/range.rb' + - 'lib/solargraph/rbs_map/conversions.rb' + - 'lib/solargraph/source.rb' + - 'lib/solargraph/workspace.rb' + +# Offense count: 2 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: AllowedReceivers. +# AllowedReceivers: Thread.current +Style/HashEachMethods: + Exclude: + - 'lib/solargraph/library.rb' + - 'lib/solargraph/source.rb' + +# Offense count: 25 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle, EnforcedShorthandSyntax, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols. +# SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys +# SupportedShorthandSyntax: always, never, either, consistent, either_consistent +Style/HashSyntax: + Exclude: + - 'spec/source/chain/class_variable_spec.rb' + - 'spec/source/cursor_spec.rb' + - 'spec/source/source_chainer_spec.rb' + +# Offense count: 6 +# This cop supports unsafe autocorrection (--autocorrect-all). +Style/IdenticalConditionalBranches: + Exclude: + - 'lib/solargraph/library.rb' + - 'lib/solargraph/type_checker.rb' + +# Offense count: 6 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AllowIfModifier. +Style/IfInsideElse: + Exclude: + - 'lib/solargraph/language_server/transport/data_reader.rb' + - 'lib/solargraph/parser/parser_gem/node_chainer.rb' + - 'lib/solargraph/parser/parser_gem/node_methods.rb' + - 'lib/solargraph/source_map/clip.rb' + - 'lib/solargraph/type_checker.rb' + +# Offense count: 40 +# This cop supports safe autocorrection (--autocorrect). +Style/IfUnlessModifier: + Enabled: false + +# Offense count: 2 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: call, braces +Style/LambdaCall: + Exclude: + - 'lib/solargraph/library.rb' + +# Offense count: 3 +# This cop supports unsafe autocorrection (--autocorrect-all). +Style/MapIntoArray: + Exclude: + - 'lib/solargraph/diagnostics/update_errors.rb' + - 'lib/solargraph/parser/parser_gem/node_chainer.rb' + - 'lib/solargraph/type_checker/param_def.rb' + +# Offense count: 1 +# This cop supports unsafe autocorrection (--autocorrect-all). +Style/MapToHash: + Exclude: + - 'lib/solargraph/bench.rb' + +# Offense count: 2 +# This cop supports unsafe autocorrection (--autocorrect-all). +Style/MapToSet: + Exclude: + - 'lib/solargraph/library.rb' + - 'spec/source_map/clip_spec.rb' + +# Offense count: 147 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: require_parentheses, require_no_parentheses, require_no_parentheses_except_multiline +Style/MethodDefParentheses: + Enabled: false + +# Offense count: 1 +Style/MultilineBlockChain: + Exclude: + - 'lib/solargraph/pin/search.rb' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +Style/MultilineIfModifier: + Exclude: + - 'lib/solargraph/pin/callable.rb' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +Style/MultilineTernaryOperator: + Exclude: + - 'lib/solargraph/language_server/host.rb' + +# Offense count: 19 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AllowMethodComparison, ComparisonsThreshold. +Style/MultipleComparison: + Exclude: + - 'lib/solargraph/complex_type.rb' + - 'lib/solargraph/complex_type/type_methods.rb' + - 'lib/solargraph/parser/parser_gem/node_methods.rb' + - 'lib/solargraph/parser/parser_gem/node_processors/send_node.rb' + - 'lib/solargraph/pin/method.rb' + - 'lib/solargraph/pin/parameter.rb' + - 'lib/solargraph/source.rb' + - 'lib/solargraph/type_checker.rb' + +# Offense count: 15 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: literals, strict +Style/MutableConstant: + Exclude: + - 'lib/solargraph/diagnostics/rubocop.rb' + - 'lib/solargraph/logging.rb' + - 'lib/solargraph/parser/parser_gem/node_methods.rb' + - 'lib/solargraph/rbs_map/conversions.rb' + - 'lib/solargraph/rbs_map/core_fills.rb' + - 'spec/complex_type_spec.rb' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: both, prefix, postfix +Style/NegatedIf: + Exclude: + - 'lib/solargraph/language_server/host/diagnoser.rb' + +# Offense count: 6 +# This cop supports safe autocorrection (--autocorrect). +Style/NegatedIfElseCondition: + Exclude: + - 'lib/solargraph/diagnostics/rubocop.rb' + - 'lib/solargraph/language_server/message/extended/document_gems.rb' + - 'lib/solargraph/parser/parser_gem/node_methods.rb' + - 'lib/solargraph/shell.rb' + - 'lib/solargraph/type_checker.rb' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AllowedMethods. +# AllowedMethods: be, be_a, be_an, be_between, be_falsey, be_kind_of, be_instance_of, be_truthy, be_within, eq, eql, end_with, include, match, raise_error, respond_to, start_with +Style/NestedParenthesizedCalls: + Exclude: + - 'lib/solargraph/type_checker.rb' + +# Offense count: 2 +# This cop supports safe autocorrection (--autocorrect). +Style/NestedTernaryOperator: + Exclude: + - 'lib/solargraph/pin/conversions.rb' + - 'lib/solargraph/pin/method.rb' + +# Offense count: 4 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle, MinBodyLength, AllowConsecutiveConditionals. +# SupportedStyles: skip_modifier_ifs, always +Style/Next: + Exclude: + - 'lib/solargraph/parser/parser_gem/node_processors/send_node.rb' + - 'lib/solargraph/source_map/clip.rb' + - 'lib/solargraph/type_checker/checks.rb' + +# Offense count: 11 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: Strict, AllowedNumbers, AllowedPatterns. +Style/NumericLiterals: + MinDigits: 6 + +# Offense count: 28 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: EnforcedStyle, AllowedMethods, AllowedPatterns. +# SupportedStyles: predicate, comparison +Style/NumericPredicate: + Exclude: + - 'spec/**/*' + - 'lib/solargraph/api_map.rb' + - 'lib/solargraph/api_map/index.rb' + - 'lib/solargraph/api_map/store.rb' + - 'lib/solargraph/complex_type.rb' + - 'lib/solargraph/complex_type/type_methods.rb' + - 'lib/solargraph/complex_type/unique_type.rb' + - 'lib/solargraph/language_server/message/extended/check_gem_version.rb' + - 'lib/solargraph/library.rb' + - 'lib/solargraph/parser/comment_ripper.rb' + - 'lib/solargraph/pin/delegated_method.rb' + - 'lib/solargraph/shell.rb' + - 'lib/solargraph/source/change.rb' + - 'lib/solargraph/source/source_chainer.rb' + - 'lib/solargraph/workspace.rb' + +# Offense count: 1 +Style/OpenStructUse: + Exclude: + - 'lib/solargraph/page.rb' + +# Offense count: 8 +# Configuration parameters: AllowedMethods. +# AllowedMethods: respond_to_missing? +Style/OptionalBooleanParameter: + Exclude: + - 'lib/solargraph/api_map.rb' + - 'lib/solargraph/language_server/message/text_document/completion.rb' + - 'lib/solargraph/source/chain.rb' + - 'lib/solargraph/source/chain/hash.rb' + - 'lib/solargraph/source/chain/z_super.rb' + - 'lib/solargraph/source/change.rb' + - 'lib/solargraph/source/updater.rb' + +# Offense count: 3 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AllowSafeAssignment, AllowInMultilineConditions. +Style/ParenthesesAroundCondition: + Exclude: + - 'lib/solargraph/parser/parser_gem/node_processors/send_node.rb' + - 'lib/solargraph/type_checker.rb' + +# Offense count: 1 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: short, verbose +Style/PreferredHashMethods: + Exclude: + - 'lib/solargraph/language_server/message.rb' + +# Offense count: 1 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: Methods. +Style/RedundantArgument: + Exclude: + - 'lib/solargraph/source_map/mapper.rb' + +# Offense count: 3 +# This cop supports safe autocorrection (--autocorrect). +Style/RedundantAssignment: + Exclude: + - 'lib/solargraph/language_server/host/dispatch.rb' + - 'lib/solargraph/repro.rb' + - 'lib/solargraph/workspace/config.rb' + +# Offense count: 7 +# This cop supports safe autocorrection (--autocorrect). +Style/RedundantBegin: + Exclude: + - 'lib/solargraph/language_server/transport/data_reader.rb' + - 'lib/solargraph/shell.rb' + - 'lib/solargraph/source/cursor.rb' + - 'lib/solargraph/source/encoding_fixes.rb' + - 'lib/solargraph/type_checker.rb' + - 'lib/solargraph/workspace.rb' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +Style/RedundantException: + Exclude: + - 'spec/language_server/host_spec.rb' + +# Offense count: 2 +# This cop supports safe autocorrection (--autocorrect). +Style/RedundantFreeze: + Exclude: + - 'lib/solargraph/complex_type.rb' + - 'lib/solargraph/source_map/mapper.rb' + +# Offense count: 3 +# This cop supports unsafe autocorrection (--autocorrect-all). +Style/RedundantInterpolation: + Exclude: + - 'lib/solargraph/api_map/store.rb' + - 'lib/solargraph/parser/parser_gem/node_chainer.rb' + - 'lib/solargraph/source_map/mapper.rb' + +# Offense count: 5 +# This cop supports safe autocorrection (--autocorrect). +Style/RedundantParentheses: + Exclude: + - 'lib/solargraph/language_server/message/initialize.rb' + - 'lib/solargraph/parser/parser_gem/node_chainer.rb' + - 'lib/solargraph/pin/method.rb' + - 'lib/solargraph/source.rb' + - 'lib/solargraph/type_checker.rb' + +# Offense count: 5 +# This cop supports safe autocorrection (--autocorrect). +Style/RedundantRegexpArgument: + Exclude: + - 'lib/solargraph/api_map/index.rb' + - 'lib/solargraph/workspace/config.rb' + - 'spec/diagnostics/rubocop_helpers_spec.rb' + - 'spec/language_server/host_spec.rb' + +# Offense count: 18 +# This cop supports safe autocorrection (--autocorrect). +Style/RedundantRegexpEscape: + Exclude: + - 'lib/solargraph/complex_type.rb' + - 'lib/solargraph/diagnostics/rubocop.rb' + - 'lib/solargraph/language_server/uri_helpers.rb' + - 'lib/solargraph/shell.rb' + - 'lib/solargraph/source_map/clip.rb' + - 'lib/solargraph/source_map/mapper.rb' + +# Offense count: 6 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AllowMultipleReturnValues. +Style/RedundantReturn: + Exclude: + - 'lib/solargraph/api_map.rb' + - 'lib/solargraph/complex_type/type_methods.rb' + - 'lib/solargraph/parser/parser_gem/node_methods.rb' + - 'lib/solargraph/source/chain/z_super.rb' + +# Offense count: 9 +# This cop supports safe autocorrection (--autocorrect). +Style/RedundantSelf: + Exclude: + - 'lib/solargraph/api_map.rb' + - 'lib/solargraph/equality.rb' + - 'lib/solargraph/location.rb' + - 'lib/solargraph/pin/base.rb' + - 'lib/solargraph/pin/callable.rb' + - 'lib/solargraph/source/chain.rb' + - 'lib/solargraph/source/chain/link.rb' + +# Offense count: 3 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle, AllowInnerSlashes. +# SupportedStyles: slashes, percent_r, mixed +Style/RegexpLiteral: + Exclude: + - 'lib/solargraph/language_server/uri_helpers.rb' + - 'lib/solargraph/workspace/config.rb' + +# Offense count: 13 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: ConvertCodeThatCanStartToReturnNil, AllowedMethods, MaxChainLength. +# AllowedMethods: present?, blank?, presence, try, try! +Style/SafeNavigation: + Exclude: + - 'lib/solargraph/api_map/index.rb' + - 'lib/solargraph/language_server/message/completion_item/resolve.rb' + - 'lib/solargraph/language_server/request.rb' + - 'lib/solargraph/language_server/transport/data_reader.rb' + - 'lib/solargraph/parser/parser_gem/node_processors/send_node.rb' + - 'lib/solargraph/pin/base.rb' + - 'lib/solargraph/pin/conversions.rb' + - 'lib/solargraph/pin/method.rb' + - 'lib/solargraph/range.rb' + - 'lib/solargraph/type_checker.rb' + +# Offense count: 40 +# This cop supports unsafe autocorrection (--autocorrect-all). +Style/SlicingWithRange: + Enabled: false + +# Offense count: 8 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AllowModifier. +Style/SoleNestedConditional: + Exclude: + - 'lib/solargraph/api_map.rb' + - 'lib/solargraph/complex_type/unique_type.rb' + - 'lib/solargraph/parser/flow_sensitive_typing.rb' + - 'lib/solargraph/pin/parameter.rb' + - 'lib/solargraph/source.rb' + - 'lib/solargraph/source/source_chainer.rb' + - 'lib/solargraph/type_checker.rb' + +# Offense count: 5 +# This cop supports safe autocorrection (--autocorrect). +Style/StderrPuts: + Exclude: + - 'lib/solargraph/shell.rb' + +# Offense count: 10 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: Mode. +Style/StringConcatenation: + Exclude: + - 'lib/solargraph/api_map.rb' + - 'lib/solargraph/api_map/index.rb' + - 'lib/solargraph/pin/base.rb' + - 'lib/solargraph/pin/callable.rb' + - 'lib/solargraph/pin/closure.rb' + - 'lib/solargraph/pin/local_variable.rb' + - 'lib/solargraph/pin/method.rb' + - 'lib/solargraph/pin/namespace.rb' + - 'solargraph.gemspec' + +# Offense count: 605 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline. +# SupportedStyles: single_quotes, double_quotes +Style/StringLiterals: + Enabled: false + +# Offense count: 3 +# This cop supports safe autocorrection (--autocorrect). +Style/SuperArguments: + Exclude: + - 'lib/solargraph/pin/callable.rb' + - 'lib/solargraph/pin/method.rb' + - 'lib/solargraph/pin/signature.rb' + +# Offense count: 44 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle, MinSize. +# SupportedStyles: percent, brackets +Style/SymbolArray: + Exclude: + - 'lib/solargraph/api_map.rb' + - 'lib/solargraph/parser/parser_gem/node_chainer.rb' + - 'lib/solargraph/parser/parser_gem/node_methods.rb' + - 'lib/solargraph/parser/parser_gem/node_processors/block_node.rb' + - 'lib/solargraph/parser/parser_gem/node_processors/send_node.rb' + - 'lib/solargraph/pin/method.rb' + - 'lib/solargraph/pin/parameter.rb' + - 'lib/solargraph/shell.rb' + - 'lib/solargraph/source.rb' + - 'lib/solargraph/source/chain/literal.rb' + - 'lib/solargraph/source_map/clip.rb' + - 'lib/solargraph/source_map/mapper.rb' + - 'lib/solargraph/type_checker.rb' + - 'spec/parser/node_methods_spec.rb' + - 'spec/source_map/mapper_spec.rb' + +# Offense count: 6 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: AllowMethodsWithArguments, AllowedMethods, AllowedPatterns, AllowComments. +# AllowedMethods: define_method +Style/SymbolProc: + Exclude: + - 'lib/solargraph/gem_pins.rb' + - 'lib/solargraph/language_server/message/text_document/hover.rb' + - 'lib/solargraph/language_server/message/text_document/signature_help.rb' + - 'lib/solargraph/parser/flow_sensitive_typing.rb' + - 'lib/solargraph/pin/callable.rb' + - 'lib/solargraph/pin/closure.rb' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle, AllowSafeAssignment. +# SupportedStyles: require_parentheses, require_no_parentheses, require_parentheses_when_complex +Style/TernaryParentheses: + Exclude: + - 'lib/solargraph/source_map/mapper.rb' + +# Offense count: 9 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyleForMultiline. +# SupportedStylesForMultiline: comma, consistent_comma, no_comma +Style/TrailingCommaInArguments: + Exclude: + - 'lib/solargraph/api_map.rb' + - 'lib/solargraph/parser/parser_gem/node_processors/until_node.rb' + - 'lib/solargraph/parser/parser_gem/node_processors/while_node.rb' + - 'lib/solargraph/rbs_map/conversions.rb' + - 'lib/solargraph/yard_map/mapper/to_method.rb' + +# Offense count: 2 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyleForMultiline. +# SupportedStylesForMultiline: comma, consistent_comma, diff_comma, no_comma +Style/TrailingCommaInArrayLiteral: + Exclude: + - 'lib/solargraph/language_server/message/text_document/formatting.rb' + - 'spec/complex_type_spec.rb' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyleForMultiline. +# SupportedStylesForMultiline: comma, consistent_comma, diff_comma, no_comma +Style/TrailingCommaInHashLiteral: + Exclude: + - 'lib/solargraph/api_map.rb' + +# Offense count: 2 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: ExactNameMatch, AllowPredicates, AllowDSLWriters, IgnoreClassMethods, AllowedMethods. +# AllowedMethods: to_ary, to_a, to_c, to_enum, to_h, to_hash, to_i, to_int, to_io, to_open, to_path, to_proc, to_r, to_regexp, to_str, to_s, to_sym +Style/TrivialAccessors: + Exclude: + - 'lib/solargraph/language_server/message/extended/check_gem_version.rb' + - 'lib/solargraph/pin/keyword.rb' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +Style/WhileUntilModifier: + Exclude: + - 'lib/solargraph/complex_type.rb' + +# Offense count: 27 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle, MinSize, WordRegex. +# SupportedStyles: percent, brackets +Style/WordArray: + Exclude: + - 'lib/solargraph/complex_type.rb' + - 'lib/solargraph/complex_type/unique_type.rb' + - 'lib/solargraph/diagnostics/type_check.rb' + - 'lib/solargraph/language_server/message/text_document/formatting.rb' + - 'spec/complex_type_spec.rb' + - 'spec/parser/node_chainer_spec.rb' + - 'spec/pin/method_spec.rb' + - 'spec/source/cursor_spec.rb' + - 'spec/source/source_chainer_spec.rb' + - 'spec/source_map/clip_spec.rb' + - 'spec/source_map/mapper_spec.rb' + - 'spec/source_map_spec.rb' + - 'spec/source_spec.rb' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +Style/YAMLFileRead: + Exclude: + - 'lib/solargraph/workspace/config.rb' + +# Offense count: 4 +# This cop supports unsafe autocorrection (--autocorrect-all). +Style/ZeroLengthPredicate: + Exclude: + - 'lib/solargraph/api_map.rb' + - 'lib/solargraph/api_map/index.rb' + - 'lib/solargraph/language_server/host.rb' + - 'spec/language_server/protocol_spec.rb' + +# Offense count: 173 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns, SplitStrings. +# URISchemes: http, https +Layout/LineLength: + Max: 244 diff --git a/lib/.rubocop.yml b/lib/.rubocop.yml deleted file mode 100644 index 16d2f865a..000000000 --- a/lib/.rubocop.yml +++ /dev/null @@ -1,22 +0,0 @@ -AllCops: - NewCops: enable -Style/MethodDefParentheses: - Enabled: false -Layout/EmptyLineAfterGuardClause: - Enabled: false -Layout/SpaceAroundMethodCallOperator: - Enabled: true -Lint/RaiseException: - Enabled: true -Lint/StructNewOverride: - Enabled: true -Metrics/MethodLength: - Max: 25 -Style/ExponentialNotation: - Enabled: true -Style/HashEachMethods: - Enabled: true -Style/HashTransformKeys: - Enabled: true -Style/HashTransformValues: - Enabled: true diff --git a/solargraph.gemspec b/solargraph.gemspec index 2bfb6dbdf..934ba5cbc 100755 --- a/solargraph.gemspec +++ b/solargraph.gemspec @@ -36,7 +36,9 @@ Gem::Specification.new do |s| s.add_runtime_dependency 'parser', '~> 3.0' s.add_runtime_dependency 'rbs', '~> 3.3' s.add_runtime_dependency 'reverse_markdown', '~> 3.0' - s.add_runtime_dependency 'rubocop', '~> 1.38' + s.add_runtime_dependency 'rubocop', '~> 1.76' + s.add_runtime_dependency 'rubocop-rake', '~> 0.7' + s.add_runtime_dependency 'rubocop-rspec', '~> 3.6' s.add_runtime_dependency 'thor', '~> 1.0' s.add_runtime_dependency 'tilt', '~> 2.0' s.add_runtime_dependency 'yard', '~> 0.9', '>= 0.9.24' From 0776c427fa0f5205737ea8da48d79a2d7657e697 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Fri, 13 Jun 2025 08:27:47 -0400 Subject: [PATCH 003/400] Add RuboCop workflow --- .github/workflows/rubocop.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/rubocop.yml b/.github/workflows/rubocop.yml index 5d55e4a20..2f77613ad 100644 --- a/.github/workflows/rubocop.yml +++ b/.github/workflows/rubocop.yml @@ -20,16 +20,13 @@ jobs: test: runs-on: ubuntu-latest - strategy: - matrix: - ruby-version: '3.0' steps: - uses: actions/checkout@v3 - name: Set up Ruby uses: ruby/setup-ruby@v1 with: - ruby-version: ${{ matrix.ruby-version }} + ruby-version: 3.4 bundler-cache: false - name: Install gems From 699c9c5a824fd3ccb16c13925071f29931bc242b Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Fri, 13 Jun 2025 08:28:16 -0400 Subject: [PATCH 004/400] Add RuboCop workflow --- .github/workflows/rubocop.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/rubocop.yml b/.github/workflows/rubocop.yml index 2f77613ad..9fcbafa23 100644 --- a/.github/workflows/rubocop.yml +++ b/.github/workflows/rubocop.yml @@ -17,8 +17,7 @@ permissions: contents: read jobs: - test: - + rubocop: runs-on: ubuntu-latest steps: From 1c4d161fa38478c84e48a67643424e56453987ce Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Fri, 13 Jun 2025 08:31:36 -0400 Subject: [PATCH 005/400] Add RuboCop workflow --- .rubocop.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.rubocop.yml b/.rubocop.yml index 198447e83..1fcf3dea2 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -20,6 +20,9 @@ AllCops: - "spec/fixtures/rubocop-unused-variable-error/*" - "spec/fixtures/rubocop-subfolder-configuration/.*" - "spec/fixtures/rubocop-subfolder-configuration/*" + - "spec/fixtures/invalid_byte.rb" + - "spec/fixtures/invalid_node_comment.rb" + - "spec/fixtures/invalid_utf8.rb" TargetRubyVersion: 3.0 Style/MethodDefParentheses: From 728552c86606ffacf02db488c97f901a5fa19c68 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Fri, 13 Jun 2025 08:53:50 -0400 Subject: [PATCH 006/400] Add RuboCop workflow --- .rubocop.yml | 6 ------ .rubocop_todo.yml | 9 +++++---- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 1fcf3dea2..576c17e9e 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -14,12 +14,6 @@ inherit_from: .rubocop_todo.yml AllCops: NewCops: enable Exclude: - - "spec/fixtures/rubocop-validation-error/.*" - - "spec/fixtures/rubocop-validation-error/*" - - "spec/fixtures/rubocop-unused-variable-error/.*" - - "spec/fixtures/rubocop-unused-variable-error/*" - - "spec/fixtures/rubocop-subfolder-configuration/.*" - - "spec/fixtures/rubocop-subfolder-configuration/*" - "spec/fixtures/invalid_byte.rb" - "spec/fixtures/invalid_node_comment.rb" - "spec/fixtures/invalid_utf8.rb" diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 2f0e023a3..d0a679cf4 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2025-06-13 12:23:43 UTC using RuboCop version 1.76.1. +# on 2025-06-13 12:53:14 UTC using RuboCop version 1.76.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 @@ -405,10 +405,11 @@ Lint/EmptyBlock: Exclude: - 'spec/convention_spec.rb' -# Offense count: 5 +# Offense count: 6 # Configuration parameters: AllowComments. Lint/EmptyClass: Exclude: + - 'spec/fixtures/rubocop-validation-error/app.rb' - 'spec/fixtures/workspace-with-gemfile/lib/other.rb' - 'spec/fixtures/workspace/lib/other.rb' - 'spec/fixtures/workspace/lib/something.rb' @@ -523,7 +524,7 @@ Lint/UselessAccessModifier: Exclude: - 'lib/solargraph/api_map.rb' -# Offense count: 32 +# Offense count: 33 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AutoCorrect. Lint/UselessAssignment: @@ -1162,7 +1163,7 @@ Style/FloatDivision: - 'lib/solargraph/library.rb' - 'lib/solargraph/pin/search.rb' -# Offense count: 126 +# Offense count: 127 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: EnforcedStyle. # SupportedStyles: always, always_true, never From f3e41a0e212ee36d79329ac8c57cb3cd6e0e8b8f Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Fri, 13 Jun 2025 09:41:02 -0400 Subject: [PATCH 007/400] Use undercover tool to report on PR test coverage --- .github/workflows/rspec.yml | 19 +++++++++++++++++-- Rakefile | 6 ++++++ solargraph.gemspec | 4 +++- spec/spec_helper.rb | 10 +++++++++- 4 files changed, 35 insertions(+), 4 deletions(-) diff --git a/.github/workflows/rspec.yml b/.github/workflows/rspec.yml index e2c94cc1b..830e61cd8 100644 --- a/.github/workflows/rspec.yml +++ b/.github/workflows/rspec.yml @@ -17,8 +17,7 @@ permissions: contents: read jobs: - test: - + rspec: runs-on: ubuntu-latest strategy: matrix: @@ -35,3 +34,19 @@ jobs: run: bundle install - name: Run tests run: bundle exec rspec + undercover: + name: 'Undercover' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: '3.4' + bundler-cache: false + - name: Install gems + run: bundle install + - name: Run tests + run: bundle exec rspec + - name: Check PR coverage + run: bundle exec rake undercover diff --git a/Rakefile b/Rakefile index 33b91bfa4..2c92fd843 100755 --- a/Rakefile +++ b/Rakefile @@ -18,8 +18,14 @@ task :typecheck do sh "bundle exec solargraph typecheck --level typed" end +desc "Check PR coverage" +task :undercover do + sh 'bundle exec undercover --exclude-files "Rakefile,spec/**/*" --compare origin/master' +end + desc "Run all tests" task :test do Rake::Task["typecheck"].invoke Rake::Task["spec"].invoke + Rake::Task["undercover"].invoke end diff --git a/solargraph.gemspec b/solargraph.gemspec index 2bfb6dbdf..8715a789d 100755 --- a/solargraph.gemspec +++ b/solargraph.gemspec @@ -46,7 +46,9 @@ Gem::Specification.new do |s| s.add_development_dependency 'public_suffix', '~> 3.1' s.add_development_dependency 'rake', '~> 13.2' s.add_development_dependency 'rspec', '~> 3.5' - s.add_development_dependency 'simplecov', '~> 0.14' + s.add_development_dependency 'simplecov', '~> 0.21' + s.add_development_dependency 'simplecov-lcov', '~> 0.8' + s.add_development_dependency 'undercover', '~> 0.6' s.add_development_dependency 'webmock', '~> 3.6' # work around missing yard dependency needed as of Ruby 3.5 s.add_development_dependency 'irb', '~> 1.15' diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 5e0385b74..cdd81df82 100755 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -2,8 +2,16 @@ require 'webmock/rspec' WebMock.disable_net_connect!(allow_localhost: true) unless ENV['SIMPLECOV_DISABLED'] + # set up lcov reporting for undercover require 'simplecov' - SimpleCov.start + require 'simplecov-lcov' + SimpleCov::Formatter::LcovFormatter.config.report_with_single_file = true + SimpleCov.formatter = SimpleCov::Formatter::LcovFormatter + SimpleCov.start do + add_filter(%r{^/spec/}) + add_filter('/Rakefile') + enable_coverage(:branch) + end end require 'solargraph' # Suppress logger output in specs (if possible) From a1bb9687cd946148e7d4c7586d765804d991e35e Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Fri, 13 Jun 2025 10:13:32 -0400 Subject: [PATCH 008/400] Use undercover tool to report on PR test coverage --- .github/workflows/rspec.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/rspec.yml b/.github/workflows/rspec.yml index 830e61cd8..d9cacbaee 100644 --- a/.github/workflows/rspec.yml +++ b/.github/workflows/rspec.yml @@ -39,6 +39,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 + with: + # fetch all history for all branches and tags so we can + # compare against origin/master + fetch-depth: 0 - name: Set up Ruby uses: ruby/setup-ruby@v1 with: From 3faecc91f226d5c916141cc3bf844b3ee2b643ab Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Fri, 13 Jun 2025 10:22:05 -0400 Subject: [PATCH 009/400] Use undercover tool to report on PR test coverage --- Rakefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Rakefile b/Rakefile index 2c92fd843..dfdce8fc7 100755 --- a/Rakefile +++ b/Rakefile @@ -20,7 +20,7 @@ end desc "Check PR coverage" task :undercover do - sh 'bundle exec undercover --exclude-files "Rakefile,spec/**/*" --compare origin/master' + sh 'bundle exec undercover --exclude-files "Rakefile,spec/*,spec/**/*" --compare origin/master' end desc "Run all tests" From 3eaa610bac0de99f1b1be1cb20ba1e27b2b39275 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Wed, 9 Jul 2025 14:25:09 -0400 Subject: [PATCH 010/400] Add linting workflow, watching for RuboCop + Solargraph regressions --- .github/workflows/linting.yml | 75 +++++++++++++++++++++++++++++++++++ .overcommit.yml | 51 ++++++++++++++++++++++++ solargraph.gemspec | 2 + 3 files changed, 128 insertions(+) create mode 100644 .github/workflows/linting.yml create mode 100644 .overcommit.yml diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml new file mode 100644 index 000000000..a616a5460 --- /dev/null +++ b/.github/workflows/linting.yml @@ -0,0 +1,75 @@ +--- +# To debug locally: +# npm install -g act +# act pull_release -j overcommit +# + +name: Linting + +on: + workflow_dispatch: {} + pull_request: + branches: [main] + push: + branches: + - 'main' + tags: + - 'v*' + +permissions: + pull-requests: write + +jobs: + overcommit: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + # Number of commits to fetch. 0 indicates all history for all branches and tags. + with: + fetch-depth: 0 + + - uses: ruby/setup-ruby@v1 + with: + ruby-version: 3.4 + bundler: latest + bundler-cache: true + cache-version: ${{ matrix.solargraph-version }}-${{ matrix.versions.rails-major }}.${{ matrix.versions.rails-minor }}-2025-06-06 + + - name: Restore cache of gem annotations + id: dot-cache-restore + uses: actions/cache/restore@v4 + with: + key: | + 2025-06-26-09-${{ runner.os }}-dot-cache-${{ matrix.solargraph-version }}-${{ matrix.versions.rails-major }}--${{ matrix.versions.rails-minor }}-${{ hashFiles('spec/**/Gemfile.lock') }}-${{ hashFiles('Gemfile.lock') }} + restore-keys: | + 2025-06-26-09-${{ runner.os }}-dot-cache-${{ matrix.solargraph-version }}-${{ matrix.versions.rails-major }}-${{ matrix.versions.rails-minor }}-${{ hashFiles('spec/**/Gemfile.lock') }}- + 2025-06-26-09-${{ runner.os }}-dot-cache-${{ matrix.solargraph-version }}-${{ matrix.versions.rails-major }}-${{ matrix.versions.rails-minor }}- + 2025-06-26-09-${{ runner.os }}-dot-cache-${{ matrix.solargraph-version }}-${{ matrix.versions.rails-major }}- + 2025-06-26-09-${{ runner.os }}-dot-cache-${{ matrix.solargraph-version }}- + path: | + /home/runner/.cache/solargraph + + - name: Overcommit + run: | + bundle exec overcommit --sign + bundle exec overcommit --run --diff origin/main + rubocop: + name: rubocop + runs-on: ubuntu-latest + env: + BUNDLE_ONLY: rubocop + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + - uses: ruby/setup-ruby@1a615958ad9d422dd932dc1d5823942ee002799f # v1.227.0 + with: + ruby-version: '3.3' + bundler-cache: true + - uses: reviewdog/action-rubocop@fcb74ba274da10b18d038d0bcddaae3518739634 # v2.21.2 + with: + reporter: github-pr-check + skip_install: true + use_bundler: true + rubocop_extensions: 'rubocop-performance:gemfile rubocop-rspec:gemfile rubocop-rake:gemfile rubocop-yard:gemfile' + fail_level: info + rubocop_version: Gemfile + level: info diff --git a/.overcommit.yml b/.overcommit.yml new file mode 100644 index 000000000..215770aed --- /dev/null +++ b/.overcommit.yml @@ -0,0 +1,51 @@ +--- +# Use this file to configure the Overcommit hooks you wish to use. This will +# extend the default configuration defined in: +# https://github.com/sds/overcommit/blob/master/config/default.yml +# +# At the topmost level of this YAML file is a key representing type of hook +# being run (e.g. pre-commit, commit-msg, etc.). Within each type you can +# customize each hook, such as whether to only run it on certain files (via +# `include`), whether to only display output if it fails (via `quiet`), etc. +# +# For a complete list of hooks, see: +# https://github.com/sds/overcommit/tree/master/lib/overcommit/hook +# +# For a complete list of options that you can use to customize hooks, see: +# https://github.com/sds/overcommit#configuration +# +# Uncomment the following lines to make the configuration take effect. + +PreCommit: + RuboCop: + enabled: true + on_warn: fail # Treat all warnings as failures + + Solargraph: + enabled: true + exclude: + - 'spec/**/*' + - lib/solargraph/rails/annotations/**/* + - vendor/**/* + - ".bundle/**/*" + + # creates false positives in CI + AuthorName: + enabled: false + + # creates false positives in CI + AuthorEmail: + enabled: false + +# +# TrailingWhitespace: +# enabled: true +# exclude: +# - '**/db/structure.sql' # Ignore trailing whitespace in generated files +# +#PostCheckout: +# ALL: # Special hook name that customizes all hooks of this type +# quiet: true # Change all post-checkout hooks to only display output on failure +# +# IndexTags: +# enabled: true # Generate a tags file with `ctags` each time HEAD changes diff --git a/solargraph.gemspec b/solargraph.gemspec index 8a3c7a20c..94ebbe46c 100755 --- a/solargraph.gemspec +++ b/solargraph.gemspec @@ -40,6 +40,7 @@ Gem::Specification.new do |s| s.add_runtime_dependency 'rubocop', '~> 1.76' s.add_runtime_dependency 'rubocop-rake', '~> 0.7' s.add_runtime_dependency 'rubocop-rspec', '~> 3.6' + s.add_runtime_dependency 'rubocop-yard', '~> 1.0' s.add_runtime_dependency 'thor', '~> 1.0' s.add_runtime_dependency 'tilt', '~> 2.0' s.add_runtime_dependency 'yard', '~> 0.9', '>= 0.9.24' @@ -52,6 +53,7 @@ Gem::Specification.new do |s| s.add_development_dependency 'simplecov', '~> 0.21' s.add_development_dependency 'simplecov-lcov', '~> 0.8' s.add_development_dependency 'undercover', '~> 0.6' + s.add_development_dependency 'overcommit', '~> 0.68.0' s.add_development_dependency 'webmock', '~> 3.6' # work around missing yard dependency needed as of Ruby 3.5 s.add_development_dependency 'irb', '~> 1.15' From 534f2020391f311b815ea6510db5781fa6c7a4f6 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Wed, 9 Jul 2025 14:29:47 -0400 Subject: [PATCH 011/400] Add rubocop-yard --- .rubocop.yml | 1 + .rubocop_todo.yml | 405 ++++++++++++++++++++++++++++++++-------------- 2 files changed, 286 insertions(+), 120 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 576c17e9e..a769ad37e 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -31,3 +31,4 @@ Metrics/MethodLength: plugins: - rubocop-rspec - rubocop-rake + - rubocop-yard diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index d0a679cf4..a4307b7e5 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,12 +1,12 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2025-06-13 12:53:14 UTC using RuboCop version 1.76.1. +# on 2025-07-09 18:29:07 UTC using RuboCop version 1.78.0. # 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: 20 +# Offense count: 22 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: Include. # Include: **/*.gemspec @@ -23,7 +23,7 @@ Gemspec/DeprecatedAttributeAssignment: - 'solargraph.gemspec' - 'spec/fixtures/rdoc-lib/rdoc-lib.gemspec' -# Offense count: 7 +# Offense count: 10 # Configuration parameters: EnforcedStyle, AllowedGems, Include. # SupportedStyles: Gemfile, gems.rb, gemspec # Include: **/*.gemspec, **/Gemfile, **/gems.rb @@ -31,6 +31,14 @@ Gemspec/DevelopmentDependencies: Exclude: - 'solargraph.gemspec' +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: TreatCommentsAsGroupSeparators, ConsiderPunctuation, Include. +# Include: **/*.gemspec +Gemspec/OrderedDependencies: + Exclude: + - 'solargraph.gemspec' + # Offense count: 3 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: Severity, Include. @@ -67,6 +75,12 @@ Layout/BlockAlignment: Exclude: - 'spec/source_map/mapper_spec.rb' +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +Layout/ClosingHeredocIndentation: + Exclude: + - 'spec/rbs_map/conversions_spec.rb' + # Offense count: 8 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowForAlignment. @@ -77,31 +91,44 @@ Layout/CommentIndentation: - 'lib/solargraph/parser/parser_gem/node_methods.rb' - 'lib/solargraph/source_map/mapper.rb' -# Offense count: 22 +# Offense count: 23 # This cop supports safe autocorrection (--autocorrect). Layout/ElseAlignment: Enabled: false -# Offense count: 2 +# Offense count: 3 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EmptyLineBetweenMethodDefs, EmptyLineBetweenClassDefs, EmptyLineBetweenModuleDefs, DefLikeMacros, AllowAdjacentOneLineDefs, NumberOfEmptyLines. Layout/EmptyLineBetweenDefs: Exclude: + - 'lib/solargraph/doc_map.rb' - 'lib/solargraph/language_server/message/initialize.rb' - 'lib/solargraph/pin/delegated_method.rb' -# Offense count: 8 +# Offense count: 12 # This cop supports safe autocorrection (--autocorrect). Layout/EmptyLines: Exclude: - 'lib/solargraph/bench.rb' - 'lib/solargraph/complex_type/unique_type.rb' - 'lib/solargraph/convention.rb' + - 'lib/solargraph/doc_map.rb' - 'lib/solargraph/language_server/message/extended/check_gem_version.rb' - 'lib/solargraph/language_server/message/initialize.rb' - 'lib/solargraph/pin/delegated_method.rb' - - 'spec/pin/parameter_spec.rb' + - 'lib/solargraph/rbs_map/conversions.rb' + - 'spec/complex_type_spec.rb' + - 'spec/pin/local_variable_spec.rb' - 'spec/pin/symbol_spec.rb' + - 'spec/type_checker/levels/strict_spec.rb' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines, beginning_only, ending_only +Layout/EmptyLinesAroundClassBody: + Exclude: + - 'lib/solargraph/rbs_map/core_map.rb' # Offense count: 1 # This cop supports safe autocorrection (--autocorrect). @@ -128,14 +155,17 @@ Layout/EndOfLine: - 'lib/solargraph/source/encoding_fixes.rb' - 'solargraph.gemspec' -# Offense count: 3 +# Offense count: 7 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowForAlignment, AllowBeforeTrailingComments, ForceEqualSignAlignment. Layout/ExtraSpacing: Exclude: - 'lib/solargraph/parser/parser_gem/node_processors/opasgn_node.rb' + - 'lib/solargraph/pin/closure.rb' + - 'lib/solargraph/pin/local_variable.rb' - 'lib/solargraph/rbs_map/conversions.rb' - 'lib/solargraph/type_checker.rb' + - 'spec/spec_helper.rb' # Offense count: 2 # This cop supports safe autocorrection (--autocorrect). @@ -158,7 +188,7 @@ Layout/FirstArrayElementIndentation: - 'spec/source/source_chainer_spec.rb' - 'spec/source_spec.rb' -# Offense count: 63 +# Offense count: 65 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle, IndentationWidth. # SupportedStyles: special_inside_parentheses, consistent, align_braces @@ -169,6 +199,7 @@ Layout/FirstHashElementIndentation: - 'lib/solargraph/language_server/message/text_document/completion.rb' - 'lib/solargraph/language_server/message/text_document/rename.rb' - 'lib/solargraph/language_server/message/text_document/signature_help.rb' + - 'lib/solargraph/pin/base_variable.rb' - 'spec/language_server/host_spec.rb' - 'spec/language_server/message/completion_item/resolve_spec.rb' - 'spec/language_server/message/initialize_spec.rb' @@ -189,10 +220,11 @@ Layout/HashAlignment: Exclude: - 'lib/solargraph/workspace/config.rb' -# Offense count: 1 +# Offense count: 2 # This cop supports safe autocorrection (--autocorrect). Layout/HeredocIndentation: Exclude: + - 'spec/rbs_map/conversions_spec.rb' - 'spec/yard_map/mapper/to_method_spec.rb' # Offense count: 24 @@ -242,12 +274,13 @@ Layout/MultilineMethodCallIndentation: - 'lib/solargraph/pin/search.rb' - 'lib/solargraph/type_checker.rb' -# Offense count: 3 +# Offense count: 6 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle, IndentationWidth. # SupportedStyles: aligned, indented Layout/MultilineOperationIndentation: Exclude: + - 'lib/solargraph/api_map.rb' - 'lib/solargraph/language_server/host/dispatch.rb' - 'lib/solargraph/source.rb' @@ -257,7 +290,26 @@ Layout/SpaceAfterComma: Exclude: - 'spec/source/cursor_spec.rb' -# Offense count: 27 +# Offense count: 6 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: space, no_space +Layout/SpaceAroundEqualsInParameterDefault: + Exclude: + - 'lib/solargraph/pin/base.rb' + - 'lib/solargraph/pin/base_variable.rb' + - 'lib/solargraph/pin/callable.rb' + - 'lib/solargraph/pin/closure.rb' + - 'lib/solargraph/pin/local_variable.rb' + - 'lib/solargraph/pin/parameter.rb' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +Layout/SpaceAroundKeyword: + Exclude: + - 'spec/rbs_map/conversions_spec.rb' + +# Offense count: 28 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowForAlignment, EnforcedStyleForExponentOperator, EnforcedStyleForRationalLiterals. # SupportedStylesForExponentOperator: space, no_space @@ -266,6 +318,7 @@ Layout/SpaceAroundOperators: Exclude: - 'lib/solargraph/library.rb' - 'lib/solargraph/parser/parser_gem/node_methods.rb' + - 'lib/solargraph/pin/local_variable.rb' - 'lib/solargraph/source.rb' - 'lib/solargraph/source/change.rb' - 'lib/solargraph/source/cursor.rb' @@ -275,7 +328,7 @@ Layout/SpaceAroundOperators: - 'spec/library_spec.rb' - 'spec/yard_map/mapper_spec.rb' -# Offense count: 112 +# Offense count: 108 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces. # SupportedStyles: space, no_space @@ -289,7 +342,7 @@ Layout/SpaceBeforeComma: Exclude: - 'spec/source/cursor_spec.rb' -# Offense count: 189 +# Offense count: 183 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters. # SupportedStyles: space, no_space @@ -297,18 +350,16 @@ Layout/SpaceBeforeComma: Layout/SpaceInsideBlockBraces: Enabled: false -# Offense count: 26 +# Offense count: 10 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces. # SupportedStyles: space, no_space, compact # SupportedStylesForEmptyBraces: space, no_space Layout/SpaceInsideHashLiteralBraces: Exclude: - - 'lib/solargraph/language_server/message/extended/document.rb' - 'lib/solargraph/language_server/message/extended/search.rb' - 'lib/solargraph/language_server/message/initialize.rb' - 'lib/solargraph/workspace/config.rb' - - 'spec/complex_type_spec.rb' - 'spec/language_server/host/message_worker_spec.rb' - 'spec/language_server/message/extended/check_gem_version_spec.rb' @@ -321,7 +372,7 @@ Layout/SpaceInsideParens: - 'lib/solargraph/pin/namespace.rb' - 'lib/solargraph/source_map.rb' -# Offense count: 4 +# Offense count: 3 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowInHeredoc. Layout/TrailingWhitespace: @@ -329,7 +380,6 @@ Layout/TrailingWhitespace: - 'lib/solargraph/language_server/message/client/register_capability.rb' - 'spec/api_map/config_spec.rb' - 'spec/convention_spec.rb' - - 'spec/source_map/clip_spec.rb' # Offense count: 2 # This cop supports safe autocorrection (--autocorrect). @@ -350,11 +400,26 @@ Lint/AmbiguousOperator: - 'lib/solargraph/pin/constant.rb' - 'lib/solargraph/pin/method.rb' -# Offense count: 1 +# Offense count: 5 # This cop supports safe autocorrection (--autocorrect). Lint/AmbiguousOperatorPrecedence: Exclude: + - 'lib/solargraph/pin/method.rb' + - 'lib/solargraph/source.rb' + +# Offense count: 18 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: RequireParenthesesForMethodChains. +Lint/AmbiguousRange: + Exclude: + - 'lib/solargraph/library.rb' + - 'lib/solargraph/parser/parser_gem/node_methods.rb' - 'lib/solargraph/source.rb' + - 'lib/solargraph/source/change.rb' + - 'lib/solargraph/source/cursor.rb' + - 'lib/solargraph/source/source_chainer.rb' + - 'lib/solargraph/source_map/clip.rb' + - 'spec/library_spec.rb' # Offense count: 1 # This cop supports unsafe autocorrection (--autocorrect-all). @@ -383,20 +448,25 @@ Lint/ConstantDefinitionInBlock: Exclude: - 'spec/complex_type_spec.rb' -# Offense count: 6 +# Offense count: 8 # Configuration parameters: IgnoreLiteralBranches, IgnoreConstantBranches, IgnoreDuplicateElseBranch. Lint/DuplicateBranch: Exclude: - 'lib/solargraph/complex_type/type_methods.rb' - 'lib/solargraph/parser/parser_gem/node_chainer.rb' + - 'lib/solargraph/pin/base.rb' - 'lib/solargraph/rbs_map/conversions.rb' -# Offense count: 5 +# Offense count: 9 Lint/DuplicateMethods: Exclude: - 'lib/solargraph/complex_type.rb' - 'lib/solargraph/location.rb' - - 'lib/solargraph/pin/method.rb' + - 'lib/solargraph/pin/base.rb' + - 'lib/solargraph/pin/common.rb' + - 'lib/solargraph/pin/signature.rb' + - 'lib/solargraph/rbs_map.rb' + - 'lib/solargraph/rbs_map/core_map.rb' - 'lib/solargraph/source/chain/link.rb' # Offense count: 1 @@ -446,8 +516,8 @@ Lint/MissingSuper: # This cop supports safe autocorrection (--autocorrect). Lint/ParenthesesAsGroupedExpression: Exclude: + - 'lib/solargraph.rb' - 'lib/solargraph/parser/parser_gem/node_chainer.rb' - - 'spec/complex_type_spec.rb' - 'spec/language_server/host_spec.rb' - 'spec/source_map/clip_spec.rb' @@ -488,6 +558,14 @@ Lint/SuppressedException: Exclude: - 'Rakefile' +# Offense count: 5 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: strict, consistent +Lint/SymbolConversion: + Exclude: + - 'lib/solargraph/pin/base.rb' + # Offense count: 1 # Configuration parameters: AllowKeywordBlockArguments. Lint/UnderscorePrefixedVariableName: @@ -501,6 +579,11 @@ Lint/UnexpectedBlockArity: - 'lib/solargraph/language_server/message/completion_item/resolve.rb' - 'lib/solargraph/type_checker.rb' +# Offense count: 1 +Lint/UnmodifiedReduceAccumulator: + Exclude: + - 'lib/solargraph/pin/method.rb' + # Offense count: 4 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AutoCorrect, IgnoreEmptyBlocks, AllowUnusedKeywordArguments. @@ -510,7 +593,7 @@ Lint/UnusedBlockArgument: - 'lib/solargraph/logging.rb' - 'spec/language_server/transport/data_reader_spec.rb' -# Offense count: 35 +# Offense count: 38 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AutoCorrect, AllowUnusedKeywordArguments, IgnoreEmptyMethods, IgnoreNotImplementedMethods, NotImplementedExceptions. # NotImplementedExceptions: NotImplementedError @@ -524,13 +607,13 @@ Lint/UselessAccessModifier: Exclude: - 'lib/solargraph/api_map.rb' -# Offense count: 33 +# Offense count: 40 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AutoCorrect. Lint/UselessAssignment: Enabled: false -# Offense count: 1 +# Offense count: 2 Lint/UselessConstantScoping: Exclude: - 'lib/solargraph/rbs_map/conversions.rb' @@ -542,12 +625,12 @@ Lint/UselessMethodDefinition: Exclude: - 'lib/solargraph/pin/signature.rb' -# Offense count: 209 +# Offense count: 227 # Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes. Metrics/AbcSize: Max: 200 -# Offense count: 11 +# Offense count: 12 # Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns, inherit_mode. # AllowedMethods: refine Metrics/BlockLength: @@ -558,17 +641,17 @@ Metrics/BlockLength: Metrics/BlockNesting: Max: 6 -# Offense count: 27 +# Offense count: 30 # Configuration parameters: CountComments, CountAsOne. Metrics/ClassLength: - Max: 541 + Max: 580 -# Offense count: 97 +# Offense count: 111 # Configuration parameters: AllowedMethods, AllowedPatterns. Metrics/CyclomaticComplexity: Max: 42 -# Offense count: 47 +# Offense count: 50 # Configuration parameters: CountComments, Max, CountAsOne, AllowedMethods, AllowedPatterns. Metrics/MethodLength: Enabled: false @@ -576,15 +659,15 @@ Metrics/MethodLength: # Offense count: 4 # Configuration parameters: CountComments, CountAsOne. Metrics/ModuleLength: - Max: 458 + Max: 168 -# Offense count: 13 +# Offense count: 14 # Configuration parameters: CountKeywordArgs. Metrics/ParameterLists: Max: 9 MaxOptionalParameters: 5 -# Offense count: 82 +# Offense count: 88 # Configuration parameters: AllowedMethods, AllowedPatterns. Metrics/PerceivedComplexity: Max: 47 @@ -609,7 +692,7 @@ Naming/HeredocDelimiterNaming: Exclude: - 'spec/yard_map/mapper/to_method_spec.rb' -# Offense count: 5 +# Offense count: 9 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: EnforcedStyleForLeadingUnderscores. # SupportedStylesForLeadingUnderscores: disallowed, required, optional @@ -619,6 +702,8 @@ Naming/MemoizedInstanceVariableName: - 'lib/solargraph/convention/gemfile.rb' - 'lib/solargraph/convention/gemspec.rb' - 'lib/solargraph/convention/rakefile.rb' + - 'lib/solargraph/doc_map.rb' + - 'lib/solargraph/rbs_map.rb' - 'lib/solargraph/workspace.rb' # Offense count: 16 @@ -633,9 +718,10 @@ Naming/MethodParameterName: - 'lib/solargraph/yard_map/mapper/to_method.rb' - 'lib/solargraph/yard_map/to_method.rb' -# Offense count: 17 -# Configuration parameters: Mode, AllowedMethods. +# Offense count: 11 +# Configuration parameters: Mode, AllowedMethods, AllowedPatterns, AllowBangMethods, WaywardPredicates. # AllowedMethods: call +# WaywardPredicates: nonzero? Naming/PredicateMethod: Exclude: - 'lib/solargraph/api_map/store.rb' @@ -644,14 +730,10 @@ Naming/PredicateMethod: - 'lib/solargraph/library.rb' - 'lib/solargraph/parser/parser_gem/node_processors/send_node.rb' - 'lib/solargraph/pin/base.rb' - - 'lib/solargraph/pin/base_variable.rb' - 'lib/solargraph/pin/local_variable.rb' - - 'lib/solargraph/pin/method.rb' - - 'lib/solargraph/pin/parameter.rb' - - 'lib/solargraph/source_map.rb' - 'lib/solargraph/workspace.rb' -# Offense count: 4 +# Offense count: 6 # Configuration parameters: NamePrefix, ForbiddenPrefixes, AllowedMethods, MethodDefinitionMacros, UseSorbetSigs. # NamePrefix: is_, has_, have_, does_ # ForbiddenPrefixes: is_, has_, have_, does_ @@ -663,6 +745,7 @@ Naming/PredicatePrefix: - 'lib/solargraph/api_map.rb' - 'lib/solargraph/language_server/host.rb' - 'lib/solargraph/parser/parser_gem/class_methods.rb' + - 'lib/solargraph/pin_cache.rb' - 'lib/solargraph/workspace.rb' # Offense count: 1 @@ -679,12 +762,11 @@ RSpec/Be: - 'spec/rbs_map_spec.rb' - 'spec/source/source_chainer_spec.rb' -# Offense count: 5 +# Offense count: 3 # This cop supports unsafe autocorrection (--autocorrect-all). RSpec/BeEq: Exclude: - 'spec/complex_type_spec.rb' - - 'spec/pin/base_spec.rb' - 'spec/pin/method_spec.rb' # Offense count: 7 @@ -707,7 +789,7 @@ RSpec/BeforeAfterAll: - 'spec/language_server/host/dispatch_spec.rb' - 'spec/language_server/protocol_spec.rb' -# Offense count: 14 +# Offense count: 25 # Configuration parameters: Prefixes, AllowedPatterns. # Prefixes: when, with, without RSpec/ContextWording: @@ -722,7 +804,7 @@ RSpec/ContextWording: - 'spec/type_checker/levels/strong_spec.rb' - 'spec/type_checker/levels/typed_spec.rb' -# Offense count: 1 +# Offense count: 2 # Configuration parameters: IgnoredMetadata. RSpec/DescribeClass: Exclude: @@ -731,9 +813,10 @@ RSpec/DescribeClass: - '**/spec/routing/**/*' - '**/spec/system/**/*' - '**/spec/views/**/*' + - 'spec/complex_type_spec.rb' - 'spec/source_map/node_processor_spec.rb' -# Offense count: 493 +# Offense count: 407 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: SkipBlocks, EnforcedStyle, OnlyStaticConstants. # SupportedStyles: described_class, explicit @@ -753,7 +836,7 @@ RSpec/EmptyLineAfterFinalLet: Exclude: - 'spec/workspace/config_spec.rb' -# Offense count: 914 +# Offense count: 928 # Configuration parameters: CountAsOne. RSpec/ExampleLength: Max: 59 @@ -767,10 +850,11 @@ RSpec/ExampleWording: - 'spec/pin/base_spec.rb' - 'spec/pin/method_spec.rb' -# Offense count: 1 +# Offense count: 2 # This cop supports safe autocorrection (--autocorrect). RSpec/ExcessiveDocstringSpacing: Exclude: + - 'spec/rbs_map/conversions_spec.rb' - 'spec/source/chain/call_spec.rb' # Offense count: 5 @@ -796,7 +880,14 @@ RSpec/HookArgument: - 'spec/workspace/config_spec.rb' - 'spec/workspace_spec.rb' -# Offense count: 246 +# Offense count: 2 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: . +# SupportedStyles: is_expected, should +RSpec/ImplicitExpect: + EnforcedStyle: should + +# Offense count: 247 # Configuration parameters: AssignmentOnly. RSpec/InstanceVariable: Exclude: @@ -807,6 +898,12 @@ RSpec/InstanceVariable: - 'spec/language_server/host_spec.rb' - 'spec/language_server/protocol_spec.rb' +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +RSpec/LeadingSubject: + Exclude: + - 'spec/rbs_map/conversions_spec.rb' + # Offense count: 1 RSpec/LeakyConstantDeclaration: Exclude: @@ -830,10 +927,15 @@ RSpec/MissingExampleGroupArgument: Exclude: - 'spec/diagnostics/rubocop_helpers_spec.rb' -# Offense count: 466 +# Offense count: 471 RSpec/MultipleExpectations: Max: 14 +# Offense count: 1 +# Configuration parameters: AllowedGroups. +RSpec/NestedGroups: + Max: 4 + # Offense count: 8 # Configuration parameters: AllowedPatterns. # AllowedPatterns: ^expect_, ^assert_ @@ -847,22 +949,23 @@ RSpec/NoExpectationExample: - 'spec/type_checker/checks_spec.rb' - 'spec/type_checker/levels/typed_spec.rb' -# Offense count: 1 +# Offense count: 2 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle. # SupportedStyles: not_to, to_not RSpec/NotToNot: Exclude: + - 'spec/api_map_spec.rb' - 'spec/rbs_map/core_map_spec.rb' -# Offense count: 33 +# Offense count: 28 RSpec/PendingWithoutReason: Exclude: - 'spec/api_map_spec.rb' - 'spec/complex_type_spec.rb' - 'spec/parser/node_chainer_spec.rb' - 'spec/parser/node_methods_spec.rb' - - 'spec/pin/method_spec.rb' + - 'spec/pin/local_variable_spec.rb' - 'spec/rbs_map/core_map_spec.rb' - 'spec/source/chain/call_spec.rb' - 'spec/source/chain_spec.rb' @@ -890,7 +993,7 @@ RSpec/RemoveConst: Exclude: - 'spec/diagnostics/rubocop_helpers_spec.rb' -# Offense count: 46 +# Offense count: 48 RSpec/RepeatedDescription: Exclude: - 'spec/api_map_spec.rb' @@ -903,7 +1006,7 @@ RSpec/RepeatedDescription: - 'spec/type_checker/levels/normal_spec.rb' - 'spec/type_checker/levels/strict_spec.rb' -# Offense count: 28 +# Offense count: 30 RSpec/RepeatedExample: Exclude: - 'spec/api_map_spec.rb' @@ -919,7 +1022,7 @@ RSpec/ScatteredLet: Exclude: - 'spec/complex_type_spec.rb' -# Offense count: 87 +# Offense count: 88 # Configuration parameters: Include, CustomTransform, IgnoreMethods, IgnoreMetadata. # Include: **/*_spec.rb RSpec/SpecFilePathFormat: @@ -930,7 +1033,7 @@ RSpec/StubbedMock: Exclude: - 'spec/language_server/host/message_worker_spec.rb' -# Offense count: 24 +# Offense count: 23 # Configuration parameters: IgnoreNameless, IgnoreSymbolicNames. RSpec/VerifiedDoubles: Exclude: @@ -951,9 +1054,9 @@ RSpec/VerifiedDoubles: # Offense count: 1 Security/MarshalLoad: Exclude: - - 'lib/solargraph/cache.rb' + - 'lib/solargraph/pin_cache.rb' -# Offense count: 12 +# Offense count: 13 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: EnforcedStyle, AllowModifiersOnSymbols, AllowModifiersOnAttrs, AllowModifiersOnAliasMethod. # SupportedStyles: inline, group @@ -963,6 +1066,7 @@ Style/AccessModifierDeclarations: - 'lib/solargraph/complex_type.rb' - 'lib/solargraph/complex_type/unique_type.rb' - 'lib/solargraph/location.rb' + - 'lib/solargraph/pin/base.rb' - 'lib/solargraph/position.rb' - 'lib/solargraph/range.rb' - 'lib/solargraph/source/chain.rb' @@ -972,17 +1076,19 @@ Style/AccessModifierDeclarations: - 'lib/solargraph/source/chain/link.rb' - 'lib/solargraph/source/chain/literal.rb' -# Offense count: 9 +# Offense count: 13 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle. # SupportedStyles: separated, grouped Style/AccessorGrouping: Exclude: + - 'lib/solargraph/doc_map.rb' - 'lib/solargraph/parser/flow_sensitive_typing.rb' - - 'lib/solargraph/pin/callable.rb' + - 'lib/solargraph/pin/base.rb' - 'lib/solargraph/pin/method.rb' + - 'lib/solargraph/rbs_map.rb' -# Offense count: 39 +# Offense count: 38 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: EnforcedStyle. # SupportedStyles: always, conditionals @@ -1014,7 +1120,7 @@ Style/ArgumentsForwarding: - 'lib/solargraph/api_map.rb' - 'lib/solargraph/complex_type.rb' -# Offense count: 61 +# Offense count: 52 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle, ProceduralMethods, FunctionalMethods, AllowedMethods, AllowedPatterns, AllowBracesOnProceduralOneLiners, BracesRequiredMethods. # SupportedStyles: line_count_based, semantic, braces_for_chaining, always_braces @@ -1056,12 +1162,13 @@ Style/ClassAndModuleChildren: - 'lib/solargraph/language_server/message/workspace/did_change_workspace_folders.rb' - 'lib/solargraph/language_server/message/workspace/workspace_symbol.rb' -# Offense count: 2 +# Offense count: 5 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: AllowedMethods, AllowedPatterns. # AllowedMethods: ==, equal?, eql? Style/ClassEqualityComparison: Exclude: + - 'lib/solargraph/gem_pins.rb' - 'lib/solargraph/pin/base.rb' # Offense count: 13 @@ -1120,13 +1227,14 @@ Style/EmptyLambdaParameter: Exclude: - 'spec/rbs_map/core_map_spec.rb' -# Offense count: 4 +# Offense count: 5 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AutoCorrect, EnforcedStyle. # SupportedStyles: compact, expanded Style/EmptyMethod: Exclude: - 'lib/solargraph/language_server/message/client/register_capability.rb' + - 'lib/solargraph/pin/base.rb' - 'spec/fixtures/formattable.rb' - 'spec/fixtures/rdoc-lib/lib/example.rb' - 'spec/fixtures/workspace-with-gemfile/lib/thing.rb' @@ -1147,12 +1255,13 @@ Style/ExpandPathArguments: Exclude: - 'solargraph.gemspec' -# Offense count: 1 +# Offense count: 2 # This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowedVars. +# Configuration parameters: AllowedVars, DefaultToNil. Style/FetchEnvVar: Exclude: - 'spec/api_map/config_spec.rb' + - 'spec/spec_helper.rb' # Offense count: 2 # This cop supports unsafe autocorrection (--autocorrect-all). @@ -1163,22 +1272,23 @@ Style/FloatDivision: - 'lib/solargraph/library.rb' - 'lib/solargraph/pin/search.rb' -# Offense count: 127 +# Offense count: 128 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: EnforcedStyle. # SupportedStyles: always, always_true, never Style/FrozenStringLiteralComment: Enabled: false -# Offense count: 8 +# Offense count: 11 # This cop supports unsafe autocorrection (--autocorrect-all). Style/GlobalStdStream: Exclude: - 'lib/solargraph/logging.rb' + - 'lib/solargraph/pin/base.rb' - 'lib/solargraph/shell.rb' - 'spec/logging_spec.rb' -# Offense count: 11 +# Offense count: 12 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: MinBodyLength, AllowConsecutiveConditionals. Style/GuardClause: @@ -1186,11 +1296,19 @@ Style/GuardClause: - 'lib/solargraph/api_map.rb' - 'lib/solargraph/library.rb' - 'lib/solargraph/parser/parser_gem/node_processors/send_node.rb' + - 'lib/solargraph/pin_cache.rb' - 'lib/solargraph/range.rb' - 'lib/solargraph/rbs_map/conversions.rb' - 'lib/solargraph/source.rb' - 'lib/solargraph/workspace.rb' +# Offense count: 2 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: AllowSplatArgument. +Style/HashConversion: + Exclude: + - 'lib/solargraph/doc_map.rb' + # Offense count: 2 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: AllowedReceivers. @@ -1218,18 +1336,19 @@ Style/IdenticalConditionalBranches: - 'lib/solargraph/library.rb' - 'lib/solargraph/type_checker.rb' -# Offense count: 6 +# Offense count: 7 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowIfModifier. Style/IfInsideElse: Exclude: + - 'lib/solargraph/complex_type/type_methods.rb' - 'lib/solargraph/language_server/transport/data_reader.rb' - 'lib/solargraph/parser/parser_gem/node_chainer.rb' - 'lib/solargraph/parser/parser_gem/node_methods.rb' - 'lib/solargraph/source_map/clip.rb' - 'lib/solargraph/type_checker.rb' -# Offense count: 40 +# Offense count: 46 # This cop supports safe autocorrection (--autocorrect). Style/IfUnlessModifier: Enabled: false @@ -1263,7 +1382,7 @@ Style/MapToSet: - 'lib/solargraph/library.rb' - 'spec/source_map/clip_spec.rb' -# Offense count: 147 +# Offense count: 198 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle. # SupportedStyles: require_parentheses, require_no_parentheses, require_no_parentheses_except_multiline @@ -1287,7 +1406,7 @@ Style/MultilineTernaryOperator: Exclude: - 'lib/solargraph/language_server/host.rb' -# Offense count: 19 +# Offense count: 20 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowMethodComparison, ComparisonsThreshold. Style/MultipleComparison: @@ -1296,12 +1415,13 @@ Style/MultipleComparison: - 'lib/solargraph/complex_type/type_methods.rb' - 'lib/solargraph/parser/parser_gem/node_methods.rb' - 'lib/solargraph/parser/parser_gem/node_processors/send_node.rb' + - 'lib/solargraph/pin/base.rb' - 'lib/solargraph/pin/method.rb' - 'lib/solargraph/pin/parameter.rb' - 'lib/solargraph/source.rb' - 'lib/solargraph/type_checker.rb' -# Offense count: 15 +# Offense count: 17 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: EnforcedStyle. # SupportedStyles: literals, strict @@ -1312,6 +1432,7 @@ Style/MutableConstant: - 'lib/solargraph/parser/parser_gem/node_methods.rb' - 'lib/solargraph/rbs_map/conversions.rb' - 'lib/solargraph/rbs_map/core_fills.rb' + - 'lib/solargraph/yard_map/mapper/to_method.rb' - 'spec/complex_type_spec.rb' # Offense count: 1 @@ -1347,13 +1468,14 @@ Style/NestedTernaryOperator: - 'lib/solargraph/pin/conversions.rb' - 'lib/solargraph/pin/method.rb' -# Offense count: 4 +# Offense count: 5 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle, MinBodyLength, AllowConsecutiveConditionals. # SupportedStyles: skip_modifier_ifs, always Style/Next: Exclude: - 'lib/solargraph/parser/parser_gem/node_processors/send_node.rb' + - 'lib/solargraph/pin/signature.rb' - 'lib/solargraph/source_map/clip.rb' - 'lib/solargraph/type_checker/checks.rb' @@ -1363,27 +1485,12 @@ Style/Next: Style/NumericLiterals: MinDigits: 6 -# Offense count: 28 +# Offense count: 31 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: EnforcedStyle, AllowedMethods, AllowedPatterns. # SupportedStyles: predicate, comparison Style/NumericPredicate: - Exclude: - - 'spec/**/*' - - 'lib/solargraph/api_map.rb' - - 'lib/solargraph/api_map/index.rb' - - 'lib/solargraph/api_map/store.rb' - - 'lib/solargraph/complex_type.rb' - - 'lib/solargraph/complex_type/type_methods.rb' - - 'lib/solargraph/complex_type/unique_type.rb' - - 'lib/solargraph/language_server/message/extended/check_gem_version.rb' - - 'lib/solargraph/library.rb' - - 'lib/solargraph/parser/comment_ripper.rb' - - 'lib/solargraph/pin/delegated_method.rb' - - 'lib/solargraph/shell.rb' - - 'lib/solargraph/source/change.rb' - - 'lib/solargraph/source/source_chainer.rb' - - 'lib/solargraph/workspace.rb' + Enabled: false # Offense count: 1 Style/OpenStructUse: @@ -1434,7 +1541,7 @@ Style/RedundantAssignment: - 'lib/solargraph/repro.rb' - 'lib/solargraph/workspace/config.rb' -# Offense count: 7 +# Offense count: 8 # This cop supports safe autocorrection (--autocorrect). Style/RedundantBegin: Exclude: @@ -1458,6 +1565,13 @@ Style/RedundantFreeze: - 'lib/solargraph/complex_type.rb' - 'lib/solargraph/source_map/mapper.rb' +# Offense count: 1 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: AutoCorrect, AllowComments. +Style/RedundantInitialize: + Exclude: + - 'lib/solargraph/rbs_map/core_map.rb' + # Offense count: 3 # This cop supports unsafe autocorrection (--autocorrect-all). Style/RedundantInterpolation: @@ -1466,13 +1580,14 @@ Style/RedundantInterpolation: - 'lib/solargraph/parser/parser_gem/node_chainer.rb' - 'lib/solargraph/source_map/mapper.rb' -# Offense count: 5 +# Offense count: 7 # This cop supports safe autocorrection (--autocorrect). Style/RedundantParentheses: Exclude: - 'lib/solargraph/language_server/message/initialize.rb' - 'lib/solargraph/parser/parser_gem/node_chainer.rb' - 'lib/solargraph/pin/method.rb' + - 'lib/solargraph/pin/parameter.rb' - 'lib/solargraph/source.rb' - 'lib/solargraph/type_checker.rb' @@ -1496,17 +1611,18 @@ Style/RedundantRegexpEscape: - 'lib/solargraph/source_map/clip.rb' - 'lib/solargraph/source_map/mapper.rb' -# Offense count: 6 +# Offense count: 9 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowMultipleReturnValues. Style/RedundantReturn: Exclude: - 'lib/solargraph/api_map.rb' - 'lib/solargraph/complex_type/type_methods.rb' + - 'lib/solargraph/doc_map.rb' - 'lib/solargraph/parser/parser_gem/node_methods.rb' - 'lib/solargraph/source/chain/z_super.rb' -# Offense count: 9 +# Offense count: 19 # This cop supports safe autocorrection (--autocorrect). Style/RedundantSelf: Exclude: @@ -1515,6 +1631,7 @@ Style/RedundantSelf: - 'lib/solargraph/location.rb' - 'lib/solargraph/pin/base.rb' - 'lib/solargraph/pin/callable.rb' + - 'lib/solargraph/pin/signature.rb' - 'lib/solargraph/source/chain.rb' - 'lib/solargraph/source/chain/link.rb' @@ -1527,13 +1644,22 @@ Style/RegexpLiteral: - 'lib/solargraph/language_server/uri_helpers.rb' - 'lib/solargraph/workspace/config.rb' -# Offense count: 13 +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: implicit, explicit +Style/RescueStandardError: + Exclude: + - 'lib/solargraph/pin/base.rb' + +# Offense count: 17 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: ConvertCodeThatCanStartToReturnNil, AllowedMethods, MaxChainLength. # AllowedMethods: present?, blank?, presence, try, try! Style/SafeNavigation: Exclude: - 'lib/solargraph/api_map/index.rb' + - 'lib/solargraph/doc_map.rb' - 'lib/solargraph/language_server/message/completion_item/resolve.rb' - 'lib/solargraph/language_server/request.rb' - 'lib/solargraph/language_server/transport/data_reader.rb' @@ -1541,20 +1667,26 @@ Style/SafeNavigation: - 'lib/solargraph/pin/base.rb' - 'lib/solargraph/pin/conversions.rb' - 'lib/solargraph/pin/method.rb' + - 'lib/solargraph/pin_cache.rb' - 'lib/solargraph/range.rb' - 'lib/solargraph/type_checker.rb' -# Offense count: 40 +# Offense count: 1 +# Configuration parameters: Max. +Style/SafeNavigationChainLength: + Exclude: + - 'lib/solargraph/doc_map.rb' + +# Offense count: 39 # This cop supports unsafe autocorrection (--autocorrect-all). Style/SlicingWithRange: Enabled: false -# Offense count: 8 +# Offense count: 6 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowModifier. Style/SoleNestedConditional: Exclude: - - 'lib/solargraph/api_map.rb' - 'lib/solargraph/complex_type/unique_type.rb' - 'lib/solargraph/parser/flow_sensitive_typing.rb' - 'lib/solargraph/pin/parameter.rb' @@ -1562,10 +1694,11 @@ Style/SoleNestedConditional: - 'lib/solargraph/source/source_chainer.rb' - 'lib/solargraph/type_checker.rb' -# Offense count: 5 +# Offense count: 8 # This cop supports safe autocorrection (--autocorrect). Style/StderrPuts: Exclude: + - 'lib/solargraph/pin/base.rb' - 'lib/solargraph/shell.rb' # Offense count: 10 @@ -1583,17 +1716,18 @@ Style/StringConcatenation: - 'lib/solargraph/pin/namespace.rb' - 'solargraph.gemspec' -# Offense count: 605 +# Offense count: 617 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline. # SupportedStyles: single_quotes, double_quotes Style/StringLiterals: Enabled: false -# Offense count: 3 +# Offense count: 4 # This cop supports safe autocorrection (--autocorrect). Style/SuperArguments: Exclude: + - 'lib/solargraph/pin/base_variable.rb' - 'lib/solargraph/pin/callable.rb' - 'lib/solargraph/pin/method.rb' - 'lib/solargraph/pin/signature.rb' @@ -1620,7 +1754,7 @@ Style/SymbolArray: - 'spec/parser/node_methods_spec.rb' - 'spec/source_map/mapper_spec.rb' -# Offense count: 6 +# Offense count: 7 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: AllowMethodsWithArguments, AllowedMethods, AllowedPatterns, AllowComments. # AllowedMethods: define_method @@ -1630,6 +1764,7 @@ Style/SymbolProc: - 'lib/solargraph/language_server/message/text_document/hover.rb' - 'lib/solargraph/language_server/message/text_document/signature_help.rb' - 'lib/solargraph/parser/flow_sensitive_typing.rb' + - 'lib/solargraph/pin/base.rb' - 'lib/solargraph/pin/callable.rb' - 'lib/solargraph/pin/closure.rb' @@ -1641,17 +1776,25 @@ Style/TernaryParentheses: Exclude: - 'lib/solargraph/source_map/mapper.rb' -# Offense count: 9 +# Offense count: 19 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyleForMultiline. # SupportedStylesForMultiline: comma, consistent_comma, no_comma Style/TrailingCommaInArguments: Exclude: - 'lib/solargraph/api_map.rb' + - 'lib/solargraph/parser/node_processor.rb' + - 'lib/solargraph/parser/parser_gem/node_processors/block_node.rb' + - 'lib/solargraph/parser/parser_gem/node_processors/def_node.rb' + - 'lib/solargraph/parser/parser_gem/node_processors/defs_node.rb' + - 'lib/solargraph/parser/parser_gem/node_processors/sclass_node.rb' - 'lib/solargraph/parser/parser_gem/node_processors/until_node.rb' - 'lib/solargraph/parser/parser_gem/node_processors/while_node.rb' + - 'lib/solargraph/pin/method.rb' - 'lib/solargraph/rbs_map/conversions.rb' + - 'lib/solargraph/yard_map/mapper/to_constant.rb' - 'lib/solargraph/yard_map/mapper/to_method.rb' + - 'lib/solargraph/yard_map/mapper/to_namespace.rb' # Offense count: 2 # This cop supports safe autocorrection (--autocorrect). @@ -1660,15 +1803,21 @@ Style/TrailingCommaInArguments: Style/TrailingCommaInArrayLiteral: Exclude: - 'lib/solargraph/language_server/message/text_document/formatting.rb' - - 'spec/complex_type_spec.rb' + - 'lib/solargraph/rbs_map/core_fills.rb' -# Offense count: 1 +# Offense count: 7 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyleForMultiline. # SupportedStylesForMultiline: comma, consistent_comma, diff_comma, no_comma Style/TrailingCommaInHashLiteral: Exclude: - - 'lib/solargraph/api_map.rb' + - 'lib/solargraph/pin/base.rb' + - 'lib/solargraph/pin/base_variable.rb' + - 'lib/solargraph/pin/callable.rb' + - 'lib/solargraph/pin/closure.rb' + - 'lib/solargraph/pin/local_variable.rb' + - 'lib/solargraph/pin/parameter.rb' + - 'lib/solargraph/rbs_map/conversions.rb' # Offense count: 2 # This cop supports safe autocorrection (--autocorrect). @@ -1685,7 +1834,7 @@ Style/WhileUntilModifier: Exclude: - 'lib/solargraph/complex_type.rb' -# Offense count: 27 +# Offense count: 23 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle, MinSize, WordRegex. # SupportedStyles: percent, brackets @@ -1695,7 +1844,6 @@ Style/WordArray: - 'lib/solargraph/complex_type/unique_type.rb' - 'lib/solargraph/diagnostics/type_check.rb' - 'lib/solargraph/language_server/message/text_document/formatting.rb' - - 'spec/complex_type_spec.rb' - 'spec/parser/node_chainer_spec.rb' - 'spec/pin/method_spec.rb' - 'spec/source/cursor_spec.rb' @@ -1711,18 +1859,35 @@ Style/YAMLFileRead: Exclude: - 'lib/solargraph/workspace/config.rb' -# Offense count: 4 +# Offense count: 7 # This cop supports unsafe autocorrection (--autocorrect-all). Style/ZeroLengthPredicate: Exclude: - 'lib/solargraph/api_map.rb' - 'lib/solargraph/api_map/index.rb' - 'lib/solargraph/language_server/host.rb' + - 'lib/solargraph/pin/method.rb' + - 'lib/solargraph/source/chain/array.rb' - 'spec/language_server/protocol_spec.rb' -# Offense count: 173 +# Offense count: 1 # This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns, SplitStrings. -# URISchemes: http, https -Layout/LineLength: - Max: 244 +# Configuration parameters: EnforcedStyle. +# SupportedStyles: long, short +YARD/CollectionType: + Exclude: + - 'lib/solargraph/range.rb' + +# Offense count: 65 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStylePrototypeName. +# SupportedStylesPrototypeName: before, after +YARD/MismatchName: + Enabled: false + +# Offense count: 4 +YARD/TagTypeSyntax: + Exclude: + - 'lib/solargraph/language_server/host.rb' + - 'lib/solargraph/parser/comment_ripper.rb' + - 'lib/solargraph/type_checker.rb' From 0b628959170fe076b249cb57b90bfeaf4a6f3c4a Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Wed, 9 Jul 2025 14:31:48 -0400 Subject: [PATCH 012/400] Make undercover capitalization consistent --- .github/workflows/rspec.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/rspec.yml b/.github/workflows/rspec.yml index d9cacbaee..43d7c1f65 100644 --- a/.github/workflows/rspec.yml +++ b/.github/workflows/rspec.yml @@ -35,7 +35,6 @@ jobs: - name: Run tests run: bundle exec rspec undercover: - name: 'Undercover' runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 From f74754132fc1733010f810361dfb13ad57695eb3 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Wed, 9 Jul 2025 14:34:52 -0400 Subject: [PATCH 013/400] Fix rubocop todo file --- .rubocop_todo.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index a4307b7e5..54dca7c30 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2025-07-09 18:29:07 UTC using RuboCop version 1.78.0. +# on 2025-07-09 18:34:33 UTC using RuboCop version 1.78.0. # 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 @@ -1891,3 +1891,10 @@ YARD/TagTypeSyntax: - 'lib/solargraph/language_server/host.rb' - 'lib/solargraph/parser/comment_ripper.rb' - 'lib/solargraph/type_checker.rb' + +# Offense count: 191 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AllowHeredoc, AllowURI, AllowQualifiedName, URISchemes, IgnoreCopDirectives, AllowedPatterns, SplitStrings. +# URISchemes: http, https +Layout/LineLength: + Max: 257 From 809030d75a0b1dcfa08ed301b6140293f173298e Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Wed, 9 Jul 2025 15:05:59 -0400 Subject: [PATCH 014/400] Add rubocop binstub --- bin/rubocop | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100755 bin/rubocop diff --git a/bin/rubocop b/bin/rubocop new file mode 100755 index 000000000..369a05bed --- /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") From 51eacbedf476201d8600f79cbe6bef263e384e1a Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Wed, 9 Jul 2025 16:46:25 -0400 Subject: [PATCH 015/400] Fix some workflow issues --- .github/workflows/linting.yml | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml index a616a5460..aa29bb3dd 100644 --- a/.github/workflows/linting.yml +++ b/.github/workflows/linting.yml @@ -9,7 +9,7 @@ name: Linting on: workflow_dispatch: {} pull_request: - branches: [main] + branches: [ master ] push: branches: - 'main' @@ -33,19 +33,17 @@ jobs: ruby-version: 3.4 bundler: latest bundler-cache: true - cache-version: ${{ matrix.solargraph-version }}-${{ matrix.versions.rails-major }}.${{ matrix.versions.rails-minor }}-2025-06-06 + cache-version: 2025-06-06 - name: Restore cache of gem annotations id: dot-cache-restore uses: actions/cache/restore@v4 with: key: | - 2025-06-26-09-${{ runner.os }}-dot-cache-${{ matrix.solargraph-version }}-${{ matrix.versions.rails-major }}--${{ matrix.versions.rails-minor }}-${{ hashFiles('spec/**/Gemfile.lock') }}-${{ hashFiles('Gemfile.lock') }} + 2025-06-26-09-${{ runner.os }}-dot-cache-${{ hashFiles('spec/**/Gemfile.lock') }}-${{ hashFiles('Gemfile.lock') }} restore-keys: | - 2025-06-26-09-${{ runner.os }}-dot-cache-${{ matrix.solargraph-version }}-${{ matrix.versions.rails-major }}-${{ matrix.versions.rails-minor }}-${{ hashFiles('spec/**/Gemfile.lock') }}- - 2025-06-26-09-${{ runner.os }}-dot-cache-${{ matrix.solargraph-version }}-${{ matrix.versions.rails-major }}-${{ matrix.versions.rails-minor }}- - 2025-06-26-09-${{ runner.os }}-dot-cache-${{ matrix.solargraph-version }}-${{ matrix.versions.rails-major }}- - 2025-06-26-09-${{ runner.os }}-dot-cache-${{ matrix.solargraph-version }}- + 2025-06-26-09-${{ runner.os }}-dot-cache-${{ hashFiles('spec/**/Gemfile.lock') }}- + 2025-06-26-09-${{ runner.os }}-dot-cache- path: | /home/runner/.cache/solargraph From a2e92dc049dba3afaf5e4962a6820f7e4fb0d71c Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Wed, 9 Jul 2025 16:49:41 -0400 Subject: [PATCH 016/400] Fix some workflow issues --- .github/workflows/linting.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml index aa29bb3dd..4e6d8980b 100644 --- a/.github/workflows/linting.yml +++ b/.github/workflows/linting.yml @@ -67,7 +67,7 @@ jobs: reporter: github-pr-check skip_install: true use_bundler: true - rubocop_extensions: 'rubocop-performance:gemfile rubocop-rspec:gemfile rubocop-rake:gemfile rubocop-yard:gemfile' + rubocop_extensions: 'rubocop-rspec:gemfile rubocop-rake:gemfile rubocop-yard:gemfile' fail_level: info rubocop_version: Gemfile level: info From 6ac08b7b935bf670d4c3ee9218074e417d472a1f Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Wed, 9 Jul 2025 16:58:54 -0400 Subject: [PATCH 017/400] Fix some workflow issues --- .github/workflows/linting.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml index 4e6d8980b..c5a10b8c1 100644 --- a/.github/workflows/linting.yml +++ b/.github/workflows/linting.yml @@ -40,9 +40,9 @@ jobs: uses: actions/cache/restore@v4 with: key: | - 2025-06-26-09-${{ runner.os }}-dot-cache-${{ hashFiles('spec/**/Gemfile.lock') }}-${{ hashFiles('Gemfile.lock') }} + 2025-06-26-09-${{ runner.os }}-dot-cache-${{ hashFiles('Gemfile.lock') }} restore-keys: | - 2025-06-26-09-${{ runner.os }}-dot-cache-${{ hashFiles('spec/**/Gemfile.lock') }}- + 2025-06-26-09-${{ runner.os }}-dot-cache 2025-06-26-09-${{ runner.os }}-dot-cache- path: | /home/runner/.cache/solargraph @@ -68,6 +68,7 @@ jobs: skip_install: true use_bundler: true rubocop_extensions: 'rubocop-rspec:gemfile rubocop-rake:gemfile rubocop-yard:gemfile' + rubocop_flags: '-c .rubocop.yml' fail_level: info rubocop_version: Gemfile level: info From a9963b0f39d2ea31f8be9f426437bd86519217f8 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Wed, 9 Jul 2025 17:27:00 -0400 Subject: [PATCH 018/400] Fix some workflow issues --- .github/workflows/linting.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml index c5a10b8c1..b33268df1 100644 --- a/.github/workflows/linting.yml +++ b/.github/workflows/linting.yml @@ -50,7 +50,7 @@ jobs: - name: Overcommit run: | bundle exec overcommit --sign - bundle exec overcommit --run --diff origin/main + bundle exec overcommit --run --diff origin/master rubocop: name: rubocop runs-on: ubuntu-latest From 9b17f752bd569e79f3eef98e720f9c9b981ec3f5 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Wed, 9 Jul 2025 18:05:58 -0400 Subject: [PATCH 019/400] Workflow fixes --- .github/workflows/linting.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml index b33268df1..026e8c126 100644 --- a/.github/workflows/linting.yml +++ b/.github/workflows/linting.yml @@ -54,8 +54,6 @@ jobs: rubocop: name: rubocop runs-on: ubuntu-latest - env: - BUNDLE_ONLY: rubocop steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - uses: ruby/setup-ruby@1a615958ad9d422dd932dc1d5823942ee002799f # v1.227.0 From 325d835c37ac4b0788838d4c72b77e946bffada9 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Wed, 9 Jul 2025 18:06:09 -0400 Subject: [PATCH 020/400] Workflow fixes --- .github/workflows/rubocop.yml | 2 +- solargraph.gemspec | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/rubocop.yml b/.github/workflows/rubocop.yml index 9fcbafa23..e11526a06 100644 --- a/.github/workflows/rubocop.yml +++ b/.github/workflows/rubocop.yml @@ -17,7 +17,7 @@ permissions: contents: read jobs: - rubocop: + full: runs-on: ubuntu-latest steps: diff --git a/solargraph.gemspec b/solargraph.gemspec index 94ebbe46c..137a14cdb 100755 --- a/solargraph.gemspec +++ b/solargraph.gemspec @@ -38,9 +38,6 @@ Gem::Specification.new do |s| s.add_runtime_dependency 'rbs', '~> 3.3' s.add_runtime_dependency 'reverse_markdown', '~> 3.0' s.add_runtime_dependency 'rubocop', '~> 1.76' - s.add_runtime_dependency 'rubocop-rake', '~> 0.7' - s.add_runtime_dependency 'rubocop-rspec', '~> 3.6' - s.add_runtime_dependency 'rubocop-yard', '~> 1.0' s.add_runtime_dependency 'thor', '~> 1.0' s.add_runtime_dependency 'tilt', '~> 2.0' s.add_runtime_dependency 'yard', '~> 0.9', '>= 0.9.24' @@ -50,6 +47,9 @@ Gem::Specification.new do |s| s.add_development_dependency 'public_suffix', '~> 3.1' s.add_development_dependency 'rake', '~> 13.2' s.add_development_dependency 'rspec', '~> 3.5' + s.add_development_dependency 'rubocop-rake', '~> 0.7' + s.add_development_dependency 'rubocop-rspec', '~> 3.6' + s.add_development_dependency 'rubocop-yard', '~> 1.0' s.add_development_dependency 'simplecov', '~> 0.21' s.add_development_dependency 'simplecov-lcov', '~> 0.8' s.add_development_dependency 'undercover', '~> 0.6' From c473c8075e08b030b9451a8ddf60d07a370dbd1c Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Thu, 10 Jul 2025 15:54:43 -0400 Subject: [PATCH 021/400] Ignore vendor directory in RuboCop --- .rubocop.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.rubocop.yml b/.rubocop.yml index a769ad37e..b95236b84 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -17,6 +17,7 @@ AllCops: - "spec/fixtures/invalid_byte.rb" - "spec/fixtures/invalid_node_comment.rb" - "spec/fixtures/invalid_utf8.rb" + - "vendor/**/*.rb" TargetRubyVersion: 3.0 Style/MethodDefParentheses: From da33ef57ef7a92b22a1c0509c4c225d14033576b Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Sat, 12 Jul 2025 12:26:09 -0400 Subject: [PATCH 022/400] Add rubocop-on-rbs and associated fixes --- .github/workflows/linting.yml | 2 +- .rubocop.yml | 1 + rbs/fills/tuple.rbs | 5 ++--- solargraph.gemspec | 1 + spec/spec_helper.rb | 2 ++ 5 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml index 026e8c126..8dabe946b 100644 --- a/.github/workflows/linting.yml +++ b/.github/workflows/linting.yml @@ -65,7 +65,7 @@ jobs: reporter: github-pr-check skip_install: true use_bundler: true - rubocop_extensions: 'rubocop-rspec:gemfile rubocop-rake:gemfile rubocop-yard:gemfile' + rubocop_extensions: 'rubocop-rspec:gemfile rubocop-rake:gemfile rubocop-yard:gemfile rubocop-on-rbs:gemfile' rubocop_flags: '-c .rubocop.yml' fail_level: info rubocop_version: Gemfile diff --git a/.rubocop.yml b/.rubocop.yml index b95236b84..b18815cce 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -30,6 +30,7 @@ Metrics/MethodLength: Max: 25 plugins: + - rubocop-on-rbs - rubocop-rspec - rubocop-rake - rubocop-yard diff --git a/rbs/fills/tuple.rbs b/rbs/fills/tuple.rbs index 9a0a00d0e..f4e213355 100644 --- a/rbs/fills/tuple.rbs +++ b/rbs/fills/tuple.rbs @@ -45,7 +45,6 @@ module Solargraph | (7 index) -> H | (8 index) -> I | (9 index) -> J - | (0 index) -> K | (int index) -> nil # +# The Specification class contains the information for a gem. Typically defined +# in a .gemspec file or a Rakefile, and looks like this: +# +# Gem::Specification.new do |s| +# s.name = 'example' +# s.version = '0.1.0' +# s.licenses = ['MIT'] +# s.summary = "This is an example!" +# s.description = "Much longer explanation of the example!" +# s.authors = ["Ruby Coder"] +# s.email = 'rubycoder@example.com' +# s.files = ["lib/example.rb"] +# s.homepage = 'https://rubygems.org/gems/example' +# s.metadata = { "source_code_uri" => "https://github.com/example/example" } +# end +# +# Starting in RubyGems 2.0, a Specification can hold arbitrary metadata. See +# #metadata for restrictions on the format and size of metadata items you may +# add to a specification. +# +class Gem::Specification < Gem::BasicSpecification + @@required_attributes: untyped + + @@default_value: untyped + + @@attributes: untyped + + @@array_attributes: untyped + + @@nil_attributes: untyped + + @@non_nil_attributes: untyped + + @@dirs: untyped + + self.@load_cache: untyped + + self.@load_cache_mutex: untyped + + self.@specification_record: untyped + + self.@unresolved_deps: untyped + + @removed_method_calls: untyped + + # DO NOT CHANGE TO ||= ! This is not a normal accessor. (yes, it sucks) + # DOC: Why isn't it normal? Why does it suck? How can we fix this? + @files: untyped + + @authors: untyped + + @licenses: untyped + + @original_platform: untyped + + @new_platform: untyped + + @platform: untyped + + @require_paths: untyped + + @executables: untyped + + @extensions: untyped + + @extra_rdoc_files: untyped + + @installed_by_version: untyped + + @rdoc_options: untyped + + @required_ruby_version: untyped + + @required_rubygems_version: untyped + + @requirements: untyped + + @test_files: untyped + + @extensions_dir: untyped + + @activated: untyped + + @loaded: untyped + + @bin_dir: untyped + + @cache_dir: untyped + + @cache_file: untyped + + @date: untyped + + @dependencies: untyped + + @description: untyped + + @doc_dir: untyped + + @full_name: untyped + + @gems_dir: untyped + + @has_rdoc: untyped + + @base_dir: untyped + + @loaded_from: untyped + + @ri_dir: untyped + + @spec_dir: untyped + + @spec_file: untyped + + @summary: untyped + + @test_suite_file: untyped + + @version: untyped + + extend Gem::Deprecate + + # + # The version number of a specification that does not specify one (i.e. RubyGems + # 0.7 or earlier). + # + NONEXISTENT_SPECIFICATION_VERSION: -1 + + CURRENT_SPECIFICATION_VERSION: 4 + + SPECIFICATION_VERSION_HISTORY: { -1 => ::Array["(RubyGems versions up to and including 0.7 did not have versioned specifications)"], 1 => ::Array["Deprecated \"test_suite_file\" in favor of the new, but equivalent, \"test_files\"" | "\"test_file=x\" is a shortcut for \"test_files=[x]\""], 2 => ::Array["Added \"required_rubygems_version\"" | "Now forward-compatible with future versions"], 3 => ::Array["Added Fixnum validation to the specification_version"], 4 => ::Array["Added sandboxed freeform metadata to the specification version."] } + + MARSHAL_FIELDS: { -1 => 16, 1 => 16, 2 => 16, 3 => 17, 4 => 18 } + + TODAY: untyped + + VALID_NAME_PATTERN: ::Regexp + + # rubocop:disable Style/MutableConstant + INITIALIZE_CODE_FOR_DEFAULTS: ::Hash[untyped, untyped] + + # Sentinel object to represent "not found" stubs + NOT_FOUND: untyped + + # Tracking removed method calls to warn users during build time. + REMOVED_METHODS: ::Array[:rubyforge_project= | :mark_version] + + # + # + def removed_method_calls: () -> untyped + + # + # This gem's name. + # + # Usage: + # + # spec.name = 'rake' + # + attr_accessor name: String + + # + # This gem's version. + # + # The version string can contain numbers and periods, such as `1.0.0`. A gem is + # a 'prerelease' gem if the version has a letter in it, such as `1.0.0.pre`. + # + # Usage: + # + # spec.version = '0.4.1' + # + attr_reader version: String + + # + # A short summary of this gem's description. Displayed in `gem list -d`. + # + # The #description should be more detailed than the summary. + # + # Usage: + # + # spec.summary = "This is a small summary of my gem" + # + attr_reader summary: untyped + + # + # Files included in this gem. You cannot append to this accessor, you must + # assign to it. + # + # Only add files you can require to this list, not directories, etc. + # + # Directories are automatically stripped from this list when building a gem, + # other non-files cause an error. + # + # Usage: + # + # require 'rake' + # spec.files = FileList['lib/**/*.rb', + # 'bin/*', + # '[A-Z]*'].to_a + # + # # or without Rake... + # spec.files = Dir['lib/**/*.rb'] + Dir['bin/*'] + # spec.files += Dir['[A-Z]*'] + # spec.files.reject! { |fn| fn.include? "CVS" } + # + def files: () -> Enumerable[String] + + # + # A list of authors for this gem. + # + # Alternatively, a single author can be specified by assigning a string to + # `spec.author` + # + # Usage: + # + # spec.authors = ['John Jones', 'Mary Smith'] + # + def authors=: (untyped value) -> untyped + + # + # The version of Ruby required by this gem + # + # Usage: + # + # spec.required_ruby_version = '>= 2.7.0' + # + attr_reader required_ruby_version: untyped + + # + # A long description of this gem + # + # The description should be more detailed than the summary but not excessively + # long. A few paragraphs is a recommended length with no examples or + # formatting. + # + # Usage: + # + # spec.description = <<-EOF + # Rake is a Make-like program implemented in Ruby. Tasks and + # dependencies are specified in standard Ruby syntax. + # EOF + # + attr_reader description: untyped + + # + # A contact email address (or addresses) for this gem + # + # Usage: + # + # spec.email = 'john.jones@example.com' + # spec.email = ['jack@example.com', 'jill@example.com'] + # + attr_accessor email: untyped + + # + # The URL of this gem's home page + # + # Usage: + # + # spec.homepage = 'https://github.com/ruby/rake' + # + attr_accessor homepage: untyped + + # + # The license for this gem. + # + # The license must be no more than 64 characters. + # + # This should just be the name of your license. The full text of the license + # should be inside of the gem (at the top level) when you build it. + # + # The simplest way is to specify the standard SPDX ID https://spdx.org/licenses/ + # for the license. Ideally, you should pick one that is OSI (Open Source + # Initiative) http://opensource.org/licenses/alphabetical approved. + # + # The most commonly used OSI-approved licenses are MIT and Apache-2.0. GitHub + # also provides a license picker at http://choosealicense.com/. + # + # You can also use a custom license file along with your gemspec and specify a + # LicenseRef-, where idstring is the name of the file containing the + # license text. + # + # You should specify a license for your gem so that people know how they are + # permitted to use it and any restrictions you're placing on it. Not specifying + # a license means all rights are reserved; others have no right to use the code + # for any purpose. + # + # You can set multiple licenses with #licenses= + # + # Usage: + # spec.license = 'MIT' + # + def license=: (untyped o) -> untyped + + # + # The license(s) for the library. + # + # Each license must be a short name, no more than 64 characters. + # + # This should just be the name of your license. The full text of the license + # should be inside of the gem when you build it. + # + # See #license= for more discussion + # + # Usage: + # spec.licenses = ['MIT', 'GPL-2.0'] + # + def licenses=: (untyped licenses) -> untyped + + # + # The metadata holds extra data for this gem that may be useful to other + # consumers and is settable by gem authors. + # + # Metadata items have the following restrictions: + # + # * The metadata must be a Hash object + # * All keys and values must be Strings + # * Keys can be a maximum of 128 bytes and values can be a maximum of 1024 + # bytes + # * All strings must be UTF-8, no binary data is allowed + # + # You can use metadata to specify links to your gem's homepage, codebase, + # documentation, wiki, mailing list, issue tracker and changelog. + # + # s.metadata = { + # "bug_tracker_uri" => "https://example.com/user/bestgemever/issues", + # "changelog_uri" => "https://example.com/user/bestgemever/CHANGELOG.md", + # "documentation_uri" => "https://www.example.info/gems/bestgemever/0.0.1", + # "homepage_uri" => "https://bestgemever.example.io", + # "mailing_list_uri" => "https://groups.example.com/bestgemever", + # "source_code_uri" => "https://example.com/user/bestgemever", + # "wiki_uri" => "https://example.com/user/bestgemever/wiki" + # "funding_uri" => "https://example.com/donate" + # } + # + # These links will be used on your gem's page on rubygems.org and must pass + # validation against following regex. + # + # %r{\Ahttps?:\/\/([^\s:@]+:[^\s:@]*@)?[A-Za-z\d\-]+(\.[A-Za-z\d\-]+)+\.?(:\d{1,5})?([\/?]\S*)?\z} + # + attr_accessor metadata: untyped + + # + # Singular (alternative) writer for #authors + # + # Usage: + # + # spec.author = 'John Jones' + # + def author=: (untyped o) -> untyped + + # + # The path in the gem for executable scripts. Usually 'bin' + # + # Usage: + # + # spec.bindir = 'bin' + # + attr_accessor bindir: untyped + + # + # The certificate chain used to sign this gem. See Gem::Security for details. + # + attr_accessor cert_chain: untyped + + # + # A message that gets displayed after the gem is installed. + # + # Usage: + # + # spec.post_install_message = "Thanks for installing!" + # + attr_accessor post_install_message: untyped + + # + # The platform this gem runs on. + # + # This is usually Gem::Platform::RUBY or Gem::Platform::CURRENT. + # + # Most gems contain pure Ruby code; they should simply leave the default value + # in place. Some gems contain C (or other) code to be compiled into a Ruby + # "extension". The gem should leave the default value in place unless the code + # will only compile on a certain type of system. Some gems consist of + # pre-compiled code ("binary gems"). It's especially important that they set + # the platform attribute appropriately. A shortcut is to set the platform to + # Gem::Platform::CURRENT, which will cause the gem builder to set the platform + # to the appropriate value for the system on which the build is being performed. + # + # If this attribute is set to a non-default value, it will be included in the + # filename of the gem when it is built such as: nokogiri-1.6.0-x86-mingw32.gem + # + # Usage: + # + # spec.platform = Gem::Platform.local + # + def platform=: (untyped platform) -> untyped + + # + # Paths in the gem to add to `$LOAD_PATH` when this gem is activated. If you + # have an extension you do not need to add `"ext"` to the require path, the + # extension build process will copy the extension files into "lib" for you. + # + # The default value is `"lib"` + # + # Usage: + # + # # If all library files are in the root directory... + # spec.require_paths = ['.'] + # + def require_paths=: (untyped val) -> untyped + + # + # The RubyGems version required by this gem + # + attr_reader required_rubygems_version: untyped + + # + # The key used to sign this gem. See Gem::Security for details. + # + attr_accessor signing_key: untyped + + # + # Adds a development dependency named `gem` with `requirements` to this gem. + # + # Usage: + # + # spec.add_development_dependency 'example', '~> 1.1', '>= 1.1.4' + # + # Development dependencies aren't installed by default and aren't activated when + # a gem is required. + # + def add_development_dependency: (untyped gem, *untyped requirements) -> untyped + + # + # + def add_dependency: (untyped gem, *untyped requirements) -> untyped + + # + # Executables included in the gem. + # + # For example, the rake gem has rake as an executable. You don’t specify the + # full path (as in bin/rake); all application-style files are expected to be + # found in bindir. These files must be executable Ruby files. Files that use + # bash or other interpreters will not work. + # + # Executables included may only be ruby scripts, not scripts for other languages + # or compiled binaries. + # + # Usage: + # + # spec.executables << 'rake' + # + def executables: () -> untyped + + # + # Extensions to build when installing the gem, specifically the paths to + # extconf.rb-style files used to compile extensions. + # + # These files will be run when the gem is installed, causing the C (or whatever) + # code to be compiled on the user’s machine. + # + # Usage: + # + # spec.extensions << 'ext/rmagic/extconf.rb' + # + # See Gem::Ext::Builder for information about writing extensions for gems. + # + def extensions: () -> untyped + + # + # Extra files to add to RDoc such as README or doc/examples.txt + # + # When the user elects to generate the RDoc documentation for a gem (typically + # at install time), all the library files are sent to RDoc for processing. This + # option allows you to have some non-code files included for a more complete set + # of documentation. + # + # Usage: + # + # spec.extra_rdoc_files = ['README', 'doc/user-guide.txt'] + # + def extra_rdoc_files: () -> untyped + + def installed_by_version: () -> untyped + + def installed_by_version=: (untyped version) -> untyped + + # + # Specifies the rdoc options to be used when generating API documentation. + # + # Usage: + # + # spec.rdoc_options << '--title' << 'Rake -- Ruby Make' << + # '--main' << 'README' << + # '--line-numbers' + # + def rdoc_options: () -> untyped + + LATEST_RUBY_WITHOUT_PATCH_VERSIONS: untyped + + # + # The version of Ruby required by this gem. The ruby version can be specified + # to the patch-level: + # + # $ ruby -v -e 'p Gem.ruby_version' + # ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-darwin12.4.0] + # # + # + # Prereleases can also be specified. + # + # Usage: + # + # # This gem will work with 1.8.6 or greater... + # spec.required_ruby_version = '>= 1.8.6' + # + # # Only with final releases of major version 2 where minor version is at least 3 + # spec.required_ruby_version = '~> 2.3' + # + # # Only prereleases or final releases after 2.6.0.preview2 + # spec.required_ruby_version = '> 2.6.0.preview2' + # + # # This gem will work with 2.3.0 or greater, including major version 3, but lesser than 4.0.0 + # spec.required_ruby_version = '>= 2.3', '< 4' + # + def required_ruby_version=: (untyped req) -> untyped + + # + # The RubyGems version required by this gem + # + def required_rubygems_version=: (untyped req) -> untyped + + # + # Lists the external (to RubyGems) requirements that must be met for this gem to + # work. It's simply information for the user. + # + # Usage: + # + # spec.requirements << 'libmagick, v6.0' + # spec.requirements << 'A good graphics card' + # + def requirements: () -> untyped + + def test_files=: (untyped files) -> untyped + + # + # The version of RubyGems used to create this gem. + # + # Do not set this, it is set automatically when the gem is packaged. + # + attr_accessor rubygems_version: untyped + + def extensions_dir: () -> untyped + + # + # True when this gemspec has been activated. This attribute is not persisted. + # + attr_accessor activated: untyped + + # + # True when this gemspec has been activated. This attribute is not persisted. + # + alias activated? activated + + attr_accessor autorequire: untyped + + attr_writer default_executable: untyped + + attr_writer original_platform: untyped + + # + # The Gem::Specification version of this gemspec. + # + # Do not set this, it is set automatically when the gem is packaged. + # + attr_accessor specification_version: untyped + + def self._all: () -> untyped + + def self.clear_load_cache: () -> untyped + + def self.gem_path: () -> untyped + + def self.each_gemspec: (untyped dirs) { (untyped) -> untyped } -> untyped + + # + # + def self.gemspec_stubs_in: (untyped dir, untyped pattern) { (untyped) -> untyped } -> untyped + + def self.each_spec: (untyped dirs) { (untyped) -> untyped } -> untyped + + # + # Returns a Gem::StubSpecification for every installed gem + # + def self.stubs: () -> untyped + + # + # Returns a Gem::StubSpecification for default gems + # + def self.default_stubs: (?::String pattern) -> untyped + + # + # Returns a Gem::StubSpecification for installed gem named `name` only returns + # stubs that match Gem.platforms + # + def self.stubs_for: (untyped name) -> untyped + + # + # Finds stub specifications matching a pattern from the standard locations, + # optionally filtering out specs not matching the current platform + # + def self.stubs_for_pattern: (untyped pattern, ?bool match_platform) -> untyped + + def self._resort!: (untyped specs) -> untyped + + # + # Loads the default specifications. It should be called only once. + # + def self.load_defaults: () -> untyped + + # + # Adds `spec` to the known specifications, keeping the collection properly + # sorted. + # + def self.add_spec: (untyped spec) -> untyped + + # + # Removes `spec` from the known specs. + # + def self.remove_spec: (untyped spec) -> untyped + + # + # Returns all specifications. This method is discouraged from use. You probably + # want to use one of the Enumerable methods instead. + # + def self.all: () -> untyped + + # + # Sets the known specs to `specs`. Not guaranteed to work for you in the future. + # Use at your own risk. Caveat emptor. Doomy doom doom. Etc etc. + # + def self.all=: (untyped specs) -> untyped + + # + # Return full names of all specs in sorted order. + # + def self.all_names: () -> untyped + + # + # Return the list of all array-oriented instance variables. + # + def self.array_attributes: () -> untyped + + # + # Return the list of all instance variables. + # + def self.attribute_names: () -> untyped + + # + # Return the directories that Specification uses to find specs. + # + def self.dirs: () -> untyped + + # + # Set the directories that Specification uses to find specs. Setting this resets + # the list of known specs. + # + def self.dirs=: (untyped dirs) -> untyped + + extend Enumerable[Gem::Specification] + + # + # Enumerate every known spec. See ::dirs= and ::add_spec to set the list of + # specs. + # + def self.each: () { (Gem::Specification) -> untyped } -> untyped + + # + # Returns every spec that matches `name` and optional `requirements`. + # + def self.find_all_by_name: (untyped name, *untyped requirements) -> untyped + + # + # Returns every spec that has the given `full_name` + # + def self.find_all_by_full_name: (untyped full_name) -> untyped + + # + # Find the best specification matching a `name` and `requirements`. Raises if + # the dependency doesn't resolve to a valid specification. + # + def self.find_by_name: (untyped name, *untyped requirements) -> instance + + # + # Find the best specification matching a +full_name+. + def self.find_by_full_name: (untyped full_name) -> instance + + # + # Return the best specification that contains the file matching `path`. + # + def self.find_by_path: (untyped path) -> instance + + # + # Return the best specification that contains the file matching `path` amongst + # the specs that are not activated. + # + def self.find_inactive_by_path: (untyped path) -> untyped + + # + # + def self.find_active_stub_by_path: (untyped path) -> untyped + + # + # Return currently unresolved specs that contain the file matching `path`. + # + def self.find_in_unresolved: (untyped path) -> untyped + + # + # Search through all unresolved deps and sub-dependencies and return specs that + # contain the file matching `path`. + # + def self.find_in_unresolved_tree: (untyped path) -> (untyped | ::Array[untyped]) + + # + # + def self.unresolved_specs: () -> untyped + + # + # Special loader for YAML files. When a Specification object is loaded from a + # YAML file, it bypasses the normal Ruby object initialization routine + # (#initialize). This method makes up for that and deals with gems of different + # ages. + # + # `input` can be anything that YAML.load() accepts: String or IO. + # + def self.from_yaml: (untyped input) -> untyped + + # + # Return the latest specs, optionally including prerelease specs if `prerelease` + # is true. + # + def self.latest_specs: (?bool prerelease) -> untyped + + # + # Return the latest installed spec for gem `name`. + # + def self.latest_spec_for: (untyped name) -> untyped + + def self._latest_specs: (untyped specs, ?bool prerelease) -> untyped + + # + # Loads Ruby format gemspec from `file`. + # + def self.load: (untyped file) -> (nil | untyped) + + # + # Specification attributes that must be non-nil + # + def self.non_nil_attributes: () -> untyped + + # + # Make sure the YAML specification is properly formatted with dashes + # + def self.normalize_yaml_input: (untyped input) -> untyped + + # + # Return a list of all outdated local gem names. This method is HEAVY as it + # must go fetch specifications from the server. + # + # Use outdated_and_latest_version if you wish to retrieve the latest remote + # version as well. + # + def self.outdated: () -> untyped + + # + # Enumerates the outdated local gems yielding the local specification and the + # latest remote version. + # + # This method may take some time to return as it must check each local gem + # against the server's index. + # + def self.outdated_and_latest_version: () ?{ (untyped) -> untyped } -> (untyped | nil) + + # + # Is `name` a required attribute? + # + def self.required_attribute?: (untyped name) -> untyped + + # + # Required specification attributes + # + def self.required_attributes: () -> untyped + + # + # Reset the list of known specs, running pre and post reset hooks registered in + # Gem. + # + def self.reset: () -> untyped + + def self.specification_record: () -> untyped + + # + # DOC: This method needs documented or nodoc'd + # + def self.unresolved_deps: () -> untyped + + # + # Load custom marshal format, re-initializing defaults as needed + # + def self._load: (untyped str) -> untyped + + def <=>: (untyped other) -> untyped + + def ==: (untyped other) -> untyped + + # + # Dump only crucial instance variables. + # + def _dump: (untyped limit) -> untyped + + # + # Activate this spec, registering it as a loaded spec and adding it's lib paths + # to $LOAD_PATH. Returns true if the spec was activated, false if it was + # previously activated. Freaks out if there are conflicts upon activation. + # + def activate: () -> (false | true) + + # + # Activate all unambiguously resolved runtime dependencies of this spec. Add any + # ambiguous dependencies to the unresolved list to be resolved later, as needed. + # + def activate_dependencies: () -> untyped + + # + # Abbreviate the spec for downloading. Abbreviated specs are only used for + # searching, downloading and related activities and do not need deployment + # specific information (e.g. list of files). So we abbreviate the spec, making + # it much smaller for quicker downloads. + # + def abbreviate: () -> untyped + + # + # Sanitize the descriptive fields in the spec. Sometimes non-ASCII characters + # will garble the site index. Non-ASCII characters will be replaced by their + # XML entity equivalent. + # + def sanitize: () -> untyped + + # + # Sanitize a single string. + # + def sanitize_string: (untyped string) -> untyped + + # + # Returns an array with bindir attached to each executable in the `executables` + # list + # + def add_bindir: (untyped executables) -> untyped + + private + + # + # Adds a dependency on gem `dependency` with type `type` that requires + # `requirements`. Valid types are currently `:runtime` and `:development`. + # + def add_dependency_with_type: (untyped dependency, untyped type, untyped requirements) -> untyped + + public + + # + # Adds a runtime dependency named `gem` with `requirements` to this gem. + # + # Usage: + # + # spec.add_runtime_dependency 'example', '~> 1.1', '>= 1.1.4' + # + alias add_runtime_dependency add_dependency + + # + # Adds this spec's require paths to LOAD_PATH, in the proper location. + # + def add_self_to_load_path: () -> (nil | untyped) + + # + # Singular reader for #authors. Returns the first author in the list + # + def author: () -> untyped + + # + # The list of author names who wrote this gem. + # + # spec.authors = ['Chad Fowler', 'Jim Weirich', 'Rich Kilmer'] + # + def authors: () -> untyped + + # + # Returns the full path to installed gem's bin directory. + # + # NOTE: do not confuse this with `bindir`, which is just 'bin', not a full path. + # + def bin_dir: () -> untyped + + # + # Returns the full path to an executable named `name` in this gem. + # + def bin_file: (untyped name) -> untyped + + # + # Returns the build_args used to install the gem + # + def build_args: () -> (untyped | ::Array[untyped]) + + def build_extensions: () -> (nil | untyped) + + # + # Returns the full path to the build info directory + # + def build_info_dir: () -> untyped + + # + # Returns the full path to the file containing the build information generated + # when the gem was installed + # + def build_info_file: () -> untyped + + # + # Returns the full path to the cache directory containing this spec's cached + # gem. + # + def cache_dir: () -> untyped + + # + # Returns the full path to the cached gem for this spec. + # + def cache_file: () -> untyped + + # + # Return any possible conflicts against the currently loaded specs. + # + def conflicts: () -> untyped + + def conficts_when_loaded_with?: (untyped list_of_specs) -> untyped + + # + # Return true if there are possible conflicts against the currently loaded + # specs. + # + def has_conflicts?: () -> untyped + + # + # The date this gem was created. + # + # If SOURCE_DATE_EPOCH is set as an environment variable, use that to support + # reproducible builds; otherwise, default to the current UTC date. + # + # Details on SOURCE_DATE_EPOCH: + # https://reproducible-builds.org/specs/source-date-epoch/ + # + def date: () -> untyped + + DateLike: untyped + + def self.===: (untyped obj) -> untyped + + DateTimeFormat: ::Regexp + + # + # The date this gem was created + # + # DO NOT set this, it is set automatically when the gem is packaged. + # + def date=: (untyped date) -> untyped + + def default_executable: () -> untyped + + # + # The default value for specification attribute `name` + # + def default_value: (untyped name) -> untyped + + # + # A list of Gem::Dependency objects this gem depends on. + # + # Use #add_dependency or #add_development_dependency to add dependencies to a + # gem. + # + def dependencies: () -> Array[Gem::Dependency] + + # + # Return a list of all gems that have a dependency on this gemspec. The list is + # structured with entries that conform to: + # + # [depending_gem, dependency, [list_of_gems_that_satisfy_dependency]] + # + def dependent_gems: (?bool check_dev) -> untyped + + # + # Returns all specs that matches this spec's runtime dependencies. + # + def dependent_specs: () -> untyped + + # + # A detailed description of this gem. See also #summary + # + def description=: (untyped str) -> untyped + + # + # List of dependencies that are used for development + # + def development_dependencies: () -> Array[Gem::Dependency] + + # + # Returns the full path to this spec's documentation directory. If `type` is + # given it will be appended to the end. For example: + # + # spec.doc_dir # => "/path/to/gem_repo/doc/a-1" + # + # spec.doc_dir 'ri' # => "/path/to/gem_repo/doc/a-1/ri" + # + def doc_dir: (?untyped? type) -> untyped + + def encode_with: (untyped coder) -> untyped + + def eql?: (untyped other) -> untyped + + # + # Singular accessor for #executables + # + def executable: () -> untyped + + # + # Singular accessor for #executables + # + def executable=: (untyped o) -> untyped + + # + # Sets executables to `value`, ensuring it is an array. + # + def executables=: (untyped value) -> untyped + + # + # Sets extensions to `extensions`, ensuring it is an array. + # + def extensions=: (untyped extensions) -> untyped + + # + # Sets extra_rdoc_files to `files`, ensuring it is an array. + # + def extra_rdoc_files=: (untyped files) -> untyped + + # + # The default (generated) file name of the gem. See also #spec_name. + # + # spec.file_name # => "example-1.0.gem" + # + def file_name: () -> ::String + + # + # Sets files to `files`, ensuring it is an array. + # + def files=: (untyped files) -> untyped + + private + + # + # Finds all gems that satisfy `dep` + # + def find_all_satisfiers: (untyped dep) { (untyped) -> untyped } -> untyped + + public + + # + # Creates a duplicate spec without large blobs that aren't used at runtime. + # + def for_cache: () -> untyped + + # + # + def full_name: () -> untyped + + def gem_dir: () -> untyped + + # + # + def gems_dir: () -> untyped + + def has_rdoc: () -> true + + def has_rdoc=: (untyped ignored) -> untyped + + alias has_rdoc? has_rdoc + + def has_unit_tests?: () -> untyped + + # :stopdoc: + alias has_test_suite? has_unit_tests? + + def hash: () -> untyped + + def init_with: (untyped coder) -> untyped + + # + # Specification constructor. Assigns the default values to the attributes and + # yields itself for further initialization. Optionally takes `name` and + # `version`. + # + def initialize: (?untyped? name, ?untyped? version) ?{ (untyped) -> untyped } -> void + + # + # Duplicates array_attributes from `other_spec` so state isn't shared. + # + def initialize_copy: (untyped other_spec) -> untyped + + # + # + def base_dir: () -> untyped + + private + + # + # Expire memoized instance variables that can incorrectly generate, replace or + # miss files due changes in certain attributes used to compute them. + # + def invalidate_memoized_attributes: () -> untyped + + public + + def inspect: () -> (untyped | ::String) + + # + # Files in the Gem under one of the require_paths + # + def lib_files: () -> untyped + + # + # Singular accessor for #licenses + # + def license: () -> untyped + + # + # Plural accessor for setting licenses + # + # See #license= for details + # + def licenses: () -> untyped + + def internal_init: () -> untyped + + def method_missing: (untyped sym, *untyped a) { (?) -> untyped } -> (nil | untyped) + + # + # Is this specification missing its extensions? When this returns true you + # probably want to build_extensions + # + def missing_extensions?: () -> (false | true) + + # + # Normalize the list of files so that: + # * All file lists have redundancies removed. + # * Files referenced in the extra_rdoc_files are included in the package file + # list. + # + def normalize: () -> untyped + + # + # Return a NameTuple that represents this Specification + # + def name_tuple: () -> untyped + + def original_name: () -> ::String + + def original_platform: () -> untyped + + # + # The platform this gem runs on. See Gem::Platform for details. + # + def platform: () -> untyped + + def pretty_print: (untyped q) -> untyped + + private + + def check_version_conflict: (untyped other) -> (nil | untyped) + + public + + def raise_if_conflicts: () -> (untyped | nil) + + # + # Sets rdoc_options to `value`, ensuring it is an array. + # + def rdoc_options=: (untyped options) -> untyped + + # + # Singular accessor for #require_paths + # + def require_path: () -> untyped + + # + # Singular accessor for #require_paths + # + def require_path=: (untyped path) -> untyped + + # + # Set requirements to `req`, ensuring it is an array. + # + def requirements=: (untyped req) -> untyped + + def respond_to_missing?: (untyped m, ?bool include_private) -> false + + # + # Returns the full path to this spec's ri directory. + # + def ri_dir: () -> untyped + + private + + # + # Return a string containing a Ruby code representation of the given object. + # + def ruby_code: (untyped obj) -> untyped + + public + + # + # List of dependencies that will automatically be activated at runtime. + # + def runtime_dependencies: () -> untyped + + private + + # + # True if this gem has the same attributes as `other`. + # + def same_attributes?: (untyped spec) -> untyped + + public + + # + # Checks if this specification meets the requirement of `dependency`. + # + def satisfies_requirement?: (untyped dependency) -> untyped + + # + # Returns an object you can use to sort specifications in #sort_by. + # + def sort_obj: () -> ::Array[untyped] + + def source: () -> untyped + + # + # Returns the full path to the directory containing this spec's gemspec file. + # eg: /usr/local/lib/ruby/gems/1.8/specifications + # + def spec_dir: () -> untyped + + # + # Returns the full path to this spec's gemspec file. eg: + # /usr/local/lib/ruby/gems/1.8/specifications/mygem-1.0.gemspec + # + def spec_file: () -> untyped + + # + # The default name of the gemspec. See also #file_name + # + # spec.spec_name # => "example-1.0.gemspec" + # + def spec_name: () -> ::String + + # + # A short summary of this gem's description. + # + def summary=: (untyped str) -> untyped + + def test_file: () -> untyped + + def test_file=: (untyped file) -> untyped + + def test_files: () -> untyped + + # + # Returns a Ruby code representation of this specification, such that it can be + # eval'ed and reconstruct the same specification later. Attributes that still + # have their default values are omitted. + # + def to_ruby: () -> untyped + + # + # Returns a Ruby lighter-weight code representation of this specification, used + # for indexing only. + # + # See #to_ruby. + # + def to_ruby_for_cache: () -> untyped + + def to_s: () -> ::String + + # + # Returns self + # + def to_spec: () -> self + + def to_yaml: (?::Hash[untyped, untyped] opts) -> untyped + + # + # Recursively walk dependencies of this spec, executing the `block` for each + # hop. + # + def traverse: (?untyped trail, ?::Hash[untyped, untyped] visited) { (?) -> untyped } -> untyped + + # + # Checks that the specification contains all required fields, and does a very + # basic sanity check. + # + # Raises InvalidSpecificationException if the spec does not pass the checks.. + # + def validate: (?bool packaging, ?bool strict) -> untyped + + # + # + def keep_only_files_and_directories: () -> untyped + + def validate_for_resolution: () -> untyped + + # + # + def validate_metadata: () -> untyped + + # + # + def validate_dependencies: () -> untyped + + # + # + def validate_permissions: () -> untyped + + # + # Set the version to `version`, potentially also setting + # required_rubygems_version if `version` indicates it is a prerelease. + # + def version=: (untyped version) -> (nil | untyped) + + # + # + def stubbed?: () -> false + + def yaml_initialize: (untyped tag, untyped vals) -> untyped + + # + # Reset nil attributes to their default values to make the spec valid + # + def reset_nil_attributes_to_default: () -> nil + + def flatten_require_paths: () -> (nil | untyped) + + def raw_require_paths: () -> untyped +end From 55ee9f79c32e5390dbbe10d30f937a70092bfef6 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Sun, 20 Jul 2025 11:41:34 -0400 Subject: [PATCH 096/400] Quiet specs --- lib/solargraph/api_map.rb | 2 +- lib/solargraph/doc_map.rb | 9 +++++---- lib/solargraph/workspace.rb | 2 +- spec/api_map_spec.rb | 2 +- spec/doc_map_spec.rb | 10 +++++----- spec/gem_pins_spec.rb | 4 ++-- spec/type_checker/levels/strict_spec.rb | 2 +- spec/yard_map/mapper_spec.rb | 12 +++++++----- 8 files changed, 23 insertions(+), 20 deletions(-) diff --git a/lib/solargraph/api_map.rb b/lib/solargraph/api_map.rb index d3f4f6827..85de6304e 100755 --- a/lib/solargraph/api_map.rb +++ b/lib/solargraph/api_map.rb @@ -104,7 +104,7 @@ def catalog bench @doc_map.any_uncached? if recreate_docmap - @doc_map = DocMap.new(unresolved_requires, bench.workspace) # @todo Implement gem preferences + @doc_map = DocMap.new(unresolved_requires, bench.workspace, out: nil) # @todo Implement gem preferences @gemspecs = @doc_map.workspace.gemspecs @unresolved_requires = @doc_map.unresolved_requires end diff --git a/lib/solargraph/doc_map.rb b/lib/solargraph/doc_map.rb index 3d23ef2b3..af2cc7735 100644 --- a/lib/solargraph/doc_map.rb +++ b/lib/solargraph/doc_map.rb @@ -31,11 +31,12 @@ def uncached_gemspecs # @param requires [Array] # @param workspace [Workspace] - def initialize requires, workspace + # @param out [IO, nil] output stream for logging + def initialize requires, workspace, out: $stderr @requires = requires.compact @workspace = workspace @global_environ = Convention.for_global(self) - load_serialized_gem_pins + load_serialized_gem_pins(out: out) pins.concat global_environ.pins end @@ -64,7 +65,7 @@ def cache_doc_map_gems! out end logger.debug { "Caching: #{uncached_gemspecs.map(&:name)}" } PinCache.cache_core unless PinCache.core? - load_serialized_gem_pins + load_serialized_gem_pins(out: out) time = Benchmark.measure do uncached_gemspecs.each do |gemspec| cache(gemspec, out: out) @@ -74,7 +75,7 @@ def cache_doc_map_gems! out if (milliseconds > 500) && uncached_gemspecs.any? && out && uncached_gemspecs.any? out.puts "Built #{uncached_gemspecs.length} gems in #{milliseconds} ms" end - load_serialized_gem_pins + load_serialized_gem_pins(out: out) end # @return [Array] diff --git a/lib/solargraph/workspace.rb b/lib/solargraph/workspace.rb index 90c104077..19aa729ac 100644 --- a/lib/solargraph/workspace.rb +++ b/lib/solargraph/workspace.rb @@ -68,7 +68,7 @@ def resolve_require require def global_environ # empty docmap, since the result needs to work in any possible # context here - @environ ||= Convention.for_global(DocMap.new([], self)) + @environ ||= Convention.for_global(DocMap.new([], self, out: nil)) end # @param gemspec [Gem::Specification, Bundler::LazySpecification] diff --git a/spec/api_map_spec.rb b/spec/api_map_spec.rb index 8dc6db842..4100dede9 100755 --- a/spec/api_map_spec.rb +++ b/spec/api_map_spec.rb @@ -2,7 +2,7 @@ describe Solargraph::ApiMap do before :all do - @api_map = Solargraph::ApiMap.new + @api_map = Solargraph::ApiMap.load_with_cache(Dir.pwd, nil) end it 'returns core methods' do diff --git a/spec/doc_map_spec.rb b/spec/doc_map_spec.rb index c9481d354..751b40b37 100644 --- a/spec/doc_map_spec.rb +++ b/spec/doc_map_spec.rb @@ -4,7 +4,7 @@ describe Solargraph::DocMap do subject(:doc_map) do - Solargraph::DocMap.new(requires, workspace) + Solargraph::DocMap.new(requires, workspace, out: nil) end let(:pre_cache) { true } @@ -14,10 +14,10 @@ Solargraph::Workspace.new(Dir.pwd) end - let(:plain_doc_map) { Solargraph::DocMap.new([], workspace) } + let(:plain_doc_map) { Solargraph::DocMap.new([], workspace, out: nil) } before do - doc_map.cache_doc_map_gems!($stderr) if pre_cache + doc_map.cache_doc_map_gems!(nil) if pre_cache end context 'with a require in solargraph test bundle' do @@ -64,8 +64,8 @@ context 'with require as bundle/require' do it 'imports all gems when bundler/require used' do - doc_map_with_bundler_require = Solargraph::DocMap.new(['bundler/require'], workspace) - doc_map_with_bundler_require.cache_doc_map_gems!($stderr) + doc_map_with_bundler_require = Solargraph::DocMap.new(['bundler/require'], workspace, out: nil) + doc_map_with_bundler_require.cache_doc_map_gems!(nil) expect(doc_map_with_bundler_require.pins.length - plain_doc_map.pins.length).to be_positive end end diff --git a/spec/gem_pins_spec.rb b/spec/gem_pins_spec.rb index ecab06001..093aa4cc1 100644 --- a/spec/gem_pins_spec.rb +++ b/spec/gem_pins_spec.rb @@ -3,8 +3,8 @@ describe Solargraph::GemPins do it 'can merge YARD and RBS' do workspace = Solargraph::Workspace.new(Dir.pwd) - doc_map = Solargraph::DocMap.new(['rbs'], workspace) - doc_map.cache_doc_map_gems!($stderr) + doc_map = Solargraph::DocMap.new(['rbs'], workspace, out: nil) + doc_map.cache_doc_map_gems!(nil) core_root = doc_map.pins.find { |pin| pin.path == 'RBS::EnvironmentLoader#core_root' } expect(core_root.return_type.to_s).to eq('Pathname, nil') diff --git a/spec/type_checker/levels/strict_spec.rb b/spec/type_checker/levels/strict_spec.rb index 70fb0797c..13c20e85f 100644 --- a/spec/type_checker/levels/strict_spec.rb +++ b/spec/type_checker/levels/strict_spec.rb @@ -59,7 +59,7 @@ def bar(a); end require 'kramdown-parser-gfm' Kramdown::Parser::GFM.undefined_call ), 'test.rb') - api_map = Solargraph::ApiMap.load_with_cache('.', $stdout) + api_map = Solargraph::ApiMap.load_with_cache('.', nil) api_map.catalog Solargraph::Bench.new(source_maps: [source_map], external_requires: ['kramdown-parser-gfm']) checker = Solargraph::TypeChecker.new('test.rb', api_map: api_map, level: :strict) expect(checker.problems).to be_empty diff --git a/spec/yard_map/mapper_spec.rb b/spec/yard_map/mapper_spec.rb index d4d1127ad..d60e0fcd5 100644 --- a/spec/yard_map/mapper_spec.rb +++ b/spec/yard_map/mapper_spec.rb @@ -1,13 +1,15 @@ describe Solargraph::YardMap::Mapper do - before do - Solargraph::ApiMap.load_with_cache('.', $stderr) + before :all do # rubocop:disable RSpec/BeforeAfterAll + # this takes some time to load, so we do it once - tests must not + # mutate it without creating their own + @api_map = Solargraph::ApiMap.load_with_cache('.', nil) end - let(:workspace) { Solargraph::Workspace.new(Dir.pwd) } + let(:workspace) { @api_map.workspace } # rubocop:disable RSpec/InstanceVariable def pins_with require - doc_map = Solargraph::DocMap.new([require], workspace) - doc_map.cache_doc_map_gems!($stderr) + doc_map = Solargraph::DocMap.new([require], workspace, out: nil) + doc_map.cache_doc_map_gems!(nil) doc_map.pins end From a4282e63b53a708899f80596ec85e03cbae77856 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Sun, 20 Jul 2025 11:42:42 -0400 Subject: [PATCH 097/400] Add spec --- spec/api_map_spec.rb | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/spec/api_map_spec.rb b/spec/api_map_spec.rb index 4100dede9..c56f1be4b 100755 --- a/spec/api_map_spec.rb +++ b/spec/api_map_spec.rb @@ -10,6 +10,33 @@ expect(pins.map(&:path)).to include('String#upcase') end + describe '.load_with_cache' do + context 'without core already cached' do + before do + Solargraph::PinCache.uncache_core(out: nil) + end + + it 'automatically caches core' do + api_map = Solargraph::ApiMap.load_with_cache(Dir.pwd, nil) + pins = api_map.get_methods('String') + expect(pins.map(&:path)).to include('String#upcase') + end + end + + context 'without gem already cached' do + before do + gemspec = @api_map.find_gem('rubocop') + @api_map.workspace.uncache_gem(gemspec) + end + + it 'automatically caches gems' do + api_map = Solargraph::ApiMap.load_with_cache(Dir.pwd, nil) + pins = api_map.get_methods('RuboCop::Cop::Base') + expect(pins.map(&:path)).to include('RuboCop::Cop::Base#active_support_extensions_enabled?') + end + end + end + it 'returns core classes' do pins = @api_map.get_constants('') expect(pins.map(&:path)).to include('String') From 3341939d29b5b33eaf765713d870e811901bdd4c Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Sun, 20 Jul 2025 11:53:22 -0400 Subject: [PATCH 098/400] Avoid full load_with_cache in spec --- lib/solargraph/api_map.rb | 2 +- spec/yard_map/mapper_spec.rb | 8 ++------ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/lib/solargraph/api_map.rb b/lib/solargraph/api_map.rb index 85de6304e..c62160868 100755 --- a/lib/solargraph/api_map.rb +++ b/lib/solargraph/api_map.rb @@ -228,7 +228,7 @@ class << self # @todo IO::NULL is incorrectly inferred to be a String. # @sg-ignore # - # @param directory [String] + # @param directory [String] workspace directory # @param out [IO] The output stream for messages # @return [ApiMap] def self.load_with_cache directory, out diff --git a/spec/yard_map/mapper_spec.rb b/spec/yard_map/mapper_spec.rb index d60e0fcd5..450b459e4 100644 --- a/spec/yard_map/mapper_spec.rb +++ b/spec/yard_map/mapper_spec.rb @@ -1,14 +1,10 @@ describe Solargraph::YardMap::Mapper do before :all do # rubocop:disable RSpec/BeforeAfterAll - # this takes some time to load, so we do it once - tests must not - # mutate it without creating their own - @api_map = Solargraph::ApiMap.load_with_cache('.', nil) + @api_map = Solargraph::ApiMap.load('.') end - let(:workspace) { @api_map.workspace } # rubocop:disable RSpec/InstanceVariable - def pins_with require - doc_map = Solargraph::DocMap.new([require], workspace, out: nil) + doc_map = Solargraph::DocMap.new([require], @api_map.workspace, out: nil) # rubocop:disable RSpec/InstanceVariable doc_map.cache_doc_map_gems!(nil) doc_map.pins end From 12bad52bf231df1e51097ef53dfc3990389ea00a Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Sun, 20 Jul 2025 13:02:58 -0400 Subject: [PATCH 099/400] Add another shell spec --- spec/shell_spec.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/spec/shell_spec.rb b/spec/shell_spec.rb index f0df98121..bd0de9042 100644 --- a/spec/shell_spec.rb +++ b/spec/shell_spec.rb @@ -55,6 +55,14 @@ def bundle_exec(*cmd) end end + describe 'gems' do + it 'caches all without erroring out' do + output = bundle_exec('solargraph', 'gems') + + expect(output).to include('Documentation cached for all') + end + end + describe 'cache' do it 'caches without erroring out' do output = bundle_exec('solargraph', 'cache', 'solargraph') From 2af7f35be7e1197acc6b27b9c333a5205e3b1687 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Sun, 20 Jul 2025 13:51:15 -0400 Subject: [PATCH 100/400] Consolidate logging code --- lib/solargraph/doc_map.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/solargraph/doc_map.rb b/lib/solargraph/doc_map.rb index af2cc7735..e7a21e4d9 100644 --- a/lib/solargraph/doc_map.rb +++ b/lib/solargraph/doc_map.rb @@ -58,12 +58,12 @@ def any_uncached? # @param out [IO, nil] output stream for logging # @return [void] def cache_doc_map_gems! out - # if we log at debug level: - if logger.info? - gem_desc = uncached_gemspecs.map { |gemspec| "#{gemspec.name}:#{gemspec.version}" }.join(', ') - logger.info "Caching pins for gems: #{gem_desc}" unless uncached_gemspecs.empty? + unless uncached_gemspecs.empty? + logger.info do + gem_desc = uncached_gemspecs.map { |gemspec| "#{gemspec.name}:#{gemspec.version}" }.join(', ') + "Caching pins for gems: #{gem_desc}" + end end - logger.debug { "Caching: #{uncached_gemspecs.map(&:name)}" } PinCache.cache_core unless PinCache.core? load_serialized_gem_pins(out: out) time = Benchmark.measure do From a2f42cf59dc219c1a9a707a8e211e9716cf27b25 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Sun, 20 Jul 2025 13:56:07 -0400 Subject: [PATCH 101/400] Reduce need to covnert gemspecs, save time --- lib/solargraph/workspace.rb | 1 - lib/solargraph/workspace/gemspecs.rb | 93 +++++++++++++++------------- rbs/fills/bundler/0/bundler.rbs | 4 +- 3 files changed, 52 insertions(+), 46 deletions(-) diff --git a/lib/solargraph/workspace.rb b/lib/solargraph/workspace.rb index 19aa729ac..6089fc8fa 100644 --- a/lib/solargraph/workspace.rb +++ b/lib/solargraph/workspace.rb @@ -49,7 +49,6 @@ def config # @param gemspec [Gem::Specification] # @return [Array] def fetch_dependencies gemspec - raise ArgumentError, 'gemspec must be a Gem::Specification' unless gemspec.is_a?(Gem::Specification) gemspecs.fetch_dependencies(gemspec) end diff --git a/lib/solargraph/workspace/gemspecs.rb b/lib/solargraph/workspace/gemspecs.rb index 4bc90fcc1..edb3b83b2 100644 --- a/lib/solargraph/workspace/gemspecs.rb +++ b/lib/solargraph/workspace/gemspecs.rb @@ -89,8 +89,6 @@ def find_gem name, version # @param gemspec [Gem::Specification] # @return [Array] def fetch_dependencies gemspec - raise ArgumentError, 'gemspec must be a Gem::Specification' unless gemspec.is_a?(Gem::Specification) - gemspecs = all_gemspecs_from_bundle # @param runtime_dep [Gem::Dependency] @@ -122,10 +120,41 @@ def all_gemspecs_from_bundle private + # @param specish [Gem::Specification, Bundler::LazySpecification, Bundler::StubSpecification] + # @return [Gem::Specification, nil] + def to_gem_specification specish + # print time including milliseconds + case specish + when Gem::Specification + # yay! + specish + when Bundler::LazySpecification + # materializing didn't work. Let's look in the local + # rubygems without bundler's help + resolve_gem_ignoring_local_bundle specish.name, specish.version + when Bundler::StubSpecification + # turns a Bundler::StubSpecification into a + # Gem::StubSpecification into a Gem::Specification + specish = specish.stub + if specish.respond_to?(:spec) + specish.spec + else + resolve_gem_ignoring_local_bundle specish.name, specish.version + end + else + @@warned_on_gem_type ||= false # rubocop:disable Style/ClassVars + unless @@warned_on_gem_type + logger.warn "Unexpected type while resolving gem: #{specish.class}" + @@warned_on_gem_type = true # rubocop:disable Style/ClassVars + end + nil + end + end + # @param command [String] The expression to evaluate in the external bundle # @sg-ignore Need a JSON type - # @yield [undefined] - def query_external_bundle command, &block + # @yield [undefined, nil] + def query_external_bundle command Solargraph.with_clean_env do cmd = [ 'ruby', '-e', @@ -135,8 +164,7 @@ def query_external_bundle command, &block o, e, s = Open3.capture3(*cmd) if s.success? Solargraph.logger.debug "External bundle: #{o}" - data = o && !o.empty? ? JSON.parse(o.split("\n").last) : {} - block.yield data + o && !o.empty? ? JSON.parse(o.split("\n").last) : nil else Solargraph.logger.warn e raise BundleNotFoundError, "Failed to load gems from bundle at #{directory}" @@ -148,7 +176,7 @@ def in_this_bundle? directory && Bundler.definition&.lockfile&.to_s&.start_with?(directory) # rubocop:disable Style/SafeNavigationChainLength end - # @return [Array] + # @return [Array] def all_gemspecs_from_this_bundle # Find only the gems bundler is now using specish_objects = Bundler.definition.locked_gems.specs @@ -156,34 +184,16 @@ def all_gemspecs_from_this_bundle specish_objects = specish_objects.map(&:materialize_for_installation) end specish_objects.map do |specish| - case specish - when Gem::Specification - # yay! + if specish.respond_to?(:name) && specish.respond_to?(:version) + # good enough for most uses! specish - when Bundler::LazySpecification - # materializing didn't work. Let's look in the local - # rubygems without bundler's help - resolve_gem_ignoring_local_bundle specish.name, specish.version - when Bundler::StubSpecification - # turns a Bundler::StubSpecification into a - # Gem::StubSpecification into a Gem::Specification - specish = specish.stub - if specish.respond_to?(:spec) - specish.spec - else - resolve_gem_ignoring_local_bundle specish.name, specish.version - end else - @@warned_on_gem_type ||= false # rubocop:disable Style/ClassVars - unless @@warned_on_gem_type - logger.warn "Unexpected type while resolving gem: #{specish.class}" - @@warned_on_gem_type = true # rubocop:disable Style/ClassVars - end + to_gem_specification(specish) end - end + end.compact end - # @return [Array] + # @return [Array] def auto_required_gemspecs_from_bundler logger.info 'Fetching gemspecs autorequired from Bundler (bundler/require)' @auto_required_gemspecs_from_bundler ||= @@ -194,7 +204,7 @@ def auto_required_gemspecs_from_bundler end end - # @return [Array] + # @return [Array] def auto_required_gemspecs_from_this_bundle # Adapted from require() in lib/bundler/runtime.rb dep_names = Bundler.definition.dependencies.select do |dep| @@ -207,27 +217,26 @@ def auto_required_gemspecs_from_this_bundle # @sg-ignore # Solargraph::Workspace::Gemspecs#auto_required_gemspecs_from_external_bundle # return type could not be inferred - # @return [Array] + # @return [Array] def auto_required_gemspecs_from_external_bundle @auto_required_gemspecs_from_external_bundle ||= begin logger.info 'Fetching auto-required gemspecs from Bundler (bundler/require)' command = 'Bundler.definition.dependencies' \ - '.select { |dep| dep.groups.include?(:default) && dep.should_include? }.map(&:name)' + '.select { |dep| dep.groups.include?(:default) && dep.should_include? }' \ + '.map { |dep| [dep.name, dep. version] }' # @sg-ignore - # @type [Array] - dep_names = query_external_bundle(command) { |dependency_names| dependency_names } + # @type [Array] + dep_details = query_external_bundle command - all_gemspecs_from_bundle.select { |gemspec| dep_names.include?(gemspec.name) } + dep_details.map { |name, version| find_gem(name, version) }.compact end end # @param gemspec [Gem::Specification] # @return [Array] def only_runtime_dependencies gemspec - raise ArgumentError, 'gemspec must be a Gem::Specification' unless gemspec.is_a?(Gem::Specification) - gemspec.dependencies - gemspec.development_dependencies end @@ -257,11 +266,9 @@ def all_gemspecs_from_external_bundle command = 'Bundler.definition.locked_gems&.specs&.map { |spec| [spec.name, spec.version] }.to_h' - query_external_bundle command do |names_and_versions| - names_and_versions.map do |name, version| - resolve_gem_ignoring_local_bundle(name, version) - end.compact - end + query_external_bundle(command).map do |name, version| + resolve_gem_ignoring_local_bundle(name, version) + end.compact end end diff --git a/rbs/fills/bundler/0/bundler.rbs b/rbs/fills/bundler/0/bundler.rbs index 4af422af1..8b23710d4 100644 --- a/rbs/fills/bundler/0/bundler.rbs +++ b/rbs/fills/bundler/0/bundler.rbs @@ -3076,7 +3076,7 @@ class Bundler::RemoteSpecification def initialize: (untyped name, untyped version, untyped platform, untyped spec_fetcher) -> void - def name: () -> untyped + def name: () -> String def platform: () -> untyped @@ -3106,7 +3106,7 @@ class Bundler::RemoteSpecification def to_s: () -> untyped - def version: () -> untyped + def version: () -> String end class Bundler::Resolver From d3a4d642930fba7159ddbaadced2fc04f2a677db Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Sun, 20 Jul 2025 14:08:45 -0400 Subject: [PATCH 102/400] Handle a fake-Gem::Specification issue --- lib/solargraph/workspace/gemspecs.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/solargraph/workspace/gemspecs.rb b/lib/solargraph/workspace/gemspecs.rb index edb3b83b2..be8d28438 100644 --- a/lib/solargraph/workspace/gemspecs.rb +++ b/lib/solargraph/workspace/gemspecs.rb @@ -64,6 +64,8 @@ def resolve_require require # look ourselves just in case this is hanging out somewhere # that find_by_path doesn't index' gemspec = all_gemspecs.find do |spec| + spec = to_gem_specification(spec) unless spec.respond_to?(:files) + spec&.files&.any? { |gemspec_file| file == gemspec_file } end return [gemspec_or_preference(gemspec)] if gemspec @@ -108,7 +110,7 @@ def fetch_dependencies gemspec # Returns all gemspecs directly depended on by this workspace's # bundle (does not include transitive dependencies). # - # @return [Array] + # @return [Array] def all_gemspecs_from_bundle @all_gemspecs_from_bundle ||= if in_this_bundle? From e3150d55aca5a0a81aded5cea3717742f1161a42 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Sun, 20 Jul 2025 14:27:21 -0400 Subject: [PATCH 103/400] Handle a fake-Gem::Specification issue --- lib/solargraph/workspace/gemspecs.rb | 63 +++++++++++++++++----------- 1 file changed, 38 insertions(+), 25 deletions(-) diff --git a/lib/solargraph/workspace/gemspecs.rb b/lib/solargraph/workspace/gemspecs.rb index be8d28438..1b0589c4f 100644 --- a/lib/solargraph/workspace/gemspecs.rb +++ b/lib/solargraph/workspace/gemspecs.rb @@ -122,35 +122,45 @@ def all_gemspecs_from_bundle private + # @return [Hash{Gem::Specification, Bundler::LazySpecification, Bundler::StubSpecification => Gem::Specification}] + private_class_method def self.gem_specification_cache + @gem_specification_cache ||= {} + end + # @param specish [Gem::Specification, Bundler::LazySpecification, Bundler::StubSpecification] + # @sg-ignore # @return [Gem::Specification, nil] def to_gem_specification specish # print time including milliseconds - case specish - when Gem::Specification - # yay! - specish - when Bundler::LazySpecification - # materializing didn't work. Let's look in the local - # rubygems without bundler's help - resolve_gem_ignoring_local_bundle specish.name, specish.version - when Bundler::StubSpecification - # turns a Bundler::StubSpecification into a - # Gem::StubSpecification into a Gem::Specification - specish = specish.stub - if specish.respond_to?(:spec) - specish.spec - else - resolve_gem_ignoring_local_bundle specish.name, specish.version - end - else - @@warned_on_gem_type ||= false # rubocop:disable Style/ClassVars - unless @@warned_on_gem_type - logger.warn "Unexpected type while resolving gem: #{specish.class}" - @@warned_on_gem_type = true # rubocop:disable Style/ClassVars - end - nil - end + self.class.gem_specification_cache[specish] ||= case specish + when Gem::Specification + # yay! + specish + when Bundler::LazySpecification + # materializing didn't work. Let's look in the local + # rubygems without bundler's help + resolve_gem_ignoring_local_bundle specish.name, + specish.version + when Bundler::StubSpecification + # turns a Bundler::StubSpecification into a + # Gem::StubSpecification into a Gem::Specification + specish = specish.stub + if specish.respond_to?(:spec) + specish.spec + else + resolve_gem_ignoring_local_bundle specish.name, + specish.version + end + else + @@warned_on_gem_type ||= # rubocop:disable Style/ClassVars + false + unless @@warned_on_gem_type + logger.warn 'Unexpected type while resolving gem: ' \ + "#{specish.class}" + @@warned_on_gem_type = true # rubocop:disable Style/ClassVars + end + nil + end end # @param command [String] The expression to evaluate in the external bundle @@ -239,6 +249,9 @@ def auto_required_gemspecs_from_external_bundle # @param gemspec [Gem::Specification] # @return [Array] def only_runtime_dependencies gemspec + unless gemspec.respond_to?(:dependencies) && gemspec.respond_to?(:development_dependencies) + gemspec = to_gem_specification(gemspec) + end gemspec.dependencies - gemspec.development_dependencies end From f362c433713ab48932c10c71db88640e561d2648 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Sun, 20 Jul 2025 14:42:03 -0400 Subject: [PATCH 104/400] Fix caching output --- lib/solargraph/workspace.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/solargraph/workspace.rb b/lib/solargraph/workspace.rb index 6089fc8fa..a4a29f45e 100644 --- a/lib/solargraph/workspace.rb +++ b/lib/solargraph/workspace.rb @@ -191,7 +191,7 @@ def rbs_collection_config_path # @param rebuild [Boolean] whether to rebuild the pins even if they are cached # @return [void] def cache_all_for_workspace! out, rebuild: false - PinCache.cache_core(out: $stdout) unless PinCache.core? + PinCache.cache_core(out: out) unless PinCache.core? # @type [Array] specs = gemspecs.all_gemspecs_from_bundle specs.each do |spec| From 2cd2139af8a6f253ef19a7b833cf108421986d20 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Sun, 20 Jul 2025 14:42:20 -0400 Subject: [PATCH 105/400] Drop unneeded &. --- lib/solargraph/api_map.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/solargraph/api_map.rb b/lib/solargraph/api_map.rb index c62160868..1998f67b3 100755 --- a/lib/solargraph/api_map.rb +++ b/lib/solargraph/api_map.rb @@ -185,7 +185,7 @@ def self.load directory # @param out [IO, nil] # @return [void] def cache_all_for_doc_map! out - @doc_map&.cache_doc_map_gems!(out) + @doc_map.cache_doc_map_gems!(out) end # @param out [IO, nil] From 8af693f2d8d9935f6a2994cf0d9b0c4da366712e Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Sun, 20 Jul 2025 15:03:49 -0400 Subject: [PATCH 106/400] Fix permissions issue --- lib/solargraph/workspace/gemspecs.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/solargraph/workspace/gemspecs.rb b/lib/solargraph/workspace/gemspecs.rb index 1b0589c4f..25a89acea 100644 --- a/lib/solargraph/workspace/gemspecs.rb +++ b/lib/solargraph/workspace/gemspecs.rb @@ -120,13 +120,13 @@ def all_gemspecs_from_bundle end end - private - # @return [Hash{Gem::Specification, Bundler::LazySpecification, Bundler::StubSpecification => Gem::Specification}] - private_class_method def self.gem_specification_cache + def self.gem_specification_cache @gem_specification_cache ||= {} end + private + # @param specish [Gem::Specification, Bundler::LazySpecification, Bundler::StubSpecification] # @sg-ignore # @return [Gem::Specification, nil] From de28f001e86102d55e5ac43a72665582e466f26d Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Sun, 20 Jul 2025 15:18:53 -0400 Subject: [PATCH 107/400] Handle another duck type case for Gem::Sepcification-alikes --- lib/solargraph/workspace/gemspecs.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/solargraph/workspace/gemspecs.rb b/lib/solargraph/workspace/gemspecs.rb index 25a89acea..aa203e43a 100644 --- a/lib/solargraph/workspace/gemspecs.rb +++ b/lib/solargraph/workspace/gemspecs.rb @@ -196,8 +196,8 @@ def all_gemspecs_from_this_bundle specish_objects = specish_objects.map(&:materialize_for_installation) end specish_objects.map do |specish| - if specish.respond_to?(:name) && specish.respond_to?(:version) - # good enough for most uses! + if specish.respond_to?(:name) && specish.respond_to?(:version) && specish.respond_to?(:gem_dir) + # duck type is good enough for outside uses! specish else to_gem_specification(specish) From 1c65656730e3ac9abb892fbac9371161899993c1 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Sun, 20 Jul 2025 15:28:16 -0400 Subject: [PATCH 108/400] Fix another issue snaking logging through --- lib/solargraph/rbs_map.rb | 2 +- lib/solargraph/rbs_map/stdlib_map.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/solargraph/rbs_map.rb b/lib/solargraph/rbs_map.rb index f56ad4729..263f9f2dd 100644 --- a/lib/solargraph/rbs_map.rb +++ b/lib/solargraph/rbs_map.rb @@ -117,7 +117,7 @@ def self.from_gemspec gemspec, rbs_collection_path, rbs_collection_config_path # @return [Array] def pins out: $stderr @pins ||= if resolved? - loader.libs.each { |lib| log_caching(lib, out: $stderr) } + loader.libs.each { |lib| log_caching(lib, out: out) } conversions.pins else [] diff --git a/lib/solargraph/rbs_map/stdlib_map.rb b/lib/solargraph/rbs_map/stdlib_map.rb index 4ab83eb5f..89142b429 100644 --- a/lib/solargraph/rbs_map/stdlib_map.rb +++ b/lib/solargraph/rbs_map/stdlib_map.rb @@ -13,7 +13,7 @@ class StdlibMap < RbsMap @stdlib_maps_hash = {} def log_caching gemspec, out: $stderr - out.puts("Caching RBS pins for standard library #{gemspec.name}") + out&.puts("Caching RBS pins for standard library #{gemspec.name}") end # @param library [String] From 8b990c48d30f1e47a16e6047aa21b4b8018db727 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Mon, 21 Jul 2025 08:45:02 -0400 Subject: [PATCH 109/400] Force build --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 98df20346..d234e2780 100755 --- a/README.md +++ b/README.md @@ -65,7 +65,7 @@ The RSpec framework is supported via [solargraph-rspec](https://github.com/lekem When editing code, a `require` call that references a gem will pull the documentation into the code maps and include the gem's API in code completion and intellisense. Solargraph automatically generates code maps from installed gems, based on the YARD or RBS type information inside the gem. You can also eagerly cache gem documentation with the `solargraph gems` command. -If your project automatically requires bundled gems (e.g., `require 'bundler/require'`), Solargraph will add all of the Gemfile's default dependencies to the map. +If your project automatically requires bundled gem with the `Bundler.require` statement, Solargraph will add all of the Gemfile's default dependencies to the map. To ensure you have types for gems which contain neither RBS nor YARD information, use From 36b526da15bd2f5bc909153b73748172d63ad2ea Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Mon, 21 Jul 2025 08:56:02 -0400 Subject: [PATCH 110/400] Force build --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d234e2780..b3cb2ef5a 100755 --- a/README.md +++ b/README.md @@ -81,7 +81,7 @@ Once installed, you can also insert your own local overrides and definitions in ### Type Checking -As of version 0.33.0, Solargraph includes a [type checker](https://github.com/castwide/solargraph/issues/192) that uses a combination of YARD tags and code analysis to report missing type definitions. In strict mode, it performs type inference to determine whether the tags match the types it detects from code. +As of version 0.33.0, Solargraph includes a [type checker](https://github.com/castwide/solargraph/issues/192) that uses a combination of YARD tags and code analysis to report missing type definitions. In strict mode, it performs type inference to determine whether the tags match the types it detects from code. In strong mode it will ask you to clarify your intentions by adding annotations for better validation. ### The Documentation Cache From 36525df58d3a13260ba608b4afa6d79c1721c971 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Mon, 21 Jul 2025 09:50:13 -0400 Subject: [PATCH 111/400] Add another spec, clean up existing and ratchet rubocop --- .rubocop_todo.yml | 23 ++++++++--------------- spec/api_map_spec.rb | 43 +++++++++++++++++++++++++------------------ 2 files changed, 33 insertions(+), 33 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index b4f40f056..5ee8f20d0 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1005,13 +1005,12 @@ RSpec/BeNil: - 'spec/api_map/source_to_yard_spec.rb' - 'spec/language_server/host_spec.rb' -# Offense count: 4 +# Offense count: 3 RSpec/BeforeAfterAll: Exclude: - '**/spec/spec_helper.rb' - '**/spec/rails_helper.rb' - '**/spec/support/**/*.rb' - - 'spec/api_map_spec.rb' - 'spec/language_server/host/dispatch_spec.rb' - 'spec/language_server/protocol_spec.rb' @@ -1038,7 +1037,7 @@ RSpec/DescribeClass: - 'spec/complex_type_spec.rb' - 'spec/source_map/node_processor_spec.rb' -# Offense count: 396 +# Offense count: 388 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: SkipBlocks, EnforcedStyle, OnlyStaticConstants. # SupportedStyles: described_class, explicit @@ -1047,7 +1046,6 @@ RSpec/DescribedClass: - 'spec/api_map/cache_spec.rb' - 'spec/api_map/source_to_yard_spec.rb' - 'spec/api_map/store_spec.rb' - - 'spec/api_map_spec.rb' - 'spec/diagnostics/base_spec.rb' - 'spec/diagnostics/require_not_found_spec.rb' - 'spec/diagnostics/rubocop_helpers_spec.rb' @@ -1205,12 +1203,11 @@ RSpec/HookArgument: RSpec/ImplicitExpect: EnforcedStyle: should -# Offense count: 247 +# Offense count: 126 # Configuration parameters: AssignmentOnly. RSpec/InstanceVariable: Exclude: - 'spec/api_map/config_spec.rb' - - 'spec/api_map_spec.rb' - 'spec/diagnostics/require_not_found_spec.rb' - 'spec/language_server/host/dispatch_spec.rb' - 'spec/language_server/host_spec.rb' @@ -1330,13 +1327,12 @@ RSpec/NoExpectationExample: - 'spec/type_checker/checks_spec.rb' - 'spec/type_checker/levels/typed_spec.rb' -# Offense count: 2 +# Offense count: 1 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle. # SupportedStyles: not_to, to_not RSpec/NotToNot: Exclude: - - 'spec/api_map_spec.rb' - 'spec/rbs_map/core_map_spec.rb' # Offense count: 28 @@ -1374,10 +1370,9 @@ RSpec/RemoveConst: Exclude: - 'spec/diagnostics/rubocop_helpers_spec.rb' -# Offense count: 50 +# Offense count: 48 RSpec/RepeatedDescription: Exclude: - - 'spec/api_map_spec.rb' - 'spec/language_server/protocol_spec.rb' - 'spec/parser/node_methods_spec.rb' - 'spec/source/chain/call_spec.rb' @@ -1387,7 +1382,7 @@ RSpec/RepeatedDescription: - 'spec/type_checker/levels/normal_spec.rb' - 'spec/type_checker/levels/strict_spec.rb' -# Offense count: 30 +# Offense count: 28 RSpec/RepeatedExample: Exclude: - 'spec/api_map_spec.rb' @@ -1809,7 +1804,7 @@ Style/FloatDivision: - 'lib/solargraph/library.rb' - 'lib/solargraph/pin/search.rb' -# Offense count: 127 +# Offense count: 126 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: EnforcedStyle. # SupportedStyles: always, always_true, never @@ -1839,7 +1834,6 @@ Style/FrozenStringLiteralComment: - 'spec/api_map/cache_spec.rb' - 'spec/api_map/config_spec.rb' - 'spec/api_map/source_to_yard_spec.rb' - - 'spec/api_map_spec.rb' - 'spec/complex_type_spec.rb' - 'spec/convention/struct_definition_spec.rb' - 'spec/convention_spec.rb' @@ -2790,7 +2784,7 @@ YARD/TagTypeSyntax: - 'lib/solargraph/parser/comment_ripper.rb' - 'lib/solargraph/type_checker.rb' -# Offense count: 186 +# Offense count: 185 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: Max, AllowHeredoc, AllowURI, AllowQualifiedName, URISchemes, IgnoreCopDirectives, AllowedPatterns, SplitStrings. # URISchemes: http, https @@ -2849,7 +2843,6 @@ Layout/LineLength: - 'lib/solargraph/workspace.rb' - 'lib/solargraph/workspace/config.rb' - 'lib/solargraph/yard_map/mapper/to_method.rb' - - 'spec/api_map_spec.rb' - 'spec/complex_type_spec.rb' - 'spec/language_server/message/completion_item/resolve_spec.rb' - 'spec/language_server/message/extended/check_gem_version_spec.rb' diff --git a/spec/api_map_spec.rb b/spec/api_map_spec.rb index c56f1be4b..4d7077ccd 100755 --- a/spec/api_map_spec.rb +++ b/spec/api_map_spec.rb @@ -1,12 +1,16 @@ +# frozen_string_literal: true + require 'tmpdir' describe Solargraph::ApiMap do - before :all do - @api_map = Solargraph::ApiMap.load_with_cache(Dir.pwd, nil) + # avoid performance hit of doing this many times + # rubocop:disable RSpec/InstanceVariable + before :all do # rubocop:disable RSpec/BeforeAfterAll + @api_map = described_class.load_with_cache(Dir.pwd, nil) end it 'returns core methods' do - pins = @api_map.get_methods('String') + pins = @api_map.get_methods('String') # rubocop:disable RSpec/InstanceVariable expect(pins.map(&:path)).to include('String#upcase') end @@ -17,7 +21,7 @@ end it 'automatically caches core' do - api_map = Solargraph::ApiMap.load_with_cache(Dir.pwd, nil) + api_map = described_class.load_with_cache(Dir.pwd, nil) pins = api_map.get_methods('String') expect(pins.map(&:path)).to include('String#upcase') end @@ -25,12 +29,12 @@ context 'without gem already cached' do before do - gemspec = @api_map.find_gem('rubocop') + gemspec = @api_map.find_gem('rubocop') # rubocop:disable RSpec/InstanceVariable @api_map.workspace.uncache_gem(gemspec) end it 'automatically caches gems' do - api_map = Solargraph::ApiMap.load_with_cache(Dir.pwd, nil) + api_map = described_class.load_with_cache(Dir.pwd, nil) pins = api_map.get_methods('RuboCop::Cop::Base') expect(pins.map(&:path)).to include('RuboCop::Cop::Base#active_support_extensions_enabled?') end @@ -220,7 +224,7 @@ def prot end it 'adds Object instance methods to duck types' do - api_map = Solargraph::ApiMap.new + api_map = described_class.new type = Solargraph::ComplexType.parse('#foo') pins = api_map.get_complex_type_methods(type) expect(pins.any? { |p| p.namespace == 'BasicObject' }).to be(true) @@ -461,14 +465,14 @@ class Sup xit 'understands tuples inherit from regular arrays' do method_pins = @api_map.get_method_stack("Array(1, 2, 'a')", 'include?') method_pin = method_pins.first - expect(method_pin).to_not be_nil + expect(method_pin).not_to be_nil expect(method_pin.path).to eq('Array#include?') parameter_type = method_pin.signatures.first.parameters.first.return_type expect(parameter_type.rooted_tags).to eq("1, 2, 'a'") end it 'loads workspaces from directories' do - api_map = Solargraph::ApiMap.load('spec/fixtures/workspace') + api_map = described_class.load('spec/fixtures/workspace') expect(api_map.source_map(File.absolute_path('spec/fixtures/workspace/app.rb'))).to be_a(Solargraph::SourceMap) end @@ -558,7 +562,7 @@ module Includer expect(fqns).to eq('Foo::Bar') end - it 'handles multiple type parameters without losing cache coherence' do + it 'understands type parameters' do tag = @api_map.qualify('Array') expect(tag).to eq('Array') tag = @api_map.qualify('Array') @@ -782,18 +786,18 @@ def bar; end end it 'can qualify "Boolean"' do - api_map = Solargraph::ApiMap.new + api_map = described_class.new expect(api_map.qualify('Boolean')).to eq('Boolean') end it 'knows that true is a "subtype" of Boolean' do - api_map = Solargraph::ApiMap.new + api_map = described_class.new expect(api_map.super_and_sub?('Boolean', 'true')).to be(true) end it 'knows that false is a "subtype" of Boolean' do - api_map = Solargraph::ApiMap.new - expect(api_map.super_and_sub?('Boolean', 'true')).to be(true) + api_map = described_class.new + expect(api_map.super_and_sub?('Boolean', 'false')).to be(true) end it 'resolves aliases for YARD methods' do @@ -808,7 +812,7 @@ class Foo alias baz foo end )).pins - # api_map = Solargraph::ApiMap.new(pins: yard_pins + source_pins) + # api_map = described_class.new(pins: yard_pins + source_pins) @api_map.index yard_pins + source_pins baz = @api_map.get_method_stack('Foo', 'baz').first expect(baz).to be_a(Solargraph::Pin::Method) @@ -817,8 +821,10 @@ class Foo it 'ignores malformed mixins' do closure = Solargraph::Pin::Namespace.new(name: 'Foo', closure: Solargraph::Pin::ROOT_PIN, type: :class) - mixin = Solargraph::Pin::Reference::Include.new(name: 'defined?(DidYouMean::SpellChecker) && defined?(DidYouMean::Correctable)', closure: closure) - api_map = Solargraph::ApiMap.new(pins: [closure, mixin]) + mixin = Solargraph::Pin::Reference::Include.new( + name: 'defined?(DidYouMean::SpellChecker) && defined?(DidYouMean::Correctable)', closure: closure + ) + api_map = described_class.new(pins: [closure, mixin]) expect(api_map.get_method_stack('Foo', 'foo')).to be_empty end @@ -839,9 +845,10 @@ def baz end ), 'test.rb') - api_map = Solargraph::ApiMap.new.map(source) + api_map = described_class.new.map(source) clip = api_map.clip_at('test.rb', [11, 10]) expect(clip.infer.to_s).to eq('Symbol') end + # rubocop:enable RSpec/InstanceVariable end From d68f448bf463ab6da007b2917b175dbd2d02c214 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Mon, 21 Jul 2025 10:20:04 -0400 Subject: [PATCH 112/400] Fix RuboCop issues --- .rubocop_todo.yml | 3 +-- lib/solargraph/yardoc.rb | 10 +++++----- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 5ee8f20d0..97a41ccd1 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -2075,7 +2075,7 @@ Style/MapToSet: - 'lib/solargraph/library.rb' - 'spec/source_map/clip_spec.rb' -# Offense count: 202 +# Offense count: 197 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle. # SupportedStyles: require_parentheses, require_no_parentheses, require_no_parentheses_except_multiline @@ -2131,7 +2131,6 @@ Style/MethodDefParentheses: - 'lib/solargraph/type_checker.rb' - 'lib/solargraph/type_checker/checks.rb' - 'lib/solargraph/yard_map/helpers.rb' - - 'lib/solargraph/yardoc.rb' - 'spec/fixtures/rdoc-lib/lib/example.rb' - 'spec/source_map_spec.rb' - 'spec/spec_helper.rb' diff --git a/lib/solargraph/yardoc.rb b/lib/solargraph/yardoc.rb index cbc2af910..e21ae1a00 100644 --- a/lib/solargraph/yardoc.rb +++ b/lib/solargraph/yardoc.rb @@ -13,7 +13,7 @@ module Yardoc # @param gemspec [Gem::Specification] # # @return [void] - def build_docs(gem_yardoc_path, yard_plugins, gemspec) + def build_docs gem_yardoc_path, yard_plugins, gemspec return if docs_built?(gem_yardoc_path) Solargraph.logger.info "Saving yardoc for #{gemspec.name} #{gemspec.version} into #{gem_yardoc_path}" @@ -34,7 +34,7 @@ def build_docs(gem_yardoc_path, yard_plugins, gemspec) # @param gemspec [Gem::Specification] # @param out [IO, nil] where to log messages # @return [Array] - def build_pins(gem_yardoc_path, gemspec, out: $stderr) + def build_pins gem_yardoc_path, gemspec, out: $stderr yardoc = load!(gem_yardoc_path) YardMap::Mapper.new(yardoc, gemspec).map end @@ -42,7 +42,7 @@ def build_pins(gem_yardoc_path, gemspec, out: $stderr) # True if the gem yardoc is cached. # # @param gem_yardoc_path [String] - def docs_built?(gem_yardoc_path) + def docs_built? gem_yardoc_path yardoc = File.join(gem_yardoc_path, 'complete') File.exist?(yardoc) end @@ -50,7 +50,7 @@ def docs_built?(gem_yardoc_path) # True if another process is currently building the yardoc cache. # # @param gem_yardoc_path [String] the path to the yardoc cache of a particular gem - def processing?(gem_yardoc_path) + def processing? gem_yardoc_path yardoc = File.join(gem_yardoc_path, 'processing') File.exist?(yardoc) end @@ -61,7 +61,7 @@ def processing?(gem_yardoc_path) # # @param gem_yardoc_path [String] the path to the yardoc cache of a particular gem # @return [Array] - def load!(gem_yardoc_path) + def load! gem_yardoc_path YARD::Registry.load! gem_yardoc_path YARD::Registry.all end From e08588f910290d30214df3f35b99d2120c97d06a Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Mon, 21 Jul 2025 10:44:23 -0400 Subject: [PATCH 113/400] Add Yardoc spec --- spec/yardoc_spec.rb | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 spec/yardoc_spec.rb diff --git a/spec/yardoc_spec.rb b/spec/yardoc_spec.rb new file mode 100644 index 000000000..50a533dcf --- /dev/null +++ b/spec/yardoc_spec.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +require 'tmpdir' + +describe Solargraph::Yardoc do + describe '#build_docs' do + around do |testobj| + @tmpdir = Dir.mktmpdir + + testobj.run + ensure + FileUtils.remove_entry(@tmpdir) # rubocop:disable RSpec/InstanceVariable + end + + it 'builds docs for a gem' do + gem_yardoc_path = File.join(@tmpdir, 'solargraph', 'yardoc', 'test_gem') # rubocop:disable RSpec/InstanceVariable + api_map = Solargraph::ApiMap.load(Dir.pwd) + gem = api_map.find_gem('rubocop') + described_class.build_docs(gem.gem_yardoc_path, [], gemspec) + expect(File.exist?(File.join(gem_yardoc_path, 'complete'))).to be true + end + end +end From a7cc850ffe8bcd48688fd6722b7aa9db2dbbd08f Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Mon, 21 Jul 2025 10:59:57 -0400 Subject: [PATCH 114/400] Fix spec --- spec/yardoc_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/yardoc_spec.rb b/spec/yardoc_spec.rb index 50a533dcf..2f863cbaa 100644 --- a/spec/yardoc_spec.rb +++ b/spec/yardoc_spec.rb @@ -15,8 +15,8 @@ it 'builds docs for a gem' do gem_yardoc_path = File.join(@tmpdir, 'solargraph', 'yardoc', 'test_gem') # rubocop:disable RSpec/InstanceVariable api_map = Solargraph::ApiMap.load(Dir.pwd) - gem = api_map.find_gem('rubocop') - described_class.build_docs(gem.gem_yardoc_path, [], gemspec) + gemspec = api_map.find_gem('rubocop') + described_class.build_docs(gem_yardoc_path, [], gemspec) expect(File.exist?(File.join(gem_yardoc_path, 'complete'))).to be true end end From 91df9e7f2d8e28ba12e7ab60698f70b14c1a052c Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Mon, 21 Jul 2025 11:17:57 -0400 Subject: [PATCH 115/400] Add more specs --- spec/yardoc_spec.rb | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/spec/yardoc_spec.rb b/spec/yardoc_spec.rb index 2f863cbaa..92d2840ca 100644 --- a/spec/yardoc_spec.rb +++ b/spec/yardoc_spec.rb @@ -12,12 +12,38 @@ FileUtils.remove_entry(@tmpdir) # rubocop:disable RSpec/InstanceVariable end + let(:gem_yardoc_path) do + File.join(@tmpdir, 'solargraph', 'yardoc', 'test_gem') # rubocop:disable RSpec/InstanceVariable + end + + describe '#processing?' do + it 'returns true if the yardoc is being processed' do + gem_yardoc_path = File.join(@tmpdir, 'yardoc') + FileUtils.mkdir_p(gem_yardoc_path) + FileUtils.touch(File.join(gem_yardoc_path, 'processing')) + expect(Solargraph::Yardoc.processing?(gem_yardoc_path)).to be(true) + end + + it 'returns false if the yardoc is not being processed' do + gem_yardoc_path = File.join(@tmpdir, 'yardoc') + FileUtils.mkdir_p(gem_yardoc_path) + expect(Solargraph::Yardoc.processing?(gem_yardoc_path)).to be(false) + end + end + it 'builds docs for a gem' do - gem_yardoc_path = File.join(@tmpdir, 'solargraph', 'yardoc', 'test_gem') # rubocop:disable RSpec/InstanceVariable api_map = Solargraph::ApiMap.load(Dir.pwd) gemspec = api_map.find_gem('rubocop') described_class.build_docs(gem_yardoc_path, [], gemspec) expect(File.exist?(File.join(gem_yardoc_path, 'complete'))).to be true end + + it 'is idempotent' do + api_map = Solargraph::ApiMap.load(Dir.pwd) + gemspec = api_map.find_gem('rubocop') + described_class.build_docs(gem_yardoc_path, [], gemspec) + described_class.build_docs(gem_yardoc_path, [], gemspec) + expect(File.exist?(File.join(gem_yardoc_path, 'complete'))).to be true + end end end From 5c27b7408936398452708f6488a356d4718328c7 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Mon, 21 Jul 2025 11:51:32 -0400 Subject: [PATCH 116/400] Add more specs --- spec/yardoc_spec.rb | 72 +++++++++++++++++++++++++++++---------------- 1 file changed, 47 insertions(+), 25 deletions(-) diff --git a/spec/yardoc_spec.rb b/spec/yardoc_spec.rb index 92d2840ca..84b1b6fb6 100644 --- a/spec/yardoc_spec.rb +++ b/spec/yardoc_spec.rb @@ -1,49 +1,71 @@ # frozen_string_literal: true require 'tmpdir' +require 'open3' describe Solargraph::Yardoc do - describe '#build_docs' do - around do |testobj| - @tmpdir = Dir.mktmpdir + around do |testobj| + @tmpdir = Dir.mktmpdir + + testobj.run + ensure + FileUtils.remove_entry(@tmpdir) # rubocop:disable RSpec/InstanceVariable + end + + let(:gem_yardoc_path) do + File.join(@tmpdir, 'solargraph', 'yardoc', 'test_gem') # rubocop:disable RSpec/InstanceVariable + end - testobj.run - ensure - FileUtils.remove_entry(@tmpdir) # rubocop:disable RSpec/InstanceVariable + before do + FileUtils.mkdir_p(gem_yardoc_path) + end + + describe '#processing?' do + it 'returns true if the yardoc is being processed' do + FileUtils.touch(File.join(gem_yardoc_path, 'processing')) + expect(described_class.processing?(gem_yardoc_path)).to be(true) end - let(:gem_yardoc_path) do - File.join(@tmpdir, 'solargraph', 'yardoc', 'test_gem') # rubocop:disable RSpec/InstanceVariable + it 'returns false if the yardoc is not being processed' do + expect(described_class.processing?(gem_yardoc_path)).to be(false) end + end - describe '#processing?' do - it 'returns true if the yardoc is being processed' do - gem_yardoc_path = File.join(@tmpdir, 'yardoc') - FileUtils.mkdir_p(gem_yardoc_path) - FileUtils.touch(File.join(gem_yardoc_path, 'processing')) - expect(Solargraph::Yardoc.processing?(gem_yardoc_path)).to be(true) - end + describe '#build_docs' do + let(:api_map) { Solargraph::ApiMap.load(Dir.pwd) } + let(:gemspec) { api_map.find_gem('rubocop') } + let(:output) { '' } - it 'returns false if the yardoc is not being processed' do - gem_yardoc_path = File.join(@tmpdir, 'yardoc') - FileUtils.mkdir_p(gem_yardoc_path) - expect(Solargraph::Yardoc.processing?(gem_yardoc_path)).to be(false) - end + before do + allow(Solargraph.logger).to receive(:warn) + allow(Solargraph.logger).to receive(:info) end it 'builds docs for a gem' do - api_map = Solargraph::ApiMap.load(Dir.pwd) - gemspec = api_map.find_gem('rubocop') described_class.build_docs(gem_yardoc_path, [], gemspec) expect(File.exist?(File.join(gem_yardoc_path, 'complete'))).to be true end it 'is idempotent' do - api_map = Solargraph::ApiMap.load(Dir.pwd) - gemspec = api_map.find_gem('rubocop') - described_class.build_docs(gem_yardoc_path, [], gemspec) described_class.build_docs(gem_yardoc_path, [], gemspec) + described_class.build_docs(gem_yardoc_path, [], gemspec) # second time expect(File.exist?(File.join(gem_yardoc_path, 'complete'))).to be true end + + context 'with an error from yard' do + before do + allow(Open3).to receive(:capture2e).and_return([output, result]) + end + + let(:result) { instance_double(Process::Status) } + + it 'does not raise on error from yard' do + allow(result).to receive(:success?).and_return(false) + + expect do + described_class.build_docs(gem_yardoc_path, [], gemspec) + end.not_to raise_error + end + end end end From 4be3f2782e201ef03072cea82344e99e6c4f2f76 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Mon, 21 Jul 2025 12:25:25 -0400 Subject: [PATCH 117/400] Add more specs --- lib/solargraph/workspace/require_paths.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/solargraph/workspace/require_paths.rb b/lib/solargraph/workspace/require_paths.rb index 22b04b40a..07207dfe1 100644 --- a/lib/solargraph/workspace/require_paths.rb +++ b/lib/solargraph/workspace/require_paths.rb @@ -1,5 +1,7 @@ # frozen_string_literal: true +require 'open3' + module Solargraph # A workspace consists of the files in a project's directory and the # project's configuration. It provides a Source for each file to be used From 5400ac812ef6e916288e7e95263c6c53bb8b8049 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Mon, 21 Jul 2025 12:32:55 -0400 Subject: [PATCH 118/400] Add more specs --- spec/workspace/require_paths_spec.rb | 34 ++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 spec/workspace/require_paths_spec.rb diff --git a/spec/workspace/require_paths_spec.rb b/spec/workspace/require_paths_spec.rb new file mode 100644 index 000000000..2f0d9082d --- /dev/null +++ b/spec/workspace/require_paths_spec.rb @@ -0,0 +1,34 @@ +# frozen_string_literal: true + +require 'fileutils' +require 'tmpdir' + +describe Solargraph::Workspace::RequirePaths do + subject(:paths) { described_class.new(dir_path, config).generate } + + let(:config) { Solargraph::Workspace::Config.new(dir_path) } + + context 'with current bundle' do + let(:dir_path) { Dir.pwd } + + it 'includes the lib directory' do + expect(paths).to include(File.join(dir_path, 'lib')) + end + + it 'queried via Open3.capture3' do + allow(Open3).to receive(:capture3).and_call_original + + paths + + expect(Open3).to have_received(:capture3) + end + end + + context 'with no gemspec file' do + let(:dir_path) { File.realpath(Dir.mktmpdir) } + + it 'includes the lib directory' do + expect(paths).to include(File.join(dir_path, 'lib')) + end + end +end From 96f8e2be2df7b40cb76acf29df91180e5da72185 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Mon, 21 Jul 2025 12:33:40 -0400 Subject: [PATCH 119/400] Drop unused method --- lib/solargraph/workspace/require_paths.rb | 7 ------- 1 file changed, 7 deletions(-) diff --git a/lib/solargraph/workspace/require_paths.rb b/lib/solargraph/workspace/require_paths.rb index 07207dfe1..c12b66724 100644 --- a/lib/solargraph/workspace/require_paths.rb +++ b/lib/solargraph/workspace/require_paths.rb @@ -62,13 +62,6 @@ def configured_require_paths config.require_paths.map { |p| File.join(directory, p) } end - # True if the workspace contains at least one gemspec file. - # - # @return [Boolean] - def gemspec? - !gemspec_file_paths.empty? - end - # Generate require paths from gemspecs if they exist or assume the default # lib directory. # From c6655354b4d85137ebcfc3a64c50f8d4f08fbbcf Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Mon, 21 Jul 2025 12:42:19 -0400 Subject: [PATCH 120/400] Add more specs --- spec/shell_spec.rb | 18 ++++++++++++++++++ spec/workspace/require_paths_spec.rb | 8 ++++++++ 2 files changed, 26 insertions(+) diff --git a/spec/shell_spec.rb b/spec/shell_spec.rb index bd0de9042..ec98f7892 100644 --- a/spec/shell_spec.rb +++ b/spec/shell_spec.rb @@ -15,6 +15,8 @@ raise "Failure installing bundle: #{output}" unless status.success? end + # @type cmd [Array] + # @return [String] def bundle_exec(*cmd) # run the command in the temporary directory with bundle exec output, status = Open3.capture2e("bundle exec #{cmd.join(' ')}", chdir: temp_dir) @@ -45,6 +47,14 @@ def bundle_exec(*cmd) expect(output).to include('Clearing pin cache in') end + + it 'uncaches stdlib without erroring out' do + expect { bundle_exec('solargraph', 'uncache', 'stdlib') }.not_to raise_error + end + + it 'uncaches core without erroring out' do + expect { bundle_exec('solargraph', 'uncache', 'core') }.not_to raise_error + end end describe 'gem' do @@ -56,6 +66,14 @@ def bundle_exec(*cmd) end describe 'gems' do + it 'caches a stdlib gem without erroring out' do + expect { bundle_exec('solargraph', 'cache', 'stringio') }.not_to raise_error + end + + it 'caches core without erroring out' do + expect { bundle_exec('solargraph', 'cache', 'core') }.not_to raise_error + end + it 'caches all without erroring out' do output = bundle_exec('solargraph', 'gems') diff --git a/spec/workspace/require_paths_spec.rb b/spec/workspace/require_paths_spec.rb index 2f0d9082d..97cf9c285 100644 --- a/spec/workspace/require_paths_spec.rb +++ b/spec/workspace/require_paths_spec.rb @@ -8,6 +8,14 @@ let(:config) { Solargraph::Workspace::Config.new(dir_path) } + context 'with no config' do + let(:config) { nil } + + it 'includes the lib directory' do + expect(paths).to include(File.join(dir_path, 'lib')) + end + end + context 'with current bundle' do let(:dir_path) { Dir.pwd } From 363b47dfc07d0b00093656b6ef691da1e0cc5a82 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Tue, 22 Jul 2025 16:43:30 -0400 Subject: [PATCH 121/400] Add asserts and RBS collection during overcommit --- .github/workflows/linting.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml index ff46725de..932c901a9 100644 --- a/.github/workflows/linting.yml +++ b/.github/workflows/linting.yml @@ -51,10 +51,13 @@ jobs: path: | /home/runner/.cache/solargraph + - name: Install gem types + run: bundle exec rbs collection install + - name: Overcommit run: | bundle exec overcommit --sign - bundle exec overcommit --run --diff origin/master + SOLARGRAPH_ASSERTS=on bundle exec overcommit --run --diff origin/master rubocop: name: rubocop runs-on: ubuntu-latest From 24698bea906bcd49bb432d5291fa05dac662e34e Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Tue, 22 Jul 2025 16:52:03 -0400 Subject: [PATCH 122/400] Add RBS validate check --- .github/workflows/linting.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml index 932c901a9..fbd80a490 100644 --- a/.github/workflows/linting.yml +++ b/.github/workflows/linting.yml @@ -77,6 +77,23 @@ jobs: fail_level: info rubocop_version: Gemfile level: info + rbs_validate: + name: rbs validate + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: 3.4 + bundler-cache: false + + - name: Install gems + run: bundle install + + - name: Run rbs validate + run: bundle exec rbs validate rubocop_todo: name: .rubocop_todo.yml runs-on: ubuntu-latest From d48e4970d8375222f2b5df497ab260c12635e7ce Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Tue, 22 Jul 2025 20:49:22 -0400 Subject: [PATCH 123/400] Fix spec --- spec/workspace/require_paths_spec.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spec/workspace/require_paths_spec.rb b/spec/workspace/require_paths_spec.rb index 97cf9c285..0b57432a9 100644 --- a/spec/workspace/require_paths_spec.rb +++ b/spec/workspace/require_paths_spec.rb @@ -4,11 +4,13 @@ require 'tmpdir' describe Solargraph::Workspace::RequirePaths do + subject(:paths) { described_class.new(dir_path, config).generate } let(:config) { Solargraph::Workspace::Config.new(dir_path) } context 'with no config' do + let(:dir_path) { Dir.pwd } let(:config) { nil } it 'includes the lib directory' do From e17f7d731a3cceeb983b7fbff335770935ffe32e Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Tue, 22 Jul 2025 20:51:24 -0400 Subject: [PATCH 124/400] Fix annotations --- lib/solargraph/parser/parser_gem/class_methods.rb | 7 ------- lib/solargraph/pin_cache.rb | 1 - lib/solargraph/shell.rb | 2 -- lib/solargraph/workspace.rb | 1 - lib/solargraph/workspace/gemspecs.rb | 5 ----- lib/solargraph/workspace/require_paths.rb | 1 - lib/solargraph/yardoc.rb | 2 -- 7 files changed, 19 deletions(-) diff --git a/lib/solargraph/parser/parser_gem/class_methods.rb b/lib/solargraph/parser/parser_gem/class_methods.rb index f86759c04..cb4f6fc72 100644 --- a/lib/solargraph/parser/parser_gem/class_methods.rb +++ b/lib/solargraph/parser/parser_gem/class_methods.rb @@ -59,9 +59,6 @@ def references source, name # @return [Array(Integer, Integer), Array(nil, nil)] extract_offset = ->(code, offset) { [soff = code.index(name, offset), soff + name.length] } end - # @sg-ignore Wrong argument type for - # Solargraph::Parser::ParserGem::ClassMethods#inner_node_references: - # top expected AST::Node, received Parser::AST::Node, nil inner_node_references(name, source.node).map do |n| rng = Range.from_node(n) offset = Position.to_offset(source.code, rng.start) @@ -131,9 +128,6 @@ def node_range node # @param node [Parser::AST::Node] # @return [Array] def string_ranges node - # @sg-ignore Wrong argument type for - # Solargraph::Parser::ParserGem::ClassMethods#is_ast_node?: - # node expected Object, received Parser::AST::Node return [] unless is_ast_node?(node) result = [] if node.type == :str @@ -144,7 +138,6 @@ def string_ranges node end if node.type == :dstr && node.children.last.nil? last = node.children[-2] - # @sg-ignore Unresolved call to nil? unless last.nil? rng = Range.from_node(last) pos = Position.new(rng.ending.line, rng.ending.column - 1) diff --git a/lib/solargraph/pin_cache.rb b/lib/solargraph/pin_cache.rb index 14da097e4..a12a672aa 100644 --- a/lib/solargraph/pin_cache.rb +++ b/lib/solargraph/pin_cache.rb @@ -21,7 +21,6 @@ def initialize(rbs_collection_path:, rbs_collection_config_path:, @yard_plugins = yard_plugins end - # @sg-ignore # @param gemspec [Gem::Specification, Bundler::LazySpecification] def cached?(gemspec) rbs_version_cache_key = lookup_rbs_version_cache_key(gemspec) diff --git a/lib/solargraph/shell.rb b/lib/solargraph/shell.rb index bb93446f6..5b6028a11 100755 --- a/lib/solargraph/shell.rb +++ b/lib/solargraph/shell.rb @@ -67,7 +67,6 @@ def stdio def config(directory = '.') matches = [] if options[:extensions] - # @sg-ignore Unresolved call to each Gem::Specification.each do |g| if g.name.match(/^solargraph\-[A-Za-z0-9_\-]*?\-ext/) require g.name @@ -82,7 +81,6 @@ def config(directory = '.') end end File.open(File.join(directory, '.solargraph.yml'), 'w') do |file| - # @sg-ignore Unresolved call to to_yaml file.puts conf.to_yaml end STDOUT.puts "Configuration file initialized." diff --git a/lib/solargraph/workspace.rb b/lib/solargraph/workspace.rb index a4a29f45e..b037ab2fc 100644 --- a/lib/solargraph/workspace.rb +++ b/lib/solargraph/workspace.rb @@ -264,7 +264,6 @@ def require_plugins def read_rbs_collection_path return unless rbs_collection_config_path - # @sg-ignore Unresolved call to load_file path = YAML.load_file(rbs_collection_config_path)&.fetch('path') # make fully qualified File.expand_path(path, directory) diff --git a/lib/solargraph/workspace/gemspecs.rb b/lib/solargraph/workspace/gemspecs.rb index aa203e43a..465e0f3d5 100644 --- a/lib/solargraph/workspace/gemspecs.rb +++ b/lib/solargraph/workspace/gemspecs.rb @@ -128,7 +128,6 @@ def self.gem_specification_cache private # @param specish [Gem::Specification, Bundler::LazySpecification, Bundler::StubSpecification] - # @sg-ignore # @return [Gem::Specification, nil] def to_gem_specification specish # print time including milliseconds @@ -172,7 +171,6 @@ def query_external_bundle command 'ruby', '-e', "require 'bundler'; require 'json'; Dir.chdir('#{directory}') { puts #{command}.to_json }" ] - # @sg-ignore Unresolved call to capture3 o, e, s = Open3.capture3(*cmd) if s.success? Solargraph.logger.debug "External bundle: #{o}" @@ -226,9 +224,6 @@ def auto_required_gemspecs_from_this_bundle all_gemspecs_from_bundle.select { |gemspec| dep_names.include?(gemspec.name) } end - # @sg-ignore - # Solargraph::Workspace::Gemspecs#auto_required_gemspecs_from_external_bundle - # return type could not be inferred # @return [Array] def auto_required_gemspecs_from_external_bundle @auto_required_gemspecs_from_external_bundle ||= diff --git a/lib/solargraph/workspace/require_paths.rb b/lib/solargraph/workspace/require_paths.rb index c12b66724..18364b141 100644 --- a/lib/solargraph/workspace/require_paths.rb +++ b/lib/solargraph/workspace/require_paths.rb @@ -78,7 +78,6 @@ def require_path_from_gemspec_file gemspec_file_path "spec = eval(File.read('#{gemspec_file_path}'), TOPLEVEL_BINDING, '#{gemspec_file_path}'); " \ 'return unless Gem::Specification === spec; ' \ 'puts({name: spec.name, paths: spec.require_paths}.to_json)'] - # @sg-ignore Unresolved call to capture3 o, e, s = Open3.capture3(*cmd) if s.success? begin diff --git a/lib/solargraph/yardoc.rb b/lib/solargraph/yardoc.rb index e21ae1a00..8f9c2f04d 100644 --- a/lib/solargraph/yardoc.rb +++ b/lib/solargraph/yardoc.rb @@ -22,8 +22,6 @@ def build_docs gem_yardoc_path, yard_plugins, gemspec Solargraph.logger.debug { "Running: #{cmd}" } # @todo set these up to run in parallel # - # @sg-ignore RBS gem doesn't reflect that Open3.* also include - # kwopts from Process.spawn() stdout_and_stderr_str, status = Open3.capture2e(cmd, chdir: gemspec.gem_dir) return if status.success? Solargraph.logger.warn { "YARD failed running #{cmd.inspect} in #{gemspec.gem_dir}" } From f8f86bcea08b12d7f24923578d9fb2e55d6ee453 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Tue, 22 Jul 2025 23:22:10 -0400 Subject: [PATCH 125/400] Support YAML stdlib requires --- lib/solargraph/api_map.rb | 9 +++++++-- lib/solargraph/api_map/store.rb | 7 ++++++- lib/solargraph/rbs_map.rb | 15 ++++++++++----- lib/solargraph/rbs_map/stdlib_map.rb | 15 ++++++++++++++- lib/solargraph/workspace/gemspecs.rb | 21 ++++++++++++++------- 5 files changed, 51 insertions(+), 16 deletions(-) diff --git a/lib/solargraph/api_map.rb b/lib/solargraph/api_map.rb index 1998f67b3..95a1a13de 100755 --- a/lib/solargraph/api_map.rb +++ b/lib/solargraph/api_map.rb @@ -550,6 +550,11 @@ def get_method_stack rooted_tag, name, scope: :instance, visibility: [:private, namespace_pin = store.get_path_pins(fqns).select { |p| p.is_a?(Pin::Namespace) }.first methods = get_methods(rooted_tag, scope: scope, visibility: visibility).select { |p| p.name == name } methods = erase_generics(namespace_pin, rooted_type, methods) unless preserve_generics + if methods.empty? && namespace_pin.nil? + # namespace may be set by an alias + constant = store.constant_pins.find { |c| c.name == fqns && visibility.include?(c.visibility) } + return get_method_stack(constant.return_type.tag, name, scope: scope, visibility: visibility, preserve_generics: preserve_generics) if constant + end methods end @@ -558,7 +563,7 @@ def get_method_stack rooted_tag, name, scope: :instance, visibility: [:private, # @deprecated Use #get_path_pins instead. # # @param path [String] The path to find - # @return [Enumerable] + # @return [Array] def get_path_suggestions path return [] if path.nil? resolve_method_aliases store.get_path_pins(path) @@ -567,7 +572,7 @@ def get_path_suggestions path # Get an array of pins that match the specified path. # # @param path [String] - # @return [Enumerable] + # @return [Array] def get_path_pins path get_path_suggestions(path) end diff --git a/lib/solargraph/api_map/store.rb b/lib/solargraph/api_map/store.rb index 47f92194c..7079a0a37 100644 --- a/lib/solargraph/api_map/store.rb +++ b/lib/solargraph/api_map/store.rb @@ -49,7 +49,7 @@ def inspect # @param fqns [String] # @param visibility [Array] - # @return [Enumerable] + # @return [Enumerable] def get_constants fqns, visibility = [:public] namespace_children(fqns).select { |pin| !pin.name.empty? && (pin.is_a?(Pin::Namespace) || pin.is_a?(Pin::Constant)) && visibility.include?(pin.visibility) @@ -142,6 +142,11 @@ def namespace_pins pins_by_class(Solargraph::Pin::Namespace) end + # @return [Enumerable] + def constant_pins + pins_by_class(Solargraph::Pin::Constant) + end + # @return [Enumerable] def method_pins pins_by_class(Solargraph::Pin::Method) diff --git a/lib/solargraph/rbs_map.rb b/lib/solargraph/rbs_map.rb index 263f9f2dd..45bb7c3b2 100644 --- a/lib/solargraph/rbs_map.rb +++ b/lib/solargraph/rbs_map.rb @@ -64,9 +64,10 @@ def self.rbs_source_desc cache_key # for the given library. Must change when the RBS info is # updated upstream for the same library and version. May change # if the config for where information comes form changes. - # @sg-ignore Solargraph::RbsMap#cache_key return type could not be inferred def cache_key @hextdigest ||= begin + return CACHE_KEY_UNRESOLVED unless resolved? + data = nil # @type gem_config [nil, Hash{String => Hash{String => String}}] gem_config = nil @@ -79,7 +80,7 @@ def cache_key end end if gem_config.nil? - CACHE_KEY_UNRESOLVED + CACHE_KEY_STDLIB else # @type [String] source = gem_config.dig('source', 'type') @@ -108,9 +109,13 @@ def self.from_gemspec gemspec, rbs_collection_path, rbs_collection_config_path return rbs_map if rbs_map.resolved? # try any version of the gem in the collection - RbsMap.new(gemspec.name, nil, - rbs_collection_paths: [rbs_collection_path].compact, - rbs_collection_config_path: rbs_collection_config_path) + rbs_map = RbsMap.new(gemspec.name, nil, + rbs_collection_paths: [rbs_collection_path].compact, + rbs_collection_config_path: rbs_collection_config_path) + + return rbs_map if rbs_map.resolved? + + StdlibMap.new(gemspec.name) end # @param out [IO, nil] where to log messages diff --git a/lib/solargraph/rbs_map/stdlib_map.rb b/lib/solargraph/rbs_map/stdlib_map.rb index 89142b429..7794ace5f 100644 --- a/lib/solargraph/rbs_map/stdlib_map.rb +++ b/lib/solargraph/rbs_map/stdlib_map.rb @@ -29,7 +29,7 @@ def initialize library, out: $stderr super unless resolved? @pins = [] - logger.info { "Could not resolve #{library.inspect}" } + logger.debug { "StdlibMap could not resolve #{library.inspect}" } return end generated_pins = pins @@ -38,6 +38,19 @@ def initialize library, out: $stderr end end + def self.source + @source ||= RBS::Collection::Sources::Stdlib.instance + end + + # @return [Array String}>, nil] + def self.stdlib_dependencies(name, version) + if source.has?(name, version) + source.dependencies_of(name, version) + else + [] + end + end + # @param library [String] # @return [StdlibMap] def self.load library diff --git a/lib/solargraph/workspace/gemspecs.rb b/lib/solargraph/workspace/gemspecs.rb index 465e0f3d5..d72d97f41 100644 --- a/lib/solargraph/workspace/gemspecs.rb +++ b/lib/solargraph/workspace/gemspecs.rb @@ -1,5 +1,6 @@ # frozen_string_literal: true +require 'rubygems' require 'bundler' module Solargraph @@ -82,10 +83,7 @@ def find_gem name, version gemspec = all_gemspecs_from_bundle.find { |gemspec| gemspec.name == name && gemspec.version == version } return gemspec if gemspec - Gem::Specification.find_by_name(name, version) - rescue Gem::MissingSpecError - logger.warn "Please install the gem #{name}:#{version} in Solargraph's Ruby environment" - nil + resolve_gem_ignoring_local_bundle name, version end # @param gemspec [Gem::Specification] @@ -95,7 +93,7 @@ def fetch_dependencies gemspec # @param runtime_dep [Gem::Dependency] # @param deps [Set] - only_runtime_dependencies(gemspec).each_with_object(Set.new) do |runtime_dep, deps| + gem_dep_gemspecs = only_runtime_dependencies(gemspec).each_with_object(Set.new) do |runtime_dep, deps| Solargraph.logger.info "Adding #{runtime_dep.name} dependency for #{gemspec.name}" dep = gemspecs.find { |dep| dep.name == runtime_dep.name } dep ||= Gem::Specification.find_by_name(runtime_dep.name, runtime_dep.requirement) @@ -105,6 +103,11 @@ def fetch_dependencies gemspec "for #{gemspec.name} not found in bundle.") nil end.to_a.compact + # RBS tracks implicit dependencies, like how the YAML standard + # library implies pulling in the psych library. + stdlib_deps = RbsMap::StdlibMap.stdlib_dependencies(gemspec.name, gemspec.version) || [] + stdlib_dep_gemspecs = stdlib_deps.map { |dep| find_gem(dep['name'], dep['version']) }.compact + (gem_dep_gemspecs + stdlib_dep_gemspecs).sort.uniq end # Returns all gemspecs directly depended on by this workspace's @@ -127,6 +130,7 @@ def self.gem_specification_cache private + # @sg-ignore # @param specish [Gem::Specification, Bundler::LazySpecification, Bundler::StubSpecification] # @return [Gem::Specification, nil] def to_gem_specification specish @@ -261,8 +265,11 @@ def resolve_gem_ignoring_local_bundle name, version begin Gem::Specification.find_by_name(name) rescue Gem::MissingSpecError - logger.warn "Please install the gem #{name}:#{version} in Solargraph's Ruby environment" - nil + stdlibmap = RbsMap::StdlibMap.new(name) + if !stdlibmap.resolved? + logger.warn "Please install the gem #{name}:#{version} in Solargraph's Ruby environment" + end + nil # either not here or in stdlib end end From b284720c79e7a8d4cb6893db3733e15baeb68939 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Wed, 23 Jul 2025 07:00:22 -0400 Subject: [PATCH 126/400] Fix annotations --- lib/solargraph/rbs_map/stdlib_map.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/solargraph/rbs_map/stdlib_map.rb b/lib/solargraph/rbs_map/stdlib_map.rb index 7794ace5f..92f68a013 100644 --- a/lib/solargraph/rbs_map/stdlib_map.rb +++ b/lib/solargraph/rbs_map/stdlib_map.rb @@ -38,10 +38,13 @@ def initialize library, out: $stderr end end + # @return [RBS::Collection::Sources::Stdlib] def self.source @source ||= RBS::Collection::Sources::Stdlib.instance end + # @param name [String] + # @param version [String] # @return [Array String}>, nil] def self.stdlib_dependencies(name, version) if source.has?(name, version) From 01f55803cd911b250a14043fb9c4e99a945c095c Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Wed, 23 Jul 2025 07:02:07 -0400 Subject: [PATCH 127/400] Fix merge --- lib/solargraph/yardoc.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/solargraph/yardoc.rb b/lib/solargraph/yardoc.rb index 8f9c2f04d..9701018cf 100644 --- a/lib/solargraph/yardoc.rb +++ b/lib/solargraph/yardoc.rb @@ -22,6 +22,7 @@ def build_docs gem_yardoc_path, yard_plugins, gemspec Solargraph.logger.debug { "Running: #{cmd}" } # @todo set these up to run in parallel # + # @sg-ignore stdout_and_stderr_str, status = Open3.capture2e(cmd, chdir: gemspec.gem_dir) return if status.success? Solargraph.logger.warn { "YARD failed running #{cmd.inspect} in #{gemspec.gem_dir}" } From 9786b51cae593d52757a423b7cec0cc1e3bb5f4d Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Wed, 23 Jul 2025 07:19:23 -0400 Subject: [PATCH 128/400] RuboCop fixes --- lib/solargraph/rbs_map/stdlib_map.rb | 2 +- lib/solargraph/workspace/gemspecs.rb | 2 +- spec/workspace/require_paths_spec.rb | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/solargraph/rbs_map/stdlib_map.rb b/lib/solargraph/rbs_map/stdlib_map.rb index 92f68a013..d254b03e8 100644 --- a/lib/solargraph/rbs_map/stdlib_map.rb +++ b/lib/solargraph/rbs_map/stdlib_map.rb @@ -46,7 +46,7 @@ def self.source # @param name [String] # @param version [String] # @return [Array String}>, nil] - def self.stdlib_dependencies(name, version) + def self.stdlib_dependencies name, version if source.has?(name, version) source.dependencies_of(name, version) else diff --git a/lib/solargraph/workspace/gemspecs.rb b/lib/solargraph/workspace/gemspecs.rb index d72d97f41..8de2c785b 100644 --- a/lib/solargraph/workspace/gemspecs.rb +++ b/lib/solargraph/workspace/gemspecs.rb @@ -266,7 +266,7 @@ def resolve_gem_ignoring_local_bundle name, version Gem::Specification.find_by_name(name) rescue Gem::MissingSpecError stdlibmap = RbsMap::StdlibMap.new(name) - if !stdlibmap.resolved? + unless stdlibmap.resolved? logger.warn "Please install the gem #{name}:#{version} in Solargraph's Ruby environment" end nil # either not here or in stdlib diff --git a/spec/workspace/require_paths_spec.rb b/spec/workspace/require_paths_spec.rb index 0b57432a9..db5516447 100644 --- a/spec/workspace/require_paths_spec.rb +++ b/spec/workspace/require_paths_spec.rb @@ -4,7 +4,6 @@ require 'tmpdir' describe Solargraph::Workspace::RequirePaths do - subject(:paths) { described_class.new(dir_path, config).generate } let(:config) { Solargraph::Workspace::Config.new(dir_path) } From bbed2fe8cdddabb8aa3c3a0517df0bcc2867dbab Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Wed, 23 Jul 2025 07:26:34 -0400 Subject: [PATCH 129/400] Fix typechecking errors --- lib/solargraph/api_map/index.rb | 3 +++ lib/solargraph/api_map/store.rb | 7 ++++++- lib/solargraph/workspace/require_paths.rb | 1 + 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/solargraph/api_map/index.rb b/lib/solargraph/api_map/index.rb index 810600534..7490769f0 100644 --- a/lib/solargraph/api_map/index.rb +++ b/lib/solargraph/api_map/index.rb @@ -15,6 +15,9 @@ def pins @pins ||= [] end + # @return [Set>, nil] + attr_reader :namespaces + # @return [Hash{String => Array}] def namespace_hash @namespace_hash ||= Hash.new { |h, k| h[k] = [] } diff --git a/lib/solargraph/api_map/store.rb b/lib/solargraph/api_map/store.rb index 7079a0a37..3e453bb35 100644 --- a/lib/solargraph/api_map/store.rb +++ b/lib/solargraph/api_map/store.rb @@ -16,7 +16,7 @@ def pins index.pins end - # @param pinsets [Array>] + # @param pinsets [Array>] # @return [Boolean] True if the index was updated def update *pinsets return catalog(pinsets) if pinsets.length != @pinsets.length @@ -205,12 +205,17 @@ def fqns_pins fqns private + # @return [Index] def index @indexes.last end + # @param pinsets [Array>] + # + # @return [void] def catalog pinsets @pinsets = pinsets + # @type [Array] @indexes = [] pinsets.each do |pins| if @indexes.last && pins.empty? diff --git a/lib/solargraph/workspace/require_paths.rb b/lib/solargraph/workspace/require_paths.rb index 18364b141..443752084 100644 --- a/lib/solargraph/workspace/require_paths.rb +++ b/lib/solargraph/workspace/require_paths.rb @@ -78,6 +78,7 @@ def require_path_from_gemspec_file gemspec_file_path "spec = eval(File.read('#{gemspec_file_path}'), TOPLEVEL_BINDING, '#{gemspec_file_path}'); " \ 'return unless Gem::Specification === spec; ' \ 'puts({name: spec.name, paths: spec.require_paths}.to_json)'] + # @sg-ignore o, e, s = Open3.capture3(*cmd) if s.success? begin From 75c11b97b8c38e7546cdc4201f0e6ab565708801 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Wed, 23 Jul 2025 07:28:03 -0400 Subject: [PATCH 130/400] Fix typecheck and rubocop issues --- lib/solargraph/rbs_map.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/solargraph/rbs_map.rb b/lib/solargraph/rbs_map.rb index 45bb7c3b2..613719e90 100644 --- a/lib/solargraph/rbs_map.rb +++ b/lib/solargraph/rbs_map.rb @@ -60,14 +60,15 @@ def self.rbs_source_desc cache_key end end + # @sg-ignore # @return [String] representing the version of the RBS info fetched # for the given library. Must change when the RBS info is # updated upstream for the same library and version. May change # if the config for where information comes form changes. def cache_key - @hextdigest ||= begin - return CACHE_KEY_UNRESOLVED unless resolved? + return CACHE_KEY_UNRESOLVED unless resolved? + @hextdigest ||= begin data = nil # @type gem_config [nil, Hash{String => Hash{String => String}}] gem_config = nil From 4fa1a3aea1891115fac8e2787a58b3b2f132d25c Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Wed, 23 Jul 2025 07:30:44 -0400 Subject: [PATCH 131/400] Fix rubocop issues --- .rubocop_todo.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 97a41ccd1..53f64fc3c 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1231,12 +1231,6 @@ RSpec/LetBeforeExamples: Exclude: - 'spec/complex_type_spec.rb' -# Offense count: 3 -# Configuration parameters: . -# SupportedStyles: have_received, receive -RSpec/MessageSpies: - EnforcedStyle: receive - # Offense count: 2 RSpec/MissingExampleGroupArgument: Exclude: From 7d1d0be2d64fe1d8a1edd17eabbe9e7f9a9ad6a1 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Wed, 23 Jul 2025 07:36:54 -0400 Subject: [PATCH 132/400] Fix RuboCop issues --- spec/doc_map_spec.rb | 3 ++- spec/language_server/host/diagnoser_spec.rb | 3 ++- spec/language_server/host/message_worker_spec.rb | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/spec/doc_map_spec.rb b/spec/doc_map_spec.rb index 751b40b37..a6f52d033 100644 --- a/spec/doc_map_spec.rb +++ b/spec/doc_map_spec.rb @@ -76,8 +76,9 @@ it 'does not warn' do # Requiring 'set' is unnecessary because it's already included in core. It # might make sense to log redundant requires, but a warning is overkill. - expect(Solargraph.logger).not_to receive(:warn).with(/path set/) + allow(Solargraph.logger).to receive(:warn) doc_map + expect(Solargraph.logger).not_to have_received(:warn).with(/path set/) end end diff --git a/spec/language_server/host/diagnoser_spec.rb b/spec/language_server/host/diagnoser_spec.rb index d59a843f1..69ee0b866 100644 --- a/spec/language_server/host/diagnoser_spec.rb +++ b/spec/language_server/host/diagnoser_spec.rb @@ -3,7 +3,8 @@ host = double(Solargraph::LanguageServer::Host, options: { 'diagnostics' => true }, synchronizing?: false) diagnoser = Solargraph::LanguageServer::Host::Diagnoser.new(host) diagnoser.schedule 'file.rb' - expect(host).to receive(:diagnose).with('file.rb') + allow(host).to receive(:diagnose) diagnoser.tick + expect(host).to have_received(:diagnose).with('file.rb') end end diff --git a/spec/language_server/host/message_worker_spec.rb b/spec/language_server/host/message_worker_spec.rb index b9ce2a41f..9e5ce5721 100644 --- a/spec/language_server/host/message_worker_spec.rb +++ b/spec/language_server/host/message_worker_spec.rb @@ -2,11 +2,12 @@ it "handle requests on queue" do host = double(Solargraph::LanguageServer::Host) message = {'method' => '$/example'} - expect(host).to receive(:receive).with(message).and_return(nil) + allow(host).to receive(:receive).with(message).and_return(nil) worker = Solargraph::LanguageServer::Host::MessageWorker.new(host) worker.queue(message) expect(worker.messages).to eq [message] worker.tick + expect(host).to have_received(:receive).with(message) end end From ee7091a6aa751b7a3be98c4106475df8fb02f5d1 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Wed, 23 Jul 2025 07:42:44 -0400 Subject: [PATCH 133/400] Fix spec --- lib/solargraph/workspace/gemspecs.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/solargraph/workspace/gemspecs.rb b/lib/solargraph/workspace/gemspecs.rb index 8de2c785b..952937c68 100644 --- a/lib/solargraph/workspace/gemspecs.rb +++ b/lib/solargraph/workspace/gemspecs.rb @@ -107,7 +107,7 @@ def fetch_dependencies gemspec # library implies pulling in the psych library. stdlib_deps = RbsMap::StdlibMap.stdlib_dependencies(gemspec.name, gemspec.version) || [] stdlib_dep_gemspecs = stdlib_deps.map { |dep| find_gem(dep['name'], dep['version']) }.compact - (gem_dep_gemspecs + stdlib_dep_gemspecs).sort.uniq + (gem_dep_gemspecs + stdlib_dep_gemspecs).uniq(&:name) end # Returns all gemspecs directly depended on by this workspace's From 78d71470379fe5dc118402be40786f945c667f0b Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Wed, 23 Jul 2025 07:50:52 -0400 Subject: [PATCH 134/400] Annotation fixes --- lib/solargraph/api_map/index.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/solargraph/api_map/index.rb b/lib/solargraph/api_map/index.rb index 7490769f0..01820a441 100644 --- a/lib/solargraph/api_map/index.rb +++ b/lib/solargraph/api_map/index.rb @@ -39,6 +39,7 @@ def path_pin_hash def pins_by_class klass # @type [Set] s = Set.new + # @sg-ignore Need to handle block parameter destructuring @pin_select_cache[klass] ||= pin_class_hash.each_with_object(s) { |(key, o), n| n.merge(o) if key <= klass } end @@ -63,6 +64,7 @@ def superclass_references end # @param pins [Array] + # @return [self] def merge pins deep_clone.catalog pins end @@ -72,6 +74,7 @@ def merge pins attr_writer :pins, :pin_select_cache, :namespace_hash, :pin_class_hash, :path_pin_hash, :include_references, :extend_references, :prepend_references, :superclass_references + # @return [self] def deep_clone Index.allocate.tap do |copy| copy.pin_select_cache = {} @@ -87,6 +90,8 @@ def deep_clone end # @param new_pins [Array] + # + # @return [self] def catalog new_pins @pin_select_cache = {} pins.concat new_pins From 3df4a6b2caf1d5ab343f40354a17866079c99cb2 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Wed, 23 Jul 2025 07:51:25 -0400 Subject: [PATCH 135/400] Deal with type issue --- lib/solargraph/workspace/gemspecs.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/solargraph/workspace/gemspecs.rb b/lib/solargraph/workspace/gemspecs.rb index 952937c68..5c3ef292e 100644 --- a/lib/solargraph/workspace/gemspecs.rb +++ b/lib/solargraph/workspace/gemspecs.rb @@ -175,6 +175,7 @@ def query_external_bundle command 'ruby', '-e', "require 'bundler'; require 'json'; Dir.chdir('#{directory}') { puts #{command}.to_json }" ] + # @sg-ignore o, e, s = Open3.capture3(*cmd) if s.success? Solargraph.logger.debug "External bundle: #{o}" From 841097762b688c7ad2beaaa55402f335e0256501 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Wed, 23 Jul 2025 08:11:09 -0400 Subject: [PATCH 136/400] RuboCop fixes to keep todo file under control --- .rubocop_todo.yml | 22 +++------------- lib/solargraph/api_map.rb | 25 ++++++++++++------- lib/solargraph/api_map/index.rb | 4 +-- lib/solargraph/api_map/store.rb | 2 +- lib/solargraph/gem_pins.rb | 8 ++++-- lib/solargraph/library.rb | 16 ++++++------ .../parser/parser_gem/class_methods.rb | 8 +++--- lib/solargraph/rbs_map.rb | 8 +++--- lib/solargraph/shell.rb | 14 ++++++----- lib/solargraph/workspace.rb | 9 ++++--- spec/workspace_spec.rb | 3 ++- 11 files changed, 58 insertions(+), 61 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 53f64fc3c..023e4ea1a 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -264,22 +264,18 @@ Layout/HeredocIndentation: - 'spec/rbs_map/conversions_spec.rb' - 'spec/yard_map/mapper/to_method_spec.rb' -# Offense count: 24 +# Offense count: 19 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: Width, AllowedPatterns. Layout/IndentationWidth: Exclude: - 'lib/solargraph.rb' - - 'lib/solargraph/api_map/store.rb' - 'lib/solargraph/diagnostics/rubocop.rb' - 'lib/solargraph/language_server/message/extended/check_gem_version.rb' - - 'lib/solargraph/library.rb' - 'lib/solargraph/parser/parser_gem/node_methods.rb' - 'lib/solargraph/parser/parser_gem/node_processors/block_node.rb' - 'lib/solargraph/pin/method.rb' - 'lib/solargraph/pin/namespace.rb' - - 'lib/solargraph/rbs_map.rb' - - 'lib/solargraph/shell.rb' - 'lib/solargraph/source/chain/call.rb' - 'lib/solargraph/source_map/clip.rb' - 'lib/solargraph/source_map/mapper.rb' @@ -1392,11 +1388,6 @@ RSpec/ScatteredLet: Exclude: - 'spec/complex_type_spec.rb' -# Offense count: 1 -RSpec/StubbedMock: - Exclude: - - 'spec/language_server/host/message_worker_spec.rb' - # Offense count: 23 # Configuration parameters: IgnoreNameless, IgnoreSymbolicNames. RSpec/VerifiedDoubles: @@ -2001,20 +1992,16 @@ Style/IfInsideElse: - 'lib/solargraph/source_map/clip.rb' - 'lib/solargraph/type_checker.rb' -# Offense count: 62 +# Offense count: 56 # This cop supports safe autocorrection (--autocorrect). Style/IfUnlessModifier: Exclude: - - 'lib/solargraph/api_map.rb' - - 'lib/solargraph/api_map/index.rb' - 'lib/solargraph/complex_type.rb' - 'lib/solargraph/complex_type/unique_type.rb' - 'lib/solargraph/language_server/message/completion_item/resolve.rb' - 'lib/solargraph/language_server/message/initialize.rb' - 'lib/solargraph/language_server/message/text_document/completion.rb' - 'lib/solargraph/language_server/message/text_document/hover.rb' - - 'lib/solargraph/library.rb' - - 'lib/solargraph/parser/parser_gem/class_methods.rb' - 'lib/solargraph/parser/parser_gem/node_chainer.rb' - 'lib/solargraph/parser/parser_gem/node_methods.rb' - 'lib/solargraph/parser/parser_gem/node_processors/sclass_node.rb' @@ -2035,7 +2022,6 @@ Style/IfUnlessModifier: - 'lib/solargraph/source_map/clip.rb' - 'lib/solargraph/source_map/mapper.rb' - 'lib/solargraph/type_checker.rb' - - 'lib/solargraph/workspace.rb' - 'lib/solargraph/workspace/config.rb' - 'lib/solargraph/yard_map/helpers.rb' - 'lib/solargraph/yard_map/mapper/to_method.rb' @@ -2777,7 +2763,7 @@ YARD/TagTypeSyntax: - 'lib/solargraph/parser/comment_ripper.rb' - 'lib/solargraph/type_checker.rb' -# Offense count: 185 +# Offense count: 178 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: Max, AllowHeredoc, AllowURI, AllowQualifiedName, URISchemes, IgnoreCopDirectives, AllowedPatterns, SplitStrings. # URISchemes: http, https @@ -2833,7 +2819,6 @@ Layout/LineLength: - 'lib/solargraph/source_map/clip.rb' - 'lib/solargraph/source_map/mapper.rb' - 'lib/solargraph/type_checker.rb' - - 'lib/solargraph/workspace.rb' - 'lib/solargraph/workspace/config.rb' - 'lib/solargraph/yard_map/mapper/to_method.rb' - 'spec/complex_type_spec.rb' @@ -2845,4 +2830,3 @@ Layout/LineLength: - 'spec/source/chain_spec.rb' - 'spec/source_map/clip_spec.rb' - 'spec/source_map_spec.rb' - - 'spec/workspace_spec.rb' diff --git a/lib/solargraph/api_map.rb b/lib/solargraph/api_map.rb index 95a1a13de..28ff32c10 100755 --- a/lib/solargraph/api_map.rb +++ b/lib/solargraph/api_map.rb @@ -544,7 +544,8 @@ def get_complex_type_methods complex_type, context = '', internal = false # @param preserve_generics [Boolean] True to preserve any # unresolved generic parameters, false to erase them # @return [Array] - def get_method_stack rooted_tag, name, scope: :instance, visibility: [:private, :protected, :public], preserve_generics: false + def get_method_stack rooted_tag, name, scope: :instance, visibility: [:private, :protected, :public], + preserve_generics: false rooted_type = ComplexType.parse(rooted_tag) fqns = rooted_type.namespace namespace_pin = store.get_path_pins(fqns).select { |p| p.is_a?(Pin::Namespace) }.first @@ -553,7 +554,10 @@ def get_method_stack rooted_tag, name, scope: :instance, visibility: [:private, if methods.empty? && namespace_pin.nil? # namespace may be set by an alias constant = store.constant_pins.find { |c| c.name == fqns && visibility.include?(c.visibility) } - return get_method_stack(constant.return_type.tag, name, scope: scope, visibility: visibility, preserve_generics: preserve_generics) if constant + if constant + return get_method_stack(constant.return_type.tag, name, scope: scope, visibility: visibility, + preserve_generics: preserve_generics) + end end methods end @@ -694,7 +698,9 @@ def resolve_method_aliases pins, visibility = [:public, :private, :protected] next nil if resolved.respond_to?(:visibility) && !visibility.include?(resolved.visibility) resolved end.compact - logger.debug { "ApiMap#resolve_method_aliases(pins=#{pins.map(&:name)}, visibility=#{visibility}) => #{with_resolved_aliases.map(&:name)}" } + logger.debug do + "ApiMap#resolve_method_aliases(pins=#{pins.map(&:name)}, visibility=#{visibility}) => #{with_resolved_aliases.map(&:name)}" + end GemPins.combine_method_pins_by_path(with_resolved_aliases) end @@ -746,11 +752,13 @@ def inner_get_methods rooted_tag, scope, visibility, deep, skip, no_core = false if scope == :instance store.get_includes(fqns).reverse.each do |include_tag| rooted_include_tag = qualify(include_tag, rooted_tag) - result.concat inner_get_methods_from_reference(rooted_include_tag, namespace_pin, rooted_type, scope, visibility, deep, skip, true) + result.concat inner_get_methods_from_reference(rooted_include_tag, namespace_pin, rooted_type, scope, + visibility, deep, skip, true) end rooted_sc_tag = qualify_superclass(rooted_tag) unless rooted_sc_tag.nil? - result.concat inner_get_methods_from_reference(rooted_sc_tag, namespace_pin, rooted_type, scope, visibility, true, skip, no_core) + result.concat inner_get_methods_from_reference(rooted_sc_tag, namespace_pin, rooted_type, scope, + visibility, true, skip, no_core) end else store.get_extends(fqns).reverse.each do |em| @@ -759,7 +767,8 @@ def inner_get_methods rooted_tag, scope, visibility, deep, skip, no_core = false end rooted_sc_tag = qualify_superclass(rooted_tag) unless rooted_sc_tag.nil? - result.concat inner_get_methods_from_reference(rooted_sc_tag, namespace_pin, rooted_type, scope, visibility, true, skip, true) + result.concat inner_get_methods_from_reference(rooted_sc_tag, namespace_pin, rooted_type, scope, + visibility, true, skip, true) end unless no_core || fqns.empty? type = get_namespace_type(fqns) @@ -827,9 +836,7 @@ def inner_get_constants fqns, visibility, skip result.concat inner_get_constants(qualify(is, fqns), [:public], skip) end fqsc = qualify_superclass(fqns) - unless %w[Object BasicObject].include?(fqsc) - result.concat inner_get_constants(fqsc, [:public], skip) - end + result.concat inner_get_constants(fqsc, [:public], skip) unless %w[Object BasicObject].include?(fqsc) result end diff --git a/lib/solargraph/api_map/index.rb b/lib/solargraph/api_map/index.rb index 01820a441..6577ad188 100644 --- a/lib/solargraph/api_map/index.rb +++ b/lib/solargraph/api_map/index.rb @@ -146,9 +146,7 @@ def map_overrides pins = path_pin_hash[ovr.name] logger.debug { "ApiMap::Index#map_overrides: pins for path=#{ovr.name}: #{pins}" } pins.each do |pin| - new_pin = if pin.path.end_with?('#initialize') - path_pin_hash[pin.path.sub(/#initialize/, '.new')].first - end + new_pin = (path_pin_hash[pin.path.sub(/#initialize/, '.new')].first if pin.path.end_with?('#initialize')) (ovr.tags.map(&:tag_name) + ovr.delete).uniq.each do |tag| pin.docstring.delete_tags tag new_pin.docstring.delete_tags tag if new_pin diff --git a/lib/solargraph/api_map/store.rb b/lib/solargraph/api_map/store.rb index 3e453bb35..830995b3d 100644 --- a/lib/solargraph/api_map/store.rb +++ b/lib/solargraph/api_map/store.rb @@ -31,7 +31,7 @@ def update *pinsets pinsets[changed..].each_with_index do |pins, idx| @pinsets[changed + idx] = pins @indexes[changed + idx] = if pins.empty? - @indexes[changed + idx - 1] + @indexes[changed + idx - 1] else @indexes[changed + idx - 1].merge(pins) end diff --git a/lib/solargraph/gem_pins.rb b/lib/solargraph/gem_pins.rb index 9ef123719..dead29c34 100644 --- a/lib/solargraph/gem_pins.rb +++ b/lib/solargraph/gem_pins.rb @@ -50,12 +50,16 @@ def self.combine(yard_pins, rbs_pins) next yard_pin unless rbs_pin && yard_pin.class == Pin::Method unless rbs_pin - logger.debug { "GemPins.combine: No rbs pin for #{yard_pin.path} - using YARD's '#{yard_pin.inspect} (return_type=#{yard_pin.return_type}; signatures=#{yard_pin.signatures})" } + logger.debug do + "GemPins.combine: No rbs pin for #{yard_pin.path} - using YARD's '#{yard_pin.inspect} (return_type=#{yard_pin.return_type}; signatures=#{yard_pin.signatures})" + end next yard_pin end out = combine_method_pins(rbs_pin, yard_pin) - logger.debug { "GemPins.combine: Combining yard.path=#{yard_pin.path} - rbs=#{rbs_pin.inspect} with yard=#{yard_pin.inspect} into #{out}" } + logger.debug do + "GemPins.combine: Combining yard.path=#{yard_pin.path} - rbs=#{rbs_pin.inspect} with yard=#{yard_pin.inspect} into #{out}" + end out end in_rbs_only = rbs_pins.select do |pin| diff --git a/lib/solargraph/library.rb b/lib/solargraph/library.rb index 85a74f4e5..90f428086 100644 --- a/lib/solargraph/library.rb +++ b/lib/solargraph/library.rb @@ -249,7 +249,7 @@ def references_from filename, line, column, strip: false, only: false return [] unless pin result = [] files = if only - [api_map.source_map(filename)] + [api_map.source_map(filename)] else (workspace.sources + (@current ? [@current] : [])) end @@ -274,12 +274,12 @@ def references_from filename, line, column, strip: false, only: false # HACK: for language clients that exclude special characters from the start of variable names if strip && match = cursor.word.match(/^[^a-z0-9_]+/i) found.map! do |loc| - Solargraph::Location.new(loc.filename, Solargraph::Range.from_to(loc.range.start.line, loc.range.start.column + match[0].length, loc.range.ending.line, loc.range.ending.column)) + Solargraph::Location.new(loc.filename, + Solargraph::Range.from_to(loc.range.start.line, loc.range.start.column + match[0].length, loc.range.ending.line, + loc.range.ending.column)) end end - result.concat(found.sort do |a, b| - a.range.start.line <=> b.range.start.line - end) + result.concat(found.sort { |a, b| a.range.start.line <=> b.range.start.line }) end result.uniq end @@ -304,9 +304,7 @@ def locate_ref location return nil if pin.nil? # @param full [String] return_if_match = proc do |full| - if source_map_hash.key?(full) - return Location.new(full, Solargraph::Range.from_to(0, 0, 0, 0)) - end + return Location.new(full, Solargraph::Range.from_to(0, 0, 0, 0)) if source_map_hash.key?(full) end workspace.require_paths.each do |path| full = File.join path, pin.name @@ -657,7 +655,7 @@ def report_cache_progress gem_name, pending @total = pending if pending > @total finished = @total - pending pct = if @total.zero? - 0 + 0 else ((finished.to_f / @total.to_f) * 100).to_i end diff --git a/lib/solargraph/parser/parser_gem/class_methods.rb b/lib/solargraph/parser/parser_gem/class_methods.rb index cb4f6fc72..c00391af2 100644 --- a/lib/solargraph/parser/parser_gem/class_methods.rb +++ b/lib/solargraph/parser/parser_gem/class_methods.rb @@ -77,9 +77,11 @@ def references source, name # @param top [Parser::AST::Node] # @return [Array] def inner_node_references name, top + # @type [Array] result = [] if top.is_a?(AST::Node) && top.to_s.include?(":#{name}") result.push top if top.children.any? { |c| c.to_s == name } + # @sg-ignore top.children.each { |c| result.concat inner_node_references(name, c) } end result @@ -128,16 +130,16 @@ def node_range node # @param node [Parser::AST::Node] # @return [Array] def string_ranges node + # @sg-ignore return [] unless is_ast_node?(node) result = [] - if node.type == :str - result.push Range.from_node(node) - end + result.push Range.from_node(node) if node.type == :str node.children.each do |child| result.concat string_ranges(child) end if node.type == :dstr && node.children.last.nil? last = node.children[-2] + # @sg-ignore unless last.nil? rng = Range.from_node(last) pos = Position.new(rng.ending.line, rng.ending.column - 1) diff --git a/lib/solargraph/rbs_map.rb b/lib/solargraph/rbs_map.rb index 613719e90..e795b8df2 100644 --- a/lib/solargraph/rbs_map.rb +++ b/lib/solargraph/rbs_map.rb @@ -189,10 +189,10 @@ def log_caching gemspec, out:; end # @return [Boolean] true if adding the library succeeded def add_library loader, library, version, out: $stderr @resolved = if loader.has_library?(library: library, version: version) - # we find our own dependencies from gemfile.lock - loader.add library: library, version: version, resolve_dependencies: false - logger.debug { "#{short_name} successfully loaded library #{library}:#{version}" } - true + # we find our own dependencies from gemfile.lock + loader.add library: library, version: version, resolve_dependencies: false + logger.debug { "#{short_name} successfully loaded library #{library}:#{version}" } + true else logger.info { "#{short_name} did not find data for library #{library}:#{version}" } false diff --git a/lib/solargraph/shell.rb b/lib/solargraph/shell.rb index 5b6028a11..810bdf7ad 100755 --- a/lib/solargraph/shell.rb +++ b/lib/solargraph/shell.rb @@ -193,7 +193,9 @@ def typecheck *files problems = checker.problems next if problems.empty? problems.sort! { |a, b| a.location.range.start.line <=> b.location.range.start.line } - puts problems.map { |prob| "#{prob.location.filename}:#{prob.location.range.start.line + 1} - #{prob.message}" }.join("\n") + puts problems.map { |prob| + "#{prob.location.filename}:#{prob.location.range.start.line + 1} - #{prob.message}" + }.join("\n") filecount += 1 probcount += problems.length end @@ -253,11 +255,11 @@ def list # @return [String] def pin_description pin desc = if pin.path.nil? || pin.path.empty? - if pin.closure - "#{pin.closure.path} | #{pin.name}" - else - "#{pin.context.namespace} | #{pin.name}" - end + if pin.closure + "#{pin.closure.path} | #{pin.name}" + else + "#{pin.context.namespace} | #{pin.name}" + end else pin.path end diff --git a/lib/solargraph/workspace.rb b/lib/solargraph/workspace.rb index b037ab2fc..443d261e1 100644 --- a/lib/solargraph/workspace.rb +++ b/lib/solargraph/workspace.rb @@ -195,9 +195,7 @@ def cache_all_for_workspace! out, rebuild: false # @type [Array] specs = gemspecs.all_gemspecs_from_bundle specs.each do |spec| - unless pin_cache.cached?(spec) - pin_cache.cache_gem(gemspec: spec, rebuild: rebuild, out: out) - end + pin_cache.cache_gem(gemspec: spec, rebuild: rebuild, out: out) unless pin_cache.cached?(spec) end out.puts "Documentation cached for all #{specs.length} gems." end @@ -238,7 +236,10 @@ def load_sources source_hash.clear unless directory.empty? || directory == '*' size = config.calculated.length - raise WorkspaceTooLargeError, "The workspace is too large to index (#{size} files, #{config.max_files} max)" if config.max_files > 0 and size > config.max_files + if config.max_files > 0 and size > config.max_files + raise WorkspaceTooLargeError, + "The workspace is too large to index (#{size} files, #{config.max_files} max)" + end config.calculated.each do |filename| begin source_hash[filename] = Solargraph::Source.load(filename) diff --git a/spec/workspace_spec.rb b/spec/workspace_spec.rb index f152a0a85..2e9203fb7 100644 --- a/spec/workspace_spec.rb +++ b/spec/workspace_spec.rb @@ -122,7 +122,8 @@ end it 'rescues errors loading files into sources' do - config = double(:Config, directory: './path', calculated: ['./path/does_not_exist.rb'], max_files: 5000, require_paths: [], plugins: []) + config = double(:Config, directory: './path', calculated: ['./path/does_not_exist.rb'], max_files: 5000, + require_paths: [], plugins: []) expect { Solargraph::Workspace.new('./path', config) }.not_to raise_error From 759ebf98270de2196a576fc9f1cc6798034de136 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Wed, 23 Jul 2025 11:49:01 -0400 Subject: [PATCH 137/400] Increase test coverage --- spec/shell_spec.rb | 29 ++++++++++++++++++ spec/workspace/require_paths_spec.rb | 44 ++++++++++++++++++++++++++++ spec/yardoc_spec.rb | 6 ++++ 3 files changed, 79 insertions(+) diff --git a/spec/shell_spec.rb b/spec/shell_spec.rb index ec98f7892..ce877f68e 100644 --- a/spec/shell_spec.rb +++ b/spec/shell_spec.rb @@ -57,12 +57,41 @@ def bundle_exec(*cmd) end end + def capture_stdout(&block) + original_stdout = $stdout + $stdout = StringIO.new + begin + block.call + $stdout.string + ensure + $stdout = original_stdout + end + end + describe 'gem' do it 'caches without erroring out' do output = bundle_exec('solargraph', 'gem', 'solargraph') expect(output).to include('Caching these gems') end + + it 'caches a YARD-using gem and loads pins' do + shell = Solargraph::Shell.new + output = capture_stdout do + shell.uncache('backport') + end + expect(output).to include('Clearing pin cache in') + + output = capture_stdout do + shell.gems('backport') + end + + expect(output).to include('Caching YARD pins for gem backport') + + api_map = Solargraph::ApiMap.load(Dir.pwd) + methods = api_map.get_method_stack('Backport::Adapter', 'remote') + expect(methods.first.return_type.tag).to eq('Hash{Symbol => String, Integer}') + end end describe 'gems' do diff --git a/spec/workspace/require_paths_spec.rb b/spec/workspace/require_paths_spec.rb index db5516447..2f78b1dd0 100644 --- a/spec/workspace/require_paths_spec.rb +++ b/spec/workspace/require_paths_spec.rb @@ -17,6 +17,16 @@ end end + context 'with config and no gemspec' do + let(:dir_path) { File.realpath(Dir.pwd) } + + let(:config) { instance_double(Solargraph::Workspace::Config, require_paths: [], allow?: true) } + + it 'includes the lib directory' do + expect(paths).to include(File.join(dir_path, 'lib')) + end + end + context 'with current bundle' do let(:dir_path) { Dir.pwd } @@ -33,6 +43,40 @@ end end + context 'with an invalid gemspec file' do + let(:dir_path) { File.realpath(Dir.mktmpdir) } + let(:gemspec_file) { File.join(dir_path, 'invalid.gemspec') } + + before do + File.write(gemspec_file, "bogus") + end + + it 'includes the lib directory' do + expect(paths).to include(File.join(dir_path, 'lib')) + end + + it 'does not raise an error' do + expect { paths }.not_to raise_error + end + end + + context 'with a valid gemspec file that outputs to stdout' do + let(:dir_path) { File.realpath(Dir.mktmpdir) } + let(:gemspec_file) { File.join(dir_path, 'invalid.gemspec') } + + before do + File.write(gemspec_file, "print '{'; Gem::Specification.new") + end + + it 'includes the lib directory' do + expect(paths).to include(File.join(dir_path, 'lib')) + end + + it 'does not raise an error' do + expect { paths }.not_to raise_error + end + end + context 'with no gemspec file' do let(:dir_path) { File.realpath(Dir.mktmpdir) } diff --git a/spec/yardoc_spec.rb b/spec/yardoc_spec.rb index 84b1b6fb6..9096ab0e3 100644 --- a/spec/yardoc_spec.rb +++ b/spec/yardoc_spec.rb @@ -31,6 +31,12 @@ end end + describe '#load!' do + it 'does not blow up when called on empty directory' do + expect { described_class.load!(gem_yardoc_path) }.not_to raise_error + end + end + describe '#build_docs' do let(:api_map) { Solargraph::ApiMap.load(Dir.pwd) } let(:gemspec) { api_map.find_gem('rubocop') } From dae35df74d831191e2ea6b700d0212479fc2b78d Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Wed, 23 Jul 2025 11:49:13 -0400 Subject: [PATCH 138/400] Drop unreachable line --- lib/solargraph/workspace/require_paths.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/solargraph/workspace/require_paths.rb b/lib/solargraph/workspace/require_paths.rb index 443752084..d3e48590b 100644 --- a/lib/solargraph/workspace/require_paths.rb +++ b/lib/solargraph/workspace/require_paths.rb @@ -27,7 +27,6 @@ def generate result = require_paths_from_gemspec_files return configured_require_paths if result.empty? result.concat(config.require_paths.map { |p| File.join(directory, p) }) if config - result.push File.join(directory, 'lib') if result.empty? result end From 62df9ba6c9f40807bda63df328d3f47fe28bf5a2 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Wed, 23 Jul 2025 12:11:19 -0400 Subject: [PATCH 139/400] Handle an RBS collection case --- lib/solargraph/pin_cache.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/solargraph/pin_cache.rb b/lib/solargraph/pin_cache.rb index a12a672aa..e4256e18f 100644 --- a/lib/solargraph/pin_cache.rb +++ b/lib/solargraph/pin_cache.rb @@ -90,6 +90,7 @@ def lookup_rbs_version_cache_key(gemspec) # @param rbs_collection_pins [Array] # @return [void] def cache_combined_pins(gemspec, rbs_version_cache_key, yard_pins, rbs_collection_pins) + raise "rbs_pins must be provided" unless rbs_pins combined_pins = GemPins.combine(yard_pins, rbs_collection_pins) serialize_combined_gem(gemspec, rbs_version_cache_key, combined_pins) end @@ -172,7 +173,7 @@ def build_combine_and_cache(gemspec, # this can be nil even if we aren't told to build it - see suppress_yard_cache? yard_pins = deserialize_yard_pin_cache(gemspec) || [] cache_rbs_collection_pins(gemspec, out) if build_rbs_collection - rbs_collection_pins = deserialize_rbs_collection_cache(gemspec, rbs_version_cache_key) + rbs_collection_pins = deserialize_rbs_collection_cache(gemspec, rbs_version_cache_key) || [] cache_combined_pins(gemspec, rbs_version_cache_key, yard_pins, rbs_collection_pins) if build_combined end From d557795bd71584b50481c12b6b8375e9541ee697 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Wed, 23 Jul 2025 12:12:40 -0400 Subject: [PATCH 140/400] Drop debugging line --- lib/solargraph/pin_cache.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/solargraph/pin_cache.rb b/lib/solargraph/pin_cache.rb index e4256e18f..f3097c6c9 100644 --- a/lib/solargraph/pin_cache.rb +++ b/lib/solargraph/pin_cache.rb @@ -90,7 +90,6 @@ def lookup_rbs_version_cache_key(gemspec) # @param rbs_collection_pins [Array] # @return [void] def cache_combined_pins(gemspec, rbs_version_cache_key, yard_pins, rbs_collection_pins) - raise "rbs_pins must be provided" unless rbs_pins combined_pins = GemPins.combine(yard_pins, rbs_collection_pins) serialize_combined_gem(gemspec, rbs_version_cache_key, combined_pins) end From 0714988048b8d1ab236f9ab686efb63829ca4d44 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Wed, 23 Jul 2025 15:50:19 -0400 Subject: [PATCH 141/400] More specs, aggressively cache stdlib in 'solargraph gems' --- lib/solargraph/pin_cache.rb | 24 ++++ lib/solargraph/workspace.rb | 13 ++- lib/solargraph/workspace/gemspecs.rb | 42 +++++-- spec/shell_spec.rb | 6 +- spec/spec_helper.rb | 4 +- .../gemspecs_resolve_require_spec.rb | 110 ++++++++++++++++++ 6 files changed, 182 insertions(+), 17 deletions(-) create mode 100644 spec/workspace/gemspecs_resolve_require_spec.rb diff --git a/lib/solargraph/pin_cache.rb b/lib/solargraph/pin_cache.rb index f3097c6c9..efbf25622 100644 --- a/lib/solargraph/pin_cache.rb +++ b/lib/solargraph/pin_cache.rb @@ -59,6 +59,15 @@ def suppress_yard_cache?(gemspec, rbs_version_cache_key) false end + # @param out [IO, nil] output stream for logging + # + # @return [void] + def cache_all_stdlibs(out: $stderr) + possible_stdlibs.each do |stdlib| + RbsMap::StdlibMap.new(stdlib, out: out) + end + end + # @param path [String] require path that might be in the RBS stdlib collection # @return [void] def cache_stdlib_rbs_map path @@ -125,6 +134,21 @@ def yardoc_processing?(gemspec) Yardoc.processing?(yardoc_path(gemspec)) end + # @return [Array] a list of possible standard library names + def possible_stdlibs + # all dirs and .rb files in Gem::RUBYGEMS_DIR + Dir.glob(File.join(Gem::RUBYGEMS_DIR, '*')).map do |file_or_dir| + basename = File.basename(file_or_dir) + # remove .rb + basename = basename[0..-4] if basename.end_with?('.rb') + basename + end.sort.uniq + rescue StandardError => e + logger.info { "Failed to get possible stdlibs: #{e.message}" } + logger.debug { e.backtrace.join("\n") } + [] + end + private # @param gemspec [Gem::Specification, Bundler::LazySpecification] diff --git a/lib/solargraph/workspace.rb b/lib/solargraph/workspace.rb index 443d261e1..0fb7a62b3 100644 --- a/lib/solargraph/workspace.rb +++ b/lib/solargraph/workspace.rb @@ -192,12 +192,22 @@ def rbs_collection_config_path # @return [void] def cache_all_for_workspace! out, rebuild: false PinCache.cache_core(out: out) unless PinCache.core? + # @type [Array] - specs = gemspecs.all_gemspecs_from_bundle + gem_specs = gemspecs.all_gemspecs_from_bundle + # try any possible standard libraries, but be quiet about it + stdlib_specs = pin_cache.possible_stdlibs.map { |stdlib| gemspecs.find_gem(stdlib, out: nil) }.compact + specs = (gem_specs + stdlib_specs) specs.each do |spec| pin_cache.cache_gem(gemspec: spec, rebuild: rebuild, out: out) unless pin_cache.cached?(spec) end out.puts "Documentation cached for all #{specs.length} gems." + + # do this after so that we prefer stdlib requires from gems, + # which are likely to be newer and have more pins + pin_cache.cache_all_stdlibs(out: out) + + out.puts "Documentation cached for core, standard library and gems." end # Synchronize the workspace from the provided updater. @@ -265,6 +275,7 @@ def require_plugins def read_rbs_collection_path return unless rbs_collection_config_path + # @sg-ignore path = YAML.load_file(rbs_collection_config_path)&.fetch('path') # make fully qualified File.expand_path(path, directory) diff --git a/lib/solargraph/workspace/gemspecs.rb b/lib/solargraph/workspace/gemspecs.rb index 5c3ef292e..999a6a007 100644 --- a/lib/solargraph/workspace/gemspecs.rb +++ b/lib/solargraph/workspace/gemspecs.rb @@ -12,10 +12,20 @@ class Gemspecs attr_reader :directory, :preferences # @param directory [String] - def initialize directory + # @param preferences [Array] + def initialize directory, preferences: [] + # @todo an issue with both external bundles and the potential + # preferences feature is that bundler gives you a 'clean' + # rubygems environment with only the specified versions + # installed. Possible alternatives: + # + # *) prompt the user to run solargraph outside of bundler + # and treat all bundles as external + # *) reinstall the needed gems dynamically each time + # *) manipulate the rubygems/bundler environment @directory = File.absolute_path(directory) - # @todo implement preferences - @preferences = [] + # @todo implement preferences as a config-exposed feature + @preferences = preferences end # Take the path given to a 'require' statement in a source file @@ -39,7 +49,7 @@ def resolve_require require spec_with_path = Gem::Specification.find_by_path(file) rescue Gem::MissingSpecError logger.debug do - "Require path #{require} could not be resolved to a gem via find_by_name or path of #{file}" + "Require #{require.inspect} could not be resolved to a gem via find_by_name or path of #{file}" end [] end @@ -77,13 +87,17 @@ def resolve_require require # @param name [String] # @param version [String, nil] + # @param out [IO, nil] output stream for logging # # @return [Gem::Specification, nil] - def find_gem name, version + def find_gem name, version = nil, out: $stderr gemspec = all_gemspecs_from_bundle.find { |gemspec| gemspec.name == name && gemspec.version == version } return gemspec if gemspec - resolve_gem_ignoring_local_bundle name, version + gemspec = all_gemspecs_from_bundle.find { |gemspec| gemspec.name == name } + return gemspec if gemspec + + resolve_gem_ignoring_local_bundle name, version, out: out end # @param gemspec [Gem::Specification] @@ -130,9 +144,9 @@ def self.gem_specification_cache private - # @sg-ignore # @param specish [Gem::Specification, Bundler::LazySpecification, Bundler::StubSpecification] # @return [Gem::Specification, nil] + # @sg-ignore def to_gem_specification specish # print time including milliseconds self.class.gem_specification_cache[specish] ||= case specish @@ -175,7 +189,6 @@ def query_external_bundle command 'ruby', '-e', "require 'bundler'; require 'json'; Dir.chdir('#{directory}') { puts #{command}.to_json }" ] - # @sg-ignore o, e, s = Open3.capture3(*cmd) if s.success? Solargraph.logger.debug "External bundle: #{o}" @@ -259,8 +272,10 @@ def only_runtime_dependencies gemspec # # @param name [String] # @param version [String] + # @param out [IO, nil] output stream for logging + # # @return [Gem::Specification, nil] - def resolve_gem_ignoring_local_bundle name, version + def resolve_gem_ignoring_local_bundle name, version, out: $stderr Gem::Specification.find_by_name(name, version) rescue Gem::MissingSpecError begin @@ -268,7 +283,9 @@ def resolve_gem_ignoring_local_bundle name, version rescue Gem::MissingSpecError stdlibmap = RbsMap::StdlibMap.new(name) unless stdlibmap.resolved? - logger.warn "Please install the gem #{name}:#{version} in Solargraph's Ruby environment" + gem_desc = name + gem_desc += ":#{version}" if version + out&.puts "Please install the gem #{gem_desc} in Solargraph's Ruby environment" end nil # either not here or in stdlib end @@ -282,7 +299,7 @@ def all_gemspecs_from_external_bundle begin logger.info 'Fetching gemspecs required from external bundle' - command = 'Bundler.definition.locked_gems&.specs&.map { |spec| [spec.name, spec.version] }.to_h' + command = 'Bundler.definition.locked_gems&.specs&.map { |spec| [spec.name, spec.version.to_s] }.to_h' query_external_bundle(command).map do |name, version| resolve_gem_ignoring_local_bundle(name, version) @@ -311,7 +328,8 @@ def gemspec_or_preference gemspec def change_gemspec_version gemspec, version Gem::Specification.find_by_name(gemspec.name, "= #{version}") rescue Gem::MissingSpecError - Solargraph.logger.info "Gem #{gemspec.name} version #{version} not found. Using #{gemspec.version} instead" + Solargraph.logger.info "Gem #{gemspec.name} version #{version.inspect} not found. " \ + "Using #{gemspec.version} instead" gemspec end end diff --git a/spec/shell_spec.rb b/spec/shell_spec.rb index ce877f68e..a8383b32d 100644 --- a/spec/shell_spec.rb +++ b/spec/shell_spec.rb @@ -57,7 +57,7 @@ def bundle_exec(*cmd) end end - def capture_stdout(&block) + def capture_stdout &block original_stdout = $stdout $stdout = StringIO.new begin @@ -75,8 +75,8 @@ def capture_stdout(&block) expect(output).to include('Caching these gems') end - it 'caches a YARD-using gem and loads pins' do - shell = Solargraph::Shell.new + it 'caches a YARD-using gem and loads pins' do # rubocop:disable RSpec/MultipleExpectations + shell = described_class.new output = capture_stdout do shell.uncache('backport') end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index da7a6280e..a9ea4a15a 100755 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -14,7 +14,9 @@ end end require 'solargraph' -# Suppress logger output in specs (if possible) +# execute any logging blocks to make sure they don't blow up +Solargraph::Logging.logger.sev_threshold = Logger::DEBUG +# ...but still suppress logger output in specs (if possible) Solargraph::Logging.logger.reopen(File::NULL) if Solargraph::Logging.logger.respond_to?(:reopen) # @param name [String] diff --git a/spec/workspace/gemspecs_resolve_require_spec.rb b/spec/workspace/gemspecs_resolve_require_spec.rb new file mode 100644 index 000000000..158915ec5 --- /dev/null +++ b/spec/workspace/gemspecs_resolve_require_spec.rb @@ -0,0 +1,110 @@ +# frozen_string_literal: true + +require 'fileutils' +require 'tmpdir' +require 'rubygems/commands/install_command' + +describe Solargraph::Workspace::Gemspecs, '#resolve_require' do + subject(:specs) { gemspecs.resolve_require(require) } + + let(:gemspecs) { described_class.new(dir_path) } + + def find_or_install gem_name, version + Gem::Specification.find_by_name(gem_name, version) + rescue Gem::LoadError + install_gem(gem_name, version) + end + + def install_gem gem_name, version + Bundler.with_unbundled_env do + cmd = Gem::Commands::InstallCommand.new + cmd.handle_options [gem_name, '-v', version] + cmd.execute + rescue Gem::SystemExitException => e + raise unless e.exit_code == 0 + end + end + + context 'with local bundle' do + let(:dir_path) { File.realpath(Dir.pwd) } + + context 'with a known gem' do + let(:require) { 'solargraph' } + + it 'returns a single spec' do + expect(specs.size).to eq(1) + end + + it 'resolves to the right known gem' do + expect(specs.map(&:name)).to eq(['solargraph']) + end + end + + context 'with a less usual require mapping' do + let(:require) { 'diff/lcs' } + + it 'returns a single spec' do + expect(specs.size).to eq(1) + end + + it 'resolves to the right known gem' do + expect(specs.map(&:name)).to eq(['diff-lcs']) + end + end + + context 'with Bundler.require' do + let(:require) { 'bundler/require' } + + it 'returns the gemspec gem' do + expect(specs.map(&:name)).to include('solargraph') + end + end + end + + context 'with external bundle' do + let(:dir_path) { File.realpath(Dir.mktmpdir).to_s } + + before do + # write out Gemfile + File.write(File.join(dir_path, 'Gemfile'), <<~GEMFILE) + source 'https://rubygems.org' + gem 'backport' + GEMFILE + + # run bundle install + output, status = Solargraph.with_clean_env do + Open3.capture2e('bundle install --verbose', chdir: dir_path) + end + raise "Failure installing bundle: #{output}" unless status.success? + + # ensure Gemfile.lock exists + unless File.exist?(File.join(dir_path, 'Gemfile.lock')) + raise "Gemfile.lock not found after bundle install in #{dir_path}" + end + end + + context 'with a gem preference' do + before do + find_or_install('backport', '1.0.0') + Gem::Specification.find_by_name('backport', '= 1.0.0') + end + + let(:preferences) do + [ + Gem::Specification.new.tap do |spec| + spec.name = 'backport' + spec.version = '1.0.0' + end + ] + end + + it 'returns the preferred gemspec' do + gemspecs = described_class.new(dir_path, preferences: preferences) + specs = gemspecs.resolve_require('backport') + backport = specs.find { |spec| spec.name == 'backport' } + + expect(backport.version.to_s).to eq('1.0.0') + end + end + end +end From 6fc79522cce7eeada8c3f14b0cdcf29d25751c62 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Wed, 23 Jul 2025 15:55:51 -0400 Subject: [PATCH 142/400] Fix string literal nit --- spec/workspace/require_paths_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/workspace/require_paths_spec.rb b/spec/workspace/require_paths_spec.rb index 2f78b1dd0..eb95d0c5b 100644 --- a/spec/workspace/require_paths_spec.rb +++ b/spec/workspace/require_paths_spec.rb @@ -48,7 +48,7 @@ let(:gemspec_file) { File.join(dir_path, 'invalid.gemspec') } before do - File.write(gemspec_file, "bogus") + File.write(gemspec_file, 'bogus') end it 'includes the lib directory' do From 6cfc56b6fa2b9aac37512e4b882fd79b447343a7 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Wed, 23 Jul 2025 16:30:34 -0400 Subject: [PATCH 143/400] Add error handler for Ruby 3.0 situation --- lib/solargraph/workspace/gemspecs.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/solargraph/workspace/gemspecs.rb b/lib/solargraph/workspace/gemspecs.rb index 999a6a007..2d7f71008 100644 --- a/lib/solargraph/workspace/gemspecs.rb +++ b/lib/solargraph/workspace/gemspecs.rb @@ -112,6 +112,16 @@ def fetch_dependencies gemspec dep = gemspecs.find { |dep| dep.name == runtime_dep.name } dep ||= Gem::Specification.find_by_name(runtime_dep.name, runtime_dep.requirement) deps.merge fetch_dependencies(dep) if deps.add?(dep) + rescue NoMethodError => e + raise unless e.message.include?('identifier') && e.message.include?('lib/ruby/gems') + # Can happen on system gems in Ruby 3.0, it seems: + # + # https://github.com/castwide/solargraph/actions/runs/16480452864/job/46593077954?pr=1006 + log.debug do + "Skipping dependency #{runtime_dep.name} for #{gemspec.name} due to NoMethodError: #{e.message}" + end + + nil rescue Gem::MissingSpecError Solargraph.logger.warn("Gem dependency #{runtime_dep.name} #{runtime_dep.requirement} " \ "for #{gemspec.name} not found in bundle.") From 9c931489a5535a7da9ad994b47b674ce2c22655e Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Wed, 23 Jul 2025 16:48:04 -0400 Subject: [PATCH 144/400] Disable spec for older Ruby --- lib/solargraph/workspace/gemspecs.rb | 1 + .../gemspecs_resolve_require_spec.rb | 45 ++++++++++--------- 2 files changed, 25 insertions(+), 21 deletions(-) diff --git a/lib/solargraph/workspace/gemspecs.rb b/lib/solargraph/workspace/gemspecs.rb index 2d7f71008..cba593128 100644 --- a/lib/solargraph/workspace/gemspecs.rb +++ b/lib/solargraph/workspace/gemspecs.rb @@ -199,6 +199,7 @@ def query_external_bundle command 'ruby', '-e', "require 'bundler'; require 'json'; Dir.chdir('#{directory}') { puts #{command}.to_json }" ] + # @sg-ignore o, e, s = Open3.capture3(*cmd) if s.success? Solargraph.logger.debug "External bundle: #{o}" diff --git a/spec/workspace/gemspecs_resolve_require_spec.rb b/spec/workspace/gemspecs_resolve_require_spec.rb index 158915ec5..a1cca9d4d 100644 --- a/spec/workspace/gemspecs_resolve_require_spec.rb +++ b/spec/workspace/gemspecs_resolve_require_spec.rb @@ -83,27 +83,30 @@ def install_gem gem_name, version end end - context 'with a gem preference' do - before do - find_or_install('backport', '1.0.0') - Gem::Specification.find_by_name('backport', '= 1.0.0') - end - - let(:preferences) do - [ - Gem::Specification.new.tap do |spec| - spec.name = 'backport' - spec.version = '1.0.0' - end - ] - end - - it 'returns the preferred gemspec' do - gemspecs = described_class.new(dir_path, preferences: preferences) - specs = gemspecs.resolve_require('backport') - backport = specs.find { |spec| spec.name == 'backport' } - - expect(backport.version.to_s).to eq('1.0.0') + # find_or_install helper doesn't seem to work on older versions + if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.1.0') + context 'with a gem preference' do + before do + find_or_install('backport', '1.0.0') + Gem::Specification.find_by_name('backport', '= 1.0.0') + end + + let(:preferences) do + [ + Gem::Specification.new.tap do |spec| + spec.name = 'backport' + spec.version = '1.0.0' + end + ] + end + + it 'returns the preferred gemspec' do + gemspecs = described_class.new(dir_path, preferences: preferences) + specs = gemspecs.resolve_require('backport') + backport = specs.find { |spec| spec.name == 'backport' } + + expect(backport.version.to_s).to eq('1.0.0') + end end end end From 551de9ca5fd256ed82a79386d8280d9bbe8df6f2 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Wed, 23 Jul 2025 17:16:16 -0400 Subject: [PATCH 145/400] More specs --- .../gemspecs_resolve_require_spec.rb | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/spec/workspace/gemspecs_resolve_require_spec.rb b/spec/workspace/gemspecs_resolve_require_spec.rb index a1cca9d4d..e38b65469 100644 --- a/spec/workspace/gemspecs_resolve_require_spec.rb +++ b/spec/workspace/gemspecs_resolve_require_spec.rb @@ -83,6 +83,15 @@ def install_gem gem_name, version end end + context 'with external bundle that does not exist' do + let(:dir_path) { File.realpath(Dir.mktmpdir).to_s } + let(:require) { 'bundler/require' } + + it 'raises' do + expect { specs }.to raise_error(Solargraph::BundleNotFoundError) + end + end + # find_or_install helper doesn't seem to work on older versions if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.1.0') context 'with a gem preference' do @@ -108,6 +117,47 @@ def install_gem gem_name, version expect(backport.version.to_s).to eq('1.0.0') end end + + context 'with a gem preference that does not exist' do + let(:preferences) do + [ + Gem::Specification.new.tap do |spec| + spec.name = 'backport' + spec.version = '99.0.0' + end + ] + end + + it 'returns the gemspec we do have' do + gemspecs = described_class.new(dir_path, preferences: preferences) + specs = gemspecs.resolve_require('backport') + backport = specs.find { |spec| spec.name == 'backport' } + + expect(backport.version.to_s).to eq('1.2.0') + end + end + + context 'with a gem preference already set to the version we use' do + let(:version) { Gem::Specification.find_by_name('backport').version.to_s } + + let(:preferences) do + [ + Gem::Specification.new.tap do |spec| + spec.name = 'backport' + spec.version = version + end + ] + end + + it 'returns the gemspec we do have' do + gemspecs = described_class.new(dir_path, preferences: preferences) + specs = gemspecs.resolve_require('backport') + backport = specs.find { |spec| spec.name == 'backport' } + + expect(backport.version.to_s).to eq(version) + end + end + end end end From 6066b55c4a358f80f56f0e1f54fc2bb954f48bbb Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Thu, 24 Jul 2025 08:58:00 -0400 Subject: [PATCH 146/400] Work through a '*' / '' case --- lib/solargraph/workspace.rb | 15 +++++++++++--- lib/solargraph/workspace/gemspecs.rb | 13 +++++++----- lib/solargraph/workspace/require_paths.rb | 7 +++---- .../gemspecs_resolve_require_spec.rb | 20 +++++++++++++++++++ 4 files changed, 43 insertions(+), 12 deletions(-) diff --git a/lib/solargraph/workspace.rb b/lib/solargraph/workspace.rb index 0fb7a62b3..ab788be06 100644 --- a/lib/solargraph/workspace.rb +++ b/lib/solargraph/workspace.rb @@ -19,10 +19,12 @@ class Workspace # @return [String] attr_reader :directory - # @param directory [String] + # @param directory [String] TODO: Document and test '' and '*' semantics # @param config [Config, nil] # @param server [Hash] def initialize directory = '', config = nil, server = {} + raise ArgumentError, 'directory must be a String' unless directory.is_a?(String) + @directory = if ['*', ''].include?(directory) directory else @@ -38,7 +40,8 @@ def initialize directory = '', config = nil, server = {} # # @return [Array] def require_paths - @require_paths ||= RequirePaths.new(directory, config).generate + # @todo are the semantics of '*' the same as '', meaning 'don't send back any require paths'? + @require_paths ||= RequirePaths.new(directory_or_nil, config).generate end # @return [Solargraph::Workspace::Config] @@ -223,9 +226,15 @@ def command_path server['commandPath'] || 'solargraph' end + # @return [String, nil] + def directory_or_nil + return nil if directory.empty? || directory == '*' + directory + end + # @return [Solargraph::Workspace::Gemspecs] def gemspecs - @gemspecs ||= Solargraph::Workspace::Gemspecs.new(directory) + @gemspecs ||= Solargraph::Workspace::Gemspecs.new(directory_or_nil) end private diff --git a/lib/solargraph/workspace/gemspecs.rb b/lib/solargraph/workspace/gemspecs.rb index cba593128..cc30b797c 100644 --- a/lib/solargraph/workspace/gemspecs.rb +++ b/lib/solargraph/workspace/gemspecs.rb @@ -11,7 +11,7 @@ class Gemspecs attr_reader :directory, :preferences - # @param directory [String] + # @param directory [String, nil] If nil, assume no bundle is present # @param preferences [Array] def initialize directory, preferences: [] # @todo an issue with both external bundles and the potential @@ -23,7 +23,7 @@ def initialize directory, preferences: [] # and treat all bundles as external # *) reinstall the needed gems dynamically each time # *) manipulate the rubygems/bundler environment - @directory = File.absolute_path(directory) + @directory = directory && File.absolute_path(directory) # @todo implement preferences as a config-exposed feature @preferences = preferences end @@ -139,6 +139,8 @@ def fetch_dependencies gemspec # # @return [Array] def all_gemspecs_from_bundle + return [] unless directory + @all_gemspecs_from_bundle ||= if in_this_bundle? all_gemspecs_from_this_bundle @@ -212,7 +214,7 @@ def query_external_bundle command end def in_this_bundle? - directory && Bundler.definition&.lockfile&.to_s&.start_with?(directory) # rubocop:disable Style/SafeNavigationChainLength + Bundler.definition&.lockfile&.to_s&.start_with?(directory) # rubocop:disable Style/SafeNavigationChainLength end # @return [Array] @@ -234,6 +236,8 @@ def all_gemspecs_from_this_bundle # @return [Array] def auto_required_gemspecs_from_bundler + return [] unless directory + logger.info 'Fetching gemspecs autorequired from Bundler (bundler/require)' @auto_required_gemspecs_from_bundler ||= if in_this_bundle? @@ -303,9 +307,8 @@ def resolve_gem_ignoring_local_bundle name, version, out: $stderr end # @return [Array] + # @sg-ignore def all_gemspecs_from_external_bundle - return [] unless directory - @all_gemspecs_from_external_bundle ||= begin logger.info 'Fetching gemspecs required from external bundle' diff --git a/lib/solargraph/workspace/require_paths.rb b/lib/solargraph/workspace/require_paths.rb index d3e48590b..57ebf5044 100644 --- a/lib/solargraph/workspace/require_paths.rb +++ b/lib/solargraph/workspace/require_paths.rb @@ -12,7 +12,7 @@ class Workspace class RequirePaths attr_reader :directory, :config - # @param directory [String] + # @param directory [String, nil] # @param config [Config, nil] def initialize directory, config @directory = directory @@ -45,8 +45,7 @@ def require_paths_from_gemspec_files # # @return [Array] def gemspec_file_paths - # @todo Document what '*' means and how a user should use it - return [] if directory.empty? || directory == '*' + return [] if directory.nil? @gemspec_file_paths ||= Dir[File.join(directory, '**/*.gemspec')].select do |gs| config.nil? || config.allow?(gs) end @@ -56,7 +55,7 @@ def gemspec_file_paths # # @return [Array] def configured_require_paths - return ['lib'] if directory.empty? + return ['lib'] unless directory return [File.join(directory, 'lib')] if !config || config.require_paths.empty? config.require_paths.map { |p| File.join(directory, p) } end diff --git a/spec/workspace/gemspecs_resolve_require_spec.rb b/spec/workspace/gemspecs_resolve_require_spec.rb index e38b65469..fe927fc44 100644 --- a/spec/workspace/gemspecs_resolve_require_spec.rb +++ b/spec/workspace/gemspecs_resolve_require_spec.rb @@ -61,6 +61,26 @@ def install_gem gem_name, version end end + context 'with nil as directory' do + let(:dir_path) { nil } + + context 'with simple require' do + let(:require) { 'solargraph' } + + it 'finds solargraph' do + expect(specs.map(&:name)).to eq(['solargraph']) + end + end + + context 'with Bundler.require' do + let(:require) { 'bundler/require' } + + it 'finds nothing' do + expect(specs).to be_empty + end + end + end + context 'with external bundle' do let(:dir_path) { File.realpath(Dir.mktmpdir).to_s } From 1775bac4f2f4d5e83d4763fb0de15804e8ffbc6a Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Thu, 24 Jul 2025 12:33:23 -0400 Subject: [PATCH 147/400] More specs --- lib/solargraph/rbs_map.rb | 4 +- spec/workspace/gemspecs_find_gem_spec.rb | 62 +++++++++++++++++++ .../gemspecs_resolve_require_spec.rb | 1 - 3 files changed, 64 insertions(+), 3 deletions(-) create mode 100644 spec/workspace/gemspecs_find_gem_spec.rb diff --git a/lib/solargraph/rbs_map.rb b/lib/solargraph/rbs_map.rb index e795b8df2..b4eab0ea8 100644 --- a/lib/solargraph/rbs_map.rb +++ b/lib/solargraph/rbs_map.rb @@ -177,10 +177,10 @@ def conversions @conversions ||= Conversions.new(loader: loader) end - # @param gemspec [RBS::EnvironmentLoader::Library] + # @param lib [RBS::EnvironmentLoader::Library] # @param out [IO, nil] where to log messages # @return [void] - def log_caching gemspec, out:; end + def log_caching lib, out:; end # @param loader [RBS::EnvironmentLoader] # @param library [String] diff --git a/spec/workspace/gemspecs_find_gem_spec.rb b/spec/workspace/gemspecs_find_gem_spec.rb new file mode 100644 index 000000000..707c27535 --- /dev/null +++ b/spec/workspace/gemspecs_find_gem_spec.rb @@ -0,0 +1,62 @@ +# frozen_string_literal: true + +require 'fileutils' +require 'tmpdir' +require 'rubygems/commands/install_command' + +describe Solargraph::Workspace::Gemspecs, '#find_gem' do + subject(:gemspec) { gemspecs.find_gem(name, version, out: out) } + + let(:gemspecs) { described_class.new(dir_path) } + let(:out) { StringIO.new } + + context 'with local bundle' do + let(:dir_path) { File.realpath(Dir.pwd) } + + context 'with solargraph from bundle' do + let(:name) { 'solargraph' } + let(:version) { nil } + + it 'returns the gem' do + expect(gemspec.name).to eq(name) + end + end + + context 'with random from core' do + let(:name) { 'random' } + let(:version) { nil } + + it 'returns no gemspec' do + expect(gemspec).to be_nil + end + + it 'does not complain' do + expect(out.string).to be_empty + end + end + + context 'with abbrev from stdlib' do + let(:name) { 'abbrev' } + let(:version) { nil } + + it 'returns no gemspec' do + expect(gemspec).to be_nil + end + end + + context 'with gem not in bundle' do + let(:name) { 'checkoff' } + let(:version) { nil } + + it 'returns no gemspec' do + expect(gemspec).to be_nil + end + + it 'complains' do + gemspec + + expect(out.string).to include('install the gem checkoff') + end + end + end +end diff --git a/spec/workspace/gemspecs_resolve_require_spec.rb b/spec/workspace/gemspecs_resolve_require_spec.rb index fe927fc44..719a57427 100644 --- a/spec/workspace/gemspecs_resolve_require_spec.rb +++ b/spec/workspace/gemspecs_resolve_require_spec.rb @@ -177,7 +177,6 @@ def install_gem gem_name, version expect(backport.version.to_s).to eq(version) end end - end end end From e7bb915b0f5bbde0d5a37721f9279dbd870e06a1 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Thu, 24 Jul 2025 15:02:40 -0400 Subject: [PATCH 148/400] Add spec and then make it work --- lib/solargraph/rbs_map/stdlib_map.rb | 4 +- lib/solargraph/shell.rb | 7 +- lib/solargraph/workspace/gemspecs.rb | 17 +- spec/shell_spec.rb | 26 ++- spec/workspace/gemspecs_find_gem_spec.rb | 44 ++++- .../gemspecs_resolve_require_spec.rb | 155 ++++++++++-------- 6 files changed, 164 insertions(+), 89 deletions(-) diff --git a/lib/solargraph/rbs_map/stdlib_map.rb b/lib/solargraph/rbs_map/stdlib_map.rb index d254b03e8..bd3fd5a99 100644 --- a/lib/solargraph/rbs_map/stdlib_map.rb +++ b/lib/solargraph/rbs_map/stdlib_map.rb @@ -12,8 +12,8 @@ class StdlibMap < RbsMap # @type [Hash{String => RbsMap}] @stdlib_maps_hash = {} - def log_caching gemspec, out: $stderr - out&.puts("Caching RBS pins for standard library #{gemspec.name}") + def log_caching lib, out: $stderr + out&.puts("Caching RBS pins for standard library #{lib.name}") end # @param library [String] diff --git a/lib/solargraph/shell.rb b/lib/solargraph/shell.rb index 810bdf7ad..b303c8a5c 100755 --- a/lib/solargraph/shell.rb +++ b/lib/solargraph/shell.rb @@ -67,6 +67,7 @@ def stdio def config(directory = '.') matches = [] if options[:extensions] + # @sg-ignore Gem::Specification.each do |g| if g.name.match(/^solargraph\-[A-Za-z0-9_\-]*?\-ext/) require g.name @@ -125,7 +126,11 @@ def gems *names end gemspec = api_map.find_gem(*name.split('=')) - api_map.cache_gem(gemspec, rebuild: options.rebuild, out: $stdout) + if gemspec.nil? + warn "Gem '#{name}' not found" + else + api_map.cache_gem(gemspec, rebuild: options.rebuild, out: $stdout) + end rescue Gem::MissingSpecError warn "Gem '#{name}' not found" end diff --git a/lib/solargraph/workspace/gemspecs.rb b/lib/solargraph/workspace/gemspecs.rb index cc30b797c..b07166db5 100644 --- a/lib/solargraph/workspace/gemspecs.rb +++ b/lib/solargraph/workspace/gemspecs.rb @@ -46,6 +46,7 @@ def resolve_require require # Determine gem name based on the require path file = "lib/#{require}.rb" begin + # @sg-ignore spec_with_path = Gem::Specification.find_by_path(file) rescue Gem::MissingSpecError logger.debug do @@ -199,7 +200,7 @@ def query_external_bundle command Solargraph.with_clean_env do cmd = [ 'ruby', '-e', - "require 'bundler'; require 'json'; Dir.chdir('#{directory}') { puts #{command}.to_json }" + "require 'bundler'; require 'json'; Dir.chdir('#{directory}') { puts begin; #{command}; end.to_json }" ] # @sg-ignore o, e, s = Open3.capture3(*cmd) @@ -213,6 +214,7 @@ def query_external_bundle command end end + # @sg-ignore def in_this_bundle? Bundler.definition&.lockfile&.to_s&.start_with?(directory) # rubocop:disable Style/SafeNavigationChainLength end @@ -265,12 +267,12 @@ def auto_required_gemspecs_from_external_bundle command = 'Bundler.definition.dependencies' \ '.select { |dep| dep.groups.include?(:default) && dep.should_include? }' \ - '.map { |dep| [dep.name, dep. version] }' + '.map(&:name)' # @sg-ignore # @type [Array] - dep_details = query_external_bundle command + dep_names = query_external_bundle command - dep_details.map { |name, version| find_gem(name, version) }.compact + all_gemspecs_from_bundle.select { |gemspec| dep_names.include?(gemspec.name) } end end @@ -313,8 +315,11 @@ def all_gemspecs_from_external_bundle begin logger.info 'Fetching gemspecs required from external bundle' - command = 'Bundler.definition.locked_gems&.specs&.map { |spec| [spec.name, spec.version.to_s] }.to_h' - + command = 'specish_objects = Bundler.definition.locked_gems&.specs; ' \ + 'if specish_objects.first.respond_to?(:materialize_for_installation);' \ + 'specish_objects = specish_objects.map(&:materialize_for_installation);' \ + 'end;' \ + 'specish_objects.map { |specish| [specish.name, specish.version] }' query_external_bundle(command).map do |name, version| resolve_gem_ignoring_local_bundle(name, version) end.compact diff --git a/spec/shell_spec.rb b/spec/shell_spec.rb index a8383b32d..d20526175 100644 --- a/spec/shell_spec.rb +++ b/spec/shell_spec.rb @@ -11,17 +11,21 @@ file.puts "source 'https://rubygems.org'" file.puts "gem 'solargraph', path: '#{File.expand_path('..', __dir__)}'" end - output, status = Open3.capture2e('bundle install', chdir: temp_dir) - raise "Failure installing bundle: #{output}" unless status.success? + Bundler.with_unbundled_env do + output, status = Open3.capture2e('bundle install', chdir: temp_dir) + raise "Failure installing bundle: #{output}" unless status.success? + end end # @type cmd [Array] # @return [String] def bundle_exec(*cmd) # run the command in the temporary directory with bundle exec - output, status = Open3.capture2e("bundle exec #{cmd.join(' ')}", chdir: temp_dir) - expect(status.success?).to be(true), "Command failed: #{output}" - output + Bundler.with_unbundled_env do + output, status = Open3.capture2e("bundle exec #{cmd.join(' ')}", chdir: temp_dir) + expect(status.success?).to be(true), "Command failed: #{output}" + output + end end after do @@ -69,12 +73,24 @@ def capture_stdout &block end describe 'gem' do + it 'has a well set up test enviornment' do + output = bundle_exec('bundle', 'list') + + expect(output).to include('language_server-protocol') + end + it 'caches without erroring out' do output = bundle_exec('solargraph', 'gem', 'solargraph') expect(output).to include('Caching these gems') end + it 'gives sensible error for gem that does not exist' do + output = bundle_exec('solargraph', 'gem', 'solargraph123') + + expect(output).to include('Caching these gems') + end + it 'caches a YARD-using gem and loads pins' do # rubocop:disable RSpec/MultipleExpectations shell = described_class.new output = capture_stdout do diff --git a/spec/workspace/gemspecs_find_gem_spec.rb b/spec/workspace/gemspecs_find_gem_spec.rb index 707c27535..35f5e7a15 100644 --- a/spec/workspace/gemspecs_find_gem_spec.rb +++ b/spec/workspace/gemspecs_find_gem_spec.rb @@ -35,8 +35,8 @@ end end - context 'with abbrev from stdlib' do - let(:name) { 'abbrev' } + context 'with ripper from core' do + let(:name) { 'ripper' } let(:version) { nil } it 'returns no gemspec' do @@ -44,6 +44,15 @@ end end + context 'with base64 from stdlib' do + let(:name) { 'base64' } + let(:version) { nil } + + it 'returns a gemspec' do + expect(gemspec).not_to be_nil + end + end + context 'with gem not in bundle' do let(:name) { 'checkoff' } let(:version) { nil } @@ -55,7 +64,36 @@ it 'complains' do gemspec - expect(out.string).to include('install the gem checkoff') + expect(out.string).to include('install the gem checkoff ') + end + end + + context 'with gem not in bundle but no logger' do + let(:name) { 'checkoff' } + let(:version) { nil } + let(:out) { nil } + + it 'returns no gemspec' do + expect(gemspec).to be_nil + end + + it 'does not fail' do + expect { gemspec }.not_to raise_error + end + end + + context 'with gem not in bundle with version' do + let(:name) { 'checkoff' } + let(:version) { '1.0.0' } + + it 'returns no gemspec' do + expect(gemspec).to be_nil + end + + it 'complains' do + gemspec + + expect(out.string).to include('install the gem checkoff:1.0.0') end end end diff --git a/spec/workspace/gemspecs_resolve_require_spec.rb b/spec/workspace/gemspecs_resolve_require_spec.rb index 719a57427..d09d9d16f 100644 --- a/spec/workspace/gemspecs_resolve_require_spec.rb +++ b/spec/workspace/gemspecs_resolve_require_spec.rb @@ -84,27 +84,7 @@ def install_gem gem_name, version context 'with external bundle' do let(:dir_path) { File.realpath(Dir.mktmpdir).to_s } - before do - # write out Gemfile - File.write(File.join(dir_path, 'Gemfile'), <<~GEMFILE) - source 'https://rubygems.org' - gem 'backport' - GEMFILE - - # run bundle install - output, status = Solargraph.with_clean_env do - Open3.capture2e('bundle install --verbose', chdir: dir_path) - end - raise "Failure installing bundle: #{output}" unless status.success? - - # ensure Gemfile.lock exists - unless File.exist?(File.join(dir_path, 'Gemfile.lock')) - raise "Gemfile.lock not found after bundle install in #{dir_path}" - end - end - - context 'with external bundle that does not exist' do - let(:dir_path) { File.realpath(Dir.mktmpdir).to_s } + context 'with no actual bundle' do let(:require) { 'bundler/require' } it 'raises' do @@ -112,69 +92,100 @@ def install_gem gem_name, version end end - # find_or_install helper doesn't seem to work on older versions - if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.1.0') - context 'with a gem preference' do - before do - find_or_install('backport', '1.0.0') - Gem::Specification.find_by_name('backport', '= 1.0.0') - end - - let(:preferences) do - [ - Gem::Specification.new.tap do |spec| - spec.name = 'backport' - spec.version = '1.0.0' - end - ] + context 'with Gemfile' do + before do + # write out Gemfile + File.write(File.join(dir_path, 'Gemfile'), <<~GEMFILE) + source 'https://rubygems.org' + gem 'backport' + GEMFILE + + # run bundle install + output, status = Solargraph.with_clean_env do + Open3.capture2e('bundle install --verbose', chdir: dir_path) end + raise "Failure installing bundle: #{output}" unless status.success? - it 'returns the preferred gemspec' do - gemspecs = described_class.new(dir_path, preferences: preferences) - specs = gemspecs.resolve_require('backport') - backport = specs.find { |spec| spec.name == 'backport' } - - expect(backport.version.to_s).to eq('1.0.0') + # ensure Gemfile.lock exists + unless File.exist?(File.join(dir_path, 'Gemfile.lock')) + raise "Gemfile.lock not found after bundle install in #{dir_path}" end end - context 'with a gem preference that does not exist' do - let(:preferences) do - [ - Gem::Specification.new.tap do |spec| - spec.name = 'backport' - spec.version = '99.0.0' - end - ] - end - - it 'returns the gemspec we do have' do - gemspecs = described_class.new(dir_path, preferences: preferences) - specs = gemspecs.resolve_require('backport') - backport = specs.find { |spec| spec.name == 'backport' } + let(:require) { 'bundler/require' } - expect(backport.version.to_s).to eq('1.2.0') - end + it 'does not raise' do + expect { specs }.not_to raise_error end - context 'with a gem preference already set to the version we use' do - let(:version) { Gem::Specification.find_by_name('backport').version.to_s } + it 'returns gems' do + expect(specs.map(&:name)).to include('backport') + end - let(:preferences) do - [ - Gem::Specification.new.tap do |spec| - spec.name = 'backport' - spec.version = version - end - ] + # find_or_install helper doesn't seem to work on older versions + if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.1.0') + context 'with a gem preference' do + before do + find_or_install('backport', '1.0.0') + Gem::Specification.find_by_name('backport', '= 1.0.0') + end + + let(:preferences) do + [ + Gem::Specification.new.tap do |spec| + spec.name = 'backport' + spec.version = '1.0.0' + end + ] + end + + it 'returns the preferred gemspec' do + gemspecs = described_class.new(dir_path, preferences: preferences) + specs = gemspecs.resolve_require('backport') + backport = specs.find { |spec| spec.name == 'backport' } + + expect(backport.version.to_s).to eq('1.0.0') + end end - it 'returns the gemspec we do have' do - gemspecs = described_class.new(dir_path, preferences: preferences) - specs = gemspecs.resolve_require('backport') - backport = specs.find { |spec| spec.name == 'backport' } + context 'with a gem preference that does not exist' do + let(:preferences) do + [ + Gem::Specification.new.tap do |spec| + spec.name = 'backport' + spec.version = '99.0.0' + end + ] + end + + it 'returns the gemspec we do have' do + gemspecs = described_class.new(dir_path, preferences: preferences) + specs = gemspecs.resolve_require('backport') + backport = specs.find { |spec| spec.name == 'backport' } + + expect(backport.version.to_s).to eq('1.2.0') + end + end - expect(backport.version.to_s).to eq(version) + context 'with a gem preference already set to the version we use' do + let(:version) { Gem::Specification.find_by_name('backport').version.to_s } + + let(:preferences) do + [ + Gem::Specification.new.tap do |spec| + spec.name = 'backport' + spec.version = version + end + ] + end + + it 'returns the gemspec we do have' do + gemspecs = described_class.new(dir_path, preferences: preferences) + specs = gemspecs.resolve_require('backport') + backport = specs.find { |spec| spec.name == 'backport' } + + expect(backport.version.to_s).to eq(version) + end end end end From a3bf5ddeaad56d416e9b97314d5b716f869de1d6 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Thu, 24 Jul 2025 15:33:23 -0400 Subject: [PATCH 149/400] More spec coverage --- lib/solargraph/api_map.rb | 13 ++--- lib/solargraph/api_map/store.rb | 2 +- spec/api_map/api_map_method_spec.rb | 13 +++++ spec/shell_spec.rb | 42 ++++++++------- .../gemspecs_fetch_dependencies_spec.rb | 53 +++++++++++++++++++ 5 files changed, 98 insertions(+), 25 deletions(-) create mode 100644 spec/api_map/api_map_method_spec.rb create mode 100644 spec/workspace/gemspecs_fetch_dependencies_spec.rb diff --git a/lib/solargraph/api_map.rb b/lib/solargraph/api_map.rb index 28ff32c10..3cf79e48e 100755 --- a/lib/solargraph/api_map.rb +++ b/lib/solargraph/api_map.rb @@ -135,6 +135,7 @@ def core_pins # @param name [String] # @return [YARD::Tags::MacroDirective, nil] + # @sg-ignore Solargraph::ApiMap#named_macro return type could not be inferred def named_macro name store.named_macros[name] end @@ -192,12 +193,7 @@ def cache_all_for_doc_map! out # @param rebuild [Boolean] # @return [void] def cache_all_for_workspace! out, rebuild: false - workspace.cache_all_for_workspace!(out, rebuild: rebuild) - end - - # @return [Workspace] - def workspace - @doc_map&.workspace + workspace&.cache_all_for_workspace!(out, rebuild: rebuild) end # @param name [String] @@ -981,6 +977,11 @@ def resolve_method_alias pin private + # @return [Workspace, nil] + def workspace + @doc_map&.workspace + end + # @param namespace_pin [Pin::Namespace] # @param rooted_type [ComplexType] # @param pins [Enumerable] diff --git a/lib/solargraph/api_map/store.rb b/lib/solargraph/api_map/store.rb index 830995b3d..d3c8fc911 100644 --- a/lib/solargraph/api_map/store.rb +++ b/lib/solargraph/api_map/store.rb @@ -116,7 +116,7 @@ def get_instance_variables(fqns, scope = :instance) end # @param fqns [String] - # @return [Enumerable] + # @return [Enumerable] def get_class_variables(fqns) namespace_children(fqns).select { |pin| pin.is_a?(Pin::ClassVariable)} end diff --git a/spec/api_map/api_map_method_spec.rb b/spec/api_map/api_map_method_spec.rb new file mode 100644 index 000000000..0978569ee --- /dev/null +++ b/spec/api_map/api_map_method_spec.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +describe Solargraph::ApiMap do + describe 'cache_all_for_workspace!' do + context 'with no workspace' do + subject(:api_map) { described_class.new } + + it 'ignores the request' do + expect { api_map.cache_all_for_workspace!(nil, rebuild: false) }.not_to raise_error + end + end + end +end diff --git a/spec/shell_spec.rb b/spec/shell_spec.rb index d20526175..cebd76fa6 100644 --- a/spec/shell_spec.rb +++ b/spec/shell_spec.rb @@ -72,21 +72,39 @@ def capture_stdout &block end end - describe 'gem' do - it 'has a well set up test enviornment' do + describe 'typecheck' do + it 'typechecks without erroring out' do + output = bundle_exec('solargraph', 'typecheck', 'Gemfile', '--level=normal') + + expect(output).to include('Typecheck finished in') + end + end + + describe 'gems' do + it 'caches core without erroring out' do + expect { bundle_exec('solargraph', 'cache', 'core') }.not_to raise_error + end + + it 'has a well set up test environment' do output = bundle_exec('bundle', 'list') expect(output).to include('language_server-protocol') end - it 'caches without erroring out' do - output = bundle_exec('solargraph', 'gem', 'solargraph') + it 'caches all without erroring out' do + output = bundle_exec('solargraph', 'gems') + + expect(output).to include('Documentation cached for all') + end + + it 'caches single gem without erroring out' do + output = bundle_exec('solargraph', 'gems', 'solargraph') expect(output).to include('Caching these gems') end it 'gives sensible error for gem that does not exist' do - output = bundle_exec('solargraph', 'gem', 'solargraph123') + output = bundle_exec('solargraph', 'gems', 'solargraph123') expect(output).to include('Caching these gems') end @@ -110,23 +128,11 @@ def capture_stdout &block end end - describe 'gems' do + describe 'cache' do it 'caches a stdlib gem without erroring out' do expect { bundle_exec('solargraph', 'cache', 'stringio') }.not_to raise_error end - it 'caches core without erroring out' do - expect { bundle_exec('solargraph', 'cache', 'core') }.not_to raise_error - end - - it 'caches all without erroring out' do - output = bundle_exec('solargraph', 'gems') - - expect(output).to include('Documentation cached for all') - end - end - - describe 'cache' do it 'caches without erroring out' do output = bundle_exec('solargraph', 'cache', 'solargraph') diff --git a/spec/workspace/gemspecs_fetch_dependencies_spec.rb b/spec/workspace/gemspecs_fetch_dependencies_spec.rb new file mode 100644 index 000000000..0596d0f12 --- /dev/null +++ b/spec/workspace/gemspecs_fetch_dependencies_spec.rb @@ -0,0 +1,53 @@ +# frozen_string_literal: true + +require 'fileutils' +require 'tmpdir' +require 'rubygems/commands/install_command' + +describe Solargraph::Workspace::Gemspecs, '#fetch_dependencies' do + subject(:deps) { gemspecs.fetch_dependencies(gemspec) } + + let(:gemspecs) { described_class.new(dir_path) } + let(:dir_path) { Dir.pwd } + + context 'with a Bundler::LazySpecification in bundle' do + let(:gemspec) do + Bundler::LazySpecification.new('solargraph', nil, nil) + end + + it 'finds a known dependency' do + expect(deps.map(&:name)).to include('backport') + end + end + + context 'with external bundle' do + let(:dir_path) { File.realpath(Dir.mktmpdir).to_s } + + let(:gemspec) do + Bundler::LazySpecification.new('undercover', nil, nil) + end + + before do + # write out Gemfile + File.write(File.join(dir_path, 'Gemfile'), <<~GEMFILE) + source 'https://rubygems.org' + gem 'undercover' + GEMFILE + + # run bundle install + output, status = Solargraph.with_clean_env do + Open3.capture2e('bundle install --verbose', chdir: dir_path) + end + raise "Failure installing bundle: #{output}" unless status.success? + + # ensure Gemfile.lock exists + unless File.exist?(File.join(dir_path, 'Gemfile.lock')) + raise "Gemfile.lock not found after bundle install in #{dir_path}" + end + end + + it 'finds dependencies' do + expect(deps.map(&:name)).to include('ast') + end + end +end From 3eb52e60c492c75f9b112cac357b9a2bf506f2b1 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Thu, 24 Jul 2025 15:46:54 -0400 Subject: [PATCH 150/400] Bring back workspace method --- lib/solargraph/api_map.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/solargraph/api_map.rb b/lib/solargraph/api_map.rb index 3cf79e48e..66854781a 100755 --- a/lib/solargraph/api_map.rb +++ b/lib/solargraph/api_map.rb @@ -975,13 +975,13 @@ def resolve_method_alias pin include Logging - private - # @return [Workspace, nil] def workspace @doc_map&.workspace end + private + # @param namespace_pin [Pin::Namespace] # @param rooted_type [ComplexType] # @param pins [Enumerable] From f3d3c93ef60a7a70d5bbe062e1416183d8ad88b6 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Thu, 24 Jul 2025 15:54:55 -0400 Subject: [PATCH 151/400] Bring back workspace method --- lib/solargraph/api_map.rb | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/lib/solargraph/api_map.rb b/lib/solargraph/api_map.rb index 66854781a..e62e45b29 100755 --- a/lib/solargraph/api_map.rb +++ b/lib/solargraph/api_map.rb @@ -700,6 +700,11 @@ def resolve_method_aliases pins, visibility = [:public, :private, :protected] GemPins.combine_method_pins_by_path(with_resolved_aliases) end + # @return [Workspace, nil] + def workspace + @doc_map&.workspace + end + private # A hash of source maps with filename keys. @@ -975,13 +980,6 @@ def resolve_method_alias pin include Logging - # @return [Workspace, nil] - def workspace - @doc_map&.workspace - end - - private - # @param namespace_pin [Pin::Namespace] # @param rooted_type [ComplexType] # @param pins [Enumerable] From 8c4368c4f2fecce7398b67ee917f52ab35e4ee7b Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Thu, 24 Jul 2025 16:03:36 -0400 Subject: [PATCH 152/400] Add specs --- lib/solargraph/shell.rb | 4 ++-- spec/api_map/api_map_method_spec.rb | 12 ++++++++++++ spec/shell_spec.rb | 7 +++++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/lib/solargraph/shell.rb b/lib/solargraph/shell.rb index b303c8a5c..00d9a389c 100755 --- a/lib/solargraph/shell.rb +++ b/lib/solargraph/shell.rb @@ -151,12 +151,12 @@ def uncache *gems workspace = Workspace.new('.') gems.each do |gem| if gem == 'core' - PinCache.uncache_core + PinCache.uncache_core(out: $stdout) next end if gem == 'stdlib' - PinCache.uncache_stdlib + PinCache.uncache_stdlib(out: $stdout) next end diff --git a/spec/api_map/api_map_method_spec.rb b/spec/api_map/api_map_method_spec.rb index 0978569ee..e345ad2a2 100644 --- a/spec/api_map/api_map_method_spec.rb +++ b/spec/api_map/api_map_method_spec.rb @@ -2,6 +2,18 @@ describe Solargraph::ApiMap do describe 'cache_all_for_workspace!' do + context 'with workspace' do + subject(:api_map) { described_class.load(Dir.pwd) } + + let(:out) { StringIO.new } + + it 'processes the request' do + api_map.cache_all_for_workspace!(out, rebuild: false) + + expect(out.string).to include('Documentation cached') + end + end + context 'with no workspace' do subject(:api_map) { described_class.new } diff --git a/spec/shell_spec.rb b/spec/shell_spec.rb index cebd76fa6..53dd49090 100644 --- a/spec/shell_spec.rb +++ b/spec/shell_spec.rb @@ -78,6 +78,13 @@ def capture_stdout &block expect(output).to include('Typecheck finished in') end + + it 'caches a gem if needed before typechecking' do + bundle_exec('solargraph', 'uncache', 'core') + output = bundle_exec('solargraph', 'typecheck', 'Gemfile', '--level=normal') + + expect(output).to include('Caching ') + end end describe 'gems' do From 741f4e3a6001c9e58e0dca3071e4c81cb322eb38 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Thu, 24 Jul 2025 16:20:10 -0400 Subject: [PATCH 153/400] More specs --- spec/api_map/api_map_method_spec.rb | 33 +++++++++++++++++++++++++++++ spec/shell_spec.rb | 24 +++++++++++++++------ 2 files changed, 51 insertions(+), 6 deletions(-) diff --git a/spec/api_map/api_map_method_spec.rb b/spec/api_map/api_map_method_spec.rb index e345ad2a2..c2382001e 100644 --- a/spec/api_map/api_map_method_spec.rb +++ b/spec/api_map/api_map_method_spec.rb @@ -22,4 +22,37 @@ end end end + + describe 'cache_gem' do + context 'with no workspace' do + subject(:api_map) { described_class.new } + + let(:out) { StringIO.new } + + it 'ignores the request' do + expect { api_map.cache_gem('backport', out: out) }.not_to raise_error + end + end + + context 'with workspace' do + subject(:api_map) { described_class.load(Dir.pwd) } + + let(:out) { StringIO.new } + + it 'processes the request' do + backport = Gem::Specification.find_by_name('backport') + expect { api_map.cache_gem(backport, out: out) }.not_to raise_error + end + end + end + + describe 'get_method_stack' do + let(:out) { StringIO.new } + let(:api_map) { described_class.load_with_cache(Dir.pwd, out) } + let(:method_stack) { api_map.get_method_stack('YAML', 'safe_load', scope: :class) } + + it 'handles the YAML gem aliased to Psych' do + expect(method_stack).not_to be_empty + end + end end diff --git a/spec/shell_spec.rb b/spec/shell_spec.rb index 53dd49090..ea2cc7d82 100644 --- a/spec/shell_spec.rb +++ b/spec/shell_spec.rb @@ -116,18 +116,30 @@ def capture_stdout &block expect(output).to include('Caching these gems') end - it 'caches a YARD-using gem and loads pins' do # rubocop:disable RSpec/MultipleExpectations + it 'caches all gems as needed' do shell = described_class.new - output = capture_stdout do + _output = capture_stdout do shell.uncache('backport') end - expect(output).to include('Clearing pin cache in') - output = capture_stdout do - shell.gems('backport') + _output = capture_stdout do + shell.gems end - expect(output).to include('Caching YARD pins for gem backport') + api_map = Solargraph::ApiMap.load(Dir.pwd) + methods = api_map.get_method_stack('Backport::Adapter', 'remote') + expect(methods.first.return_type.tag).to eq('Hash{Symbol => String, Integer}') + end + + it 'caches a YARD-using gem and loads pins' do + shell = described_class.new + _output = capture_stdout do + shell.uncache('backport') + end + + _output = capture_stdout do + shell.gems('backport') + end api_map = Solargraph::ApiMap.load(Dir.pwd) methods = api_map.get_method_stack('Backport::Adapter', 'remote') From 4897e755834287ec759bdeaf5535e4019e9532c9 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Thu, 24 Jul 2025 16:42:50 -0400 Subject: [PATCH 154/400] More specs --- lib/solargraph/doc_map.rb | 2 +- spec/api_map/api_map_method_spec.rb | 14 +++++++--- spec/shell_spec.rb | 42 ++++++++++++++++++++++++----- 3 files changed, 48 insertions(+), 10 deletions(-) diff --git a/lib/solargraph/doc_map.rb b/lib/solargraph/doc_map.rb index e7a21e4d9..17b36f936 100644 --- a/lib/solargraph/doc_map.rb +++ b/lib/solargraph/doc_map.rb @@ -64,7 +64,7 @@ def cache_doc_map_gems! out "Caching pins for gems: #{gem_desc}" end end - PinCache.cache_core unless PinCache.core? + PinCache.cache_core(out: out) unless PinCache.core? load_serialized_gem_pins(out: out) time = Benchmark.measure do uncached_gemspecs.each do |gemspec| diff --git a/spec/api_map/api_map_method_spec.rb b/spec/api_map/api_map_method_spec.rb index c2382001e..ea95ace3a 100644 --- a/spec/api_map/api_map_method_spec.rb +++ b/spec/api_map/api_map_method_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true describe Solargraph::ApiMap do - describe 'cache_all_for_workspace!' do + describe '#cache_all_for_workspace!' do context 'with workspace' do subject(:api_map) { described_class.load(Dir.pwd) } @@ -23,7 +23,7 @@ end end - describe 'cache_gem' do + describe '#cache_gem' do context 'with no workspace' do subject(:api_map) { described_class.new } @@ -46,7 +46,15 @@ end end - describe 'get_method_stack' do + describe '.load_with_cache' do + let(:out) { StringIO.new } + + it 'loads the API map with cache' do + expect(out.string).to include('Documentation cached for all') + end + end + + describe '#get_method_stack' do let(:out) { StringIO.new } let(:api_map) { described_class.load_with_cache(Dir.pwd, out) } let(:method_stack) { api_map.get_method_stack('YAML', 'safe_load', scope: :class) } diff --git a/spec/shell_spec.rb b/spec/shell_spec.rb index ea2cc7d82..d69f65d33 100644 --- a/spec/shell_spec.rb +++ b/spec/shell_spec.rb @@ -4,6 +4,8 @@ require 'open3' describe Solargraph::Shell do + let(:shell) { described_class.new } + let(:temp_dir) { Dir.mktmpdir } before do @@ -47,17 +49,19 @@ def bundle_exec(*cmd) describe 'uncache' do it 'uncaches without erroring out' do - output = bundle_exec('solargraph', 'uncache', 'solargraph') + output = capture_stdout do + shell.uncache('solargraph') + end expect(output).to include('Clearing pin cache in') end it 'uncaches stdlib without erroring out' do - expect { bundle_exec('solargraph', 'uncache', 'stdlib') }.not_to raise_error + expect { shell.uncache('stdlib') }.not_to raise_error end it 'uncaches core without erroring out' do - expect { bundle_exec('solargraph', 'uncache', 'core') }.not_to raise_error + expect { shell.uncache('core') }.not_to raise_error end end @@ -72,16 +76,42 @@ def capture_stdout &block end end + def capture_both &block + original_stdout = $stdout + original_stderr = $stderr + stringio = StringIO.new + $stdout = stringio + $stderr = stringio + begin + block.call + stringio.string + ensure + $stdout = original_stdout + $stderr = original_stderr + end + end + describe 'typecheck' do it 'typechecks without erroring out' do - output = bundle_exec('solargraph', 'typecheck', 'Gemfile', '--level=normal') + output = capture_stdout do + old_options = shell.options + shell.options = { level: 'normal', directory: '.', **old_options } + shell.typecheck('Gemfile') + end expect(output).to include('Typecheck finished in') end it 'caches a gem if needed before typechecking' do - bundle_exec('solargraph', 'uncache', 'core') - output = bundle_exec('solargraph', 'typecheck', 'Gemfile', '--level=normal') + capture_stdout do + shell.uncache('core') + end + + output = capture_both do + old_options = shell.options + shell.options = { level: 'normal', directory: '.', **old_options } + shell.typecheck('Gemfile') + end expect(output).to include('Caching ') end From 5f300019aec7b5715b61450923aa0b2b28d18be8 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Thu, 24 Jul 2025 17:03:13 -0400 Subject: [PATCH 155/400] Ensure uncaching clears out in-memory cache as well Useful for testing and probably also for LSP control --- lib/solargraph/api_map.rb | 6 ++++++ lib/solargraph/pin_cache.rb | 10 +++++++++- spec/shell_spec.rb | 2 +- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/lib/solargraph/api_map.rb b/lib/solargraph/api_map.rb index e62e45b29..482c0de55 100755 --- a/lib/solargraph/api_map.rb +++ b/lib/solargraph/api_map.rb @@ -33,6 +33,12 @@ def initialize pins: [] index pins end + # @param out [IO, nil] output stream for logging + # @return [void] + def self.reset_core out: nil + @@core_map = RbsMap::CoreMap.new + end + # # This is a mutable object, which is cached in the Chain class - # if you add any fields which change the results of calls (not diff --git a/lib/solargraph/pin_cache.rb b/lib/solargraph/pin_cache.rb index efbf25622..5067ecd23 100644 --- a/lib/solargraph/pin_cache.rb +++ b/lib/solargraph/pin_cache.rb @@ -124,9 +124,15 @@ def deserialize_combined_pin_cache(gemspec) # @return [void] def uncache_gem(gemspec, out: nil) PinCache.uncache(yardoc_path(gemspec), out: out) - uncache_by_prefix(rbs_collection_pins_path_prefix(gemspec), out: out) + yard_pins_in_memory.delete([gemspec.name, gemspec.version]) PinCache.uncache(yard_gem_path(gemspec), out: out) + + rbs_version_cache_key = lookup_rbs_version_cache_key(gemspec) + uncache_by_prefix(rbs_collection_pins_path_prefix(gemspec), out: out) + rbs_collection_pins_in_memory.delete([gemspec.name, gemspec.version, rbs_version_cache_key]) + uncache_by_prefix(combined_path_prefix(gemspec), out: out) + combined_pins_in_memory.delete([gemspec.name, gemspec.version, rbs_version_cache_key]) end # @param gemspec [Gem::Specification, Bundler::LazySpecification] @@ -496,6 +502,8 @@ def uncache *path_segments, out: nil # @return [void] def uncache_core(out: nil) uncache(core_path, out: out) + # ApiMap keep this in memory + ApiMap.reset_core(out: out) end # @param out [IO, nil] diff --git a/spec/shell_spec.rb b/spec/shell_spec.rb index d69f65d33..b40618b62 100644 --- a/spec/shell_spec.rb +++ b/spec/shell_spec.rb @@ -84,11 +84,11 @@ def capture_both &block $stderr = stringio begin block.call - stringio.string ensure $stdout = original_stdout $stderr = original_stderr end + stringio.string end describe 'typecheck' do From c805d58081851fb1c5966782e6324fada26e5989 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Thu, 24 Jul 2025 17:33:18 -0400 Subject: [PATCH 156/400] Fix spec --- lib/solargraph/api_map.rb | 3 ++- lib/solargraph/shell.rb | 2 +- spec/api_map/api_map_method_spec.rb | 10 +++++++--- spec/shell_spec.rb | 26 -------------------------- spec/spec_helper.rb | 26 ++++++++++++++++++++++++++ 5 files changed, 36 insertions(+), 31 deletions(-) diff --git a/lib/solargraph/api_map.rb b/lib/solargraph/api_map.rb index 482c0de55..75ce6cc73 100755 --- a/lib/solargraph/api_map.rb +++ b/lib/solargraph/api_map.rb @@ -178,6 +178,7 @@ def clip_at filename, position # Create an ApiMap with a workspace in the specified directory. # # @param directory [String] + # # @return [ApiMap] def self.load directory api_map = new @@ -233,7 +234,7 @@ class << self # @param directory [String] workspace directory # @param out [IO] The output stream for messages # @return [ApiMap] - def self.load_with_cache directory, out + def self.load_with_cache directory, out: $stderr api_map = load(directory) if api_map.uncached_gemspecs.empty? logger.info { "All gems cached for #{directory}" } diff --git a/lib/solargraph/shell.rb b/lib/solargraph/shell.rb index 00d9a389c..b28189a91 100755 --- a/lib/solargraph/shell.rb +++ b/lib/solargraph/shell.rb @@ -183,7 +183,7 @@ def reporters # @return [void] def typecheck *files directory = File.realpath(options[:directory]) - api_map = Solargraph::ApiMap.load_with_cache(directory, $stdout) + api_map = Solargraph::ApiMap.load_with_cache(directory, out: $stdout) probcount = 0 if files.empty? files = api_map.source_maps.map(&:filename) diff --git a/spec/api_map/api_map_method_spec.rb b/spec/api_map/api_map_method_spec.rb index ea95ace3a..f476778a0 100644 --- a/spec/api_map/api_map_method_spec.rb +++ b/spec/api_map/api_map_method_spec.rb @@ -47,10 +47,14 @@ end describe '.load_with_cache' do - let(:out) { StringIO.new } - it 'loads the API map with cache' do - expect(out.string).to include('Documentation cached for all') + Solargraph::PinCache.uncache_core + + output = capture_both do + described_class.load_with_cache(Dir.pwd) + end + + expect(output).to include('aching RBS pins for Ruby core') end end diff --git a/spec/shell_spec.rb b/spec/shell_spec.rb index b40618b62..90a83545d 100644 --- a/spec/shell_spec.rb +++ b/spec/shell_spec.rb @@ -65,32 +65,6 @@ def bundle_exec(*cmd) end end - def capture_stdout &block - original_stdout = $stdout - $stdout = StringIO.new - begin - block.call - $stdout.string - ensure - $stdout = original_stdout - end - end - - def capture_both &block - original_stdout = $stdout - original_stderr = $stderr - stringio = StringIO.new - $stdout = stringio - $stderr = stringio - begin - block.call - ensure - $stdout = original_stdout - $stderr = original_stderr - end - stringio.string - end - describe 'typecheck' do it 'typechecks without erroring out' do output = capture_stdout do diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index a9ea4a15a..fdf179ede 100755 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -31,3 +31,29 @@ def with_env_var(name, value) ENV[name] = old_value # Restore the old value end end + +def capture_stdout &block + original_stdout = $stdout + $stdout = StringIO.new + begin + block.call + $stdout.string + ensure + $stdout = original_stdout + end +end + +def capture_both &block + original_stdout = $stdout + original_stderr = $stderr + stringio = StringIO.new + $stdout = stringio + $stderr = stringio + begin + block.call + ensure + $stdout = original_stdout + $stderr = original_stderr + end + stringio.string +end From fb35deba17d1d7f9f71a1b89c0405100b15a25b3 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Thu, 24 Jul 2025 17:47:10 -0400 Subject: [PATCH 157/400] Fix specs --- lib/solargraph/shell.rb | 2 +- spec/api_map/api_map_method_spec.rb | 2 +- spec/api_map_spec.rb | 6 +++--- spec/type_checker/levels/strict_spec.rb | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/solargraph/shell.rb b/lib/solargraph/shell.rb index b28189a91..71f02f88f 100755 --- a/lib/solargraph/shell.rb +++ b/lib/solargraph/shell.rb @@ -227,7 +227,7 @@ def scan # @type [Solargraph::ApiMap, nil] api_map = nil time = Benchmark.measure { - api_map = Solargraph::ApiMap.load_with_cache(directory, $stdout) + api_map = Solargraph::ApiMap.load_with_cache(directory, out: $stdout) api_map.pins.each do |pin| begin puts pin_description(pin) if options[:verbose] diff --git a/spec/api_map/api_map_method_spec.rb b/spec/api_map/api_map_method_spec.rb index f476778a0..8a272b109 100644 --- a/spec/api_map/api_map_method_spec.rb +++ b/spec/api_map/api_map_method_spec.rb @@ -60,7 +60,7 @@ describe '#get_method_stack' do let(:out) { StringIO.new } - let(:api_map) { described_class.load_with_cache(Dir.pwd, out) } + let(:api_map) { described_class.load_with_cache(Dir.pwd, out: out) } let(:method_stack) { api_map.get_method_stack('YAML', 'safe_load', scope: :class) } it 'handles the YAML gem aliased to Psych' do diff --git a/spec/api_map_spec.rb b/spec/api_map_spec.rb index 4d7077ccd..185b30be7 100755 --- a/spec/api_map_spec.rb +++ b/spec/api_map_spec.rb @@ -6,7 +6,7 @@ # avoid performance hit of doing this many times # rubocop:disable RSpec/InstanceVariable before :all do # rubocop:disable RSpec/BeforeAfterAll - @api_map = described_class.load_with_cache(Dir.pwd, nil) + @api_map = described_class.load_with_cache(Dir.pwd, out: nil) end it 'returns core methods' do @@ -21,7 +21,7 @@ end it 'automatically caches core' do - api_map = described_class.load_with_cache(Dir.pwd, nil) + api_map = described_class.load_with_cache(Dir.pwd, out: nil) pins = api_map.get_methods('String') expect(pins.map(&:path)).to include('String#upcase') end @@ -34,7 +34,7 @@ end it 'automatically caches gems' do - api_map = described_class.load_with_cache(Dir.pwd, nil) + api_map = described_class.load_with_cache(Dir.pwd, out: nil) pins = api_map.get_methods('RuboCop::Cop::Base') expect(pins.map(&:path)).to include('RuboCop::Cop::Base#active_support_extensions_enabled?') end diff --git a/spec/type_checker/levels/strict_spec.rb b/spec/type_checker/levels/strict_spec.rb index 13c20e85f..c92a76874 100644 --- a/spec/type_checker/levels/strict_spec.rb +++ b/spec/type_checker/levels/strict_spec.rb @@ -59,7 +59,7 @@ def bar(a); end require 'kramdown-parser-gfm' Kramdown::Parser::GFM.undefined_call ), 'test.rb') - api_map = Solargraph::ApiMap.load_with_cache('.', nil) + api_map = Solargraph::ApiMap.load_with_cache('.', out: nil) api_map.catalog Solargraph::Bench.new(source_maps: [source_map], external_requires: ['kramdown-parser-gfm']) checker = Solargraph::TypeChecker.new('test.rb', api_map: api_map, level: :strict) expect(checker.problems).to be_empty From 95b74be60b00517b19c7ebec478130eaf84b6248 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Thu, 24 Jul 2025 17:54:20 -0400 Subject: [PATCH 158/400] Coverage fixes --- spec/shell_spec.rb | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/spec/shell_spec.rb b/spec/shell_spec.rb index 90a83545d..d506f72ac 100644 --- a/spec/shell_spec.rb +++ b/spec/shell_spec.rb @@ -50,7 +50,7 @@ def bundle_exec(*cmd) describe 'uncache' do it 'uncaches without erroring out' do output = capture_stdout do - shell.uncache('solargraph') + shell.uncache('backport') end expect(output).to include('Clearing pin cache in') @@ -93,7 +93,7 @@ def bundle_exec(*cmd) describe 'gems' do it 'caches core without erroring out' do - expect { bundle_exec('solargraph', 'cache', 'core') }.not_to raise_error + expect { shell.cache('core') }.not_to raise_error end it 'has a well set up test environment' do @@ -109,15 +109,23 @@ def bundle_exec(*cmd) end it 'caches single gem without erroring out' do - output = bundle_exec('solargraph', 'gems', 'solargraph') + capture_both do + shell.uncache('backport') + end + + output = capture_both do + shell.gems('backport') + end - expect(output).to include('Caching these gems') + expect(output).to include('Caching').and include('backport') end it 'gives sensible error for gem that does not exist' do - output = bundle_exec('solargraph', 'gems', 'solargraph123') + output = capture_both do + shell.gems('solargraph123') + end - expect(output).to include('Caching these gems') + expect(output).to include("Gem 'solargraph123' not found") end it 'caches all gems as needed' do @@ -153,13 +161,19 @@ def bundle_exec(*cmd) describe 'cache' do it 'caches a stdlib gem without erroring out' do - expect { bundle_exec('solargraph', 'cache', 'stringio') }.not_to raise_error + expect { shell.cache('stringio') }.not_to raise_error end - it 'caches without erroring out' do - output = bundle_exec('solargraph', 'cache', 'solargraph') + it 'caches gem without erroring out' do + _output = capture_stdout do + shell.uncache('backport') + end + + output = capture_both do + shell.cache('backport') + end - expect(output).to include('Caching these gems') + expect(output).to include('Caching').and include('backport') end end end From d99b44f723bf47f359b1b57073a9678954aa7421 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Thu, 24 Jul 2025 17:59:51 -0400 Subject: [PATCH 159/400] Coverage fixes --- spec/shell_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/shell_spec.rb b/spec/shell_spec.rb index d506f72ac..52dc79ed1 100644 --- a/spec/shell_spec.rb +++ b/spec/shell_spec.rb @@ -78,7 +78,7 @@ def bundle_exec(*cmd) it 'caches a gem if needed before typechecking' do capture_stdout do - shell.uncache('core') + shell.uncache('backport') end output = capture_both do @@ -87,7 +87,7 @@ def bundle_exec(*cmd) shell.typecheck('Gemfile') end - expect(output).to include('Caching ') + expect(output).to include('Caching ').and include('backport') end end From 8dc4a6783a4e3f7ef182331952f770a443f664b0 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Thu, 24 Jul 2025 18:11:34 -0400 Subject: [PATCH 160/400] Fix flakey spec --- lib/solargraph/pin_cache.rb | 2 +- lib/solargraph/shell.rb | 4 ++-- spec/shell_spec.rb | 5 ++--- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/solargraph/pin_cache.rb b/lib/solargraph/pin_cache.rb index 5067ecd23..b71a16ff5 100644 --- a/lib/solargraph/pin_cache.rb +++ b/lib/solargraph/pin_cache.rb @@ -132,7 +132,7 @@ def uncache_gem(gemspec, out: nil) rbs_collection_pins_in_memory.delete([gemspec.name, gemspec.version, rbs_version_cache_key]) uncache_by_prefix(combined_path_prefix(gemspec), out: out) - combined_pins_in_memory.delete([gemspec.name, gemspec.version, rbs_version_cache_key]) + combined_pins_in_memory.delete([gemspec.name, gemspec.version]) end # @param gemspec [Gem::Specification, Bundler::LazySpecification] diff --git a/lib/solargraph/shell.rb b/lib/solargraph/shell.rb index 71f02f88f..22ae1e43a 100755 --- a/lib/solargraph/shell.rb +++ b/lib/solargraph/shell.rb @@ -118,7 +118,7 @@ def gems *names if names.empty? api_map.cache_all_for_workspace!($stdout, rebuild: options.rebuild) else - STDERR.puts("Caching these gems: #{names}") + $stderr.puts("Caching these gems: #{names}") names.each do |name| if name == 'core' PinCache.cache_core(out: $stdout) @@ -134,7 +134,7 @@ def gems *names rescue Gem::MissingSpecError warn "Gem '#{name}' not found" end - STDERR.puts "Documentation cached for #{names.count} gems." + $stderr.puts "Documentation cached for #{names.count} gems." end end diff --git a/spec/shell_spec.rb b/spec/shell_spec.rb index 52dc79ed1..4bc9cacfc 100644 --- a/spec/shell_spec.rb +++ b/spec/shell_spec.rb @@ -77,13 +77,12 @@ def bundle_exec(*cmd) end it 'caches a gem if needed before typechecking' do - capture_stdout do + capture_both do shell.uncache('backport') end output = capture_both do - old_options = shell.options - shell.options = { level: 'normal', directory: '.', **old_options } + shell.options = { level: 'normal', directory: Dir.pwd } shell.typecheck('Gemfile') end From 28f164b49d38bef2d344b4bc3844ca2723bbb3bb Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Fri, 25 Jul 2025 07:17:08 -0400 Subject: [PATCH 161/400] Drop unused method --- lib/solargraph/doc_map.rb | 5 ----- 1 file changed, 5 deletions(-) diff --git a/lib/solargraph/doc_map.rb b/lib/solargraph/doc_map.rb index 17b36f936..94a3380e1 100644 --- a/lib/solargraph/doc_map.rb +++ b/lib/solargraph/doc_map.rb @@ -45,11 +45,6 @@ def pin_cache @pin_cache ||= workspace.fresh_pincache end - # @return [Array] - def yard_plugins - global_environ.yard_plugins - end - def any_uncached? uncached_gemspecs.any? end From d1ee3ce1c771734e752abbad87c13695845f9909 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Fri, 25 Jul 2025 08:50:39 -0400 Subject: [PATCH 162/400] Improve coverage, fix minor bug that happens in debug logging --- lib/solargraph/api_map/index.rb | 12 ++++--- lib/solargraph/pin/callable.rb | 15 ++++++++ lib/solargraph/pin/parameter.rb | 7 ++++ spec/api_map/index_spec.rb | 64 +++++++++++++++++++++++++++++++++ 4 files changed, 93 insertions(+), 5 deletions(-) create mode 100644 spec/api_map/index_spec.rb diff --git a/lib/solargraph/api_map/index.rb b/lib/solargraph/api_map/index.rb index 6577ad188..f2fc59052 100644 --- a/lib/solargraph/api_map/index.rb +++ b/lib/solargraph/api_map/index.rb @@ -154,10 +154,13 @@ def map_overrides ovr.tags.each do |tag| pin.docstring.add_tag(tag) redefine_return_type pin, tag - if new_pin - new_pin.docstring.add_tag(tag) - redefine_return_type new_pin, tag - end + pin.reset_generated! + + next unless new_pin + + new_pin.docstring.add_tag(tag) + redefine_return_type new_pin, tag + new_pin.reset_generated! end end end @@ -174,7 +177,6 @@ def redefine_return_type pin, tag pin.signatures.each do |sig| sig.instance_variable_set(:@return_type, ComplexType.try_parse(tag.type)) end - pin.reset_generated! end end end diff --git a/lib/solargraph/pin/callable.rb b/lib/solargraph/pin/callable.rb index 20d2301eb..0f148d851 100644 --- a/lib/solargraph/pin/callable.rb +++ b/lib/solargraph/pin/callable.rb @@ -21,10 +21,13 @@ def initialize block: nil, return_type: nil, parameters: [], **splat @parameters = parameters end + # @return [String] def method_namespace closure.namespace end + # @param other [self] + # @return [Solargraph::Pin::Signature, nil] def combine_blocks(other) if block.nil? other.block @@ -57,8 +60,11 @@ def generics [] end + # @param other [self] + # @return [::Array] def choose_parameters(other) raise "Trying to combine two pins with different arities - \nself =#{inspect}, \nother=#{other.inspect}, \n\n self.arity=#{self.arity}, \nother.arity=#{other.arity}" if other.arity != arity + # @sg-ignore Wrong argument type for Array#zip: arg expected _Each, received Array parameters.zip(other.parameters).map do |param, other_param| if param.nil? && other_param.block? other_param @@ -70,6 +76,7 @@ def choose_parameters(other) end end + # @return [Array] def blockless_parameters if parameters.last&.block? parameters[0..-2] @@ -78,6 +85,7 @@ def blockless_parameters end end + # @return [Array] def arity [generics, blockless_parameters.map(&:arity_decl), block&.arity] end @@ -125,6 +133,7 @@ def typify api_map end end + # @return [String] def method_name raise "closure was nil in #{self.inspect}" if closure.nil? @method_name ||= closure.name @@ -197,6 +206,12 @@ def arity_matches? arguments, with_block true end + def reset_generated! + super + @parameters.each(&:reset_generated!) + end + + # @return [Integer] def mandatory_positional_param_count parameters.count(&:arg?) end diff --git a/lib/solargraph/pin/parameter.rb b/lib/solargraph/pin/parameter.rb index bc802b748..f11d91628 100644 --- a/lib/solargraph/pin/parameter.rb +++ b/lib/solargraph/pin/parameter.rb @@ -35,6 +35,7 @@ def combine_with(other, attrs={}) presence: choose(other, :presence), asgn_code: choose(other, :asgn_code), }.merge(attrs) + # @sg-ignore Wrong argument type for Solargraph::Pin::LocalVariable#combine_with: other expected Solargraph::Pin::LocalVariable, received self super(other, new_attrs) end @@ -43,6 +44,7 @@ def keyword? end def kwrestarg? + # @sg-ignore Unresolved call to type decl == :kwrestarg || (assignment && [:HASH, :hash].include?(assignment.type)) end @@ -125,6 +127,11 @@ def full end end + def reset_generated! + super + @return_type = nil if @return_type&.undefined? + end + # @return [ComplexType] def return_type if @return_type.nil? diff --git a/spec/api_map/index_spec.rb b/spec/api_map/index_spec.rb new file mode 100644 index 000000000..8afb74759 --- /dev/null +++ b/spec/api_map/index_spec.rb @@ -0,0 +1,64 @@ +# frozen_string_literal: true + +describe Solargraph::ApiMap::Index do + subject(:output_pins) { described_class.new(input_pins).pins } + + describe '#map_overrides' do + let(:foo_class) do + Solargraph::Pin::Namespace.new(name: 'Foo') + end + + let(:foo_initialize) do + init = Solargraph::Pin::Method.new(name: 'initialize', + scope: :instance, + parameters: [], + closure: foo_class) + # no return type specified + param = Solargraph::Pin::Parameter.new(name: 'bar', + closure: init) + init.parameters << param + init + end + + let(:foo_new) do + init = Solargraph::Pin::Method.new(name: 'new', + scope: :class, + parameters: [], + closure: foo_class) + # no return type specified + param = Solargraph::Pin::Parameter.new(name: 'bar', + closure: init) + init.parameters << param + init + end + + let(:foo_override) do + Solargraph::Pin::Reference::Override.from_comment('Foo#initialize', + '@param [String] bar') + end + + let(:input_pins) do + [ + foo_initialize, + foo_new, + foo_override + ] + end + + it 'has a docstring to process on override' do + expect(foo_override.docstring.tags).to be_empty + end + + it 'overrides .new method' do + method_pin = output_pins.find { |pin| pin.path == 'Foo.new' } + first_parameter = method_pin.parameters.first + expect(first_parameter.return_type.tag).to eq('String') + end + + it 'overrides #initialize method in signature' do + method_pin = output_pins.find { |pin| pin.path == 'Foo#initialize' } + first_parameter = method_pin.parameters.first + expect(first_parameter.return_type.tag).to eq('String') + end + end +end From 059664080ec9133b34929fe8267acfe3745104f3 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Fri, 25 Jul 2025 20:20:35 -0400 Subject: [PATCH 163/400] Add another spec --- spec/shell_spec.rb | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/spec/shell_spec.rb b/spec/shell_spec.rb index 4bc9cacfc..fb6000495 100644 --- a/spec/shell_spec.rb +++ b/spec/shell_spec.rb @@ -88,10 +88,34 @@ def bundle_exec(*cmd) expect(output).to include('Caching ').and include('backport') end + + it 'logs if it takes a certain amount of time to cache gems' do + capture_both do + shell.uncache('backport') + end + + allow_any_instance_of(Solargraph::PinCache) # rubocop:disable RSpec/AnyInstance + .to receive(:cache_gem) + .and_wrap_original do |original, *args, **kwargs| + sleep(0.5) # simulate a slow cache + original.call(*args, **kwargs) + end + + output = capture_both do + shell.options = { level: 'normal', directory: Dir.pwd } + shell.typecheck('Gemfile') + end + + expect(output).to include(' built in ').and include(' ms') + end end describe 'gems' do it 'caches core without erroring out' do + capture_both do + shell.uncache('core') + end + expect { shell.cache('core') }.not_to raise_error end From 93db9a846dff72c578a8edaff46d76f6bb123201 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Fri, 25 Jul 2025 20:24:24 -0400 Subject: [PATCH 164/400] Add another spec --- spec/shell_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/shell_spec.rb b/spec/shell_spec.rb index fb6000495..7c087fcb3 100644 --- a/spec/shell_spec.rb +++ b/spec/shell_spec.rb @@ -106,7 +106,7 @@ def bundle_exec(*cmd) shell.typecheck('Gemfile') end - expect(output).to include(' built in ').and include(' ms') + expect(output).to include('Built ').and include(' ms') end end From b00ed5a74344233ff3f2ed76e9ade284eab52b7c Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Sat, 26 Jul 2025 09:19:13 -0400 Subject: [PATCH 165/400] More tests, drop dead code --- lib/solargraph/api_map.rb | 5 ++--- lib/solargraph/doc_map.rb | 6 +----- lib/solargraph/shell.rb | 4 ++-- spec/shell_spec.rb | 3 ++- 4 files changed, 7 insertions(+), 11 deletions(-) diff --git a/lib/solargraph/api_map.rb b/lib/solargraph/api_map.rb index 75ce6cc73..261edae52 100755 --- a/lib/solargraph/api_map.rb +++ b/lib/solargraph/api_map.rb @@ -213,11 +213,10 @@ def find_gem name, version = nil # @param gemspec [Gem::Specification] # @param rebuild [Boolean] - # @param only_if_used [Boolean] # @param out [IO, nil] # @return [void] - def cache_gem gemspec, rebuild: false, only_if_used: false, out: nil - @doc_map&.cache(gemspec, rebuild: rebuild, out: out, only_if_used: only_if_used) + def cache_gem gemspec, rebuild: false, out: nil + @doc_map&.cache(gemspec, rebuild: rebuild, out: out) end class << self diff --git a/lib/solargraph/doc_map.rb b/lib/solargraph/doc_map.rb index 94a3380e1..1dd524098 100644 --- a/lib/solargraph/doc_map.rb +++ b/lib/solargraph/doc_map.rb @@ -59,7 +59,6 @@ def cache_doc_map_gems! out "Caching pins for gems: #{gem_desc}" end end - PinCache.cache_core(out: out) unless PinCache.core? load_serialized_gem_pins(out: out) time = Benchmark.measure do uncached_gemspecs.each do |gemspec| @@ -87,13 +86,10 @@ def dependencies # # @param gemspec [Gem::Specification] # @param rebuild [Boolean] whether to rebuild the pins even if they are cached - # @param only_if_used [Boolean] # @param out [IO, nil] output stream for logging # # @return [void] - def cache gemspec, rebuild: false, only_if_used: false, out: nil - return if only_if_used && !uncached_gemspecs.include?(gemspec) - + def cache gemspec, rebuild: false, out: nil pin_cache.cache_gem(gemspec: gemspec, rebuild: rebuild, out: out) diff --git a/lib/solargraph/shell.rb b/lib/solargraph/shell.rb index 22ae1e43a..03ce59410 100755 --- a/lib/solargraph/shell.rb +++ b/lib/solargraph/shell.rb @@ -116,7 +116,7 @@ def cache gem, version = nil def gems *names api_map = ApiMap.load('.') if names.empty? - api_map.cache_all_for_workspace!($stdout, rebuild: options.rebuild) + api_map.cache_all_for_workspace!($stdout, rebuild: options[:rebuild]) else $stderr.puts("Caching these gems: #{names}") names.each do |name| @@ -129,7 +129,7 @@ def gems *names if gemspec.nil? warn "Gem '#{name}' not found" else - api_map.cache_gem(gemspec, rebuild: options.rebuild, out: $stdout) + api_map.cache_gem(gemspec, rebuild: options[:rebuild], out: $stdout) end rescue Gem::MissingSpecError warn "Gem '#{name}' not found" diff --git a/spec/shell_spec.rb b/spec/shell_spec.rb index 7c087fcb3..46cfd73f0 100644 --- a/spec/shell_spec.rb +++ b/spec/shell_spec.rb @@ -173,7 +173,8 @@ def bundle_exec(*cmd) end _output = capture_stdout do - shell.gems('backport') + shell.options = { rebuild: true } + shell.gems('backport', 'thor') end api_map = Solargraph::ApiMap.load(Dir.pwd) From a6f9337debb775285c7f7d225f4fbead17714f41 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Sat, 26 Jul 2025 10:02:28 -0400 Subject: [PATCH 166/400] More tests, drop incorrect code --- lib/solargraph/doc_map.rb | 2 -- spec/doc_map_spec.rb | 33 ++++++++++++++++++++++++--------- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/lib/solargraph/doc_map.rb b/lib/solargraph/doc_map.rb index 1dd524098..9e373953b 100644 --- a/lib/solargraph/doc_map.rb +++ b/lib/solargraph/doc_map.rb @@ -118,12 +118,10 @@ def load_serialized_gem_pins out: $stderr # this will load from disk if needed; no need to manage # uncached_gemspecs to trigger that later stdlib_name_guess = path.split('/').first - # @todo this results in pins being generated in real time, not in advance with solargrpah gems rbs_pins = pin_cache.cache_stdlib_rbs_map stdlib_name_guess if stdlib_name_guess @pins.concat rbs_pins if rbs_pins end - logger.debug { "DocMap#load_serialized_gem_pins: Combining pins..." } existing_pin_count = pins.length time = Benchmark.measure do gemspecs.each do |gemspec| diff --git a/spec/doc_map_spec.rb b/spec/doc_map_spec.rb index a6f52d033..823db14d7 100644 --- a/spec/doc_map_spec.rb +++ b/spec/doc_map_spec.rb @@ -1,12 +1,14 @@ # frozen_string_literal: true require 'bundler' +require 'benchmark' describe Solargraph::DocMap do subject(:doc_map) do - Solargraph::DocMap.new(requires, workspace, out: nil) + Solargraph::DocMap.new(requires, workspace, out: out) end + let(:out) { StringIO.new } let(:pre_cache) { true } let(:requires) { [] } @@ -41,23 +43,37 @@ end end - context 'with an uncached but valid gemspec' do - let(:uncached_gemspec) do - Gem::Specification.new('uncached_gem', '1.0.0') + context 'when deserialization takes a while' do + let(:pre_cache) { false } + let(:requires) { ['backport'] } + + before do + # proxy this method to simulate a long-running deserialization + allow(Benchmark).to receive(:measure) do |&block| + block.call + 5.0 + end + end + + it 'logs timing' do + doc_map + expect(out.string).to include('Deserialized ').and include(' gem pins ').and include(' ms') end + end + + context 'with an uncached but valid gemspec' do let(:requires) { ['uncached_gem'] } let(:pre_cache) { false } let(:workspace) { instance_double(Solargraph::Workspace) } - before do + it 'tracks uncached_gemspecs' do pincache = instance_double(Solargraph::PinCache) + uncached_gemspec = Gem::Specification.new('uncached_gem', '1.0.0') allow(workspace).to receive(:resolve_require).with('uncached_gem').and_return([uncached_gemspec]) allow(workspace).to receive(:fetch_dependencies).with(uncached_gemspec).and_return([]) allow(workspace).to receive(:fresh_pincache).and_return(pincache) allow(pincache).to receive(:deserialize_combined_pin_cache).with(uncached_gemspec).and_return(nil) - end - it 'tracks uncached_gemspecs' do expect(doc_map.uncached_gemspecs).to eq([uncached_gemspec]) end end @@ -100,10 +116,9 @@ context 'with a require that has dependencies' do let(:requires) { ['rspec'] } - let(:example_dependency) { 'rspec-core' } it 'collects dependencies' do - expect(doc_map.dependencies.map(&:name)).to include(example_dependency) + expect(doc_map.dependencies.map(&:name)).to include('rspec-core') end end end From ac7c80c18cb776ef88e774728852f14412395c33 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Sat, 26 Jul 2025 13:36:02 -0400 Subject: [PATCH 167/400] More tests, drop dead code --- lib/solargraph/gem_pins.rb | 7 - spec/gem_pins_spec.rb | 59 +++++- spec/language_server/protocol_spec.rb | 2 +- spec/library_spec.rb | 250 ++++++++++++++------------ 4 files changed, 190 insertions(+), 128 deletions(-) diff --git a/lib/solargraph/gem_pins.rb b/lib/solargraph/gem_pins.rb index dead29c34..6efe3628c 100644 --- a/lib/solargraph/gem_pins.rb +++ b/lib/solargraph/gem_pins.rb @@ -49,13 +49,6 @@ def self.combine(yard_pins, rbs_pins) rbs_pin = rbs_api_map.get_path_pins(yard_pin.path).filter { |pin| pin.is_a? Pin::Method }.first next yard_pin unless rbs_pin && yard_pin.class == Pin::Method - unless rbs_pin - logger.debug do - "GemPins.combine: No rbs pin for #{yard_pin.path} - using YARD's '#{yard_pin.inspect} (return_type=#{yard_pin.return_type}; signatures=#{yard_pin.signatures})" - end - next yard_pin - end - out = combine_method_pins(rbs_pin, yard_pin) logger.debug do "GemPins.combine: Combining yard.path=#{yard_pin.path} - rbs=#{rbs_pin.inspect} with yard=#{yard_pin.inspect} into #{out}" diff --git a/spec/gem_pins_spec.rb b/spec/gem_pins_spec.rb index 093aa4cc1..ceb7fc346 100644 --- a/spec/gem_pins_spec.rb +++ b/spec/gem_pins_spec.rb @@ -1,13 +1,56 @@ # frozen_string_literal: true describe Solargraph::GemPins do - it 'can merge YARD and RBS' do - workspace = Solargraph::Workspace.new(Dir.pwd) - doc_map = Solargraph::DocMap.new(['rbs'], workspace, out: nil) - doc_map.cache_doc_map_gems!(nil) - - core_root = doc_map.pins.find { |pin| pin.path == 'RBS::EnvironmentLoader#core_root' } - expect(core_root.return_type.to_s).to eq('Pathname, nil') - expect(core_root.location.filename).to end_with('environment_loader.rb') + let(:workspace) { Solargraph::Workspace.new(Dir.pwd) } + let(:doc_map) { Solargraph::DocMap.new(requires, workspace, out: nil) } + let(:pin) { doc_map.pins.find { |pin| pin.path == path } } + + before do + doc_map.cache_doc_map_gems!(STDERR) # rubocop:disable Style/GlobalStdStream + end + + context 'with a combined method pin' do + let(:path) { 'RBS::EnvironmentLoader#core_root' } + let(:requires) { ['rbs'] } + + it 'can merge YARD and RBS' do + expect(pin.source).to eq(:combined) + end + + it 'finds types from RBS' do + expect(pin.return_type.to_s).to eq('Pathname, nil') + end + + it 'finds locations from YARD' do + expect(pin.location.filename).to end_with('environment_loader.rb') + end + end + + context 'with a YARD-only pin' do + let(:requires) { ['rake'] } + let(:path) { 'Rake::Task#prerequisites' } + + before do + workspace = doc_map.workspace + gemspecs = workspace.gemspecs + gemspec = gemspecs.find_gem('rake') + workspace.uncache_gem(gemspec) + end + + it 'found a pin' do + expect(pin.source).not_to be_nil + end + + it 'can merge YARD and RBS' do + expect(pin.source).to eq(:yardoc) + end + + it 'does not find types from YARD in this case' do + expect(pin.return_type.to_s).to eq('undefined') + end + + it 'finds locations from YARD' do + expect(pin.location.filename).to end_with('task.rb') + end end end diff --git a/spec/language_server/protocol_spec.rb b/spec/language_server/protocol_spec.rb index e88fb9c05..0b54729b5 100644 --- a/spec/language_server/protocol_spec.rb +++ b/spec/language_server/protocol_spec.rb @@ -34,7 +34,7 @@ def stop end end -describe Protocol do +describe Protocol, order: :defined do before :all do @protocol = Protocol.new(Solargraph::LanguageServer::Host.new) end diff --git a/spec/library_spec.rb b/spec/library_spec.rb index bd7cc25a0..d080d12d8 100644 --- a/spec/library_spec.rb +++ b/spec/library_spec.rb @@ -125,10 +125,11 @@ def bar expect(pins.map(&:path)).to include('Foo#bar') end - it "collects references to an instance method symbol" do - workspace = Solargraph::Workspace.new('*') - library = Solargraph::Library.new(workspace) - src1 = Solargraph::Source.load_string(%( + describe '#references_from' do + it "collects references to an instance method symbol" do + workspace = Solargraph::Workspace.new('*') + library = Solargraph::Library.new(workspace) + src1 = Solargraph::Source.load_string(%( class Foo def bar end @@ -136,8 +137,8 @@ def bar Foo.new.bar ), 'file1.rb', 0) - library.merge src1 - src2 = Solargraph::Source.load_string(%( + library.merge src1 + src2 = Solargraph::Source.load_string(%( foo = Foo.new foo.bar class Other @@ -145,17 +146,17 @@ def bar; end end Other.new.bar ), 'file2.rb', 0) - library.merge src2 - library.catalog - locs = library.references_from('file2.rb', 2, 11) - expect(locs.length).to eq(3) - expect(locs.select{|l| l.filename == 'file2.rb' && l.range.start.line == 6}).to be_empty - end + library.merge src2 + library.catalog + locs = library.references_from('file2.rb', 2, 11) + expect(locs.length).to eq(3) + expect(locs.select{|l| l.filename == 'file2.rb' && l.range.start.line == 6}).to be_empty + end - it "collects references to a class method symbol" do - workspace = Solargraph::Workspace.new('*') - library = Solargraph::Library.new(workspace) - src1 = Solargraph::Source.load_string(%( + it "collects references to a class method symbol" do + workspace = Solargraph::Workspace.new('*') + library = Solargraph::Library.new(workspace) + src1 = Solargraph::Source.load_string(%( class Foo def self.bar end @@ -167,8 +168,8 @@ def bar Foo.bar Foo.new.bar ), 'file1.rb', 0) - library.merge src1 - src2 = Solargraph::Source.load_string(%( + library.merge src1 + src2 = Solargraph::Source.load_string(%( Foo.bar Foo.new.bar class Other @@ -178,48 +179,48 @@ def bar; end Other.bar Other.new.bar ), 'file2.rb', 0) - library.merge src2 - library.catalog - locs = library.references_from('file2.rb', 1, 11) - expect(locs.length).to eq(3) - expect(locs.select{|l| l.filename == 'file1.rb' && l.range.start.line == 2}).not_to be_empty - expect(locs.select{|l| l.filename == 'file1.rb' && l.range.start.line == 9}).not_to be_empty - expect(locs.select{|l| l.filename == 'file2.rb' && l.range.start.line == 1}).not_to be_empty - end + library.merge src2 + library.catalog + locs = library.references_from('file2.rb', 1, 11) + expect(locs.length).to eq(3) + expect(locs.select{|l| l.filename == 'file1.rb' && l.range.start.line == 2}).not_to be_empty + expect(locs.select{|l| l.filename == 'file1.rb' && l.range.start.line == 9}).not_to be_empty + expect(locs.select{|l| l.filename == 'file2.rb' && l.range.start.line == 1}).not_to be_empty + end - it "collects stripped references to constant symbols" do - workspace = Solargraph::Workspace.new('*') - library = Solargraph::Library.new(workspace) - src1 = Solargraph::Source.load_string(%( + it "collects stripped references to constant symbols" do + workspace = Solargraph::Workspace.new('*') + library = Solargraph::Library.new(workspace) + src1 = Solargraph::Source.load_string(%( class Foo def bar end end Foo.new.bar ), 'file1.rb', 0) - library.merge src1 - src2 = Solargraph::Source.load_string(%( + library.merge src1 + src2 = Solargraph::Source.load_string(%( class Other foo = Foo.new foo.bar end ), 'file2.rb', 0) - library.merge src2 - library.catalog - locs = library.references_from('file1.rb', 1, 12, strip: true) - expect(locs.length).to eq(3) - locs.each do |l| - code = library.read_text(l.filename) - o1 = Solargraph::Position.to_offset(code, l.range.start) - o2 = Solargraph::Position.to_offset(code, l.range.ending) - expect(code[o1..o2-1]).to eq('Foo') + library.merge src2 + library.catalog + locs = library.references_from('file1.rb', 1, 12, strip: true) + expect(locs.length).to eq(3) + locs.each do |l| + code = library.read_text(l.filename) + o1 = Solargraph::Position.to_offset(code, l.range.start) + o2 = Solargraph::Position.to_offset(code, l.range.ending) + expect(code[o1..o2-1]).to eq('Foo') + end end - end - it 'rejects new references from different classes' do - workspace = Solargraph::Workspace.new('*') - library = Solargraph::Library.new(workspace) - source = Solargraph::Source.load_string(%( + it 'rejects new references from different classes' do + workspace = Solargraph::Workspace.new('*') + library = Solargraph::Library.new(workspace) + source = Solargraph::Source.load_string(%( class Foo def bar end @@ -227,106 +228,131 @@ def bar Foo.new Array.new ), 'test.rb') - library.merge source - library.catalog - foo_new_locs = library.references_from('test.rb', 5, 10) - expect(foo_new_locs).to eq([Solargraph::Location.new('test.rb', Solargraph::Range.from_to(5, 10, 5, 13))]) - obj_new_locs = library.references_from('test.rb', 6, 12) - expect(obj_new_locs).to eq([Solargraph::Location.new('test.rb', Solargraph::Range.from_to(6, 12, 6, 15))]) - end + library.merge source + library.catalog + foo_new_locs = library.references_from('test.rb', 5, 10) + expect(foo_new_locs).to eq([Solargraph::Location.new('test.rb', Solargraph::Range.from_to(5, 10, 5, 13))]) + obj_new_locs = library.references_from('test.rb', 6, 12) + expect(obj_new_locs).to eq([Solargraph::Location.new('test.rb', Solargraph::Range.from_to(6, 12, 6, 15))]) + end - it "searches the core for queries" do - library = Solargraph::Library.new - result = library.search('String') - expect(result).not_to be_empty - end + it "searches the core for queries" do + library = Solargraph::Library.new + result = library.search('String') + expect(result).not_to be_empty + end - it "returns YARD documentation from the core" do - library = Solargraph::Library.new - api_map, result = library.document('String') - expect(result).not_to be_empty - expect(result.first).to be_a(Solargraph::Pin::Base) - end + it "returns YARD documentation from the core" do + library = Solargraph::Library.new + api_map, result = library.document('String') + expect(result).not_to be_empty + expect(result.first).to be_a(Solargraph::Pin::Base) + end - it "returns YARD documentation from sources" do - library = Solargraph::Library.new - src = Solargraph::Source.load_string(%( + it "returns YARD documentation from sources" do + library = Solargraph::Library.new + src = Solargraph::Source.load_string(%( class Foo # My bar method def bar; end end ), 'test.rb', 0) - library.attach src - api_map, result = library.document('Foo#bar') - expect(result).not_to be_empty - expect(result.first).to be_a(Solargraph::Pin::Base) - end + library.attach src + api_map, result = library.document('Foo#bar') + expect(result).not_to be_empty + expect(result.first).to be_a(Solargraph::Pin::Base) + end - it "synchronizes sources from updaters" do - library = Solargraph::Library.new - src = Solargraph::Source.load_string(%( + it "synchronizes sources from updaters" do + library = Solargraph::Library.new + src = Solargraph::Source.load_string(%( class Foo end ), 'test.rb', 1) - library.attach src - repl = %( + library.attach src + repl = %( class Foo def bar; end end ) - updater = Solargraph::Source::Updater.new( - 'test.rb', - 2, - [Solargraph::Source::Change.new(nil, repl)] - ) - library.attach src.synchronize(updater) - expect(library.current.code).to eq(repl) - end + updater = Solargraph::Source::Updater.new( + 'test.rb', + 2, + [Solargraph::Source::Change.new(nil, repl)] + ) + library.attach src.synchronize(updater) + expect(library.current.code).to eq(repl) + end - it "finds unique references" do - library = Solargraph::Library.new(Solargraph::Workspace.new('*')) - src1 = Solargraph::Source.load_string(%( + it "finds unique references" do + library = Solargraph::Library.new(Solargraph::Workspace.new('*')) + src1 = Solargraph::Source.load_string(%( class Foo end ), 'src1.rb', 1) - library.merge src1 - src2 = Solargraph::Source.load_string(%( + library.merge src1 + src2 = Solargraph::Source.load_string(%( foo = Foo.new ), 'src2.rb', 1) - library.merge src2 - library.catalog - refs = library.references_from('src2.rb', 1, 12) - expect(refs.length).to eq(2) - end + library.merge src2 + library.catalog + refs = library.references_from('src2.rb', 1, 12) + expect(refs.length).to eq(2) + end - it "includes method parameters in references" do - library = Solargraph::Library.new(Solargraph::Workspace.new('*')) - source = Solargraph::Source.load_string(%( + it "includes method parameters in references" do + library = Solargraph::Library.new(Solargraph::Workspace.new('*')) + source = Solargraph::Source.load_string(%( class Foo def bar(baz) baz.upcase end end ), 'test.rb', 1) - library.attach source - from_def = library.references_from('test.rb', 2, 16) - expect(from_def.length).to eq(2) - from_ref = library.references_from('test.rb', 3, 10) - expect(from_ref.length).to eq(2) - end + library.attach source + from_def = library.references_from('test.rb', 2, 16) + expect(from_def.length).to eq(2) + from_ref = library.references_from('test.rb', 3, 10) + expect(from_ref.length).to eq(2) + end - it "includes block parameters in references" do - library = Solargraph::Library.new(Solargraph::Workspace.new('*')) - source = Solargraph::Source.load_string(%( + it "lies about names when client can't handle the truth" do + library = Solargraph::Library.new(Solargraph::Workspace.new('*')) + source = Solargraph::Source.load_string(%( + class Foo + def 🤦🏻foo♀️; 123; end + end + ), 'test.rb', 1) + library.attach source + from_def = library.references_from('test.rb', 2, 16, strip: true) + expect(from_def.first.range.start.column).to eq(14) + end + + it "tells the truth about names when client can handle the truth" do + library = Solargraph::Library.new(Solargraph::Workspace.new('*')) + source = Solargraph::Source.load_string(%( + class Foo + def 🤦🏻foo♀️; 123; end + end + ), 'test.rb', 1) + library.attach source + from_def = library.references_from('test.rb', 2, 16, strip: false) + expect(from_def.first.range.start.column).to eq(12) + end + + it "includes block parameters in references" do + library = Solargraph::Library.new(Solargraph::Workspace.new('*')) + source = Solargraph::Source.load_string(%( 100.times do |foo| puts foo end ), 'test.rb', 1) - library.attach source - from_def = library.references_from('test.rb', 1, 20) - expect(from_def.length).to eq(2) - from_ref = library.references_from('test.rb', 2, 13) - expect(from_ref.length).to eq(2) + library.attach source + from_def = library.references_from('test.rb', 1, 20) + expect(from_def.length).to eq(2) + from_ref = library.references_from('test.rb', 2, 13) + expect(from_ref.length).to eq(2) + end end it 'defines YARD tags' do From 817d9bf2f6d5637c68a50995e33472a16d19175b Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Sat, 26 Jul 2025 13:36:37 -0400 Subject: [PATCH 168/400] Handle a location sorting case --- lib/solargraph/location.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/solargraph/location.rb b/lib/solargraph/location.rb index 74d1318df..13ce4c560 100644 --- a/lib/solargraph/location.rb +++ b/lib/solargraph/location.rb @@ -7,13 +7,13 @@ module Solargraph class Location include Equality - # @return [String] + # @return [String, nil] attr_reader :filename # @return [Solargraph::Range] attr_reader :range - # @param filename [String] + # @param filename [String, nil] # @param range [Solargraph::Range] def initialize filename, range @filename = filename @@ -25,11 +25,14 @@ def initialize filename, range [filename, range] end + # @param other [self] def <=>(other) return nil unless other.is_a?(Location) if filename == other.filename range <=> other.range else + return -1 if filename.nil? + return 1 if other.filename.nil? filename <=> other.filename end end @@ -60,6 +63,7 @@ def to_hash end # @param node [Parser::AST::Node, nil] + # @return [self] def self.from_node(node) return nil if node.nil? || node.loc.nil? range = Range.from_node(node) From 085240430d5dfc652994acef9a1de12a70213946 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Sat, 26 Jul 2025 13:40:32 -0400 Subject: [PATCH 169/400] Loosen expectations a bit based on a trial run of settings --- .gitignore | 1 + .overcommit.yml | 11 ++++------- spec/spec_helper.rb | 8 +++++++- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index fc09c2fea..e10c43432 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ doc coverage /tmp/ +/rspec-examples.txt \ No newline at end of file diff --git a/.overcommit.yml b/.overcommit.yml index c15ded82f..dea53a923 100644 --- a/.overcommit.yml +++ b/.overcommit.yml @@ -41,9 +41,10 @@ PreCommit: enabled: false ALL: - # if you make non-trivial changes to a file, please leave it - # better than you found it - problem_on_unmodified_line: fail + # if you uncomment the next line locally, and you make changes to + # a file, overcommit will have you make the entire file pass + # + # problem_on_unmodified_line: fail on_warn: fail exclude: - lib/solargraph/rails/annotations/**/* @@ -51,10 +52,6 @@ PreCommit: - ".bundle/**/*" - 'core.*' -PrePush: - RSpec: - enabled: true - verify_signatures: false # diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index da7a6280e..d2fa1f334 100755 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -10,9 +10,15 @@ SimpleCov.start do add_filter(%r{^/spec/}) add_filter('/Rakefile') - enable_coverage(:branch) + # off by default - feel free to set if you'd like undercover to + # hold you to a thorough set of specs + enable_coverage(:branch) if ENV['SOLARGRAPH_BRANCH_COVERAGE'] end end +RSpec.configure do |c| + # Allow use of --only-failures with rspec, handy for local development + c.example_status_persistence_file_path = 'rspec-examples.txt' +end require 'solargraph' # Suppress logger output in specs (if possible) Solargraph::Logging.logger.reopen(File::NULL) if Solargraph::Logging.logger.respond_to?(:reopen) From 596dc34ba73cd647f7897e588ffbf00b090898df Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Sat, 26 Jul 2025 13:40:54 -0400 Subject: [PATCH 170/400] Run overcommit hooks under bundler --- .overcommit.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.overcommit.yml b/.overcommit.yml index dea53a923..bbcd92ac6 100644 --- a/.overcommit.yml +++ b/.overcommit.yml @@ -66,3 +66,5 @@ verify_signatures: false # # IndexTags: # enabled: true # Generate a tags file with `ctags` each time HEAD changes + +gemfile: Gemfile From bfc11212ae98d63b02615ea7bc56b8ed0896acb4 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Sat, 26 Jul 2025 14:04:44 -0400 Subject: [PATCH 171/400] Fix some new RuboCop issues, fix policy adjustment in overcommit --- .overcommit.yml | 6 +++--- lib/solargraph/parser/parser_gem/node_chainer.rb | 1 + lib/solargraph/pin/base_variable.rb | 2 +- spec/language_server/transport/adapter_spec.rb | 1 + spec/pin/documenting_spec.rb | 1 + 5 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.overcommit.yml b/.overcommit.yml index bbcd92ac6..fdbc8152d 100644 --- a/.overcommit.yml +++ b/.overcommit.yml @@ -41,11 +41,11 @@ PreCommit: enabled: false ALL: - # if you uncomment the next line locally, and you make changes to + # if you change the next line to 'report', and you make changes to # a file, overcommit will have you make the entire file pass # - # problem_on_unmodified_line: fail - on_warn: fail + problem_on_unmodified_line: warn + # on_warn: fail exclude: - lib/solargraph/rails/annotations/**/* - vendor/**/* diff --git a/lib/solargraph/parser/parser_gem/node_chainer.rb b/lib/solargraph/parser/parser_gem/node_chainer.rb index 32bb186dd..646e753d5 100644 --- a/lib/solargraph/parser/parser_gem/node_chainer.rb +++ b/lib/solargraph/parser/parser_gem/node_chainer.rb @@ -7,6 +7,7 @@ module ParserGem # class NodeChainer include NodeMethods + Chain = Source::Chain # @param node [Parser::AST::Node] diff --git a/lib/solargraph/pin/base_variable.rb b/lib/solargraph/pin/base_variable.rb index 15cdd918f..cef3f44cb 100644 --- a/lib/solargraph/pin/base_variable.rb +++ b/lib/solargraph/pin/base_variable.rb @@ -3,8 +3,8 @@ module Solargraph module Pin class BaseVariable < Base - include Solargraph::Parser::NodeMethods # include Solargraph::Source::NodeMethods + include Solargraph::Parser::NodeMethods # @return [Parser::AST::Node, nil] attr_reader :assignment diff --git a/spec/language_server/transport/adapter_spec.rb b/spec/language_server/transport/adapter_spec.rb index cf07b2841..3d30dd4e6 100644 --- a/spec/language_server/transport/adapter_spec.rb +++ b/spec/language_server/transport/adapter_spec.rb @@ -1,5 +1,6 @@ class AdapterTester include Solargraph::LanguageServer::Transport::Adapter + attr_reader :host def write data diff --git a/spec/pin/documenting_spec.rb b/spec/pin/documenting_spec.rb index 9b71d220d..1fdf9b8de 100644 --- a/spec/pin/documenting_spec.rb +++ b/spec/pin/documenting_spec.rb @@ -2,6 +2,7 @@ let(:object) { Class.new do include Solargraph::Pin::Documenting + attr_accessor :docstring end.new } From 50f9228318cff0293568cd0f2d613ace4ca3205d Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Sat, 26 Jul 2025 14:08:42 -0400 Subject: [PATCH 172/400] Add some @sg-ignores --- lib/solargraph/pin/base.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/solargraph/pin/base.rb b/lib/solargraph/pin/base.rb index cdd6a5ace..1fc0f3562 100644 --- a/lib/solargraph/pin/base.rb +++ b/lib/solargraph/pin/base.rb @@ -67,6 +67,7 @@ def assert_location_provided # @return [self] def combine_with(other, attrs={}) raise "tried to combine #{other.class} with #{self.class}" unless other.class == self.class + type_location = choose(other, :type_location) location = choose(other, :location) combined_name = combine_name(other) @@ -300,6 +301,7 @@ def choose_pin_attr_with_same_name(other, attr) # @param other [self] # @param attr [::Symbol] + # @sg-ignore Missing @return tag for Solargraph::Pin::Base#choose_pin_attr # @return [undefined] def choose_pin_attr(other, attr) # @type [Pin::Base, nil] @@ -312,6 +314,7 @@ def choose_pin_attr(other, attr) return val1 end # arbitrary way of choosing a pin + # @sg-ignore Unresolved call to _1 [val1, val2].compact.min_by { _1.best_location.to_s } end From fb022d60796950f54d600b844bbfcd818be96092 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Sat, 26 Jul 2025 14:12:03 -0400 Subject: [PATCH 173/400] Update todo file with new RuboCop --- .rubocop_todo.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 32b259f2f..815848640 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config --no-exclude-limit --no-auto-gen-timestamp` -# using RuboCop version 1.78.0. +# using RuboCop version 1.79.0. # 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 @@ -653,8 +653,9 @@ Lint/RedundantRequireStatement: # Offense count: 2 # This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: AllowedMethods. +# Configuration parameters: AllowedMethods, InferNonNilReceiver, AdditionalNilMethods. # AllowedMethods: instance_of?, kind_of?, is_a?, eql?, respond_to?, equal? +# AdditionalNilMethods: present?, blank?, try, try! Lint/RedundantSafeNavigation: Exclude: - 'lib/solargraph/api_map/source_to_yard.rb' @@ -754,7 +755,7 @@ Lint/UselessAccessModifier: Exclude: - 'lib/solargraph/api_map.rb' -# Offense count: 40 +# Offense count: 41 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AutoCorrect. Lint/UselessAssignment: From a6d405aeba1aad7d072fdf357c76eae4c9ce6f49 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Sat, 26 Jul 2025 14:15:49 -0400 Subject: [PATCH 174/400] Ratchet Rubocop todo file --- .rubocop_todo.yml | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 64bb00759..5c85be76c 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -737,13 +737,6 @@ Lint/UnusedMethodArgument: - 'lib/solargraph/source/chain/variable.rb' - 'lib/solargraph/source/chain/z_super.rb' -# Offense count: 1 -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AutoCorrect, ContextCreatingMethods, MethodCreatingMethods. -Lint/UselessAccessModifier: - Exclude: - - 'lib/solargraph/api_map.rb' - # Offense count: 41 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AutoCorrect. @@ -1233,7 +1226,7 @@ RSpec/MissingExampleGroupArgument: Exclude: - 'spec/diagnostics/rubocop_helpers_spec.rb' -# Offense count: 480 +# Offense count: 479 # Configuration parameters: Max. RSpec/MultipleExpectations: Exclude: @@ -1248,7 +1241,6 @@ RSpec/MultipleExpectations: - 'spec/diagnostics/type_check_spec.rb' - 'spec/diagnostics/update_errors_spec.rb' - 'spec/diagnostics_spec.rb' - - 'spec/gem_pins_spec.rb' - 'spec/language_server/host/message_worker_spec.rb' - 'spec/language_server/host_spec.rb' - 'spec/language_server/message/completion_item/resolve_spec.rb' @@ -1924,7 +1916,7 @@ Style/FrozenStringLiteralComment: - 'spec/yard_map/mapper/to_method_spec.rb' - 'spec/yard_map/mapper_spec.rb' -# Offense count: 11 +# Offense count: 9 # This cop supports unsafe autocorrection (--autocorrect-all). Style/GlobalStdStream: Exclude: @@ -2480,7 +2472,6 @@ Style/StringLiterals: - 'lib/solargraph/complex_type.rb' - 'lib/solargraph/complex_type/unique_type.rb' - 'lib/solargraph/convention/struct_definition.rb' - - 'lib/solargraph/doc_map.rb' - 'lib/solargraph/language_server/host.rb' - 'lib/solargraph/language_server/message/extended/document_gems.rb' - 'lib/solargraph/language_server/message/extended/download_core.rb' From b66ef0d4fc62a02e20e57b1bd0fb1ec22037113c Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Sat, 26 Jul 2025 14:29:19 -0400 Subject: [PATCH 175/400] Ratchet a couple of Rubocop todo categories --- .rubocop_todo.yml | 7 ++-- lib/solargraph/pin_cache.rb | 68 ++++++++++++++++++------------------- lib/solargraph/shell.rb | 22 ++++++------ 3 files changed, 47 insertions(+), 50 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 5c85be76c..9e024b576 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -2048,7 +2048,7 @@ Style/MapToSet: - 'lib/solargraph/library.rb' - 'spec/source_map/clip_spec.rb' -# Offense count: 197 +# Offense count: 164 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle. # SupportedStyles: require_parentheses, require_no_parentheses, require_no_parentheses_except_multiline @@ -2091,11 +2091,9 @@ Style/MethodDefParentheses: - 'lib/solargraph/pin/local_variable.rb' - 'lib/solargraph/pin/method.rb' - 'lib/solargraph/pin/parameter.rb' - - 'lib/solargraph/pin_cache.rb' - 'lib/solargraph/position.rb' - 'lib/solargraph/range.rb' - 'lib/solargraph/rbs_map/conversions.rb' - - 'lib/solargraph/shell.rb' - 'lib/solargraph/source.rb' - 'lib/solargraph/source/chain/call.rb' - 'lib/solargraph/source/chain/constant.rb' @@ -2460,7 +2458,7 @@ Style/StringConcatenation: - 'lib/solargraph/pin/namespace.rb' - 'solargraph.gemspec' -# Offense count: 612 +# Offense count: 604 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline. # SupportedStyles: single_quotes, double_quotes @@ -2486,7 +2484,6 @@ Style/StringLiterals: - 'lib/solargraph/pin/parameter.rb' - 'lib/solargraph/rbs_map/conversions.rb' - 'lib/solargraph/server_methods.rb' - - 'lib/solargraph/shell.rb' - 'lib/solargraph/workspace.rb' - 'lib/solargraph/yard_map/mapper/to_method.rb' - 'lib/solargraph/yard_tags.rb' diff --git a/lib/solargraph/pin_cache.rb b/lib/solargraph/pin_cache.rb index b71a16ff5..1a506ef9e 100644 --- a/lib/solargraph/pin_cache.rb +++ b/lib/solargraph/pin_cache.rb @@ -12,9 +12,9 @@ class PinCache # @param rbs_collection_config_path [String, nil] # @param directory [String, nil] # @param yard_plugins [Array] - def initialize(rbs_collection_path:, rbs_collection_config_path:, + def initialize rbs_collection_path:, rbs_collection_config_path:, directory:, - yard_plugins:) + yard_plugins: @rbs_collection_path = rbs_collection_path @rbs_collection_config_path = rbs_collection_config_path @directory = directory @@ -22,7 +22,7 @@ def initialize(rbs_collection_path:, rbs_collection_config_path:, end # @param gemspec [Gem::Specification, Bundler::LazySpecification] - def cached?(gemspec) + def cached? gemspec rbs_version_cache_key = lookup_rbs_version_cache_key(gemspec) combined_gem?(gemspec, rbs_version_cache_key) end @@ -31,7 +31,7 @@ def cached?(gemspec) # @param rebuild [Boolean] whether to rebuild the cache regardless of whether it already exists # @param out [IO, nil] output stream for logging # @return [void] - def cache_gem(gemspec:, rebuild: false, out: nil) + def cache_gem gemspec:, rebuild: false, out: nil rbs_version_cache_key = lookup_rbs_version_cache_key(gemspec) build_yard, build_rbs_collection, build_combined = @@ -51,7 +51,7 @@ def cache_gem(gemspec:, rebuild: false, out: nil) # @param gemspec [Gem::Specification, Bundler::LazySpecification] # @param rbs_version_cache_key [String] - def suppress_yard_cache?(gemspec, rbs_version_cache_key) + def suppress_yard_cache? gemspec, rbs_version_cache_key if gemspec.name == 'parser' && rbs_version_cache_key != RbsMap::CACHE_KEY_UNRESOLVED # parser takes forever to build YARD pins, but has excellent RBS collection pins return true @@ -62,7 +62,7 @@ def suppress_yard_cache?(gemspec, rbs_version_cache_key) # @param out [IO, nil] output stream for logging # # @return [void] - def cache_all_stdlibs(out: $stderr) + def cache_all_stdlibs out: $stderr possible_stdlibs.each do |stdlib| RbsMap::StdlibMap.new(stdlib, out: out) end @@ -88,7 +88,7 @@ def cache_stdlib_rbs_map path # @param gemspec [Gem::Specification, Bundler::LazySpecification] # # @return [String] - def lookup_rbs_version_cache_key(gemspec) + def lookup_rbs_version_cache_key gemspec rbs_map = RbsMap.from_gemspec(gemspec, rbs_collection_path, rbs_collection_config_path) rbs_map.cache_key end @@ -98,14 +98,14 @@ def lookup_rbs_version_cache_key(gemspec) # @param yard_pins [Array] # @param rbs_collection_pins [Array] # @return [void] - def cache_combined_pins(gemspec, rbs_version_cache_key, yard_pins, rbs_collection_pins) + def cache_combined_pins gemspec, rbs_version_cache_key, yard_pins, rbs_collection_pins combined_pins = GemPins.combine(yard_pins, rbs_collection_pins) serialize_combined_gem(gemspec, rbs_version_cache_key, combined_pins) end # @param gemspec [Gem::Specification] # @return [Array] - def deserialize_combined_pin_cache(gemspec) + def deserialize_combined_pin_cache gemspec unless combined_pins_in_memory[[gemspec.name, gemspec.version]].nil? return combined_pins_in_memory[[gemspec.name, gemspec.version]] end @@ -122,7 +122,7 @@ def deserialize_combined_pin_cache(gemspec) # @param gemspec [Gem::Specification] # @param out [IO, nil] # @return [void] - def uncache_gem(gemspec, out: nil) + def uncache_gem gemspec, out: nil PinCache.uncache(yardoc_path(gemspec), out: out) yard_pins_in_memory.delete([gemspec.name, gemspec.version]) PinCache.uncache(yard_gem_path(gemspec), out: out) @@ -136,7 +136,7 @@ def uncache_gem(gemspec, out: nil) end # @param gemspec [Gem::Specification, Bundler::LazySpecification] - def yardoc_processing?(gemspec) + def yardoc_processing? gemspec Yardoc.processing?(yardoc_path(gemspec)) end @@ -163,7 +163,7 @@ def possible_stdlibs # # @return [Array(Boolean, Boolean, Boolean)] whether to build YARD # pins, RBS collection pins, and combined pins - def calculate_build_needs(gemspec, rebuild:, rbs_version_cache_key:) + def calculate_build_needs gemspec, rebuild:, rbs_version_cache_key: if rebuild build_yard = true build_rbs_collection = true @@ -187,12 +187,12 @@ def calculate_build_needs(gemspec, rebuild:, rbs_version_cache_key:) # @param out [IO, nil] # # @return [void] - def build_combine_and_cache(gemspec, + def build_combine_and_cache gemspec, rbs_version_cache_key, build_yard:, build_rbs_collection:, build_combined:, - out:) + out: log_cache_info(gemspec, rbs_version_cache_key, build_yard: build_yard, build_rbs_collection: build_rbs_collection, @@ -214,12 +214,12 @@ def build_combine_and_cache(gemspec, # @param out [IO, nil] # # @return [void] - def log_cache_info(gemspec, + def log_cache_info gemspec, rbs_version_cache_key, build_yard:, build_rbs_collection:, build_combined:, - out:) + out: type = [] type << 'YARD' if build_yard rbs_source_desc = RbsMap.rbs_source_desc(rbs_version_cache_key) @@ -237,7 +237,7 @@ def log_cache_info(gemspec, # @param gemspec [Gem::Specification, Bundler::LazySpecification] # @param out [IO, nil] # @return [Array] - def cache_yard_pins(gemspec, out) + def cache_yard_pins gemspec, out gem_yardoc_path = yardoc_path(gemspec) Yardoc.build_docs(gem_yardoc_path, yard_plugins, gemspec) unless Yardoc.docs_built?(gem_yardoc_path) pins = Yardoc.build_pins(gem_yardoc_path, gemspec, out: out) @@ -264,7 +264,7 @@ def combined_pins_in_memory # @param gemspec [Gem::Specification] # @param _out [IO, nil] # @return [Array] - def cache_rbs_collection_pins(gemspec, _out) + def cache_rbs_collection_pins gemspec, _out rbs_map = RbsMap.from_gemspec(gemspec, rbs_collection_path, rbs_collection_config_path) pins = rbs_map.pins rbs_version_cache_key = rbs_map.cache_key @@ -340,39 +340,39 @@ def yard_gem_path gemspec # @param gemspec [Gem::Specification] # @return [Array] - def load_yard_gem(gemspec) + def load_yard_gem gemspec PinCache.load(yard_gem_path(gemspec)) end # @param gemspec [Gem::Specification] # @param pins [Array] # @return [void] - def serialize_yard_gem(gemspec, pins) + def serialize_yard_gem gemspec, pins PinCache.save(yard_gem_path(gemspec), pins) end # @param gemspec [Gem::Specification] # @return [Boolean] - def yard_gem?(gemspec) + def yard_gem? gemspec exist?(yard_gem_path(gemspec)) end # @param gemspec [Gem::Specification] # @return [Boolean] - def yardoc?(gemspec) + def yardoc? gemspec exist?(yardoc_path(gemspec)) end # @param gemspec [Gem::Specification] # @param hash [String, nil] # @return [String] - def rbs_collection_pins_path(gemspec, hash) + def rbs_collection_pins_path gemspec, hash rbs_collection_pins_path_prefix(gemspec) + "#{gemspec.name}-#{gemspec.version}-#{hash || 0}.ser" end # @param gemspec [Gem::Specification] # @return [String] - def rbs_collection_pins_path_prefix(gemspec) + def rbs_collection_pins_path_prefix gemspec File.join(PinCache.work_dir, 'rbs', "#{gemspec.name}-#{gemspec.version}-") end @@ -380,7 +380,7 @@ def rbs_collection_pins_path_prefix(gemspec) # @param hash [String] # # @return [Array] - def load_rbs_collection_pins(gemspec, hash) + def load_rbs_collection_pins gemspec, hash PinCache.load(rbs_collection_pins_path(gemspec, hash)) end @@ -388,20 +388,20 @@ def load_rbs_collection_pins(gemspec, hash) # @param hash [String, nil] # @param pins [Array]n # @return [void] - def serialize_rbs_collection_pins(gemspec, hash, pins) + def serialize_rbs_collection_pins gemspec, hash, pins PinCache.save(rbs_collection_pins_path(gemspec, hash), pins) end # @param gemspec [Gem::Specification] # @param hash [String, nil] # @return [String] - def combined_path(gemspec, hash) + def combined_path gemspec, hash File.join(combined_path_prefix(gemspec) + "-#{hash || 0}.ser") end # @param gemspec [Gem::Specification] # @return [String] - def combined_path_prefix(gemspec) + def combined_path_prefix gemspec File.join(PinCache.work_dir, 'combined', yard_plugins.sort.join('-'), "#{gemspec.name}-#{gemspec.version}") end @@ -409,13 +409,13 @@ def combined_path_prefix(gemspec) # @param hash [String, nil] # @param pins [Array] # @return [void] - def serialize_combined_gem(gemspec, hash, pins) + def serialize_combined_gem gemspec, hash, pins PinCache.save(combined_path(gemspec, hash), pins) end # @param gemspec [Gem::Specification, Bundler::LazySpecification] # @param hash [String] - def combined_gem?(gemspec, hash) + def combined_gem? gemspec, hash exist?(combined_path(gemspec, hash)) end @@ -428,7 +428,7 @@ def load_combined_gem gemspec, hash # @param gemspec [Gem::Specification] # @param hash [String] - def rbs_collection_pins?(gemspec, hash) + def rbs_collection_pins? gemspec, hash exist?(rbs_collection_pins_path(gemspec, hash)) end @@ -500,7 +500,7 @@ def uncache *path_segments, out: nil # @param out [IO, nil] # @return [void] - def uncache_core(out: nil) + def uncache_core out: nil uncache(core_path, out: out) # ApiMap keep this in memory ApiMap.reset_core(out: out) @@ -508,7 +508,7 @@ def uncache_core(out: nil) # @param out [IO, nil] # @return [void] - def uncache_stdlib(out: nil) + def uncache_stdlib out: nil uncache(stdlib_path, out: out) end @@ -559,7 +559,7 @@ def core? # @param out [IO, nil] # @return [Array] - def cache_core(out: $stderr) + def cache_core out: $stderr RbsMap::CoreMap.new.cache_core(out: out) end diff --git a/lib/solargraph/shell.rb b/lib/solargraph/shell.rb index 03ce59410..f8b98359a 100755 --- a/lib/solargraph/shell.rb +++ b/lib/solargraph/shell.rb @@ -16,7 +16,7 @@ def self.exit_on_failure? map %w[--version -v] => :version - desc "--version, -v", "Print the version" + desc '--version, -v', 'Print the version' # @return [void] def version puts Solargraph::VERSION @@ -31,10 +31,10 @@ def socket port = options[:port] port = available_port if port.zero? Backport.run do - Signal.trap("INT") do + Signal.trap('INT') do Backport.stop end - Signal.trap("TERM") do + Signal.trap('TERM') do Backport.stop end # @sg-ignore https://github.com/castwide/backport/pull/5 @@ -48,10 +48,10 @@ def socket def stdio require 'backport' Backport.run do - Signal.trap("INT") do + Signal.trap('INT') do Backport.stop end - Signal.trap("TERM") do + Signal.trap('TERM') do Backport.stop end # @sg-ignore https://github.com/castwide/backport/pull/5 @@ -64,7 +64,7 @@ def stdio option :extensions, type: :boolean, aliases: :e, desc: 'Add installed extensions', default: true # @param directory [String] # @return [void] - def config(directory = '.') + def config directory = '.' matches = [] if options[:extensions] # @sg-ignore @@ -84,7 +84,7 @@ def config(directory = '.') File.open(File.join(directory, '.solargraph.yml'), 'w') do |file| file.puts conf.to_yaml end - STDOUT.puts "Configuration file initialized." + STDOUT.puts 'Configuration file initialized.' end desc 'clear', 'Delete all cached documentation' @@ -93,7 +93,7 @@ def config(directory = '.') ) # @return [void] def clear - puts "Deleting all cached documentation (gems, core and stdlib)" + puts 'Deleting all cached documentation (gems, core and stdlib)' Solargraph::PinCache.clear end map 'clear-cache' => :clear @@ -138,7 +138,7 @@ def gems *names end end - desc 'uncache GEM [...GEM]', "Delete specific cached gem documentation" + desc 'uncache GEM [...GEM]', 'Delete specific cached gem documentation' long_desc %( Specify one or more gem names to clear. 'core' or 'stdlib' may also be specified to clear cached system documentation. @@ -274,7 +274,7 @@ def pin_description pin # @param type [ComplexType] # @return [void] - def print_type(type) + def print_type type if options[:rbs] puts type.to_rbs else @@ -284,7 +284,7 @@ def print_type(type) # @param pin [Solargraph::Pin::Base] # @return [void] - def print_pin(pin) + def print_pin pin if options[:rbs] puts pin.to_rbs else From c19d3d548f903641a648598e8fcf5888257c849f Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Sat, 26 Jul 2025 14:33:26 -0400 Subject: [PATCH 176/400] Ratchet a couple of Rubocop todo categories --- .rubocop_todo.yml | 3 +-- spec/doc_map_spec.rb | 6 +++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 9e024b576..c4d0e4686 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1027,7 +1027,7 @@ RSpec/DescribeClass: - 'spec/complex_type_spec.rb' - 'spec/source_map/node_processor_spec.rb' -# Offense count: 388 +# Offense count: 387 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: SkipBlocks, EnforcedStyle, OnlyStaticConstants. # SupportedStyles: described_class, explicit @@ -1043,7 +1043,6 @@ RSpec/DescribedClass: - 'spec/diagnostics/type_check_spec.rb' - 'spec/diagnostics/update_errors_spec.rb' - 'spec/diagnostics_spec.rb' - - 'spec/doc_map_spec.rb' - 'spec/language_server/host/diagnoser_spec.rb' - 'spec/language_server/host/dispatch_spec.rb' - 'spec/language_server/host/message_worker_spec.rb' diff --git a/spec/doc_map_spec.rb b/spec/doc_map_spec.rb index 823db14d7..c935c0c58 100644 --- a/spec/doc_map_spec.rb +++ b/spec/doc_map_spec.rb @@ -5,7 +5,7 @@ describe Solargraph::DocMap do subject(:doc_map) do - Solargraph::DocMap.new(requires, workspace, out: out) + described_class.new(requires, workspace, out: out) end let(:out) { StringIO.new } @@ -16,7 +16,7 @@ Solargraph::Workspace.new(Dir.pwd) end - let(:plain_doc_map) { Solargraph::DocMap.new([], workspace, out: nil) } + let(:plain_doc_map) { described_class.new([], workspace, out: nil) } before do doc_map.cache_doc_map_gems!(nil) if pre_cache @@ -80,7 +80,7 @@ context 'with require as bundle/require' do it 'imports all gems when bundler/require used' do - doc_map_with_bundler_require = Solargraph::DocMap.new(['bundler/require'], workspace, out: nil) + doc_map_with_bundler_require = described_class.new(['bundler/require'], workspace, out: nil) doc_map_with_bundler_require.cache_doc_map_gems!(nil) expect(doc_map_with_bundler_require.pins.length - plain_doc_map.pins.length).to be_positive end From 59053b133f46a3fe100d53b679c67ba0049e37dc Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Sat, 26 Jul 2025 14:33:50 -0400 Subject: [PATCH 177/400] Disable a RuboCop check --- .rubocop.yml | 4 ++++ .rubocop_todo.yml | 10 ---------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index e51b2f834..a73324db2 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -35,6 +35,10 @@ Metrics/ParameterLists: CountKeywordArgs: false +# we tend to use @@ and the risk doesn't seem high +Style/ClassVars: + Enabled: false + # # Set a relaxed standard on harder-to-address item for ease of # contribution - if you are good at refactoring, we welcome PRs to diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 815848640..aa00a82d0 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1688,16 +1688,6 @@ Style/ClassEqualityComparison: - 'lib/solargraph/gem_pins.rb' - 'lib/solargraph/pin/base.rb' -# Offense count: 13 -Style/ClassVars: - Exclude: - - 'lib/solargraph/api_map.rb' - - 'lib/solargraph/convention.rb' - - 'lib/solargraph/logging.rb' - - 'lib/solargraph/parser/node_processor.rb' - - 'lib/solargraph/rbs_map.rb' - - 'lib/solargraph/source/chain.rb' - # Offense count: 2 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: AllowedReceivers. From 2564549fdfc21a30869e71871f0f86495a8da966 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Sat, 26 Jul 2025 14:36:20 -0400 Subject: [PATCH 178/400] Drop rubocop:disable lines --- lib/solargraph/workspace/gemspecs.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/solargraph/workspace/gemspecs.rb b/lib/solargraph/workspace/gemspecs.rb index b07166db5..80f200a2a 100644 --- a/lib/solargraph/workspace/gemspecs.rb +++ b/lib/solargraph/workspace/gemspecs.rb @@ -182,12 +182,12 @@ def to_gem_specification specish specish.version end else - @@warned_on_gem_type ||= # rubocop:disable Style/ClassVars + @@warned_on_gem_type ||= false unless @@warned_on_gem_type logger.warn 'Unexpected type while resolving gem: ' \ "#{specish.class}" - @@warned_on_gem_type = true # rubocop:disable Style/ClassVars + @@warned_on_gem_type = true end nil end From c6f52066b5f868d1c1e8bd68c4535a0750d1df29 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Sat, 26 Jul 2025 15:09:16 -0400 Subject: [PATCH 179/400] Restore removed code --- lib/solargraph/gem_pins.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/solargraph/gem_pins.rb b/lib/solargraph/gem_pins.rb index 6efe3628c..b6ac5c6ce 100644 --- a/lib/solargraph/gem_pins.rb +++ b/lib/solargraph/gem_pins.rb @@ -49,6 +49,11 @@ def self.combine(yard_pins, rbs_pins) rbs_pin = rbs_api_map.get_path_pins(yard_pin.path).filter { |pin| pin.is_a? Pin::Method }.first next yard_pin unless rbs_pin && yard_pin.class == Pin::Method + unless rbs_pin + logger.debug { "GemPins.combine: No rbs pin for #{yard_pin.path} - using YARD's '#{yard_pin.inspect} (return_type=#{yard_pin.return_type}; signatures=#{yard_pin.signatures})" } + next yard_pin + end + out = combine_method_pins(rbs_pin, yard_pin) logger.debug do "GemPins.combine: Combining yard.path=#{yard_pin.path} - rbs=#{rbs_pin.inspect} with yard=#{yard_pin.inspect} into #{out}" From c2807b18ad0ac43dad5e3eab5adee49f21dc9889 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Mon, 28 Jul 2025 07:21:47 -0400 Subject: [PATCH 180/400] Fix reference --- lib/solargraph/workspace/gemspecs.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/solargraph/workspace/gemspecs.rb b/lib/solargraph/workspace/gemspecs.rb index 80f200a2a..170fe0c06 100644 --- a/lib/solargraph/workspace/gemspecs.rb +++ b/lib/solargraph/workspace/gemspecs.rb @@ -118,7 +118,7 @@ def fetch_dependencies gemspec # Can happen on system gems in Ruby 3.0, it seems: # # https://github.com/castwide/solargraph/actions/runs/16480452864/job/46593077954?pr=1006 - log.debug do + logger.debug do "Skipping dependency #{runtime_dep.name} for #{gemspec.name} due to NoMethodError: #{e.message}" end From 3a43053053c163ecb1abb2c1d48b6799572b655c Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Mon, 28 Jul 2025 08:25:18 -0400 Subject: [PATCH 181/400] Fix Ruby 3.0+RBS 3.6.1 yaml issue --- lib/solargraph/doc_map.rb | 9 +++++++-- lib/solargraph/rbs_map/stdlib_map.rb | 4 ++-- lib/solargraph/workspace.rb | 7 +++++++ lib/solargraph/workspace/gemspecs.rb | 8 ++++++++ 4 files changed, 24 insertions(+), 4 deletions(-) diff --git a/lib/solargraph/doc_map.rb b/lib/solargraph/doc_map.rb index 9e373953b..cfa84712f 100644 --- a/lib/solargraph/doc_map.rb +++ b/lib/solargraph/doc_map.rb @@ -118,8 +118,13 @@ def load_serialized_gem_pins out: $stderr # this will load from disk if needed; no need to manage # uncached_gemspecs to trigger that later stdlib_name_guess = path.split('/').first - rbs_pins = pin_cache.cache_stdlib_rbs_map stdlib_name_guess if stdlib_name_guess - @pins.concat rbs_pins if rbs_pins + + # try to resolve the stdlib name + deps = workspace.stdlib_dependencies(stdlib_name_guess) || [] + [stdlib_name_guess, *deps].each do |potential_stdlib_name| + rbs_pins = pin_cache.cache_stdlib_rbs_map potential_stdlib_name + @pins.concat rbs_pins if rbs_pins + end end existing_pin_count = pins.length diff --git a/lib/solargraph/rbs_map/stdlib_map.rb b/lib/solargraph/rbs_map/stdlib_map.rb index bd3fd5a99..3851307f3 100644 --- a/lib/solargraph/rbs_map/stdlib_map.rb +++ b/lib/solargraph/rbs_map/stdlib_map.rb @@ -44,9 +44,9 @@ def self.source end # @param name [String] - # @param version [String] + # @param version [String, nil] # @return [Array String}>, nil] - def self.stdlib_dependencies name, version + def self.stdlib_dependencies name, version = nil if source.has?(name, version) source.dependencies_of(name, version) else diff --git a/lib/solargraph/workspace.rb b/lib/solargraph/workspace.rb index ab788be06..dbc6f892c 100644 --- a/lib/solargraph/workspace.rb +++ b/lib/solargraph/workspace.rb @@ -66,6 +66,13 @@ def resolve_require require gemspecs.resolve_require(require) end + # @param stdlib_name [String] + # + # @return [Array] + def stdlib_dependencies stdlib_name + gemspecs.stdlib_dependencies(stdlib_name) + end + # @return [Environ] def global_environ # empty docmap, since the result needs to work in any possible diff --git a/lib/solargraph/workspace/gemspecs.rb b/lib/solargraph/workspace/gemspecs.rb index 170fe0c06..270b063eb 100644 --- a/lib/solargraph/workspace/gemspecs.rb +++ b/lib/solargraph/workspace/gemspecs.rb @@ -86,6 +86,14 @@ def resolve_require require nil end + # @param stdlib_name [String] + # + # @return [Array] + def stdlib_dependencies stdlib_name + deps = RbsMap::StdlibMap.stdlib_dependencies(stdlib_name, nil) || [] + deps.map { |dep| dep['name'] } + end + # @param name [String] # @param version [String, nil] # @param out [IO, nil] output stream for logging From a481c8083345289b32dd4af4e204fc814235a25c Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Mon, 28 Jul 2025 08:45:17 -0400 Subject: [PATCH 182/400] Test Thor.desc lookup, fix rbs_collection_pins_path issue --- lib/solargraph/pin_cache.rb | 2 +- spec/api_map/api_map_method_spec.rb | 17 ++++++++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/lib/solargraph/pin_cache.rb b/lib/solargraph/pin_cache.rb index 1a506ef9e..77fa3c500 100644 --- a/lib/solargraph/pin_cache.rb +++ b/lib/solargraph/pin_cache.rb @@ -367,7 +367,7 @@ def yardoc? gemspec # @param hash [String, nil] # @return [String] def rbs_collection_pins_path gemspec, hash - rbs_collection_pins_path_prefix(gemspec) + "#{gemspec.name}-#{gemspec.version}-#{hash || 0}.ser" + rbs_collection_pins_path_prefix(gemspec) + "#{hash || 0}.ser" end # @param gemspec [Gem::Specification] diff --git a/spec/api_map/api_map_method_spec.rb b/spec/api_map/api_map_method_spec.rb index 8a272b109..91899a40c 100644 --- a/spec/api_map/api_map_method_spec.rb +++ b/spec/api_map/api_map_method_spec.rb @@ -61,10 +61,21 @@ describe '#get_method_stack' do let(:out) { StringIO.new } let(:api_map) { described_class.load_with_cache(Dir.pwd, out: out) } - let(:method_stack) { api_map.get_method_stack('YAML', 'safe_load', scope: :class) } - it 'handles the YAML gem aliased to Psych' do - expect(method_stack).not_to be_empty + context 'with stdlib that has vital dependencies' do + let(:method_stack) { api_map.get_method_stack('YAML', 'safe_load', scope: :class) } + + it 'handles the YAML gem aliased to Psych' do + expect(method_stack).not_to be_empty + end + end + + context 'with thor' do + let(:method_stack) { api_map.get_method_stack('Thor', 'desc', scope: :class) } + + it 'handles finding Thor.desc' do + expect(method_stack).not_to be_empty + end end end end From c03266ef416040b4e04a7ffce8c75a3482d2f121 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Mon, 28 Jul 2025 10:11:42 -0400 Subject: [PATCH 183/400] Work around an overcommit glitch --- lib/solargraph/yardoc.rb | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/lib/solargraph/yardoc.rb b/lib/solargraph/yardoc.rb index 9701018cf..96e39816e 100644 --- a/lib/solargraph/yardoc.rb +++ b/lib/solargraph/yardoc.rb @@ -23,7 +23,7 @@ def build_docs gem_yardoc_path, yard_plugins, gemspec # @todo set these up to run in parallel # # @sg-ignore - stdout_and_stderr_str, status = Open3.capture2e(cmd, chdir: gemspec.gem_dir) + stdout_and_stderr_str, status = Open3.capture2e(current_bundle_env_tweaks, cmd, chdir: gemspec.gem_dir) return if status.success? Solargraph.logger.warn { "YARD failed running #{cmd.inspect} in #{gemspec.gem_dir}" } Solargraph.logger.info stdout_and_stderr_str @@ -64,5 +64,22 @@ def load! gem_yardoc_path YARD::Registry.load! gem_yardoc_path YARD::Registry.all end + + # If the BUNDLE_GEMFILE environment variable is set, we need to + # make sure it's an absolute path, as we'll be changing + # directories. + # + # 'bundle exec' sets an absolute path here, but at least the + # overcommit gem does not, breaking on-the-fly documention with a + # spawned yardoc command from our current bundle + # + # @return [Hash{String => String}] a hash of environment variables to override + def current_bundle_env_tweaks + tweaks = {} + if ENV['BUNDLE_GEMFILE'] && !ENV['BUNDLE_GEMFILE'].empty? + tweaks['BUNDLE_GEMFILE'] = File.expand_path(ENV['BUNDLE_GEMFILE']) + end + tweaks + end end end From ed5381fd13b669b5a79556d775e67a28d9021385 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Mon, 28 Jul 2025 10:48:06 -0400 Subject: [PATCH 184/400] Drop offense counts for easier mitigation --- .github/workflows/linting.yml | 4 +- .rubocop_todo.yml | 215 +--------------------------------- 2 files changed, 3 insertions(+), 216 deletions(-) diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml index fbd80a490..2a5968351 100644 --- a/.github/workflows/linting.yml +++ b/.github/workflows/linting.yml @@ -114,11 +114,11 @@ jobs: - name: Run RuboCop against todo file run: | - bundle exec rubocop --auto-gen-config --no-exclude-limit --no-auto-gen-timestamp + bundle exec rubocop --auto-gen-config --no-exclude-limit --no-offense-counts --no-auto-gen-timestamp if [ -n "$(git status --porcelain)" ] then git status --porcelain git diff -u . - >&2 echo "Please fix deltas if bad or run 'bundle exec rubocop --auto-gen-config --no-exclude-limit --no-auto-gen-timestamp' and push up changes if good" + >&2 echo "Please fix deltas if bad or run 'bundle exec rubocop --auto-gen-config --no-exclude-limit --no-offense-counts --no-auto-gen-timestamp' and push up changes if good" exit 1 fi diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index aa00a82d0..c5865e228 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,12 +1,11 @@ # This configuration was generated by -# `rubocop --auto-gen-config --no-exclude-limit --no-auto-gen-timestamp` +# `rubocop --auto-gen-config --no-exclude-limit --no-offense-counts --no-auto-gen-timestamp` # using RuboCop version 1.79.0. # 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: 19 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: Include. # Include: **/*.gemspec @@ -14,7 +13,6 @@ Gemspec/AddRuntimeDependency: Exclude: - 'solargraph.gemspec' -# Offense count: 2 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: Severity, Include. # Include: **/*.gemspec @@ -23,7 +21,6 @@ Gemspec/DeprecatedAttributeAssignment: - 'solargraph.gemspec' - 'spec/fixtures/rdoc-lib/rdoc-lib.gemspec' -# Offense count: 13 # Configuration parameters: EnforcedStyle, AllowedGems, Include. # SupportedStyles: Gemfile, gems.rb, gemspec # Include: **/*.gemspec, **/Gemfile, **/gems.rb @@ -31,7 +28,6 @@ Gemspec/DevelopmentDependencies: Exclude: - 'solargraph.gemspec' -# Offense count: 1 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: TreatCommentsAsGroupSeparators, ConsiderPunctuation, Include. # Include: **/*.gemspec @@ -39,7 +35,6 @@ Gemspec/OrderedDependencies: Exclude: - 'solargraph.gemspec' -# Offense count: 3 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: Severity, Include. # Include: **/*.gemspec @@ -49,7 +44,6 @@ Gemspec/RequireMFA: - 'spec/fixtures/rdoc-lib/rdoc-lib.gemspec' - 'spec/fixtures/rubocop-custom-version/specifications/rubocop-0.0.0.gemspec' -# Offense count: 3 # Configuration parameters: Severity, Include. # Include: **/*.gemspec Gemspec/RequiredRubyVersion: @@ -58,7 +52,6 @@ Gemspec/RequiredRubyVersion: - 'spec/fixtures/rubocop-custom-version/specifications/rubocop-0.0.0.gemspec' - 'spec/fixtures/vendored/vendor/do_not_use.gemspec' -# Offense count: 8 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle, IndentationWidth. # SupportedStyles: with_first_argument, with_fixed_indentation @@ -68,7 +61,6 @@ Layout/ArgumentAlignment: - 'lib/solargraph/pin/callable.rb' - 'spec/source/source_chainer_spec.rb' -# Offense count: 1 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyleAlignWith. # SupportedStylesAlignWith: either, start_of_block, start_of_line @@ -76,14 +68,12 @@ Layout/BlockAlignment: Exclude: - 'spec/source_map/mapper_spec.rb' -# Offense count: 2 # This cop supports safe autocorrection (--autocorrect). Layout/ClosingHeredocIndentation: Exclude: - 'spec/diagnostics/rubocop_spec.rb' - 'spec/rbs_map/conversions_spec.rb' -# Offense count: 8 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowForAlignment. Layout/CommentIndentation: @@ -93,7 +83,6 @@ Layout/CommentIndentation: - 'lib/solargraph/parser/parser_gem/node_methods.rb' - 'lib/solargraph/source_map/mapper.rb' -# Offense count: 23 # This cop supports safe autocorrection (--autocorrect). Layout/ElseAlignment: Exclude: @@ -115,7 +104,6 @@ Layout/ElseAlignment: - 'lib/solargraph/type_checker/rules.rb' - 'lib/solargraph/yard_map/mapper.rb' -# Offense count: 3 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EmptyLineBetweenMethodDefs, EmptyLineBetweenClassDefs, EmptyLineBetweenModuleDefs, DefLikeMacros, AllowAdjacentOneLineDefs, NumberOfEmptyLines. Layout/EmptyLineBetweenDefs: @@ -124,7 +112,6 @@ Layout/EmptyLineBetweenDefs: - 'lib/solargraph/language_server/message/initialize.rb' - 'lib/solargraph/pin/delegated_method.rb' -# Offense count: 13 # This cop supports safe autocorrection (--autocorrect). Layout/EmptyLines: Exclude: @@ -142,7 +129,6 @@ Layout/EmptyLines: - 'spec/pin/symbol_spec.rb' - 'spec/type_checker/levels/strict_spec.rb' -# Offense count: 1 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle. # SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines, beginning_only, ending_only @@ -150,7 +136,6 @@ Layout/EmptyLinesAroundClassBody: Exclude: - 'lib/solargraph/rbs_map/core_map.rb' -# Offense count: 1 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle. # SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines @@ -158,7 +143,6 @@ Layout/EmptyLinesAroundModuleBody: Exclude: - 'lib/solargraph/api_map/source_to_yard.rb' -# Offense count: 22 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyleAlignWith, Severity. # SupportedStylesAlignWith: keyword, variable, start_of_line @@ -182,7 +166,6 @@ Layout/EndAlignment: - 'lib/solargraph/type_checker/rules.rb' - 'lib/solargraph/yard_map/mapper.rb' -# Offense count: 4 # Configuration parameters: EnforcedStyle. # SupportedStyles: native, lf, crlf Layout/EndOfLine: @@ -192,7 +175,6 @@ Layout/EndOfLine: - 'lib/solargraph/source/encoding_fixes.rb' - 'solargraph.gemspec' -# Offense count: 7 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowForAlignment, AllowBeforeTrailingComments, ForceEqualSignAlignment. Layout/ExtraSpacing: @@ -204,7 +186,6 @@ Layout/ExtraSpacing: - 'lib/solargraph/type_checker.rb' - 'spec/spec_helper.rb' -# Offense count: 2 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle, IndentationWidth. # SupportedStyles: consistent, consistent_relative_to_receiver, special_for_inner_method_call, special_for_inner_method_call_in_parentheses @@ -213,7 +194,6 @@ Layout/FirstArgumentIndentation: - 'lib/solargraph/parser/parser_gem/node_processors/args_node.rb' - 'spec/source/source_chainer_spec.rb' -# Offense count: 18 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle, IndentationWidth. # SupportedStyles: special_inside_parentheses, consistent, align_brackets @@ -225,7 +205,6 @@ Layout/FirstArrayElementIndentation: - 'spec/source/source_chainer_spec.rb' - 'spec/source_spec.rb' -# Offense count: 65 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle, IndentationWidth. # SupportedStyles: special_inside_parentheses, consistent, align_braces @@ -247,7 +226,6 @@ Layout/FirstHashElementIndentation: - 'spec/language_server/message/text_document/type_definition_spec.rb' - 'spec/language_server/message/workspace/did_change_watched_files_spec.rb' -# Offense count: 4 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowMultipleStyles, EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle. # SupportedHashRocketStyles: key, separator, table @@ -258,7 +236,6 @@ Layout/HashAlignment: - 'lib/solargraph/convention/struct_definition.rb' - 'lib/solargraph/workspace/config.rb' -# Offense count: 3 # This cop supports safe autocorrection (--autocorrect). Layout/HeredocIndentation: Exclude: @@ -266,7 +243,6 @@ Layout/HeredocIndentation: - 'spec/rbs_map/conversions_spec.rb' - 'spec/yard_map/mapper/to_method_spec.rb' -# Offense count: 24 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: Width, AllowedPatterns. Layout/IndentationWidth: @@ -291,7 +267,6 @@ Layout/IndentationWidth: - 'spec/api_map/config_spec.rb' - 'spec/source_map/mapper_spec.rb' -# Offense count: 5 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowDoxygenCommentStyle, AllowGemfileRubyComment, AllowRBSInlineAnnotation, AllowSteepAnnotation. Layout/LeadingCommentSpace: @@ -301,7 +276,6 @@ Layout/LeadingCommentSpace: - 'lib/solargraph/source/chain/call.rb' - 'lib/solargraph/source_map/clip.rb' -# Offense count: 1 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle. # SupportedStyles: space, no_space @@ -309,7 +283,6 @@ Layout/LineContinuationSpacing: Exclude: - 'lib/solargraph/diagnostics/rubocop_helpers.rb' -# Offense count: 3 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle. # SupportedStyles: symmetrical, new_line, same_line @@ -318,7 +291,6 @@ Layout/MultilineMethodCallBraceLayout: - 'lib/solargraph/parser/parser_gem/node_processors/send_node.rb' - 'spec/source/source_chainer_spec.rb' -# Offense count: 12 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle, IndentationWidth. # SupportedStyles: aligned, indented, indented_relative_to_receiver @@ -332,7 +304,6 @@ Layout/MultilineMethodCallIndentation: - 'lib/solargraph/pin/search.rb' - 'lib/solargraph/type_checker.rb' -# Offense count: 6 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle, IndentationWidth. # SupportedStyles: aligned, indented @@ -342,13 +313,11 @@ Layout/MultilineOperationIndentation: - 'lib/solargraph/language_server/host/dispatch.rb' - 'lib/solargraph/source.rb' -# Offense count: 6 # This cop supports safe autocorrection (--autocorrect). Layout/SpaceAfterComma: Exclude: - 'spec/source/cursor_spec.rb' -# Offense count: 6 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle. # SupportedStyles: space, no_space @@ -361,13 +330,11 @@ Layout/SpaceAroundEqualsInParameterDefault: - 'lib/solargraph/pin/local_variable.rb' - 'lib/solargraph/pin/parameter.rb' -# Offense count: 1 # This cop supports safe autocorrection (--autocorrect). Layout/SpaceAroundKeyword: Exclude: - 'spec/rbs_map/conversions_spec.rb' -# Offense count: 28 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowForAlignment, EnforcedStyleForExponentOperator, EnforcedStyleForRationalLiterals. # SupportedStylesForExponentOperator: space, no_space @@ -386,7 +353,6 @@ Layout/SpaceAroundOperators: - 'spec/library_spec.rb' - 'spec/yard_map/mapper_spec.rb' -# Offense count: 105 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces. # SupportedStyles: space, no_space @@ -425,13 +391,11 @@ Layout/SpaceBeforeBlockBraces: - 'spec/source_map_spec.rb' - 'spec/source_spec.rb' -# Offense count: 1 # This cop supports safe autocorrection (--autocorrect). Layout/SpaceBeforeComma: Exclude: - 'spec/source/cursor_spec.rb' -# Offense count: 177 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters. # SupportedStyles: space, no_space @@ -460,7 +424,6 @@ Layout/SpaceInsideBlockBraces: - 'spec/source_map/mapper_spec.rb' - 'spec/source_spec.rb' -# Offense count: 10 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces. # SupportedStyles: space, no_space, compact @@ -473,7 +436,6 @@ Layout/SpaceInsideHashLiteralBraces: - 'spec/language_server/host/message_worker_spec.rb' - 'spec/language_server/message/extended/check_gem_version_spec.rb' -# Offense count: 2 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle. # SupportedStyles: space, compact, no_space @@ -482,7 +444,6 @@ Layout/SpaceInsideParens: - 'lib/solargraph/pin/namespace.rb' - 'lib/solargraph/source_map.rb' -# Offense count: 1 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle. # SupportedStyles: final_newline, final_blank_line @@ -490,7 +451,6 @@ Layout/TrailingEmptyLines: Exclude: - 'spec/convention/struct_definition_spec.rb' -# Offense count: 5 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowInHeredoc. Layout/TrailingWhitespace: @@ -500,7 +460,6 @@ Layout/TrailingWhitespace: - 'spec/convention/struct_definition_spec.rb' - 'spec/convention_spec.rb' -# Offense count: 2 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowedMethods, AllowedPatterns. Lint/AmbiguousBlockAssociation: @@ -508,7 +467,6 @@ Lint/AmbiguousBlockAssociation: - 'lib/solargraph/api_map.rb' - 'lib/solargraph/language_server/host.rb' -# Offense count: 15 # This cop supports safe autocorrection (--autocorrect). Lint/AmbiguousOperator: Exclude: @@ -519,14 +477,12 @@ Lint/AmbiguousOperator: - 'lib/solargraph/pin/constant.rb' - 'lib/solargraph/pin/method.rb' -# Offense count: 5 # This cop supports safe autocorrection (--autocorrect). Lint/AmbiguousOperatorPrecedence: Exclude: - 'lib/solargraph/pin/method.rb' - 'lib/solargraph/source.rb' -# Offense count: 18 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: RequireParenthesesForMethodChains. Lint/AmbiguousRange: @@ -540,19 +496,16 @@ Lint/AmbiguousRange: - 'lib/solargraph/source_map/clip.rb' - 'spec/library_spec.rb' -# Offense count: 1 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: AllowSafeAssignment. Lint/AssignmentInCondition: Exclude: - 'lib/solargraph/library.rb' -# Offense count: 3 Lint/BinaryOperatorWithIdenticalOperands: Exclude: - 'lib/solargraph/api_map/source_to_yard.rb' -# Offense count: 5 # This cop supports unsafe autocorrection (--autocorrect-all). Lint/BooleanSymbol: Exclude: @@ -560,14 +513,12 @@ Lint/BooleanSymbol: - 'lib/solargraph/parser/parser_gem/node_methods.rb' - 'lib/solargraph/source/chain/literal.rb' -# Offense count: 1 # Configuration parameters: AllowedMethods. # AllowedMethods: enums Lint/ConstantDefinitionInBlock: Exclude: - 'spec/complex_type_spec.rb' -# Offense count: 8 # Configuration parameters: IgnoreLiteralBranches, IgnoreConstantBranches, IgnoreDuplicateElseBranch. Lint/DuplicateBranch: Exclude: @@ -576,7 +527,6 @@ Lint/DuplicateBranch: - 'lib/solargraph/pin/base.rb' - 'lib/solargraph/rbs_map/conversions.rb' -# Offense count: 9 Lint/DuplicateMethods: Exclude: - 'lib/solargraph/complex_type.rb' @@ -588,13 +538,11 @@ Lint/DuplicateMethods: - 'lib/solargraph/rbs_map/core_map.rb' - 'lib/solargraph/source/chain/link.rb' -# Offense count: 1 # Configuration parameters: AllowComments, AllowEmptyLambdas. Lint/EmptyBlock: Exclude: - 'spec/convention_spec.rb' -# Offense count: 6 # Configuration parameters: AllowComments. Lint/EmptyClass: Exclude: @@ -605,13 +553,11 @@ Lint/EmptyClass: - 'spec/fixtures/workspace_folders/folder1/app.rb' - 'spec/fixtures/workspace_folders/folder2/app.rb' -# Offense count: 1 # Configuration parameters: AllowComments. Lint/EmptyFile: Exclude: - 'spec/fixtures/vendored/vendor/do_not_use.gemspec' -# Offense count: 6 # This cop supports unsafe autocorrection (--autocorrect-all). Lint/InterpolationCheck: Exclude: @@ -620,7 +566,6 @@ Lint/InterpolationCheck: - 'spec/source/chain_spec.rb' - 'spec/source/cursor_spec.rb' -# Offense count: 5 # Configuration parameters: AllowedParentClasses. Lint/MissingSuper: Exclude: @@ -630,13 +575,11 @@ Lint/MissingSuper: - 'lib/solargraph/source/chain/literal.rb' - 'lib/solargraph/source/chain/or.rb' -# Offense count: 2 # This cop supports unsafe autocorrection (--autocorrect-all). Lint/NonAtomicFileOperation: Exclude: - 'spec/diagnostics/rubocop_spec.rb' -# Offense count: 4 # This cop supports safe autocorrection (--autocorrect). Lint/ParenthesesAsGroupedExpression: Exclude: @@ -645,13 +588,11 @@ Lint/ParenthesesAsGroupedExpression: - 'spec/language_server/host_spec.rb' - 'spec/source_map/clip_spec.rb' -# Offense count: 1 # This cop supports safe autocorrection (--autocorrect). Lint/RedundantRequireStatement: Exclude: - 'spec/language_server/protocol_spec.rb' -# Offense count: 2 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: AllowedMethods, InferNonNilReceiver, AdditionalNilMethods. # AllowedMethods: instance_of?, kind_of?, is_a?, eql?, respond_to?, equal? @@ -661,7 +602,6 @@ Lint/RedundantSafeNavigation: - 'lib/solargraph/api_map/source_to_yard.rb' - 'lib/solargraph/rbs_map.rb' -# Offense count: 6 # This cop supports safe autocorrection (--autocorrect). Lint/RedundantStringCoercion: Exclude: @@ -671,19 +611,16 @@ Lint/RedundantStringCoercion: - 'lib/solargraph/pin/namespace.rb' - 'lib/solargraph/rbs_map/conversions.rb' -# Offense count: 1 # This cop supports safe autocorrection (--autocorrect). Lint/RedundantWithIndex: Exclude: - 'lib/solargraph/language_server/message/completion_item/resolve.rb' -# Offense count: 1 # Configuration parameters: AllowComments, AllowNil. Lint/SuppressedException: Exclude: - 'Rakefile' -# Offense count: 5 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle. # SupportedStyles: strict, consistent @@ -691,25 +628,21 @@ Lint/SymbolConversion: Exclude: - 'lib/solargraph/pin/base.rb' -# Offense count: 1 # Configuration parameters: AllowKeywordBlockArguments. Lint/UnderscorePrefixedVariableName: Exclude: - 'lib/solargraph/library.rb' -# Offense count: 2 # Configuration parameters: Methods. Lint/UnexpectedBlockArity: Exclude: - 'lib/solargraph/language_server/message/completion_item/resolve.rb' - 'lib/solargraph/type_checker.rb' -# Offense count: 1 Lint/UnmodifiedReduceAccumulator: Exclude: - 'lib/solargraph/pin/method.rb' -# Offense count: 4 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AutoCorrect, IgnoreEmptyBlocks, AllowUnusedKeywordArguments. Lint/UnusedBlockArgument: @@ -718,7 +651,6 @@ Lint/UnusedBlockArgument: - 'lib/solargraph/logging.rb' - 'spec/language_server/transport/data_reader_spec.rb' -# Offense count: 38 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AutoCorrect, AllowUnusedKeywordArguments, IgnoreEmptyMethods, IgnoreNotImplementedMethods, NotImplementedExceptions. # NotImplementedExceptions: NotImplementedError @@ -748,14 +680,12 @@ Lint/UnusedMethodArgument: - 'lib/solargraph/source/chain/variable.rb' - 'lib/solargraph/source/chain/z_super.rb' -# Offense count: 1 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AutoCorrect, ContextCreatingMethods, MethodCreatingMethods. Lint/UselessAccessModifier: Exclude: - 'lib/solargraph/api_map.rb' -# Offense count: 41 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AutoCorrect. Lint/UselessAssignment: @@ -784,19 +714,16 @@ Lint/UselessAssignment: - 'spec/source/chain/call_spec.rb' - 'spec/source_map/mapper_spec.rb' -# Offense count: 2 Lint/UselessConstantScoping: Exclude: - 'lib/solargraph/rbs_map/conversions.rb' -# Offense count: 1 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: AutoCorrect. Lint/UselessMethodDefinition: Exclude: - 'lib/solargraph/pin/signature.rb' -# Offense count: 22 # Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes, Max. Metrics/AbcSize: Exclude: @@ -818,7 +745,6 @@ Metrics/AbcSize: - 'lib/solargraph/source_map/mapper.rb' - 'lib/solargraph/type_checker.rb' -# Offense count: 12 # Configuration parameters: CountComments, Max, CountAsOne, AllowedMethods, AllowedPatterns, inherit_mode. # AllowedMethods: refine Metrics/BlockLength: @@ -830,7 +756,6 @@ Metrics/BlockLength: - 'lib/solargraph/source/chain/call.rb' - 'lib/solargraph/type_checker.rb' -# Offense count: 13 # Configuration parameters: CountBlocks, CountModifierForms, Max. Metrics/BlockNesting: Exclude: @@ -838,7 +763,6 @@ Metrics/BlockNesting: - 'lib/solargraph/source_map/clip.rb' - 'lib/solargraph/type_checker.rb' -# Offense count: 4 # Configuration parameters: CountComments, Max, CountAsOne. Metrics/ClassLength: Exclude: @@ -847,7 +771,6 @@ Metrics/ClassLength: - 'lib/solargraph/rbs_map/conversions.rb' - 'lib/solargraph/type_checker.rb' -# Offense count: 11 # Configuration parameters: AllowedMethods, AllowedPatterns, Max. Metrics/CyclomaticComplexity: Exclude: @@ -861,7 +784,6 @@ Metrics/CyclomaticComplexity: - 'lib/solargraph/source_map/mapper.rb' - 'lib/solargraph/type_checker.rb' -# Offense count: 7 # Configuration parameters: CountComments, Max, CountAsOne, AllowedMethods, AllowedPatterns. Metrics/MethodLength: Exclude: @@ -873,7 +795,6 @@ Metrics/MethodLength: - 'lib/solargraph/source_map/mapper.rb' - 'lib/solargraph/type_checker.rb' -# Offense count: 4 # Configuration parameters: CountComments, Max, CountAsOne. Metrics/ModuleLength: Exclude: @@ -881,7 +802,6 @@ Metrics/ModuleLength: - 'lib/solargraph/parser/parser_gem/node_methods.rb' - 'lib/solargraph/pin_cache.rb' -# Offense count: 6 # Configuration parameters: Max, CountKeywordArgs, MaxOptionalParameters. Metrics/ParameterLists: Exclude: @@ -891,7 +811,6 @@ Metrics/ParameterLists: - 'lib/solargraph/yard_map/mapper/to_method.rb' - 'lib/solargraph/yard_map/to_method.rb' -# Offense count: 9 # Configuration parameters: AllowedMethods, AllowedPatterns, Max. Metrics/PerceivedComplexity: Exclude: @@ -903,27 +822,23 @@ Metrics/PerceivedComplexity: - 'lib/solargraph/source_map/mapper.rb' - 'lib/solargraph/type_checker.rb' -# Offense count: 5 Naming/AccessorMethodName: Exclude: - 'lib/solargraph/api_map.rb' - 'lib/solargraph/api_map/store.rb' - 'lib/solargraph/language_server/message/base.rb' -# Offense count: 1 # Configuration parameters: AsciiConstants. Naming/AsciiIdentifiers: Exclude: - 'spec/fixtures/unicode.rb' -# Offense count: 1 # Configuration parameters: ForbiddenDelimiters. # ForbiddenDelimiters: (?i-mx:(^|\s)(EO[A-Z]{1}|END)(\s|$)) Naming/HeredocDelimiterNaming: Exclude: - 'spec/yard_map/mapper/to_method_spec.rb' -# Offense count: 9 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: EnforcedStyleForLeadingUnderscores. # SupportedStylesForLeadingUnderscores: disallowed, required, optional @@ -937,7 +852,6 @@ Naming/MemoizedInstanceVariableName: - 'lib/solargraph/rbs_map.rb' - 'lib/solargraph/workspace.rb' -# Offense count: 16 # Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames. # AllowedNames: as, at, by, cc, db, id, if, in, io, ip, of, on, os, pp, to Naming/MethodParameterName: @@ -949,7 +863,6 @@ Naming/MethodParameterName: - 'lib/solargraph/yard_map/mapper/to_method.rb' - 'lib/solargraph/yard_map/to_method.rb' -# Offense count: 14 # Configuration parameters: Mode, AllowedMethods, AllowedPatterns, AllowBangMethods, WaywardPredicates. # AllowedMethods: call # WaywardPredicates: nonzero? @@ -967,7 +880,6 @@ Naming/PredicateMethod: - 'lib/solargraph/pin/local_variable.rb' - 'lib/solargraph/workspace.rb' -# Offense count: 6 # Configuration parameters: NamePrefix, ForbiddenPrefixes, AllowedMethods, MethodDefinitionMacros, UseSorbetSigs. # NamePrefix: is_, has_, have_, does_ # ForbiddenPrefixes: is_, has_, have_, does_ @@ -982,34 +894,29 @@ Naming/PredicatePrefix: - 'lib/solargraph/pin_cache.rb' - 'lib/solargraph/workspace.rb' -# Offense count: 1 # Configuration parameters: EnforcedStyle, AllowedIdentifiers, AllowedPatterns, ForbiddenIdentifiers, ForbiddenPatterns. # SupportedStyles: snake_case, camelCase Naming/VariableName: Exclude: - 'spec/fixtures/unicode.rb' -# Offense count: 3 RSpec/Be: Exclude: - 'spec/rbs_map/stdlib_map_spec.rb' - 'spec/rbs_map_spec.rb' - 'spec/source/source_chainer_spec.rb' -# Offense count: 3 # This cop supports unsafe autocorrection (--autocorrect-all). RSpec/BeEq: Exclude: - 'spec/complex_type_spec.rb' - 'spec/pin/method_spec.rb' -# Offense count: 2 # This cop supports unsafe autocorrection (--autocorrect-all). RSpec/BeEql: Exclude: - 'spec/convention/struct_definition_spec.rb' -# Offense count: 7 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle. # SupportedStyles: be, be_nil @@ -1018,7 +925,6 @@ RSpec/BeNil: - 'spec/api_map/source_to_yard_spec.rb' - 'spec/language_server/host_spec.rb' -# Offense count: 5 RSpec/BeforeAfterAll: Exclude: - '**/spec/spec_helper.rb' @@ -1029,7 +935,6 @@ RSpec/BeforeAfterAll: - 'spec/language_server/host/dispatch_spec.rb' - 'spec/language_server/protocol_spec.rb' -# Offense count: 25 # Configuration parameters: Prefixes, AllowedPatterns. # Prefixes: when, with, without RSpec/ContextWording: @@ -1044,7 +949,6 @@ RSpec/ContextWording: - 'spec/type_checker/levels/strong_spec.rb' - 'spec/type_checker/levels/typed_spec.rb' -# Offense count: 2 # Configuration parameters: IgnoredMetadata. RSpec/DescribeClass: Exclude: @@ -1056,7 +960,6 @@ RSpec/DescribeClass: - 'spec/complex_type_spec.rb' - 'spec/source_map/node_processor_spec.rb' -# Offense count: 412 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: SkipBlocks, EnforcedStyle, OnlyStaticConstants. # SupportedStyles: described_class, explicit @@ -1133,20 +1036,17 @@ RSpec/DescribedClass: - 'spec/yard_map/mapper/to_method_spec.rb' - 'spec/yard_map/mapper_spec.rb' -# Offense count: 1 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: AutoCorrect. RSpec/EmptyExampleGroup: Exclude: - 'spec/convention_spec.rb' -# Offense count: 1 # This cop supports safe autocorrection (--autocorrect). RSpec/EmptyLineAfterFinalLet: Exclude: - 'spec/workspace/config_spec.rb' -# Offense count: 89 # Configuration parameters: Max, CountAsOne. RSpec/ExampleLength: Exclude: @@ -1177,7 +1077,6 @@ RSpec/ExampleLength: - 'spec/type_checker/levels/strict_spec.rb' - 'spec/type_checker_spec.rb' -# Offense count: 10 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: CustomTransform, IgnoredWords, DisallowedExamples. # DisallowedExamples: works @@ -1187,14 +1086,12 @@ RSpec/ExampleWording: - 'spec/pin/base_spec.rb' - 'spec/pin/method_spec.rb' -# Offense count: 2 # This cop supports safe autocorrection (--autocorrect). RSpec/ExcessiveDocstringSpacing: Exclude: - 'spec/rbs_map/conversions_spec.rb' - 'spec/source/chain/call_spec.rb' -# Offense count: 5 # This cop supports safe autocorrection (--autocorrect). RSpec/ExpectActual: Exclude: @@ -1202,7 +1099,6 @@ RSpec/ExpectActual: - 'spec/rbs_map/stdlib_map_spec.rb' - 'spec/source_map/mapper_spec.rb' -# Offense count: 13 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle. # SupportedStyles: implicit, each, example @@ -1217,14 +1113,12 @@ RSpec/HookArgument: - 'spec/workspace/config_spec.rb' - 'spec/workspace_spec.rb' -# Offense count: 2 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: . # SupportedStyles: is_expected, should RSpec/ImplicitExpect: EnforcedStyle: should -# Offense count: 247 # Configuration parameters: AssignmentOnly. RSpec/InstanceVariable: Exclude: @@ -1235,36 +1129,30 @@ RSpec/InstanceVariable: - 'spec/language_server/host_spec.rb' - 'spec/language_server/protocol_spec.rb' -# Offense count: 1 # This cop supports safe autocorrection (--autocorrect). RSpec/LeadingSubject: Exclude: - 'spec/rbs_map/conversions_spec.rb' -# Offense count: 1 RSpec/LeakyConstantDeclaration: Exclude: - 'spec/complex_type_spec.rb' -# Offense count: 3 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AutoCorrect. RSpec/LetBeforeExamples: Exclude: - 'spec/complex_type_spec.rb' -# Offense count: 3 # Configuration parameters: . # SupportedStyles: have_received, receive RSpec/MessageSpies: EnforcedStyle: receive -# Offense count: 2 RSpec/MissingExampleGroupArgument: Exclude: - 'spec/diagnostics/rubocop_helpers_spec.rb' -# Offense count: 481 # Configuration parameters: Max. RSpec/MultipleExpectations: Exclude: @@ -1331,13 +1219,11 @@ RSpec/MultipleExpectations: - 'spec/yard_map/mapper/to_method_spec.rb' - 'spec/yard_map/mapper_spec.rb' -# Offense count: 1 # Configuration parameters: Max, AllowedGroups. RSpec/NestedGroups: Exclude: - 'spec/complex_type_spec.rb' -# Offense count: 8 # Configuration parameters: AllowedPatterns. # AllowedPatterns: ^expect_, ^assert_ RSpec/NoExpectationExample: @@ -1350,7 +1236,6 @@ RSpec/NoExpectationExample: - 'spec/type_checker/checks_spec.rb' - 'spec/type_checker/levels/typed_spec.rb' -# Offense count: 2 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle. # SupportedStyles: not_to, to_not @@ -1359,7 +1244,6 @@ RSpec/NotToNot: - 'spec/api_map_spec.rb' - 'spec/rbs_map/core_map_spec.rb' -# Offense count: 28 RSpec/PendingWithoutReason: Exclude: - 'spec/api_map_spec.rb' @@ -1374,7 +1258,6 @@ RSpec/PendingWithoutReason: - 'spec/type_checker/levels/strict_spec.rb' - 'spec/yard_map/mapper/to_method_spec.rb' -# Offense count: 3 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: Strict, EnforcedStyle, AllowedExplicitMatchers. # SupportedStyles: inflected, explicit @@ -1383,18 +1266,15 @@ RSpec/PredicateMatcher: - 'spec/language_server/message/workspace/did_change_configuration_spec.rb' - 'spec/source_spec.rb' -# Offense count: 3 # This cop supports unsafe autocorrection (--autocorrect-all). RSpec/ReceiveMessages: Exclude: - 'spec/language_server/host_spec.rb' -# Offense count: 1 RSpec/RemoveConst: Exclude: - 'spec/diagnostics/rubocop_helpers_spec.rb' -# Offense count: 50 RSpec/RepeatedDescription: Exclude: - 'spec/api_map_spec.rb' @@ -1407,7 +1287,6 @@ RSpec/RepeatedDescription: - 'spec/type_checker/levels/normal_spec.rb' - 'spec/type_checker/levels/strict_spec.rb' -# Offense count: 30 RSpec/RepeatedExample: Exclude: - 'spec/api_map_spec.rb' @@ -1416,14 +1295,12 @@ RSpec/RepeatedExample: - 'spec/source_map/clip_spec.rb' - 'spec/type_checker/levels/strict_spec.rb' -# Offense count: 2 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AutoCorrect. RSpec/ScatteredLet: Exclude: - 'spec/complex_type_spec.rb' -# Offense count: 89 # Configuration parameters: Include, CustomTransform, IgnoreMethods, IgnoreMetadata. # Include: **/*_spec.rb RSpec/SpecFilePathFormat: @@ -1519,12 +1396,10 @@ RSpec/SpecFilePathFormat: - 'spec/yard_map/mapper/to_method_spec.rb' - 'spec/yard_map/mapper_spec.rb' -# Offense count: 1 RSpec/StubbedMock: Exclude: - 'spec/language_server/host/message_worker_spec.rb' -# Offense count: 23 # Configuration parameters: IgnoreNameless, IgnoreSymbolicNames. RSpec/VerifiedDoubles: Exclude: @@ -1542,12 +1417,10 @@ RSpec/VerifiedDoubles: - 'spec/source/source_chainer_spec.rb' - 'spec/workspace_spec.rb' -# Offense count: 1 Security/MarshalLoad: Exclude: - 'lib/solargraph/pin_cache.rb' -# Offense count: 13 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: EnforcedStyle, AllowModifiersOnSymbols, AllowModifiersOnAttrs, AllowModifiersOnAliasMethod. # SupportedStyles: inline, group @@ -1567,7 +1440,6 @@ Style/AccessModifierDeclarations: - 'lib/solargraph/source/chain/link.rb' - 'lib/solargraph/source/chain/literal.rb' -# Offense count: 13 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle. # SupportedStyles: separated, grouped @@ -1579,7 +1451,6 @@ Style/AccessorGrouping: - 'lib/solargraph/pin/method.rb' - 'lib/solargraph/rbs_map.rb' -# Offense count: 38 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: EnforcedStyle. # SupportedStyles: always, conditionals @@ -1600,7 +1471,6 @@ Style/AndOr: - 'lib/solargraph/workspace.rb' - 'lib/solargraph/yard_map/mapper.rb' -# Offense count: 4 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowOnlyRestArgument, UseAnonymousForwarding, RedundantRestArgumentNames, RedundantKeywordRestArgumentNames, RedundantBlockArgumentNames. # RedundantRestArgumentNames: args, arguments @@ -1611,7 +1481,6 @@ Style/ArgumentsForwarding: - 'lib/solargraph/api_map.rb' - 'lib/solargraph/complex_type.rb' -# Offense count: 52 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle, ProceduralMethods, FunctionalMethods, AllowedMethods, AllowedPatterns, AllowBracesOnProceduralOneLiners, BracesRequiredMethods. # SupportedStyles: line_count_based, semantic, braces_for_chaining, always_braces @@ -1647,7 +1516,6 @@ Style/BlockDelimiters: - 'spec/workspace_spec.rb' - 'spec/yard_map/mapper/to_method_spec.rb' -# Offense count: 7 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: MinBranchesCount. Style/CaseLikeIf: @@ -1659,7 +1527,6 @@ Style/CaseLikeIf: - 'lib/solargraph/source/source_chainer.rb' - 'lib/solargraph/yard_map/mapper.rb' -# Offense count: 11 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: EnforcedStyle, EnforcedStyleForClasses, EnforcedStyleForModules. # SupportedStyles: nested, compact @@ -1679,7 +1546,6 @@ Style/ClassAndModuleChildren: - 'lib/solargraph/language_server/message/workspace/did_change_workspace_folders.rb' - 'lib/solargraph/language_server/message/workspace/workspace_symbol.rb' -# Offense count: 5 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: AllowedMethods, AllowedPatterns. # AllowedMethods: ==, equal?, eql? @@ -1688,32 +1554,27 @@ Style/ClassEqualityComparison: - 'lib/solargraph/gem_pins.rb' - 'lib/solargraph/pin/base.rb' -# Offense count: 2 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: AllowedReceivers. Style/CollectionCompact: Exclude: - 'lib/solargraph/pin/constant.rb' -# Offense count: 1 # This cop supports safe autocorrection (--autocorrect). Style/ColonMethodCall: Exclude: - 'spec/type_checker_spec.rb' -# Offense count: 1 # This cop supports unsafe autocorrection (--autocorrect-all). Style/CombinableLoops: Exclude: - 'lib/solargraph/pin/parameter.rb' -# Offense count: 1 # This cop supports unsafe autocorrection (--autocorrect-all). Style/ConcatArrayLiterals: Exclude: - 'lib/solargraph/parser/parser_gem/node_processors/sclass_node.rb' -# Offense count: 3 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle, SingleLineConditionsOnly, IncludeTernaryExpressions. # SupportedStyles: assign_to_condition, assign_inside_condition @@ -1722,7 +1583,6 @@ Style/ConditionalAssignment: - 'lib/solargraph/parser/parser_gem/node_processors/defs_node.rb' - 'lib/solargraph/source/chain/call.rb' -# Offense count: 141 # Configuration parameters: AllowedConstants. Style/Documentation: Exclude: @@ -1865,13 +1725,11 @@ Style/Documentation: - 'lib/solargraph/yard_map/mapper/to_namespace.rb' - 'lib/solargraph/yard_map/to_method.rb' -# Offense count: 1 # This cop supports safe autocorrection (--autocorrect). Style/EmptyLambdaParameter: Exclude: - 'spec/rbs_map/core_map_spec.rb' -# Offense count: 5 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AutoCorrect, EnforcedStyle. # SupportedStyles: compact, expanded @@ -1883,7 +1741,6 @@ Style/EmptyMethod: - 'spec/fixtures/rdoc-lib/lib/example.rb' - 'spec/fixtures/workspace-with-gemfile/lib/thing.rb' -# Offense count: 5 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle. # SupportedStyles: trailing_conditional, ternary @@ -1893,13 +1750,11 @@ Style/EmptyStringInsideInterpolation: - 'lib/solargraph/pin/documenting.rb' - 'lib/solargraph/shell.rb' -# Offense count: 1 # This cop supports safe autocorrection (--autocorrect). Style/ExpandPathArguments: Exclude: - 'solargraph.gemspec' -# Offense count: 2 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowedVars, DefaultToNil. Style/FetchEnvVar: @@ -1907,7 +1762,6 @@ Style/FetchEnvVar: - 'spec/api_map/config_spec.rb' - 'spec/spec_helper.rb' -# Offense count: 2 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: EnforcedStyle. # SupportedStyles: left_coerce, right_coerce, single_coerce, fdiv @@ -1916,7 +1770,6 @@ Style/FloatDivision: - 'lib/solargraph/library.rb' - 'lib/solargraph/pin/search.rb' -# Offense count: 127 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: EnforcedStyle. # SupportedStyles: always, always_true, never @@ -2051,7 +1904,6 @@ Style/FrozenStringLiteralComment: - 'spec/yard_map/mapper/to_method_spec.rb' - 'spec/yard_map/mapper_spec.rb' -# Offense count: 11 # This cop supports unsafe autocorrection (--autocorrect-all). Style/GlobalStdStream: Exclude: @@ -2060,7 +1912,6 @@ Style/GlobalStdStream: - 'lib/solargraph/shell.rb' - 'spec/logging_spec.rb' -# Offense count: 12 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: MinBodyLength, AllowConsecutiveConditionals. Style/GuardClause: @@ -2074,14 +1925,12 @@ Style/GuardClause: - 'lib/solargraph/source.rb' - 'lib/solargraph/workspace.rb' -# Offense count: 2 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: AllowSplatArgument. Style/HashConversion: Exclude: - 'lib/solargraph/doc_map.rb' -# Offense count: 2 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: AllowedReceivers. # AllowedReceivers: Thread.current @@ -2090,7 +1939,6 @@ Style/HashEachMethods: - 'lib/solargraph/library.rb' - 'lib/solargraph/source.rb' -# Offense count: 25 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle, EnforcedShorthandSyntax, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols. # SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys @@ -2101,14 +1949,12 @@ Style/HashSyntax: - 'spec/source/cursor_spec.rb' - 'spec/source/source_chainer_spec.rb' -# Offense count: 6 # This cop supports unsafe autocorrection (--autocorrect-all). Style/IdenticalConditionalBranches: Exclude: - 'lib/solargraph/library.rb' - 'lib/solargraph/type_checker.rb' -# Offense count: 7 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowIfModifier. Style/IfInsideElse: @@ -2120,7 +1966,6 @@ Style/IfInsideElse: - 'lib/solargraph/source_map/clip.rb' - 'lib/solargraph/type_checker.rb' -# Offense count: 63 # This cop supports safe autocorrection (--autocorrect). Style/IfUnlessModifier: Exclude: @@ -2160,7 +2005,6 @@ Style/IfUnlessModifier: - 'lib/solargraph/yard_map/helpers.rb' - 'lib/solargraph/yard_map/mapper/to_method.rb' -# Offense count: 2 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle. # SupportedStyles: call, braces @@ -2168,7 +2012,6 @@ Style/LambdaCall: Exclude: - 'lib/solargraph/library.rb' -# Offense count: 3 # This cop supports unsafe autocorrection (--autocorrect-all). Style/MapIntoArray: Exclude: @@ -2176,20 +2019,17 @@ Style/MapIntoArray: - 'lib/solargraph/parser/parser_gem/node_chainer.rb' - 'lib/solargraph/type_checker/param_def.rb' -# Offense count: 1 # This cop supports unsafe autocorrection (--autocorrect-all). Style/MapToHash: Exclude: - 'lib/solargraph/bench.rb' -# Offense count: 2 # This cop supports unsafe autocorrection (--autocorrect-all). Style/MapToSet: Exclude: - 'lib/solargraph/library.rb' - 'spec/source_map/clip_spec.rb' -# Offense count: 203 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle. # SupportedStyles: require_parentheses, require_no_parentheses, require_no_parentheses_except_multiline @@ -2256,24 +2096,20 @@ Style/MethodDefParentheses: - 'spec/type_checker/levels/strong_spec.rb' - 'spec/type_checker/levels/typed_spec.rb' -# Offense count: 1 Style/MultilineBlockChain: Exclude: - 'lib/solargraph/pin/search.rb' -# Offense count: 1 # This cop supports safe autocorrection (--autocorrect). Style/MultilineIfModifier: Exclude: - 'lib/solargraph/pin/callable.rb' -# Offense count: 1 # This cop supports safe autocorrection (--autocorrect). Style/MultilineTernaryOperator: Exclude: - 'lib/solargraph/language_server/host.rb' -# Offense count: 20 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowMethodComparison, ComparisonsThreshold. Style/MultipleComparison: @@ -2288,7 +2124,6 @@ Style/MultipleComparison: - 'lib/solargraph/source.rb' - 'lib/solargraph/type_checker.rb' -# Offense count: 17 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: EnforcedStyle. # SupportedStyles: literals, strict @@ -2302,7 +2137,6 @@ Style/MutableConstant: - 'lib/solargraph/yard_map/mapper/to_method.rb' - 'spec/complex_type_spec.rb' -# Offense count: 1 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle. # SupportedStyles: both, prefix, postfix @@ -2310,7 +2144,6 @@ Style/NegatedIf: Exclude: - 'lib/solargraph/language_server/host/diagnoser.rb' -# Offense count: 6 # This cop supports safe autocorrection (--autocorrect). Style/NegatedIfElseCondition: Exclude: @@ -2320,7 +2153,6 @@ Style/NegatedIfElseCondition: - 'lib/solargraph/shell.rb' - 'lib/solargraph/type_checker.rb' -# Offense count: 1 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowedMethods. # AllowedMethods: be, be_a, be_an, be_between, be_falsey, be_kind_of, be_instance_of, be_truthy, be_within, eq, eql, end_with, include, match, raise_error, respond_to, start_with @@ -2328,14 +2160,12 @@ Style/NestedParenthesizedCalls: Exclude: - 'lib/solargraph/type_checker.rb' -# Offense count: 2 # This cop supports safe autocorrection (--autocorrect). Style/NestedTernaryOperator: Exclude: - 'lib/solargraph/pin/conversions.rb' - 'lib/solargraph/pin/method.rb' -# Offense count: 5 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle, MinBodyLength, AllowConsecutiveConditionals. # SupportedStyles: skip_modifier_ifs, always @@ -2346,7 +2176,6 @@ Style/Next: - 'lib/solargraph/source_map/clip.rb' - 'lib/solargraph/type_checker/checks.rb' -# Offense count: 11 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: MinDigits, Strict, AllowedNumbers, AllowedPatterns. Style/NumericLiterals: @@ -2354,7 +2183,6 @@ Style/NumericLiterals: - 'lib/solargraph/language_server/error_codes.rb' - 'spec/language_server/protocol_spec.rb' -# Offense count: 31 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: EnforcedStyle, AllowedMethods, AllowedPatterns. # SupportedStyles: predicate, comparison @@ -2378,12 +2206,10 @@ Style/NumericPredicate: - 'lib/solargraph/source/source_chainer.rb' - 'lib/solargraph/workspace.rb' -# Offense count: 1 Style/OpenStructUse: Exclude: - 'lib/solargraph/page.rb' -# Offense count: 8 # Configuration parameters: AllowedMethods. # AllowedMethods: respond_to_missing? Style/OptionalBooleanParameter: @@ -2396,7 +2222,6 @@ Style/OptionalBooleanParameter: - 'lib/solargraph/source/change.rb' - 'lib/solargraph/source/updater.rb' -# Offense count: 3 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowSafeAssignment, AllowInMultilineConditions. Style/ParenthesesAroundCondition: @@ -2404,7 +2229,6 @@ Style/ParenthesesAroundCondition: - 'lib/solargraph/parser/parser_gem/node_processors/send_node.rb' - 'lib/solargraph/type_checker.rb' -# Offense count: 1 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: EnforcedStyle. # SupportedStyles: short, verbose @@ -2412,21 +2236,18 @@ Style/PreferredHashMethods: Exclude: - 'lib/solargraph/language_server/message.rb' -# Offense count: 1 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: Methods. Style/RedundantArgument: Exclude: - 'lib/solargraph/source_map/mapper.rb' -# Offense count: 2 # This cop supports safe autocorrection (--autocorrect). Style/RedundantAssignment: Exclude: - 'lib/solargraph/language_server/host/dispatch.rb' - 'lib/solargraph/workspace/config.rb' -# Offense count: 8 # This cop supports safe autocorrection (--autocorrect). Style/RedundantBegin: Exclude: @@ -2437,27 +2258,23 @@ Style/RedundantBegin: - 'lib/solargraph/type_checker.rb' - 'lib/solargraph/workspace.rb' -# Offense count: 1 # This cop supports safe autocorrection (--autocorrect). Style/RedundantException: Exclude: - 'spec/language_server/host_spec.rb' -# Offense count: 2 # This cop supports safe autocorrection (--autocorrect). Style/RedundantFreeze: Exclude: - 'lib/solargraph/complex_type.rb' - 'lib/solargraph/source_map/mapper.rb' -# Offense count: 1 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: AutoCorrect, AllowComments. Style/RedundantInitialize: Exclude: - 'lib/solargraph/rbs_map/core_map.rb' -# Offense count: 3 # This cop supports unsafe autocorrection (--autocorrect-all). Style/RedundantInterpolation: Exclude: @@ -2465,7 +2282,6 @@ Style/RedundantInterpolation: - 'lib/solargraph/parser/parser_gem/node_chainer.rb' - 'lib/solargraph/source_map/mapper.rb' -# Offense count: 7 # This cop supports safe autocorrection (--autocorrect). Style/RedundantParentheses: Exclude: @@ -2476,7 +2292,6 @@ Style/RedundantParentheses: - 'lib/solargraph/source.rb' - 'lib/solargraph/type_checker.rb' -# Offense count: 6 # This cop supports safe autocorrection (--autocorrect). Style/RedundantRegexpArgument: Exclude: @@ -2486,7 +2301,6 @@ Style/RedundantRegexpArgument: - 'spec/diagnostics/rubocop_spec.rb' - 'spec/language_server/host_spec.rb' -# Offense count: 18 # This cop supports safe autocorrection (--autocorrect). Style/RedundantRegexpEscape: Exclude: @@ -2497,7 +2311,6 @@ Style/RedundantRegexpEscape: - 'lib/solargraph/source_map/clip.rb' - 'lib/solargraph/source_map/mapper.rb' -# Offense count: 9 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowMultipleReturnValues. Style/RedundantReturn: @@ -2508,7 +2321,6 @@ Style/RedundantReturn: - 'lib/solargraph/parser/parser_gem/node_methods.rb' - 'lib/solargraph/source/chain/z_super.rb' -# Offense count: 19 # This cop supports safe autocorrection (--autocorrect). Style/RedundantSelf: Exclude: @@ -2521,7 +2333,6 @@ Style/RedundantSelf: - 'lib/solargraph/source/chain.rb' - 'lib/solargraph/source/chain/link.rb' -# Offense count: 3 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle, AllowInnerSlashes. # SupportedStyles: slashes, percent_r, mixed @@ -2530,7 +2341,6 @@ Style/RegexpLiteral: - 'lib/solargraph/language_server/uri_helpers.rb' - 'lib/solargraph/workspace/config.rb' -# Offense count: 1 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle. # SupportedStyles: implicit, explicit @@ -2538,7 +2348,6 @@ Style/RescueStandardError: Exclude: - 'lib/solargraph/pin/base.rb' -# Offense count: 17 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: ConvertCodeThatCanStartToReturnNil, AllowedMethods, MaxChainLength. # AllowedMethods: present?, blank?, presence, try, try! @@ -2557,13 +2366,11 @@ Style/SafeNavigation: - 'lib/solargraph/range.rb' - 'lib/solargraph/type_checker.rb' -# Offense count: 1 # Configuration parameters: Max. Style/SafeNavigationChainLength: Exclude: - 'lib/solargraph/doc_map.rb' -# Offense count: 40 # This cop supports unsafe autocorrection (--autocorrect-all). Style/SlicingWithRange: Exclude: @@ -2586,7 +2393,6 @@ Style/SlicingWithRange: - 'lib/solargraph/source_map/mapper.rb' - 'lib/solargraph/type_checker/checks.rb' -# Offense count: 6 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowModifier. Style/SoleNestedConditional: @@ -2598,14 +2404,12 @@ Style/SoleNestedConditional: - 'lib/solargraph/source/source_chainer.rb' - 'lib/solargraph/type_checker.rb' -# Offense count: 8 # This cop supports safe autocorrection (--autocorrect). Style/StderrPuts: Exclude: - 'lib/solargraph/pin/base.rb' - 'lib/solargraph/shell.rb' -# Offense count: 11 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: Mode. Style/StringConcatenation: @@ -2621,7 +2425,6 @@ Style/StringConcatenation: - 'lib/solargraph/pin/namespace.rb' - 'solargraph.gemspec' -# Offense count: 613 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline. # SupportedStyles: single_quotes, double_quotes @@ -2719,7 +2522,6 @@ Style/StringLiterals: - 'spec/workspace_spec.rb' - 'spec/yard_map/mapper/to_method_spec.rb' -# Offense count: 4 # This cop supports safe autocorrection (--autocorrect). Style/SuperArguments: Exclude: @@ -2728,7 +2530,6 @@ Style/SuperArguments: - 'lib/solargraph/pin/method.rb' - 'lib/solargraph/pin/signature.rb' -# Offense count: 44 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle, MinSize. # SupportedStyles: percent, brackets @@ -2750,7 +2551,6 @@ Style/SymbolArray: - 'spec/parser/node_methods_spec.rb' - 'spec/source_map/mapper_spec.rb' -# Offense count: 7 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: AllowMethodsWithArguments, AllowedMethods, AllowedPatterns, AllowComments. # AllowedMethods: define_method @@ -2764,7 +2564,6 @@ Style/SymbolProc: - 'lib/solargraph/pin/callable.rb' - 'lib/solargraph/pin/closure.rb' -# Offense count: 1 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle, AllowSafeAssignment. # SupportedStyles: require_parentheses, require_no_parentheses, require_parentheses_when_complex @@ -2772,7 +2571,6 @@ Style/TernaryParentheses: Exclude: - 'lib/solargraph/source_map/mapper.rb' -# Offense count: 16 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyleForMultiline. # SupportedStylesForMultiline: comma, consistent_comma, no_comma @@ -2791,7 +2589,6 @@ Style/TrailingCommaInArguments: - 'lib/solargraph/yard_map/mapper/to_method.rb' - 'lib/solargraph/yard_map/mapper/to_namespace.rb' -# Offense count: 2 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyleForMultiline. # SupportedStylesForMultiline: comma, consistent_comma, diff_comma, no_comma @@ -2800,7 +2597,6 @@ Style/TrailingCommaInArrayLiteral: - 'lib/solargraph/language_server/message/text_document/formatting.rb' - 'lib/solargraph/rbs_map/core_fills.rb' -# Offense count: 7 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyleForMultiline. # SupportedStylesForMultiline: comma, consistent_comma, diff_comma, no_comma @@ -2814,7 +2610,6 @@ Style/TrailingCommaInHashLiteral: - 'lib/solargraph/pin/parameter.rb' - 'lib/solargraph/rbs_map/conversions.rb' -# Offense count: 2 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: ExactNameMatch, AllowPredicates, AllowDSLWriters, IgnoreClassMethods, AllowedMethods. # AllowedMethods: to_ary, to_a, to_c, to_enum, to_h, to_hash, to_i, to_int, to_io, to_open, to_path, to_proc, to_r, to_regexp, to_str, to_s, to_sym @@ -2823,13 +2618,11 @@ Style/TrivialAccessors: - 'lib/solargraph/language_server/message/extended/check_gem_version.rb' - 'lib/solargraph/pin/keyword.rb' -# Offense count: 1 # This cop supports safe autocorrection (--autocorrect). Style/WhileUntilModifier: Exclude: - 'lib/solargraph/complex_type.rb' -# Offense count: 23 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle, MinSize, WordRegex. # SupportedStyles: percent, brackets @@ -2848,13 +2641,11 @@ Style/WordArray: - 'spec/source_map_spec.rb' - 'spec/source_spec.rb' -# Offense count: 1 # This cop supports safe autocorrection (--autocorrect). Style/YAMLFileRead: Exclude: - 'lib/solargraph/workspace/config.rb' -# Offense count: 7 # This cop supports unsafe autocorrection (--autocorrect-all). Style/ZeroLengthPredicate: Exclude: @@ -2865,7 +2656,6 @@ Style/ZeroLengthPredicate: - 'lib/solargraph/source/chain/array.rb' - 'spec/language_server/protocol_spec.rb' -# Offense count: 1 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle. # SupportedStyles: long, short @@ -2873,7 +2663,6 @@ YARD/CollectionType: Exclude: - 'lib/solargraph/range.rb' -# Offense count: 60 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStylePrototypeName. # SupportedStylesPrototypeName: before, after @@ -2915,14 +2704,12 @@ YARD/MismatchName: - 'lib/solargraph/source/chain/z_super.rb' - 'lib/solargraph/type_checker.rb' -# Offense count: 4 YARD/TagTypeSyntax: Exclude: - 'lib/solargraph/language_server/host.rb' - 'lib/solargraph/parser/comment_ripper.rb' - 'lib/solargraph/type_checker.rb' -# Offense count: 195 # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: Max, AllowHeredoc, AllowURI, AllowQualifiedName, URISchemes, IgnoreCopDirectives, AllowedPatterns, SplitStrings. # URISchemes: http, https From 0eeef79b615f227d9586ee0cc06a57848ff2f2e8 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Mon, 28 Jul 2025 12:36:45 -0400 Subject: [PATCH 185/400] Deal with a potential nil case from CI --- lib/solargraph/workspace/gemspecs.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/solargraph/workspace/gemspecs.rb b/lib/solargraph/workspace/gemspecs.rb index 270b063eb..289a84a1c 100644 --- a/lib/solargraph/workspace/gemspecs.rb +++ b/lib/solargraph/workspace/gemspecs.rb @@ -91,7 +91,7 @@ def resolve_require require # @return [Array] def stdlib_dependencies stdlib_name deps = RbsMap::StdlibMap.stdlib_dependencies(stdlib_name, nil) || [] - deps.map { |dep| dep['name'] } + deps.map { |dep| dep['name'] }.compact end # @param name [String] From 624ffa19b1fd5e0c9ea399fe8da0b7fe2d3663f1 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Mon, 28 Jul 2025 12:56:56 -0400 Subject: [PATCH 186/400] Deal with a potential nil case from CI --- lib/solargraph/doc_map.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/solargraph/doc_map.rb b/lib/solargraph/doc_map.rb index cfa84712f..9d869a180 100644 --- a/lib/solargraph/doc_map.rb +++ b/lib/solargraph/doc_map.rb @@ -121,7 +121,7 @@ def load_serialized_gem_pins out: $stderr # try to resolve the stdlib name deps = workspace.stdlib_dependencies(stdlib_name_guess) || [] - [stdlib_name_guess, *deps].each do |potential_stdlib_name| + [stdlib_name_guess, *deps].compact.each do |potential_stdlib_name| rbs_pins = pin_cache.cache_stdlib_rbs_map potential_stdlib_name @pins.concat rbs_pins if rbs_pins end From 53c83549a7d09817488573c8d139088f754adaa6 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Mon, 28 Jul 2025 14:25:59 -0400 Subject: [PATCH 187/400] Look for external requires before cataloging bench It seems like sync_catalog will go through the motions but not actually load pins from gems here due to passing an empty requires array to ApiMap. I'm sure those requires get pulled in eventually, but we go through at least one catalog cycle without it happening. Found while trying to test a different issue but not being able to get completions from a gem in a spec. --- lib/solargraph/library.rb | 2 +- spec/library_spec.rb | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/lib/solargraph/library.rb b/lib/solargraph/library.rb index 740d700b3..c277c0697 100644 --- a/lib/solargraph/library.rb +++ b/lib/solargraph/library.rb @@ -677,8 +677,8 @@ def sync_catalog mutex.synchronize do logger.info "Cataloging #{workspace.directory.empty? ? 'generic workspace' : workspace.directory}" - api_map.catalog bench source_map_hash.values.each { |map| find_external_requires(map) } + api_map.catalog bench logger.info "Catalog complete (#{api_map.source_maps.length} files, #{api_map.pins.length} pins)" logger.info "#{api_map.uncached_yard_gemspecs.length} uncached YARD gemspecs" logger.info "#{api_map.uncached_rbs_collection_gemspecs.length} uncached RBS collection gemspecs" diff --git a/spec/library_spec.rb b/spec/library_spec.rb index bd7cc25a0..db8382290 100644 --- a/spec/library_spec.rb +++ b/spec/library_spec.rb @@ -26,6 +26,22 @@ expect(completion.pins.map(&:name)).to include('x') end + it "returns a Completion from a gem" do + library = Solargraph::Library.new(Solargraph::Workspace.new(Dir.pwd, + Solargraph::Workspace::Config.new)) + library.attach Solargraph::Source.load_string(%( + require 'backport' + + # @param adapter [Backport::Adapter] + def foo(adapter) + adapter.remo + end + ), 'file.rb', 0) + completion = library.completions_at('file.rb', 5, 19) + expect(completion).to be_a(Solargraph::SourceMap::Completion) + expect(completion.pins.map(&:name)).to include('remote') + end + it "gets definitions from a file" do library = Solargraph::Library.new src = Solargraph::Source.load_string %( From 581cc02321f791e16721305a7036310b71466211 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Mon, 28 Jul 2025 15:03:36 -0400 Subject: [PATCH 188/400] Ensure backport is pre-cached --- spec/library_spec.rb | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/spec/library_spec.rb b/spec/library_spec.rb index db8382290..bea0f2983 100644 --- a/spec/library_spec.rb +++ b/spec/library_spec.rb @@ -26,20 +26,26 @@ expect(completion.pins.map(&:name)).to include('x') end - it "returns a Completion from a gem" do - library = Solargraph::Library.new(Solargraph::Workspace.new(Dir.pwd, - Solargraph::Workspace::Config.new)) - library.attach Solargraph::Source.load_string(%( - require 'backport' + context 'with a require from an already-cached external gem' do + before do + Solargraph::Shell.new.gems('backport') + end - # @param adapter [Backport::Adapter] - def foo(adapter) - adapter.remo - end - ), 'file.rb', 0) - completion = library.completions_at('file.rb', 5, 19) - expect(completion).to be_a(Solargraph::SourceMap::Completion) - expect(completion.pins.map(&:name)).to include('remote') + it "returns a Completion" do + library = Solargraph::Library.new(Solargraph::Workspace.new(Dir.pwd, + Solargraph::Workspace::Config.new)) + library.attach Solargraph::Source.load_string(%( + require 'backport' + + # @param adapter [Backport::Adapter] + def foo(adapter) + adapter.remo + end + ), 'file.rb', 0) + completion = library.completions_at('file.rb', 5, 19) + expect(completion).to be_a(Solargraph::SourceMap::Completion) + expect(completion.pins.map(&:name)).to include('remote') + end end it "gets definitions from a file" do From 200d198024a2685301047b8975c1958c71e8614d Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Mon, 28 Jul 2025 16:15:08 -0400 Subject: [PATCH 189/400] Only cache combined pins in memory --- lib/solargraph/pin_cache.rb | 46 +------------------------------------ 1 file changed, 1 insertion(+), 45 deletions(-) diff --git a/lib/solargraph/pin_cache.rb b/lib/solargraph/pin_cache.rb index 77fa3c500..765eb401a 100644 --- a/lib/solargraph/pin_cache.rb +++ b/lib/solargraph/pin_cache.rb @@ -106,17 +106,9 @@ def cache_combined_pins gemspec, rbs_version_cache_key, yard_pins, rbs_collectio # @param gemspec [Gem::Specification] # @return [Array] def deserialize_combined_pin_cache gemspec - unless combined_pins_in_memory[[gemspec.name, gemspec.version]].nil? - return combined_pins_in_memory[[gemspec.name, gemspec.version]] - end - rbs_version_cache_key = lookup_rbs_version_cache_key(gemspec) - cached = load_combined_gem(gemspec, rbs_version_cache_key) - if cached - logger.info { "Loaded #{cached.length} cached YARD pins from #{gemspec.name}:#{gemspec.version}" } - combined_pins_in_memory[[gemspec.name, gemspec.version]] = cached - end + load_combined_gem(gemspec, rbs_version_cache_key) end # @param gemspec [Gem::Specification] @@ -124,13 +116,8 @@ def deserialize_combined_pin_cache gemspec # @return [void] def uncache_gem gemspec, out: nil PinCache.uncache(yardoc_path(gemspec), out: out) - yard_pins_in_memory.delete([gemspec.name, gemspec.version]) PinCache.uncache(yard_gem_path(gemspec), out: out) - - rbs_version_cache_key = lookup_rbs_version_cache_key(gemspec) uncache_by_prefix(rbs_collection_pins_path_prefix(gemspec), out: out) - rbs_collection_pins_in_memory.delete([gemspec.name, gemspec.version, rbs_version_cache_key]) - uncache_by_prefix(combined_path_prefix(gemspec), out: out) combined_pins_in_memory.delete([gemspec.name, gemspec.version]) end @@ -246,16 +233,6 @@ def cache_yard_pins gemspec, out pins end - # @return [Hash{Array(String, String) => Array}] gemspec name, version - def yard_pins_in_memory - PinCache.all_yard_pins_in_memory[yard_plugins] ||= {} - end - - # @return [Hash{Array(String, String, String) => Array}] gemspec name, version and rbs version cache key - def rbs_collection_pins_in_memory - PinCache.all_rbs_collection_pins_in_memory ||= {} - end - # @return [Hash{Array(String, String, String) => Array}] def combined_pins_in_memory PinCache.all_combined_pins_in_memory[yard_plugins] ||= {} @@ -283,14 +260,8 @@ def cache_rbs_collection_pins gemspec, _out # @param gemspec [Gem::Specification] # @return [Array] def deserialize_yard_pin_cache gemspec - if yard_pins_in_memory.key?([gemspec.name, gemspec.version]) - return yard_pins_in_memory[[gemspec.name, gemspec.version]] - end - cached = load_yard_gem(gemspec) if cached - logger.info { "Loaded #{cached.length} cached YARD pins from #{gemspec.name}:#{gemspec.version}" } - yard_pins_in_memory[[gemspec.name, gemspec.version]] = cached cached else logger.debug "No YARD pin cache for #{gemspec.name}:#{gemspec.version}" @@ -302,7 +273,6 @@ def deserialize_yard_pin_cache gemspec # @param rbs_version_cache_key [String] # @return [Array, nil] def deserialize_rbs_collection_cache gemspec, rbs_version_cache_key - return if rbs_collection_pins_in_memory.key?([gemspec.name, gemspec.version, rbs_version_cache_key]) cached = load_rbs_collection_pins(gemspec, rbs_version_cache_key) if cached unless cached.empty? @@ -310,7 +280,6 @@ def deserialize_rbs_collection_cache gemspec, rbs_version_cache_key "Loaded #{cached.length} pins from RBS collection cache for #{gemspec.name}:#{gemspec.version}" end end - rbs_collection_pins_in_memory[[gemspec.name, gemspec.version, rbs_version_cache_key]] = cached cached else logger.debug "No RBS collection pin cache for #{gemspec.name} #{gemspec.version}" @@ -455,19 +424,6 @@ def uncache_by_prefix *path_segments, out: nil class << self include Logging - # @return [Hash{Array => Hash{Array(String, String) => Array}}] yard - # plugins, then gemspec name and version - def all_yard_pins_in_memory - @all_yard_pins_in_memory ||= {} - end - - # @return [Hash{Array(String, String, String) => - # Array}] gemspec name, version and rbs version - # cache key - def all_rbs_collection_pins_in_memory - @all_rbs_collection_pins_in_memory ||= {} - end - # @return [Hash{Array => Hash{Array(String, String) => # Array}}] yard plugins, then gemspec name and # version From cd1306d3b6c2b9fc8035ee0eb3e118f1a05f6d58 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Mon, 28 Jul 2025 16:15:19 -0400 Subject: [PATCH 190/400] More specs --- spec/library_spec.rb | 13 ++++++++--- spec/pin_cache_spec.rb | 52 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+), 3 deletions(-) create mode 100644 spec/pin_cache_spec.rb diff --git a/spec/library_spec.rb b/spec/library_spec.rb index d51974029..76128fedb 100644 --- a/spec/library_spec.rb +++ b/spec/library_spec.rb @@ -1,5 +1,6 @@ require 'tmpdir' require 'yard' +require 'timeout' describe Solargraph::Library do it "does not open created files in the workspace" do @@ -26,9 +27,9 @@ expect(completion.pins.map(&:name)).to include('x') end - context 'with a require from an already-cached external gem' do + context 'with a require from a not-yet-cached external gem' do before do - Solargraph::Shell.new.gems('backport') + Solargraph::Shell.new.uncache('backport') end it "returns a Completion" do @@ -42,7 +43,13 @@ def foo(adapter) adapter.remo end ), 'file.rb', 0) - completion = library.completions_at('file.rb', 5, 19) + completion = nil + Timeout.timeout(10) do + # give Solargraph time to cache the gem + while (completion = library.completions_at('file.rb', 5, 19)).pins.empty? + sleep 0.25 + end + end expect(completion).to be_a(Solargraph::SourceMap::Completion) expect(completion.pins.map(&:name)).to include('remote') end diff --git a/spec/pin_cache_spec.rb b/spec/pin_cache_spec.rb new file mode 100644 index 000000000..31fba5f40 --- /dev/null +++ b/spec/pin_cache_spec.rb @@ -0,0 +1,52 @@ +# frozen_string_literal: true + +require 'bundler' +require 'benchmark' + +describe Solargraph::PinCache do + subject(:pin_cache) do + described_class.new(rbs_collection_path: '.gem_rbs_collection', + rbs_collection_config_path: 'rbs_collection.yaml', + directory: Dir.pwd, + yard_plugins: []) + end + + describe '#possible_stdlibs' do + it 'is tolerant of less usual Ruby installations' do + stub_const('Gem::RUBYGEMS_DIR', nil) + + expect(pin_cache.possible_stdlibs).to eq([]) + end + end + + describe '#cache_gem' do + context 'with an already in-memory gem' do + let(:backport_gemspec) { Gem::Specification.find_by_name('backport') } + + before do + pin_cache.cache_gem(gemspec: backport_gemspec, out: nil) + end + + it 'does not load the gem again' do + allow(Marshal).to receive(:load).and_call_original + + pin_cache.cache_gem(gemspec: backport_gemspec, out: nil) + + expect(Marshal).not_to have_received(:load).with(anything) + end + end + + context 'with the parser gem' do + before do + Solargraph::Shell.new.uncache('parser') + allow(Solargraph::Yardoc).to receive(:build_docs) + end + + it 'chooses not to use YARD' do + parser_gemspec = Gem::Specification.find_by_name('parser') + pin_cache.cache_gem(gemspec: parser_gemspec, out: nil) + expect(Solargraph::Yardoc).not_to have_received(:build_docs) + end + end + end +end From d730fad7b2991c117edfd2ea73bb676055aa427c Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Mon, 28 Jul 2025 17:26:56 -0400 Subject: [PATCH 191/400] Revert accidental formatting change --- lib/solargraph/library.rb | 2 +- lib/solargraph/pin_cache.rb | 28 +++++++++++----------------- 2 files changed, 12 insertions(+), 18 deletions(-) diff --git a/lib/solargraph/library.rb b/lib/solargraph/library.rb index 79d683262..688adef5f 100644 --- a/lib/solargraph/library.rb +++ b/lib/solargraph/library.rb @@ -655,7 +655,7 @@ def report_cache_progress gem_name, pending @total = pending if pending > @total finished = @total - pending pct = if @total.zero? - 0 + 0 else ((finished.to_f / @total.to_f) * 100).to_i end diff --git a/lib/solargraph/pin_cache.rb b/lib/solargraph/pin_cache.rb index 765eb401a..ed9e6b39f 100644 --- a/lib/solargraph/pin_cache.rb +++ b/lib/solargraph/pin_cache.rb @@ -271,20 +271,14 @@ def deserialize_yard_pin_cache gemspec # @param gemspec [Gem::Specification, Bundler::LazySpecification] # @param rbs_version_cache_key [String] - # @return [Array, nil] + # @return [Array] def deserialize_rbs_collection_cache gemspec, rbs_version_cache_key cached = load_rbs_collection_pins(gemspec, rbs_version_cache_key) - if cached - unless cached.empty? - logger.info do - "Loaded #{cached.length} pins from RBS collection cache for #{gemspec.name}:#{gemspec.version}" - end - end - cached - else - logger.debug "No RBS collection pin cache for #{gemspec.name} #{gemspec.version}" - nil + Solargraph.assert_or_log(:pin_cache_rbs_collection, 'Asked for non-existent rbs collection') if cached.nil? + logger.info do + "Loaded #{cached&.length} pins from RBS collection cache for #{gemspec.name}:#{gemspec.version}" end + cached end # @return [Array] @@ -308,7 +302,7 @@ def yard_gem_path gemspec end # @param gemspec [Gem::Specification] - # @return [Array] + # @return [Array, nil] def load_yard_gem gemspec PinCache.load(yard_gem_path(gemspec)) end @@ -348,14 +342,14 @@ def rbs_collection_pins_path_prefix gemspec # @param gemspec [Gem::Specification, Bundler::LazySpecification] # @param hash [String] # - # @return [Array] + # @return [Array, nil] def load_rbs_collection_pins gemspec, hash PinCache.load(rbs_collection_pins_path(gemspec, hash)) end # @param gemspec [Gem::Specification] # @param hash [String, nil] - # @param pins [Array]n + # @param pins [Array] # @return [void] def serialize_rbs_collection_pins gemspec, hash, pins PinCache.save(rbs_collection_pins_path(gemspec, hash), pins) @@ -390,7 +384,7 @@ def combined_gem? gemspec, hash # @param gemspec [Gem::Specification] # @param hash [String, nil] - # @return [Array] + # @return [Array, nil] def load_combined_gem gemspec, hash PinCache.load(combined_path(gemspec, hash)) end @@ -519,7 +513,7 @@ def cache_core out: $stderr RbsMap::CoreMap.new.cache_core(out: out) end - # @return [Array] + # @return [Array, nil] def load_core load(core_path) end @@ -542,7 +536,7 @@ def stdlib_require_path require end # @param require [String] - # @return [Array] + # @return [Array, nil] def load_stdlib_require require load(stdlib_require_path(require)) end From 0deb8cffd42c6a25fe3ba58ebe6e069fa7570732 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Mon, 28 Jul 2025 17:35:23 -0400 Subject: [PATCH 192/400] Drop unused method --- lib/solargraph/pin_cache.rb | 6 ------ 1 file changed, 6 deletions(-) diff --git a/lib/solargraph/pin_cache.rb b/lib/solargraph/pin_cache.rb index ed9e6b39f..2b3d73f88 100644 --- a/lib/solargraph/pin_cache.rb +++ b/lib/solargraph/pin_cache.rb @@ -320,12 +320,6 @@ def yard_gem? gemspec exist?(yard_gem_path(gemspec)) end - # @param gemspec [Gem::Specification] - # @return [Boolean] - def yardoc? gemspec - exist?(yardoc_path(gemspec)) - end - # @param gemspec [Gem::Specification] # @param hash [String, nil] # @return [String] From a812069ffd231cfed16fb92c5fa51f3ea1828455 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Mon, 28 Jul 2025 18:54:21 -0400 Subject: [PATCH 193/400] Add RBS collection types during tests --- .github/workflows/rspec.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/rspec.yml b/.github/workflows/rspec.yml index 8d1043503..5bf5e9775 100644 --- a/.github/workflows/rspec.yml +++ b/.github/workflows/rspec.yml @@ -34,6 +34,8 @@ jobs: run: | bundle install bundle update rbs # use latest available for this Ruby version + - name: Install types + run: bundle exec rbs collection update - name: Run tests run: bundle exec rspec undercover: @@ -51,6 +53,8 @@ jobs: bundler-cache: false - name: Install gems run: bundle install + - name: Install types + run: bundle exec rbs collection update - name: Run tests run: bundle exec rspec - name: Check PR coverage From 09958f47d9f0d48634b4fa0443e2b5d9d26cc701 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Mon, 28 Jul 2025 19:24:28 -0400 Subject: [PATCH 194/400] More specs --- spec/pin_cache_spec.rb | 37 +++++++++++++++++++++++++++++++++++++ spec/rbs_map_spec.rb | 8 +++++++- 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/spec/pin_cache_spec.rb b/spec/pin_cache_spec.rb index 31fba5f40..bb98af6be 100644 --- a/spec/pin_cache_spec.rb +++ b/spec/pin_cache_spec.rb @@ -45,8 +45,45 @@ it 'chooses not to use YARD' do parser_gemspec = Gem::Specification.find_by_name('parser') pin_cache.cache_gem(gemspec: parser_gemspec, out: nil) + # if this fails, you may not have run `bundle exec rbs collection update` expect(Solargraph::Yardoc).not_to have_received(:build_docs) end end + + context 'with a stdlib gem' do + let(:gem_name) { 'cgi' } + + before do + Solargraph::Shell.new.uncache(gem_name) + end + + it 'caches' do + yaml_gemspec = Gem::Specification.find_by_name(gem_name) + allow(File).to receive(:write).and_call_original + + pin_cache.cache_gem(gemspec: yaml_gemspec, out: nil) + + # match arguments with regexp using rspec-matchers syntax + expect(File).to have_received(:write).with(%r{combined/cgi-.*-stdlib.ser$}, any_args).once + end + end + + context 'with a gem packaged with its own RBS' do + let(:gem_name) { 'base64' } + + before do + Solargraph::Shell.new.uncache(gem_name) + end + + it 'caches' do + yaml_gemspec = Gem::Specification.find_by_name(gem_name) + allow(File).to receive(:write).and_call_original + + pin_cache.cache_gem(gemspec: yaml_gemspec, out: nil) + + # match arguments with regexp using rspec-matchers syntax + expect(File).to have_received(:write).with(%r{combined/base64-.*-export.ser$}, any_args).once + end + end end end diff --git a/spec/rbs_map_spec.rb b/spec/rbs_map_spec.rb index b06c975d1..a18c5d5b5 100644 --- a/spec/rbs_map_spec.rb +++ b/spec/rbs_map_spec.rb @@ -3,7 +3,13 @@ spec = Gem::Specification.find_by_name('rbs') rbs_map = Solargraph::RbsMap.from_gemspec(spec, nil, nil) pin = rbs_map.path_pin('RBS::EnvironmentLoader#add_collection') - expect(pin).to be + expect(pin).not_to be_nil + end + + it 'fails if it does not find data' do + spec = Gem::Specification.find_by_name('backport') + rbs_map = Solargraph::RbsMap.from_gemspec(spec, nil, nil) + expect(rbs_map.pins).to be_empty end it 'converts constants and aliases to correct types' do From df609a612f8f775c8892d0ce2cfde238395128b9 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Mon, 28 Jul 2025 19:32:48 -0400 Subject: [PATCH 195/400] Revert double quote changes for another PR --- lib/solargraph/shell.rb | 106 ++++++++++++++++++++-------------------- 1 file changed, 53 insertions(+), 53 deletions(-) diff --git a/lib/solargraph/shell.rb b/lib/solargraph/shell.rb index f8b98359a..c40a0894e 100755 --- a/lib/solargraph/shell.rb +++ b/lib/solargraph/shell.rb @@ -1,9 +1,9 @@ # frozen_string_literal: true -require 'benchmark' -require 'thor' -require 'yard' -require 'yaml' +require "benchmark" +require "thor" +require "yard" +require "yaml" module Solargraph class Shell < Thor @@ -16,25 +16,25 @@ def self.exit_on_failure? map %w[--version -v] => :version - desc '--version, -v', 'Print the version' + desc "--version, -v", "Print the version" # @return [void] def version puts Solargraph::VERSION end - desc 'socket', 'Run a Solargraph socket server' - option :host, type: :string, aliases: :h, desc: 'The server host', default: '127.0.0.1' - option :port, type: :numeric, aliases: :p, desc: 'The server port', default: 7658 + desc "socket", "Run a Solargraph socket server" + option :host, type: :string, aliases: :h, desc: "The server host", default: "127.0.0.1" + option :port, type: :numeric, aliases: :p, desc: "The server port", default: 7658 # @return [void] def socket - require 'backport' + require "backport" port = options[:port] port = available_port if port.zero? Backport.run do - Signal.trap('INT') do + Signal.trap("INT") do Backport.stop end - Signal.trap('TERM') do + Signal.trap("TERM") do Backport.stop end # @sg-ignore https://github.com/castwide/backport/pull/5 @@ -43,15 +43,15 @@ def socket end end - desc 'stdio', 'Run a Solargraph stdio server' + desc "stdio", "Run a Solargraph stdio server" # @return [void] def stdio - require 'backport' + require "backport" Backport.run do - Signal.trap('INT') do + Signal.trap("INT") do Backport.stop end - Signal.trap('TERM') do + Signal.trap("TERM") do Backport.stop end # @sg-ignore https://github.com/castwide/backport/pull/5 @@ -60,11 +60,11 @@ def stdio end end - desc 'config [DIRECTORY]', 'Create or overwrite a default configuration file' - option :extensions, type: :boolean, aliases: :e, desc: 'Add installed extensions', default: true + desc "config [DIRECTORY]", "Create or overwrite a default configuration file" + option :extensions, type: :boolean, aliases: :e, desc: "Add installed extensions", default: true # @param directory [String] # @return [void] - def config directory = '.' + def config directory = "." matches = [] if options[:extensions] # @sg-ignore @@ -78,84 +78,84 @@ def config directory = '.' conf = Solargraph::Workspace::Config.new.raw_data unless matches.empty? matches.each do |m| - conf['extensions'].push m + conf["extensions"].push m end end - File.open(File.join(directory, '.solargraph.yml'), 'w') do |file| + File.open(File.join(directory, ".solargraph.yml"), "w") do |file| file.puts conf.to_yaml end - STDOUT.puts 'Configuration file initialized.' + STDOUT.puts "Configuration file initialized." end - desc 'clear', 'Delete all cached documentation' + desc "clear", "Delete all cached documentation" long_desc %( This command will delete all core and gem documentation from the cache. ) # @return [void] def clear - puts 'Deleting all cached documentation (gems, core and stdlib)' + puts "Deleting all cached documentation (gems, core and stdlib)" Solargraph::PinCache.clear end - map 'clear-cache' => :clear - map 'clear-cores' => :clear + map "clear-cache" => :clear + map "clear-cores" => :clear - desc 'cache', 'Cache a gem', hide: true - option :rebuild, type: :boolean, desc: 'Rebuild existing documentation', default: false + desc "cache", "Cache a gem", hide: true + option :rebuild, type: :boolean, desc: "Rebuild existing documentation", default: false # @return [void] # @param gem [String] # @param version [String, nil] def cache gem, version = nil - gems(gem + (version ? "=#{version}" : '')) + gems(gem + (version ? "=#{version}" : "")) # " end - desc 'gems [GEM[=VERSION]]', 'Cache documentation for installed gems' - option :rebuild, type: :boolean, desc: 'Rebuild existing documentation', default: false + desc "gems [GEM[=VERSION]]", "Cache documentation for installed gems" + option :rebuild, type: :boolean, desc: "Rebuild existing documentation", default: false # @param names [Array] # @return [void] def gems *names - api_map = ApiMap.load('.') + api_map = ApiMap.load(".") if names.empty? api_map.cache_all_for_workspace!($stdout, rebuild: options[:rebuild]) else $stderr.puts("Caching these gems: #{names}") names.each do |name| - if name == 'core' + if name == "core" PinCache.cache_core(out: $stdout) next end - gemspec = api_map.find_gem(*name.split('=')) + gemspec = api_map.find_gem(*name.split("=")) if gemspec.nil? - warn "Gem '#{name}' not found" + warn "Gem "#{name}" not found" else api_map.cache_gem(gemspec, rebuild: options[:rebuild], out: $stdout) end rescue Gem::MissingSpecError - warn "Gem '#{name}' not found" + warn "Gem "#{name}" not found" end $stderr.puts "Documentation cached for #{names.count} gems." end end - desc 'uncache GEM [...GEM]', 'Delete specific cached gem documentation' + desc "uncache GEM [...GEM]", "Delete specific cached gem documentation" long_desc %( - Specify one or more gem names to clear. 'core' or 'stdlib' may + Specify one or more gem names to clear. "core" or "stdlib" may also be specified to clear cached system documentation. Documentation will be regenerated as needed. ) # @param gems [Array] # @return [void] def uncache *gems - raise ArgumentError, 'No gems specified.' if gems.empty? - workspace = Workspace.new('.') + raise ArgumentError, "No gems specified." if gems.empty? + workspace = Workspace.new(".") gems.each do |gem| - if gem == 'core' + if gem == "core" PinCache.uncache_core(out: $stdout) next end - if gem == 'stdlib' + if gem == "stdlib" PinCache.uncache_stdlib(out: $stdout) next end @@ -165,21 +165,21 @@ def uncache *gems end end - desc 'reporters', 'Get a list of diagnostics reporters' + desc "reporters", "Get a list of diagnostics reporters" # @return [void] def reporters puts Solargraph::Diagnostics.reporters end - desc 'typecheck [FILE(s)]', 'Run the type checker' + desc "typecheck [FILE(s)]", "Run the type checker" long_desc %( Perform type checking on one or more files in a workspace. Check the entire workspace if no files are specified. Type checking levels are normal, typed, strict, and strong. ) - option :level, type: :string, aliases: [:mode, :m, :l], desc: 'Type checking level', default: 'normal' - option :directory, type: :string, aliases: :d, desc: 'The workspace directory', default: '.' + option :level, type: :string, aliases: [:mode, :m, :l], desc: "Type checking level", default: "normal" + option :directory, type: :string, aliases: :d, desc: "The workspace directory", default: "." # @return [void] def typecheck *files directory = File.realpath(options[:directory]) @@ -207,20 +207,20 @@ def typecheck *files # " } puts "Typecheck finished in #{time.real} seconds." - puts "#{probcount} problem#{probcount != 1 ? 's' : ''} found#{files.length != 1 ? " in #{filecount} of #{files.length} files" : ''}." + puts "#{probcount} problem#{probcount != 1 ? "s" : ""} found#{files.length != 1 ? " in #{filecount} of #{files.length} files" : ""}." # " exit 1 if probcount > 0 end - desc 'scan', 'Test the workspace for problems' + desc "scan", "Test the workspace for problems" long_desc %( A scan loads the entire workspace to make sure that the ASTs and maps do not raise errors during analysis. It does not perform any type checking or validation; it only confirms that the analysis itself is error-free. ) - option :directory, type: :string, aliases: :d, desc: 'The workspace directory', default: '.' - option :verbose, type: :boolean, aliases: :v, desc: 'Verbose output', default: false + option :directory, type: :string, aliases: :d, desc: "The workspace directory", default: "." + option :verbose, type: :boolean, aliases: :v, desc: "Verbose output", default: false # @return [void] def scan directory = File.realpath(options[:directory]) @@ -234,7 +234,7 @@ def scan pin.typify api_map pin.probe api_map rescue StandardError => e - STDERR.puts "Error testing #{pin_description(pin)} #{pin.location ? "at #{pin.location.filename}:#{pin.location.range.start.line + 1}" : ''}" + STDERR.puts "Error testing #{pin_description(pin)} #{pin.location ? "at #{pin.location.filename}:#{pin.location.range.start.line + 1}" : ""}" STDERR.puts "[#{e.class}]: #{e.message}" STDERR.puts e.backtrace.join("\n") exit 1 @@ -244,9 +244,9 @@ def scan puts "Scanned #{directory} (#{api_map.pins.length} pins) in #{time.real} seconds." end - desc 'list', 'List the files in the workspace and the total count' - option :count, type: :boolean, aliases: :c, desc: 'Display the file count only', default: false - option :directory, type: :string, aliases: :d, desc: 'The directory to read', default: '.' + desc "list", "List the files in the workspace and the total count" + option :count, type: :boolean, aliases: :c, desc: "Display the file count only", default: false + option :directory, type: :string, aliases: :d, desc: "The directory to read", default: "." # @return [void] def list workspace = Solargraph::Workspace.new(options[:directory]) From cda38edb8dcd9d7ebd114d404dcaf9359b73e430 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Mon, 28 Jul 2025 19:35:20 -0400 Subject: [PATCH 196/400] Revert double quote changes for another PR --- lib/solargraph/shell.rb | 126 ++++++++++++++++++++-------------------- 1 file changed, 63 insertions(+), 63 deletions(-) diff --git a/lib/solargraph/shell.rb b/lib/solargraph/shell.rb index c40a0894e..047ec175f 100755 --- a/lib/solargraph/shell.rb +++ b/lib/solargraph/shell.rb @@ -22,12 +22,12 @@ def version puts Solargraph::VERSION end - desc "socket", "Run a Solargraph socket server" - option :host, type: :string, aliases: :h, desc: "The server host", default: "127.0.0.1" - option :port, type: :numeric, aliases: :p, desc: "The server port", default: 7658 + desc 'socket', 'Run a Solargraph socket server' + option :host, type: :string, aliases: :h, desc: 'The server host', default: '127.0.0.1' + option :port, type: :numeric, aliases: :p, desc: 'The server port', default: 7658 # @return [void] def socket - require "backport" + require 'backport' port = options[:port] port = available_port if port.zero? Backport.run do @@ -39,32 +39,32 @@ def socket end # @sg-ignore https://github.com/castwide/backport/pull/5 Backport.prepare_tcp_server host: options[:host], port: port, adapter: Solargraph::LanguageServer::Transport::Adapter - STDERR.puts "Solargraph is listening PORT=#{port} PID=#{Process.pid}" + STDERR.puts 'Solargraph is listening PORT=#{port} PID=#{Process.pid}' end end - desc "stdio", "Run a Solargraph stdio server" + desc 'stdio', 'Run a Solargraph stdio server' # @return [void] def stdio - require "backport" + require 'backport' Backport.run do - Signal.trap("INT") do + Signal.trap('INT') do Backport.stop end - Signal.trap("TERM") do + Signal.trap('TERM') do Backport.stop end # @sg-ignore https://github.com/castwide/backport/pull/5 Backport.prepare_stdio_server adapter: Solargraph::LanguageServer::Transport::Adapter - STDERR.puts "Solargraph is listening on stdio PID=#{Process.pid}" + STDERR.puts 'Solargraph is listening on stdio PID=#{Process.pid}' end end - desc "config [DIRECTORY]", "Create or overwrite a default configuration file" - option :extensions, type: :boolean, aliases: :e, desc: "Add installed extensions", default: true + desc 'config [DIRECTORY]', 'Create or overwrite a default configuration file' + option :extensions, type: :boolean, aliases: :e, desc: 'Add installed extensions', default: true # @param directory [String] # @return [void] - def config directory = "." + def config directory = '.' matches = [] if options[:extensions] # @sg-ignore @@ -78,84 +78,84 @@ def config directory = "." conf = Solargraph::Workspace::Config.new.raw_data unless matches.empty? matches.each do |m| - conf["extensions"].push m + conf['extensions'].push m end end - File.open(File.join(directory, ".solargraph.yml"), "w") do |file| + File.open(File.join(directory, '.solargraph.yml'), 'w') do |file| file.puts conf.to_yaml end - STDOUT.puts "Configuration file initialized." + STDOUT.puts 'Configuration file initialized.' end - desc "clear", "Delete all cached documentation" + desc 'clear', 'Delete all cached documentation' long_desc %( This command will delete all core and gem documentation from the cache. ) # @return [void] def clear - puts "Deleting all cached documentation (gems, core and stdlib)" + puts 'Deleting all cached documentation (gems, core and stdlib)' Solargraph::PinCache.clear end - map "clear-cache" => :clear - map "clear-cores" => :clear + map 'clear-cache' => :clear + map 'clear-cores' => :clear - desc "cache", "Cache a gem", hide: true - option :rebuild, type: :boolean, desc: "Rebuild existing documentation", default: false + desc 'cache', 'Cache a gem', hide: true + option :rebuild, type: :boolean, desc: 'Rebuild existing documentation', default: false # @return [void] # @param gem [String] # @param version [String, nil] def cache gem, version = nil - gems(gem + (version ? "=#{version}" : "")) - # " + gems(gem + (version ? '=#{version}' : '')) + # ' end - desc "gems [GEM[=VERSION]]", "Cache documentation for installed gems" - option :rebuild, type: :boolean, desc: "Rebuild existing documentation", default: false + desc 'gems [GEM[=VERSION]]', 'Cache documentation for installed gems' + option :rebuild, type: :boolean, desc: 'Rebuild existing documentation', default: false # @param names [Array] # @return [void] def gems *names - api_map = ApiMap.load(".") + api_map = ApiMap.load('.') if names.empty? api_map.cache_all_for_workspace!($stdout, rebuild: options[:rebuild]) else - $stderr.puts("Caching these gems: #{names}") + $stderr.puts('Caching these gems: #{names}') names.each do |name| - if name == "core" + if name == 'core' PinCache.cache_core(out: $stdout) next end - gemspec = api_map.find_gem(*name.split("=")) + gemspec = api_map.find_gem(*name.split('=')) if gemspec.nil? - warn "Gem "#{name}" not found" + warn 'Gem '#{name}' not found' else api_map.cache_gem(gemspec, rebuild: options[:rebuild], out: $stdout) end rescue Gem::MissingSpecError - warn "Gem "#{name}" not found" + warn 'Gem '#{name}' not found' end - $stderr.puts "Documentation cached for #{names.count} gems." + $stderr.puts 'Documentation cached for #{names.count} gems.' end end - desc "uncache GEM [...GEM]", "Delete specific cached gem documentation" + desc 'uncache GEM [...GEM]', 'Delete specific cached gem documentation' long_desc %( - Specify one or more gem names to clear. "core" or "stdlib" may + Specify one or more gem names to clear. 'core' or 'stdlib' may also be specified to clear cached system documentation. Documentation will be regenerated as needed. ) # @param gems [Array] # @return [void] def uncache *gems - raise ArgumentError, "No gems specified." if gems.empty? - workspace = Workspace.new(".") + raise ArgumentError, 'No gems specified.' if gems.empty? + workspace = Workspace.new('.') gems.each do |gem| - if gem == "core" + if gem == 'core' PinCache.uncache_core(out: $stdout) next end - if gem == "stdlib" + if gem == 'stdlib' PinCache.uncache_stdlib(out: $stdout) next end @@ -165,21 +165,21 @@ def uncache *gems end end - desc "reporters", "Get a list of diagnostics reporters" + desc 'reporters', 'Get a list of diagnostics reporters' # @return [void] def reporters puts Solargraph::Diagnostics.reporters end - desc "typecheck [FILE(s)]", "Run the type checker" + desc 'typecheck [FILE(s)]', 'Run the type checker' long_desc %( Perform type checking on one or more files in a workspace. Check the entire workspace if no files are specified. Type checking levels are normal, typed, strict, and strong. ) - option :level, type: :string, aliases: [:mode, :m, :l], desc: "Type checking level", default: "normal" - option :directory, type: :string, aliases: :d, desc: "The workspace directory", default: "." + option :level, type: :string, aliases: [:mode, :m, :l], desc: 'Type checking level', default: 'normal' + option :directory, type: :string, aliases: :d, desc: 'The workspace directory', default: '.' # @return [void] def typecheck *files directory = File.realpath(options[:directory]) @@ -199,28 +199,28 @@ def typecheck *files next if problems.empty? problems.sort! { |a, b| a.location.range.start.line <=> b.location.range.start.line } puts problems.map { |prob| - "#{prob.location.filename}:#{prob.location.range.start.line + 1} - #{prob.message}" - }.join("\n") + '#{prob.location.filename}:#{prob.location.range.start.line + 1} - #{prob.message}' + }.join('\n') filecount += 1 probcount += problems.length end - # " + # ' } - puts "Typecheck finished in #{time.real} seconds." - puts "#{probcount} problem#{probcount != 1 ? "s" : ""} found#{files.length != 1 ? " in #{filecount} of #{files.length} files" : ""}." - # " + puts 'Typecheck finished in #{time.real} seconds.' + puts '#{probcount} problem#{probcount != 1 ? 's' : ''} found#{files.length != 1 ? ' in #{filecount} of #{files.length} files' : ''}.' + # ' exit 1 if probcount > 0 end - desc "scan", "Test the workspace for problems" + desc 'scan', 'Test the workspace for problems' long_desc %( A scan loads the entire workspace to make sure that the ASTs and maps do not raise errors during analysis. It does not perform any type checking or validation; it only confirms that the analysis itself is error-free. ) - option :directory, type: :string, aliases: :d, desc: "The workspace directory", default: "." - option :verbose, type: :boolean, aliases: :v, desc: "Verbose output", default: false + option :directory, type: :string, aliases: :d, desc: 'The workspace directory', default: '.' + option :verbose, type: :boolean, aliases: :v, desc: 'Verbose output', default: false # @return [void] def scan directory = File.realpath(options[:directory]) @@ -234,24 +234,24 @@ def scan pin.typify api_map pin.probe api_map rescue StandardError => e - STDERR.puts "Error testing #{pin_description(pin)} #{pin.location ? "at #{pin.location.filename}:#{pin.location.range.start.line + 1}" : ""}" - STDERR.puts "[#{e.class}]: #{e.message}" - STDERR.puts e.backtrace.join("\n") + STDERR.puts 'Error testing #{pin_description(pin)} #{pin.location ? 'at #{pin.location.filename}:#{pin.location.range.start.line + 1}' : ''}' + STDERR.puts '[#{e.class}]: #{e.message}' + STDERR.puts e.backtrace.join('\n') exit 1 end end } - puts "Scanned #{directory} (#{api_map.pins.length} pins) in #{time.real} seconds." + puts 'Scanned #{directory} (#{api_map.pins.length} pins) in #{time.real} seconds.' end - desc "list", "List the files in the workspace and the total count" - option :count, type: :boolean, aliases: :c, desc: "Display the file count only", default: false - option :directory, type: :string, aliases: :d, desc: "The directory to read", default: "." + desc 'list', 'List the files in the workspace and the total count' + option :count, type: :boolean, aliases: :c, desc: 'Display the file count only', default: false + option :directory, type: :string, aliases: :d, desc: 'The directory to read', default: '.' # @return [void] def list workspace = Solargraph::Workspace.new(options[:directory]) puts workspace.filenames unless options[:count] - puts "#{workspace.filenames.length} files total." + puts '#{workspace.filenames.length} files total.' end private @@ -261,14 +261,14 @@ def list def pin_description pin desc = if pin.path.nil? || pin.path.empty? if pin.closure - "#{pin.closure.path} | #{pin.name}" + '#{pin.closure.path} | #{pin.name}' else - "#{pin.context.namespace} | #{pin.name}" + '#{pin.context.namespace} | #{pin.name}' end else pin.path end - desc += " (#{pin.location.filename} #{pin.location.range.start.line})" if pin.location + desc += ' (#{pin.location.filename} #{pin.location.range.start.line})' if pin.location desc end From da927a6f00a0b4cd8c5895d540811cee7cf26d08 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Mon, 28 Jul 2025 19:36:54 -0400 Subject: [PATCH 197/400] Revert double quote changes for another PR --- lib/solargraph/shell.rb | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/solargraph/shell.rb b/lib/solargraph/shell.rb index 047ec175f..4bc88b2df 100755 --- a/lib/solargraph/shell.rb +++ b/lib/solargraph/shell.rb @@ -1,9 +1,9 @@ # frozen_string_literal: true -require "benchmark" -require "thor" -require "yard" -require "yaml" +require 'benchmark' +require 'thor' +require 'yard' +require 'yaml' module Solargraph class Shell < Thor @@ -16,7 +16,7 @@ def self.exit_on_failure? map %w[--version -v] => :version - desc "--version, -v", "Print the version" + desc '--version, -v', 'Print the version' # @return [void] def version puts Solargraph::VERSION @@ -39,7 +39,7 @@ def socket end # @sg-ignore https://github.com/castwide/backport/pull/5 Backport.prepare_tcp_server host: options[:host], port: port, adapter: Solargraph::LanguageServer::Transport::Adapter - STDERR.puts 'Solargraph is listening PORT=#{port} PID=#{Process.pid}' + STDERR.puts "Solargraph is listening PORT=#{port} PID=#{Process.pid}" end end @@ -64,7 +64,7 @@ def stdio option :extensions, type: :boolean, aliases: :e, desc: 'Add installed extensions', default: true # @param directory [String] # @return [void] - def config directory = '.' + def config(directory = '.') matches = [] if options[:extensions] # @sg-ignore @@ -93,7 +93,7 @@ def config directory = '.' ) # @return [void] def clear - puts 'Deleting all cached documentation (gems, core and stdlib)' + puts "Deleting all cached documentation (gems, core and stdlib)" Solargraph::PinCache.clear end map 'clear-cache' => :clear From c8aa61f5f89d77d9fa5e4ab8dd2042eb340976e8 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Mon, 28 Jul 2025 19:37:57 -0400 Subject: [PATCH 198/400] Revert double quote changes for another PR --- lib/solargraph/shell.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/solargraph/shell.rb b/lib/solargraph/shell.rb index 4bc88b2df..ff44018d4 100755 --- a/lib/solargraph/shell.rb +++ b/lib/solargraph/shell.rb @@ -207,7 +207,7 @@ def typecheck *files # ' } puts 'Typecheck finished in #{time.real} seconds.' - puts '#{probcount} problem#{probcount != 1 ? 's' : ''} found#{files.length != 1 ? ' in #{filecount} of #{files.length} files' : ''}.' + puts "{probcount} problem#{probcount != 1 ? 's' : ''} found#{files.length != 1 ? ' in #{filecount} of #{files.length} files' : ''}." # ' exit 1 if probcount > 0 end @@ -234,7 +234,7 @@ def scan pin.typify api_map pin.probe api_map rescue StandardError => e - STDERR.puts 'Error testing #{pin_description(pin)} #{pin.location ? 'at #{pin.location.filename}:#{pin.location.range.start.line + 1}' : ''}' + STDERR.puts "Error testing #{pin_description(pin)} #{pin.location ? 'at #{pin.location.filename}:#{pin.location.range.start.line + 1}' : ''}" STDERR.puts '[#{e.class}]: #{e.message}' STDERR.puts e.backtrace.join('\n') exit 1 From e1665fe034c920faa19a3cbfdd906357f0568e39 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Mon, 28 Jul 2025 19:38:36 -0400 Subject: [PATCH 199/400] Revert double quote changes for another PR --- lib/solargraph/shell.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/solargraph/shell.rb b/lib/solargraph/shell.rb index ff44018d4..8a3522c38 100755 --- a/lib/solargraph/shell.rb +++ b/lib/solargraph/shell.rb @@ -127,12 +127,12 @@ def gems *names gemspec = api_map.find_gem(*name.split('=')) if gemspec.nil? - warn 'Gem '#{name}' not found' + warn "Gem '#{name}' not found" else api_map.cache_gem(gemspec, rebuild: options[:rebuild], out: $stdout) end rescue Gem::MissingSpecError - warn 'Gem '#{name}' not found' + warn "Gem '#{name}' not found" end $stderr.puts 'Documentation cached for #{names.count} gems.' end From edcfc698f88c074d1cf981f7819b5c8ee811c9a7 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Mon, 28 Jul 2025 19:42:47 -0400 Subject: [PATCH 200/400] Revert double quote changes for another PR --- lib/solargraph/shell.rb | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/solargraph/shell.rb b/lib/solargraph/shell.rb index 8a3522c38..15a4e4361 100755 --- a/lib/solargraph/shell.rb +++ b/lib/solargraph/shell.rb @@ -56,7 +56,7 @@ def stdio end # @sg-ignore https://github.com/castwide/backport/pull/5 Backport.prepare_stdio_server adapter: Solargraph::LanguageServer::Transport::Adapter - STDERR.puts 'Solargraph is listening on stdio PID=#{Process.pid}' + STDERR.puts "Solargraph is listening on stdio PID=#{Process.pid}" end end @@ -105,7 +105,7 @@ def clear # @param gem [String] # @param version [String, nil] def cache gem, version = nil - gems(gem + (version ? '=#{version}' : '')) + gems(gem + (version ? "=#{version}" : '')) # ' end @@ -118,7 +118,7 @@ def gems *names if names.empty? api_map.cache_all_for_workspace!($stdout, rebuild: options[:rebuild]) else - $stderr.puts('Caching these gems: #{names}') + $stderr.puts("Caching these gems: #{names}") names.each do |name| if name == 'core' PinCache.cache_core(out: $stdout) @@ -134,7 +134,7 @@ def gems *names rescue Gem::MissingSpecError warn "Gem '#{name}' not found" end - $stderr.puts 'Documentation cached for #{names.count} gems.' + $stderr.puts "Documentation cached for #{names.count} gems." end end @@ -199,15 +199,15 @@ def typecheck *files next if problems.empty? problems.sort! { |a, b| a.location.range.start.line <=> b.location.range.start.line } puts problems.map { |prob| - '#{prob.location.filename}:#{prob.location.range.start.line + 1} - #{prob.message}' + "#{prob.location.filename}:#{prob.location.range.start.line + 1} - #{prob.message}" }.join('\n') filecount += 1 probcount += problems.length end # ' } - puts 'Typecheck finished in #{time.real} seconds.' - puts "{probcount} problem#{probcount != 1 ? 's' : ''} found#{files.length != 1 ? ' in #{filecount} of #{files.length} files' : ''}." + puts "Typecheck finished in #{time.real} seconds." + puts "{probcount} problem#{probcount != 1 ? 's' : ''} found#{files.length != 1 ? " in #{filecount} of #{files.length} files" : ''}." # ' exit 1 if probcount > 0 end @@ -234,14 +234,14 @@ def scan pin.typify api_map pin.probe api_map rescue StandardError => e - STDERR.puts "Error testing #{pin_description(pin)} #{pin.location ? 'at #{pin.location.filename}:#{pin.location.range.start.line + 1}' : ''}" - STDERR.puts '[#{e.class}]: #{e.message}' + STDERR.puts "Error testing #{pin_description(pin)} #{pin.location ? "at #{pin.location.filename}:#{pin.location.range.start.line + 1}" : ''}" + STDERR.puts "[#{e.class}]: #{e.message}" STDERR.puts e.backtrace.join('\n') exit 1 end end } - puts 'Scanned #{directory} (#{api_map.pins.length} pins) in #{time.real} seconds.' + puts "Scanned #{directory} (#{api_map.pins.length} pins) in #{time.real} seconds." end desc 'list', 'List the files in the workspace and the total count' @@ -251,7 +251,7 @@ def scan def list workspace = Solargraph::Workspace.new(options[:directory]) puts workspace.filenames unless options[:count] - puts '#{workspace.filenames.length} files total.' + puts "#{workspace.filenames.length} files total." end private @@ -261,14 +261,14 @@ def list def pin_description pin desc = if pin.path.nil? || pin.path.empty? if pin.closure - '#{pin.closure.path} | #{pin.name}' + "#{pin.closure.path} | #{pin.name}" else - '#{pin.context.namespace} | #{pin.name}' + "#{pin.context.namespace} | #{pin.name}" end else pin.path end - desc += ' (#{pin.location.filename} #{pin.location.range.start.line})' if pin.location + desc += " (#{pin.location.filename} #{pin.location.range.start.line})" if pin.location desc end From b7af7750d8cfe16c9dcc9ec74e41fdb1957c7f51 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Mon, 28 Jul 2025 19:44:27 -0400 Subject: [PATCH 201/400] Revert double quote changes for another PR --- lib/solargraph/shell.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/solargraph/shell.rb b/lib/solargraph/shell.rb index 15a4e4361..15074f27b 100755 --- a/lib/solargraph/shell.rb +++ b/lib/solargraph/shell.rb @@ -48,10 +48,10 @@ def socket def stdio require 'backport' Backport.run do - Signal.trap('INT') do + Signal.trap("INT") do Backport.stop end - Signal.trap('TERM') do + Signal.trap("TERM") do Backport.stop end # @sg-ignore https://github.com/castwide/backport/pull/5 From 027c774cb45fa42affa9bf43c0329e6ad1fbcc6a Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Mon, 28 Jul 2025 19:44:35 -0400 Subject: [PATCH 202/400] Revert double quote changes for another PR --- lib/solargraph/shell.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/solargraph/shell.rb b/lib/solargraph/shell.rb index 15074f27b..78763030d 100755 --- a/lib/solargraph/shell.rb +++ b/lib/solargraph/shell.rb @@ -84,7 +84,7 @@ def config(directory = '.') File.open(File.join(directory, '.solargraph.yml'), 'w') do |file| file.puts conf.to_yaml end - STDOUT.puts 'Configuration file initialized.' + STDOUT.puts "Configuration file initialized." end desc 'clear', 'Delete all cached documentation' From 9c3f0b4b8d9096a6cb9e45e8c4e181294eed6cb2 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Mon, 28 Jul 2025 19:56:33 -0400 Subject: [PATCH 203/400] Revert double quote changes for another PR --- lib/solargraph/shell.rb | 38 ++++++++------------------------------ spec/shell_spec.rb | 8 ++++++++ 2 files changed, 16 insertions(+), 30 deletions(-) diff --git a/lib/solargraph/shell.rb b/lib/solargraph/shell.rb index 78763030d..fa2a343a4 100755 --- a/lib/solargraph/shell.rb +++ b/lib/solargraph/shell.rb @@ -198,9 +198,7 @@ def typecheck *files problems = checker.problems next if problems.empty? problems.sort! { |a, b| a.location.range.start.line <=> b.location.range.start.line } - puts problems.map { |prob| - "#{prob.location.filename}:#{prob.location.range.start.line + 1} - #{prob.message}" - }.join('\n') + puts problems.map { |prob| "#{prob.location.filename}:#{prob.location.range.start.line + 1} - #{prob.message}" }.join("\n") filecount += 1 probcount += problems.length end @@ -208,7 +206,7 @@ def typecheck *files } puts "Typecheck finished in #{time.real} seconds." puts "{probcount} problem#{probcount != 1 ? 's' : ''} found#{files.length != 1 ? " in #{filecount} of #{files.length} files" : ''}." - # ' + # " exit 1 if probcount > 0 end @@ -236,7 +234,7 @@ def scan rescue StandardError => e STDERR.puts "Error testing #{pin_description(pin)} #{pin.location ? "at #{pin.location.filename}:#{pin.location.range.start.line + 1}" : ''}" STDERR.puts "[#{e.class}]: #{e.message}" - STDERR.puts e.backtrace.join('\n') + STDERR.puts e.backtrace.join("\n") exit 1 end end @@ -260,36 +258,16 @@ def list # @return [String] def pin_description pin desc = if pin.path.nil? || pin.path.empty? - if pin.closure - "#{pin.closure.path} | #{pin.name}" - else - "#{pin.context.namespace} | #{pin.name}" - end + if pin.closure + "#{pin.closure.path} | #{pin.name}" + else + "#{pin.context.namespace} | #{pin.name}" + end else pin.path end desc += " (#{pin.location.filename} #{pin.location.range.start.line})" if pin.location desc end - - # @param type [ComplexType] - # @return [void] - def print_type type - if options[:rbs] - puts type.to_rbs - else - puts type.rooted_tag - end - end - - # @param pin [Solargraph::Pin::Base] - # @return [void] - def print_pin pin - if options[:rbs] - puts pin.to_rbs - else - puts pin.inspect - end - end end end diff --git a/spec/shell_spec.rb b/spec/shell_spec.rb index 46cfd73f0..5c1f26bfc 100644 --- a/spec/shell_spec.rb +++ b/spec/shell_spec.rb @@ -111,6 +111,14 @@ def bundle_exec(*cmd) end describe 'gems' do + it 'complains when gem does not exist' do + output = capture_both do + shell.gems('nonexistentgem') + end + + expect(output).to include("Gem 'nonexistentgem' not found") + end + it 'caches core without erroring out' do capture_both do shell.uncache('core') From bf740419885888e2826a737f93fe92cdffccceb7 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Tue, 29 Jul 2025 06:30:15 -0400 Subject: [PATCH 204/400] More specs --- spec/pin_cache_spec.rb | 42 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/spec/pin_cache_spec.rb b/spec/pin_cache_spec.rb index bb98af6be..c2ff986f9 100644 --- a/spec/pin_cache_spec.rb +++ b/spec/pin_cache_spec.rb @@ -68,7 +68,7 @@ end end - context 'with a gem packaged with its own RBS' do + context 'with gem packaged with its own RBS gem' do let(:gem_name) { 'base64' } before do @@ -86,4 +86,44 @@ end end end + + describe '#uncache_gem' do + subject(:call) { pin_cache.uncache_gem(gemspec, out: out) } + + let(:out) { StringIO.new } + + before do + allow(FileUtils).to receive(:rm_rf) + end + + context 'with an already cached gem' do + let(:gemspec) { Gem::Specification.find_by_name('backport') } + + it 'deletes files' do + call + + expect(FileUtils).to have_received(:rm_rf).at_least(:once) + end + end + + context 'with a non-existent gem' do + let(:gemspec) { instance_double(Gem::Specification, name: 'nonexistent', version: '0.0.1') } + + it 'does not raise an error' do + expect { call }.not_to raise_error + end + + it 'logs a message' do + call + + expect(out.string).to include('does not exist') + end + + it 'does not delete files' do + call + + expect(FileUtils).not_to have_received(:rm_rf) + end + end + end end From bbce86b3090441f9c681c94e38b3a49b00cd4b02 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Tue, 29 Jul 2025 07:10:45 -0400 Subject: [PATCH 205/400] Add spec --- spec/shell_spec.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/spec/shell_spec.rb b/spec/shell_spec.rb index 5c1f26bfc..a5263df5f 100644 --- a/spec/shell_spec.rb +++ b/spec/shell_spec.rb @@ -196,6 +196,15 @@ def bundle_exec(*cmd) expect { shell.cache('stringio') }.not_to raise_error end + context 'when gem does not exist' do + subject(:call) { shell.cache('nonexistentgem8675309') } + + it 'gives a good error message' do + # capture stderr output + expect { call }.to output(/not found/).to_stderr + end + end + it 'caches gem without erroring out' do _output = capture_stdout do shell.uncache('backport') From 81d91ed7a381f78306632805549d457f041d3bff Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Tue, 29 Jul 2025 09:41:46 -0400 Subject: [PATCH 206/400] Try to reproduce CI issue --- lib/solargraph/workspace/gemspecs.rb | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/lib/solargraph/workspace/gemspecs.rb b/lib/solargraph/workspace/gemspecs.rb index 289a84a1c..eafd521d3 100644 --- a/lib/solargraph/workspace/gemspecs.rb +++ b/lib/solargraph/workspace/gemspecs.rb @@ -121,16 +121,17 @@ def fetch_dependencies gemspec dep = gemspecs.find { |dep| dep.name == runtime_dep.name } dep ||= Gem::Specification.find_by_name(runtime_dep.name, runtime_dep.requirement) deps.merge fetch_dependencies(dep) if deps.add?(dep) - rescue NoMethodError => e - raise unless e.message.include?('identifier') && e.message.include?('lib/ruby/gems') - # Can happen on system gems in Ruby 3.0, it seems: - # - # https://github.com/castwide/solargraph/actions/runs/16480452864/job/46593077954?pr=1006 - logger.debug do - "Skipping dependency #{runtime_dep.name} for #{gemspec.name} due to NoMethodError: #{e.message}" - end - - nil +# TODO: See if this is needed +# rescue NoMethodError => e +# raise unless e.message.include?('identifier') && e.message.include?('lib/ruby/gems') +# # Can happen on system gems in Ruby 3.0, it seems: +# # +# # https://github.com/castwide/solargraph/actions/runs/16480452864/job/46593077954?pr=1006 +# logger.debug do +# "Skipping dependency #{runtime_dep.name} for #{gemspec.name} due to NoMethodError: #{e.message}" +# end + +# nil rescue Gem::MissingSpecError Solargraph.logger.warn("Gem dependency #{runtime_dep.name} #{runtime_dep.requirement} " \ "for #{gemspec.name} not found in bundle.") From 4a6ef4f9963228d851984c2fe865960728464674 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Tue, 29 Jul 2025 10:07:24 -0400 Subject: [PATCH 207/400] Disable testing against head --- .github/workflows/rspec.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/rspec.yml b/.github/workflows/rspec.yml index 5bf5e9775..3eddbabe6 100644 --- a/.github/workflows/rspec.yml +++ b/.github/workflows/rspec.yml @@ -21,7 +21,13 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - ruby-version: ['3.0', '3.1', '3.2', '3.3', '3.4', 'head'] + ruby-version: + - '3.0' + - '3.1' + - '3.2' + - '3.3' + - '3.4' + # - 'head' - see https://github.com/castwide/solargraph/issues/1022 steps: - uses: actions/checkout@v3 From 0268ef15864f770c7fc8359126568e0b10755d7e Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Tue, 29 Jul 2025 10:19:07 -0400 Subject: [PATCH 208/400] Drop dead code --- lib/solargraph/shell.rb | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/solargraph/shell.rb b/lib/solargraph/shell.rb index fa2a343a4..c23110dd1 100755 --- a/lib/solargraph/shell.rb +++ b/lib/solargraph/shell.rb @@ -131,8 +131,6 @@ def gems *names else api_map.cache_gem(gemspec, rebuild: options[:rebuild], out: $stdout) end - rescue Gem::MissingSpecError - warn "Gem '#{name}' not found" end $stderr.puts "Documentation cached for #{names.count} gems." end From 73821eebc37f445743b4478be8d38c17cf551af1 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Tue, 29 Jul 2025 10:20:20 -0400 Subject: [PATCH 209/400] Drop unintended change --- lib/solargraph/shell.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/solargraph/shell.rb b/lib/solargraph/shell.rb index c23110dd1..ff8fb74e2 100755 --- a/lib/solargraph/shell.rb +++ b/lib/solargraph/shell.rb @@ -203,7 +203,7 @@ def typecheck *files # ' } puts "Typecheck finished in #{time.real} seconds." - puts "{probcount} problem#{probcount != 1 ? 's' : ''} found#{files.length != 1 ? " in #{filecount} of #{files.length} files" : ''}." + puts "#{probcount} problem#{probcount != 1 ? 's' : ''} found#{files.length != 1 ? " in #{filecount} of #{files.length} files" : ''}." # " exit 1 if probcount > 0 end From 8564aec8504fa581d4a8e8ba01cdd03a738a0be2 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Tue, 29 Jul 2025 10:20:53 -0400 Subject: [PATCH 210/400] Drop no-longer-needed line --- lib/solargraph/shell.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/solargraph/shell.rb b/lib/solargraph/shell.rb index ff8fb74e2..2eedca90a 100755 --- a/lib/solargraph/shell.rb +++ b/lib/solargraph/shell.rb @@ -200,7 +200,6 @@ def typecheck *files filecount += 1 probcount += problems.length end - # ' } puts "Typecheck finished in #{time.real} seconds." puts "#{probcount} problem#{probcount != 1 ? 's' : ''} found#{files.length != 1 ? " in #{filecount} of #{files.length} files" : ''}." From fb988a20729e90ce552ae3dcc12495e0cc6c51f8 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Tue, 29 Jul 2025 10:29:41 -0400 Subject: [PATCH 211/400] Try abbrev instead of cgi in spec --- spec/pin_cache_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/pin_cache_spec.rb b/spec/pin_cache_spec.rb index c2ff986f9..f98763bf2 100644 --- a/spec/pin_cache_spec.rb +++ b/spec/pin_cache_spec.rb @@ -51,7 +51,7 @@ end context 'with a stdlib gem' do - let(:gem_name) { 'cgi' } + let(:gem_name) { 'abbrev' } before do Solargraph::Shell.new.uncache(gem_name) @@ -64,7 +64,7 @@ pin_cache.cache_gem(gemspec: yaml_gemspec, out: nil) # match arguments with regexp using rspec-matchers syntax - expect(File).to have_received(:write).with(%r{combined/cgi-.*-stdlib.ser$}, any_args).once + expect(File).to have_received(:write).with(%r{combined/abbrev-.*-stdlib.ser$}, any_args).once end end From 2ea23a6ed3985abaf204569d6d38ec9a02e971ab Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Tue, 29 Jul 2025 11:24:34 -0400 Subject: [PATCH 212/400] Drop unneeded error handling --- lib/solargraph/workspace/gemspecs.rb | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/lib/solargraph/workspace/gemspecs.rb b/lib/solargraph/workspace/gemspecs.rb index eafd521d3..bce35b1b7 100644 --- a/lib/solargraph/workspace/gemspecs.rb +++ b/lib/solargraph/workspace/gemspecs.rb @@ -45,15 +45,8 @@ def resolve_require require # Determine gem name based on the require path file = "lib/#{require}.rb" - begin - # @sg-ignore - spec_with_path = Gem::Specification.find_by_path(file) - rescue Gem::MissingSpecError - logger.debug do - "Require #{require.inspect} could not be resolved to a gem via find_by_name or path of #{file}" - end - [] - end + # @sg-ignore + spec_with_path = Gem::Specification.find_by_path(file) all_gemspecs = all_gemspecs_from_bundle @@ -121,17 +114,6 @@ def fetch_dependencies gemspec dep = gemspecs.find { |dep| dep.name == runtime_dep.name } dep ||= Gem::Specification.find_by_name(runtime_dep.name, runtime_dep.requirement) deps.merge fetch_dependencies(dep) if deps.add?(dep) -# TODO: See if this is needed -# rescue NoMethodError => e -# raise unless e.message.include?('identifier') && e.message.include?('lib/ruby/gems') -# # Can happen on system gems in Ruby 3.0, it seems: -# # -# # https://github.com/castwide/solargraph/actions/runs/16480452864/job/46593077954?pr=1006 -# logger.debug do -# "Skipping dependency #{runtime_dep.name} for #{gemspec.name} due to NoMethodError: #{e.message}" -# end - -# nil rescue Gem::MissingSpecError Solargraph.logger.warn("Gem dependency #{runtime_dep.name} #{runtime_dep.requirement} " \ "for #{gemspec.name} not found in bundle.") From 594bd268e3921d4bea1c0efb1a6953a3f25173ee Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Tue, 29 Jul 2025 11:38:16 -0400 Subject: [PATCH 213/400] More specs --- spec/rbs_map_spec.rb | 7 +- spec/shell_spec.rb | 11 +++ .../gemspecs_resolve_require_spec.rb | 87 +++++++++++-------- 3 files changed, 66 insertions(+), 39 deletions(-) diff --git a/spec/rbs_map_spec.rb b/spec/rbs_map_spec.rb index a18c5d5b5..f3ca90a36 100644 --- a/spec/rbs_map_spec.rb +++ b/spec/rbs_map_spec.rb @@ -6,9 +6,14 @@ expect(pin).not_to be_nil end - it 'fails if it does not find data' do + it 'fails if it does not find data from gemspec' do spec = Gem::Specification.find_by_name('backport') rbs_map = Solargraph::RbsMap.from_gemspec(spec, nil, nil) + expect(rbs_map).not_to be_resolved + end + + it 'fails if it does not find data from name' do + rbs_map = Solargraph::RbsMap.new('lskdflaksdfjl') expect(rbs_map.pins).to be_empty end diff --git a/spec/shell_spec.rb b/spec/shell_spec.rb index a5263df5f..8a73b291b 100644 --- a/spec/shell_spec.rb +++ b/spec/shell_spec.rb @@ -65,6 +65,17 @@ def bundle_exec(*cmd) end end + describe 'scan' do + it 'scans without erroring out' do + output = capture_stdout do + shell.options = { directory: 'spec/fixtures/workspace' } + shell.scan + end + + expect(output).to include('Scanned ').and include(' seconds.') + end + end + describe 'typecheck' do it 'typechecks without erroring out' do output = capture_stdout do diff --git a/spec/workspace/gemspecs_resolve_require_spec.rb b/spec/workspace/gemspecs_resolve_require_spec.rb index d09d9d16f..6e8f69442 100644 --- a/spec/workspace/gemspecs_resolve_require_spec.rb +++ b/spec/workspace/gemspecs_resolve_require_spec.rb @@ -15,6 +15,22 @@ def find_or_install gem_name, version install_gem(gem_name, version) end + def add_bundle + # write out Gemfile + File.write(File.join(dir_path, 'Gemfile'), <<~GEMFILE) + source 'https://rubygems.org' + gem 'backport' + GEMFILE + # run bundle install + output, status = Solargraph.with_clean_env do + Open3.capture2e('bundle install --verbose', chdir: dir_path) + end + raise "Failure installing bundle: #{output}" unless status.success? + # ensure Gemfile.lock exists + return if File.exist?(File.join(dir_path, 'Gemfile.lock')) + raise "Gemfile.lock not found after bundle install in #{dir_path}" + end + def install_gem gem_name, version Bundler.with_unbundled_env do cmd = Gem::Commands::InstallCommand.new @@ -92,25 +108,8 @@ def install_gem gem_name, version end end - context 'with Gemfile' do - before do - # write out Gemfile - File.write(File.join(dir_path, 'Gemfile'), <<~GEMFILE) - source 'https://rubygems.org' - gem 'backport' - GEMFILE - - # run bundle install - output, status = Solargraph.with_clean_env do - Open3.capture2e('bundle install --verbose', chdir: dir_path) - end - raise "Failure installing bundle: #{output}" unless status.success? - - # ensure Gemfile.lock exists - unless File.exist?(File.join(dir_path, 'Gemfile.lock')) - raise "Gemfile.lock not found after bundle install in #{dir_path}" - end - end + context 'with Gemfile and Bundler.require' do + before { add_bundle } let(:require) { 'bundler/require' } @@ -121,31 +120,43 @@ def install_gem gem_name, version it 'returns gems' do expect(specs.map(&:name)).to include('backport') end + end + + context 'with Gemfile but an unknown gem' do + before { add_bundle } + let(:require) { 'unknown_gemlaksdflkdf' } + + it 'returns nil' do + expect(specs).to be_nil + end + end + + context 'with a Gemfile and a gem preference' do # find_or_install helper doesn't seem to work on older versions if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.1.0') - context 'with a gem preference' do - before do - find_or_install('backport', '1.0.0') - Gem::Specification.find_by_name('backport', '= 1.0.0') - end + warn 'running the cool kid tests' + before do + add_bundle + find_or_install('backport', '1.0.0') + Gem::Specification.find_by_name('backport', '= 1.0.0') + end - let(:preferences) do - [ - Gem::Specification.new.tap do |spec| - spec.name = 'backport' - spec.version = '1.0.0' - end - ] - end + let(:preferences) do + [ + Gem::Specification.new.tap do |spec| + spec.name = 'backport' + spec.version = '1.0.0' + end + ] + end - it 'returns the preferred gemspec' do - gemspecs = described_class.new(dir_path, preferences: preferences) - specs = gemspecs.resolve_require('backport') - backport = specs.find { |spec| spec.name == 'backport' } + it 'returns the preferred gemspec' do + gemspecs = described_class.new(dir_path, preferences: preferences) + specs = gemspecs.resolve_require('backport') + backport = specs.find { |spec| spec.name == 'backport' } - expect(backport.version.to_s).to eq('1.0.0') - end + expect(backport.version.to_s).to eq('1.0.0') end context 'with a gem preference that does not exist' do From d381ba757ece988453b11b848271a690e76e382c Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Tue, 29 Jul 2025 12:11:15 -0400 Subject: [PATCH 214/400] More specs --- .../gemspecs_resolve_require_spec.rb | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/spec/workspace/gemspecs_resolve_require_spec.rb b/spec/workspace/gemspecs_resolve_require_spec.rb index 6e8f69442..6329b1797 100644 --- a/spec/workspace/gemspecs_resolve_require_spec.rb +++ b/spec/workspace/gemspecs_resolve_require_spec.rb @@ -56,6 +56,27 @@ def install_gem gem_name, version end end + context 'with an unknown type from Bundler / RubyGems' do + let(:require) { 'solargraph' } + + let(:specish_objects) { [double()] } + + let(:locked_gems) { double(specs: specish_objects) } + + before do + # specish_objects = Bundler.definition.locked_gems.specs + allow(Bundler.definition).to receive(:locked_gems).and_return(locked_gems) + end + + it 'returns a single spec' do + expect(specs.size).to eq(1) + end + + it 'resolves to the right known gem' do + expect(specs.map(&:name)).to eq(['solargraph']) + end + end + context 'with a less usual require mapping' do let(:require) { 'diff/lcs' } From b534c026eb171cf93d408ce821cba24a399c76de Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Tue, 29 Jul 2025 12:19:48 -0400 Subject: [PATCH 215/400] Fix pin caching --- spec/workspace/gemspecs_resolve_require_spec.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/spec/workspace/gemspecs_resolve_require_spec.rb b/spec/workspace/gemspecs_resolve_require_spec.rb index 6329b1797..c95535eb6 100644 --- a/spec/workspace/gemspecs_resolve_require_spec.rb +++ b/spec/workspace/gemspecs_resolve_require_spec.rb @@ -59,9 +59,9 @@ def install_gem gem_name, version context 'with an unknown type from Bundler / RubyGems' do let(:require) { 'solargraph' } - let(:specish_objects) { [double()] } + let(:specish_objects) { [double] } - let(:locked_gems) { double(specs: specish_objects) } + let(:locked_gems) { double(specs: specish_objects) } # rubocop:disable RSpec/VerifiedDoubles before do # specish_objects = Bundler.definition.locked_gems.specs @@ -156,7 +156,6 @@ def install_gem gem_name, version context 'with a Gemfile and a gem preference' do # find_or_install helper doesn't seem to work on older versions if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.1.0') - warn 'running the cool kid tests' before do add_bundle find_or_install('backport', '1.0.0') From 17fe05f8e73d49bfd2a566dc3b06d18602405d85 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Tue, 29 Jul 2025 12:25:06 -0400 Subject: [PATCH 216/400] Rebaseline rubocop todo --- .rubocop_todo.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 171a16938..754162de0 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -248,10 +248,12 @@ Layout/IndentationWidth: - 'lib/solargraph.rb' - 'lib/solargraph/diagnostics/rubocop.rb' - 'lib/solargraph/language_server/message/extended/check_gem_version.rb' + - 'lib/solargraph/library.rb' - 'lib/solargraph/parser/parser_gem/node_methods.rb' - 'lib/solargraph/parser/parser_gem/node_processors/block_node.rb' - 'lib/solargraph/pin/method.rb' - 'lib/solargraph/pin/namespace.rb' + - 'lib/solargraph/shell.rb' - 'lib/solargraph/source/chain/call.rb' - 'lib/solargraph/source_map/clip.rb' - 'lib/solargraph/source_map/mapper.rb' @@ -881,7 +883,6 @@ Naming/VariableName: RSpec/Be: Exclude: - 'spec/rbs_map/stdlib_map_spec.rb' - - 'spec/rbs_map_spec.rb' - 'spec/source/source_chainer_spec.rb' # This cop supports unsafe autocorrection (--autocorrect-all). @@ -1777,7 +1778,6 @@ Style/GuardClause: - 'lib/solargraph/api_map.rb' - 'lib/solargraph/library.rb' - 'lib/solargraph/parser/parser_gem/node_processors/send_node.rb' - - 'lib/solargraph/pin_cache.rb' - 'lib/solargraph/range.rb' - 'lib/solargraph/rbs_map/conversions.rb' - 'lib/solargraph/source.rb' @@ -1927,6 +1927,7 @@ Style/MethodDefParentheses: - 'lib/solargraph/position.rb' - 'lib/solargraph/range.rb' - 'lib/solargraph/rbs_map/conversions.rb' + - 'lib/solargraph/shell.rb' - 'lib/solargraph/source.rb' - 'lib/solargraph/source/chain/call.rb' - 'lib/solargraph/source/chain/constant.rb' @@ -2282,6 +2283,7 @@ Style/StringLiterals: - 'lib/solargraph/pin/parameter.rb' - 'lib/solargraph/rbs_map/conversions.rb' - 'lib/solargraph/server_methods.rb' + - 'lib/solargraph/shell.rb' - 'lib/solargraph/workspace.rb' - 'lib/solargraph/yard_map/mapper/to_method.rb' - 'lib/solargraph/yard_tags.rb' From af0e537d1303c0eb202837aa8efd75eeef3fe186 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Tue, 29 Jul 2025 12:43:58 -0400 Subject: [PATCH 217/400] Try again with logger, which is formally in the gemspec as a dependency --- spec/pin_cache_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/pin_cache_spec.rb b/spec/pin_cache_spec.rb index f98763bf2..825f0facb 100644 --- a/spec/pin_cache_spec.rb +++ b/spec/pin_cache_spec.rb @@ -51,7 +51,7 @@ end context 'with a stdlib gem' do - let(:gem_name) { 'abbrev' } + let(:gem_name) { 'logger' } before do Solargraph::Shell.new.uncache(gem_name) @@ -64,7 +64,7 @@ pin_cache.cache_gem(gemspec: yaml_gemspec, out: nil) # match arguments with regexp using rspec-matchers syntax - expect(File).to have_received(:write).with(%r{combined/abbrev-.*-stdlib.ser$}, any_args).once + expect(File).to have_received(:write).with(%r{combined/logger-.*-stdlib.ser$}, any_args).once end end From 05b68679e35c86de9ca8689abec5e4a0b1fd16be Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Tue, 29 Jul 2025 12:59:00 -0400 Subject: [PATCH 218/400] Drop un-needed new code --- lib/solargraph/api_map.rb | 7 ------- lib/solargraph/api_map/store.rb | 7 +------ 2 files changed, 1 insertion(+), 13 deletions(-) diff --git a/lib/solargraph/api_map.rb b/lib/solargraph/api_map.rb index 261edae52..71169157c 100755 --- a/lib/solargraph/api_map.rb +++ b/lib/solargraph/api_map.rb @@ -256,13 +256,6 @@ def keyword_pins store.pins_by_class(Pin::Keyword) end - # An array of namespace names defined in the ApiMap. - # - # @return [Set] - def namespaces - store.namespaces - end - # True if the namespace exists. # # @param name [String] The namespace to match diff --git a/lib/solargraph/api_map/store.rb b/lib/solargraph/api_map/store.rb index d3c8fc911..413c00aa7 100644 --- a/lib/solargraph/api_map/store.rb +++ b/lib/solargraph/api_map/store.rb @@ -31,7 +31,7 @@ def update *pinsets pinsets[changed..].each_with_index do |pins, idx| @pinsets[changed + idx] = pins @indexes[changed + idx] = if pins.empty? - @indexes[changed + idx - 1] + @indexes[changed + idx - 1] else @indexes[changed + idx - 1].merge(pins) end @@ -132,11 +132,6 @@ def namespace_exists?(fqns) fqns_pins(fqns).any? end - # @return [Set] - def namespaces - index.namespaces - end - # @return [Enumerable] def namespace_pins pins_by_class(Solargraph::Pin::Namespace) From 715274fc054558e5725ea253f5470eefa7e163a1 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Tue, 29 Jul 2025 13:34:30 -0400 Subject: [PATCH 219/400] Rebaseline rubocop todo --- .rubocop_todo.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 754162de0..3f3f654e9 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -246,6 +246,7 @@ Layout/HeredocIndentation: Layout/IndentationWidth: Exclude: - 'lib/solargraph.rb' + - 'lib/solargraph/api_map/store.rb' - 'lib/solargraph/diagnostics/rubocop.rb' - 'lib/solargraph/language_server/message/extended/check_gem_version.rb' - 'lib/solargraph/library.rb' From 373063bebf784bb67fdf9548f2c4edda41e36c03 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Tue, 29 Jul 2025 13:59:58 -0400 Subject: [PATCH 220/400] Another spec --- lib/solargraph/workspace/gemspecs.rb | 2 ++ .../gemspecs_fetch_dependencies_spec.rb | 22 +++++++++++++++---- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/lib/solargraph/workspace/gemspecs.rb b/lib/solargraph/workspace/gemspecs.rb index bce35b1b7..654c2e224 100644 --- a/lib/solargraph/workspace/gemspecs.rb +++ b/lib/solargraph/workspace/gemspecs.rb @@ -273,6 +273,8 @@ def only_runtime_dependencies gemspec unless gemspec.respond_to?(:dependencies) && gemspec.respond_to?(:development_dependencies) gemspec = to_gem_specification(gemspec) end + return [] if gemspec.nil? + gemspec.dependencies - gemspec.development_dependencies end diff --git a/spec/workspace/gemspecs_fetch_dependencies_spec.rb b/spec/workspace/gemspecs_fetch_dependencies_spec.rb index 0596d0f12..85ca68207 100644 --- a/spec/workspace/gemspecs_fetch_dependencies_spec.rb +++ b/spec/workspace/gemspecs_fetch_dependencies_spec.rb @@ -24,14 +24,14 @@ let(:dir_path) { File.realpath(Dir.mktmpdir).to_s } let(:gemspec) do - Bundler::LazySpecification.new('undercover', nil, nil) + Bundler::LazySpecification.new(gem_name, nil, nil) end before do # write out Gemfile File.write(File.join(dir_path, 'Gemfile'), <<~GEMFILE) source 'https://rubygems.org' - gem 'undercover' + gem '#{gem_name}' GEMFILE # run bundle install @@ -46,8 +46,22 @@ end end - it 'finds dependencies' do - expect(deps.map(&:name)).to include('ast') + context 'with gem that exists in our bundle' do + let(:gem_name) { 'undercover' } + + it 'finds dependencies' do + expect(deps.map(&:name)).to include('ast') + end + end + + context 'with gem does not hat eists in our bundle' do + let(:gem_name) { 'activerecord' } + + it 'gives a useful message' do + dep_names = nil + output = capture_both { dep_names = deps.map(&:name) } + expect(output).to include('Please install the gem activerecord') + end end end end From 79ffb59804bc21bfc3ddfc0cbbc8caad87fac6f1 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Tue, 29 Jul 2025 14:36:24 -0400 Subject: [PATCH 221/400] Improve coverage --- .../gemspecs_resolve_require_spec.rb | 53 ++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) diff --git a/spec/workspace/gemspecs_resolve_require_spec.rb b/spec/workspace/gemspecs_resolve_require_spec.rb index c95535eb6..ad0c5ec90 100644 --- a/spec/workspace/gemspecs_resolve_require_spec.rb +++ b/spec/workspace/gemspecs_resolve_require_spec.rb @@ -62,10 +62,61 @@ def install_gem gem_name, version let(:specish_objects) { [double] } let(:locked_gems) { double(specs: specish_objects) } # rubocop:disable RSpec/VerifiedDoubles + let(:lockfile) { instance_double(Bundler::LockfileParser, specs: specish_objects) } + let(:definition) { instance_double(Bundler::Definition, + locked_gems: locked_gems, + lockfile: lockfile) } before do # specish_objects = Bundler.definition.locked_gems.specs - allow(Bundler.definition).to receive(:locked_gems).and_return(locked_gems) + allow(Bundler).to receive(:definition).and_return(definition) + allow(lockfile).to receive(:to_s).and_return(dir_path) + end + + it 'returns a single spec' do + expect(specs.size).to eq(1) + end + + it 'resolves to the right known gem' do + expect(specs.map(&:name)).to eq(['solargraph']) + end + end + + context 'with a Bundler::StubSpecification from Bundler / RubyGems' do + # this can happen from local gems, which is hard to test + # organically + + let(:require) { 'solargraph' } + + let(:spec_fetcher) { instance_double(Gem::SpecFetcher) } + let(:platform) { Gem::Platform::RUBY } + let(:bundler_stub_spec) { Bundler::StubSpecification.new('solargraph', '123', platform, spec_fetcher) } + let(:gem_stub_spec) { Gem::StubSpecification.new('solargraph', '123', platform, spec_fetcher) } + + let(:specish_objects) { [bundler_stub_spec] } + + let(:real_spec) { instance_double(Gem::Specification) } + + let(:locked_gems) { double(specs: specish_objects) } # rubocop:disable RSpec/VerifiedDoubles + let(:lockfile) { instance_double(Bundler::LockfileParser, specs: specish_objects) } + let(:definition) { instance_double(Bundler::Definition, + locked_gems: locked_gems, + lockfile: lockfile) } + + before do + # specish_objects = Bundler.definition.locked_gems.specs + allow(Bundler).to receive(:definition).and_return(definition) + allow(lockfile).to receive(:to_s).and_return(dir_path) + allow(bundler_stub_spec).to receive(:name).and_return('solargraph') + allow(bundler_stub_spec).to receive(:respond_to?).with(:name).and_return(true) + allow(bundler_stub_spec).to receive(:respond_to?).with(:version).and_return(true) + allow(bundler_stub_spec).to receive(:respond_to?).with(:gem_dir).and_return(false) + allow(bundler_stub_spec).to receive(:respond_to?).with(:materialize_for_installation).and_return(false) + allow(bundler_stub_spec).to receive(:stub).and_return(gem_stub_spec) + allow(gem_stub_spec).to receive(:name).and_return('solargraph') + allow(gem_stub_spec).to receive(:version).and_return('123') + allow(gem_stub_spec).to receive(:spec).and_return(real_spec) + allow(real_spec).to receive(:name).and_return('solargraph') end it 'returns a single spec' do From 70d63656347680a9c4a46040167788779332d02f Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Tue, 29 Jul 2025 14:50:53 -0400 Subject: [PATCH 222/400] Another spec --- .../gemspecs_resolve_require_spec.rb | 44 +++++++------------ 1 file changed, 17 insertions(+), 27 deletions(-) diff --git a/spec/workspace/gemspecs_resolve_require_spec.rb b/spec/workspace/gemspecs_resolve_require_spec.rb index ad0c5ec90..96cc35a77 100644 --- a/spec/workspace/gemspecs_resolve_require_spec.rb +++ b/spec/workspace/gemspecs_resolve_require_spec.rb @@ -58,17 +58,14 @@ def install_gem gem_name, version context 'with an unknown type from Bundler / RubyGems' do let(:require) { 'solargraph' } - let(:specish_objects) { [double] } - let(:locked_gems) { double(specs: specish_objects) } # rubocop:disable RSpec/VerifiedDoubles - let(:lockfile) { instance_double(Bundler::LockfileParser, specs: specish_objects) } - let(:definition) { instance_double(Bundler::Definition, - locked_gems: locked_gems, - lockfile: lockfile) } - before do - # specish_objects = Bundler.definition.locked_gems.specs + lockfile = instance_double(Pathname) + locked_gems = instance_double(Bundler::LockfileParser, specs: specish_objects) + definition = instance_double(Bundler::Definition, + locked_gems: locked_gems, + lockfile: lockfile) allow(Bundler).to receive(:definition).and_return(definition) allow(lockfile).to receive(:to_s).and_return(dir_path) end @@ -87,35 +84,28 @@ def install_gem gem_name, version # organically let(:require) { 'solargraph' } - let(:spec_fetcher) { instance_double(Gem::SpecFetcher) } - let(:platform) { Gem::Platform::RUBY } - let(:bundler_stub_spec) { Bundler::StubSpecification.new('solargraph', '123', platform, spec_fetcher) } - let(:gem_stub_spec) { Gem::StubSpecification.new('solargraph', '123', platform, spec_fetcher) } - - let(:specish_objects) { [bundler_stub_spec] } - - let(:real_spec) { instance_double(Gem::Specification) } - - let(:locked_gems) { double(specs: specish_objects) } # rubocop:disable RSpec/VerifiedDoubles - let(:lockfile) { instance_double(Bundler::LockfileParser, specs: specish_objects) } - let(:definition) { instance_double(Bundler::Definition, - locked_gems: locked_gems, - lockfile: lockfile) } before do + platform = Gem::Platform::RUBY + gem_stub_spec = Gem::StubSpecification.new('solargraph', '123', platform, spec_fetcher) + real_spec = instance_double(Gem::Specification) + bundler_stub_spec = Bundler::StubSpecification.new('solargraph', '123', platform, spec_fetcher) + specish_objects = [bundler_stub_spec] + lockfile = instance_double(Pathname) + locked_gems = instance_double(Bundler::LockfileParser, specs: specish_objects) + definition = instance_double(Bundler::Definition, + locked_gems: locked_gems, + lockfile: lockfile) # specish_objects = Bundler.definition.locked_gems.specs allow(Bundler).to receive(:definition).and_return(definition) allow(lockfile).to receive(:to_s).and_return(dir_path) - allow(bundler_stub_spec).to receive(:name).and_return('solargraph') allow(bundler_stub_spec).to receive(:respond_to?).with(:name).and_return(true) allow(bundler_stub_spec).to receive(:respond_to?).with(:version).and_return(true) allow(bundler_stub_spec).to receive(:respond_to?).with(:gem_dir).and_return(false) allow(bundler_stub_spec).to receive(:respond_to?).with(:materialize_for_installation).and_return(false) - allow(bundler_stub_spec).to receive(:stub).and_return(gem_stub_spec) - allow(gem_stub_spec).to receive(:name).and_return('solargraph') - allow(gem_stub_spec).to receive(:version).and_return('123') - allow(gem_stub_spec).to receive(:spec).and_return(real_spec) + allow(bundler_stub_spec).to receive_messages(name: 'solargraph', stub: gem_stub_spec) + allow(gem_stub_spec).to receive_messages(name: 'solargraph', version: '123', spec: real_spec) allow(real_spec).to receive(:name).and_return('solargraph') end From 17be263a2b3cfa17055a6d2fbf17b213f6ea42ae Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Tue, 29 Jul 2025 16:23:46 -0400 Subject: [PATCH 223/400] Another spec --- lib/solargraph/doc_map.rb | 7 +++-- lib/solargraph/workspace.rb | 5 ++-- lib/solargraph/workspace/gemspecs.rb | 15 +++++----- spec/doc_map_spec.rb | 2 +- .../gemspecs_fetch_dependencies_spec.rb | 30 +++++++++++++++---- 5 files changed, 40 insertions(+), 19 deletions(-) diff --git a/lib/solargraph/doc_map.rb b/lib/solargraph/doc_map.rb index 9d869a180..593d3971e 100644 --- a/lib/solargraph/doc_map.rb +++ b/lib/solargraph/doc_map.rb @@ -77,9 +77,10 @@ def unresolved_requires @unresolved_requires ||= required_gems_map.select { |_, gemspecs| gemspecs.nil? }.keys end + # @param out [IO, nil] output stream for logging # @return [Set] - def dependencies - @dependencies ||= (gemspecs.flat_map { |spec| workspace.fetch_dependencies(spec) } - gemspecs).to_set + def dependencies out: $stderr + @dependencies ||= (gemspecs.flat_map { |spec| workspace.fetch_dependencies(spec, out: out) } - gemspecs).to_set end # Cache gem documentation if needed for this doc_map @@ -112,7 +113,7 @@ def load_serialized_gem_pins out: $stderr missing_paths = Hash[without_gemspecs].keys # @sg-ignore Need support for RBS duck interfaces like _ToHash # @type [Array] - gemspecs = Hash[with_gemspecs].values.flatten.compact + dependencies.to_a + gemspecs = Hash[with_gemspecs].values.flatten.compact + dependencies(out: out).to_a missing_paths.each do |path| # this will load from disk if needed; no need to manage diff --git a/lib/solargraph/workspace.rb b/lib/solargraph/workspace.rb index dbc6f892c..fa138bf13 100644 --- a/lib/solargraph/workspace.rb +++ b/lib/solargraph/workspace.rb @@ -49,10 +49,11 @@ def config @config ||= Solargraph::Workspace::Config.new(directory) end + # @param out [IO, nil] output stream for logging # @param gemspec [Gem::Specification] # @return [Array] - def fetch_dependencies gemspec - gemspecs.fetch_dependencies(gemspec) + def fetch_dependencies gemspec, out: $stderr + gemspecs.fetch_dependencies(gemspec, out: out) end # @return [Solargraph::PinCache] diff --git a/lib/solargraph/workspace/gemspecs.rb b/lib/solargraph/workspace/gemspecs.rb index 654c2e224..5bad76d2f 100644 --- a/lib/solargraph/workspace/gemspecs.rb +++ b/lib/solargraph/workspace/gemspecs.rb @@ -103,8 +103,10 @@ def find_gem name, version = nil, out: $stderr end # @param gemspec [Gem::Specification] + # @param out[IO, nil] output stream for logging + # # @return [Array] - def fetch_dependencies gemspec + def fetch_dependencies gemspec, out: $stderr gemspecs = all_gemspecs_from_bundle # @param runtime_dep [Gem::Dependency] @@ -113,11 +115,10 @@ def fetch_dependencies gemspec Solargraph.logger.info "Adding #{runtime_dep.name} dependency for #{gemspec.name}" dep = gemspecs.find { |dep| dep.name == runtime_dep.name } dep ||= Gem::Specification.find_by_name(runtime_dep.name, runtime_dep.requirement) - deps.merge fetch_dependencies(dep) if deps.add?(dep) rescue Gem::MissingSpecError - Solargraph.logger.warn("Gem dependency #{runtime_dep.name} #{runtime_dep.requirement} " \ - "for #{gemspec.name} not found in bundle.") - nil + dep = resolve_gem_ignoring_local_bundle runtime_dep.name, out: out + ensure + deps.merge fetch_dependencies(dep, out: out) if dep && deps.add?(dep) end.to_a.compact # RBS tracks implicit dependencies, like how the YAML standard # library implies pulling in the psych library. @@ -281,11 +282,11 @@ def only_runtime_dependencies gemspec # @todo Should this be using Gem::SpecFetcher and pull them automatically? # # @param name [String] - # @param version [String] + # @param version [String, nil] # @param out [IO, nil] output stream for logging # # @return [Gem::Specification, nil] - def resolve_gem_ignoring_local_bundle name, version, out: $stderr + def resolve_gem_ignoring_local_bundle name, version = nil, out: $stderr Gem::Specification.find_by_name(name, version) rescue Gem::MissingSpecError begin diff --git a/spec/doc_map_spec.rb b/spec/doc_map_spec.rb index c935c0c58..b2c55d54f 100644 --- a/spec/doc_map_spec.rb +++ b/spec/doc_map_spec.rb @@ -70,7 +70,7 @@ pincache = instance_double(Solargraph::PinCache) uncached_gemspec = Gem::Specification.new('uncached_gem', '1.0.0') allow(workspace).to receive(:resolve_require).with('uncached_gem').and_return([uncached_gemspec]) - allow(workspace).to receive(:fetch_dependencies).with(uncached_gemspec).and_return([]) + allow(workspace).to receive(:fetch_dependencies).with(uncached_gemspec, out: out).and_return([]) allow(workspace).to receive(:fresh_pincache).and_return(pincache) allow(pincache).to receive(:deserialize_combined_pin_cache).with(uncached_gemspec).and_return(nil) diff --git a/spec/workspace/gemspecs_fetch_dependencies_spec.rb b/spec/workspace/gemspecs_fetch_dependencies_spec.rb index 85ca68207..9a21f967c 100644 --- a/spec/workspace/gemspecs_fetch_dependencies_spec.rb +++ b/spec/workspace/gemspecs_fetch_dependencies_spec.rb @@ -10,13 +10,31 @@ let(:gemspecs) { described_class.new(dir_path) } let(:dir_path) { Dir.pwd } - context 'with a Bundler::LazySpecification in bundle' do - let(:gemspec) do - Bundler::LazySpecification.new('solargraph', nil, nil) + context 'when in our bundle' do + context 'with a Bundler::LazySpecification' do + let(:gemspec) do + Bundler::LazySpecification.new('solargraph', nil, nil) + end + + it 'finds a known dependency' do + expect(deps.map(&:name)).to include('backport') + end end - it 'finds a known dependency' do - expect(deps.map(&:name)).to include('backport') + context 'with gem whose dependency does not exist in our bundle' do + let(:gemspec) do + instance_double(Gem::Specification, + dependencies: [Gem::Dependency.new('activerecord')], + development_dependencies: [], + name: 'my_fake_gem', + version: '123') + end + let(:gem_name) { 'my_fake_gem' } + + it 'gives a useful message' do + output = capture_both { deps.map(&:name) } + expect(output).to include('Please install the gem activerecord') + end end end @@ -54,7 +72,7 @@ end end - context 'with gem does not hat eists in our bundle' do + context 'with gem does not exist in our bundle' do let(:gem_name) { 'activerecord' } it 'gives a useful message' do From e286fa558a398f54b68e3d91c0c0a9bae87e15e3 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Tue, 29 Jul 2025 16:52:53 -0400 Subject: [PATCH 224/400] More specs --- lib/solargraph/workspace/gemspecs.rb | 4 +- .../gemspecs_resolve_require_spec.rb | 59 ++++++++++++++----- 2 files changed, 45 insertions(+), 18 deletions(-) diff --git a/lib/solargraph/workspace/gemspecs.rb b/lib/solargraph/workspace/gemspecs.rb index 5bad76d2f..e99a751b5 100644 --- a/lib/solargraph/workspace/gemspecs.rb +++ b/lib/solargraph/workspace/gemspecs.rb @@ -170,8 +170,8 @@ def to_gem_specification specish if specish.respond_to?(:spec) specish.spec else - resolve_gem_ignoring_local_bundle specish.name, - specish.version + # turn the crank again + to_gem_specification(specish) end else @@warned_on_gem_type ||= diff --git a/spec/workspace/gemspecs_resolve_require_spec.rb b/spec/workspace/gemspecs_resolve_require_spec.rb index 96cc35a77..682251f78 100644 --- a/spec/workspace/gemspecs_resolve_require_spec.rb +++ b/spec/workspace/gemspecs_resolve_require_spec.rb @@ -63,6 +63,7 @@ def install_gem gem_name, version before do lockfile = instance_double(Pathname) locked_gems = instance_double(Bundler::LockfileParser, specs: specish_objects) + definition = instance_double(Bundler::Definition, locked_gems: locked_gems, lockfile: lockfile) @@ -79,6 +80,25 @@ def install_gem gem_name, version end end + def configure_bundler_spec stub_value + platform = Gem::Platform::RUBY + bundler_stub_spec = Bundler::StubSpecification.new('solargraph', '123', platform, spec_fetcher) + specish_objects = [bundler_stub_spec] + lockfile = instance_double(Pathname) + locked_gems = instance_double(Bundler::LockfileParser, specs: specish_objects) + definition = instance_double(Bundler::Definition, + locked_gems: locked_gems, + lockfile: lockfile) + # specish_objects = Bundler.definition.locked_gems.specs + allow(Bundler).to receive(:definition).and_return(definition) + allow(lockfile).to receive(:to_s).and_return(dir_path) + allow(bundler_stub_spec).to receive(:respond_to?).with(:name).and_return(true) + allow(bundler_stub_spec).to receive(:respond_to?).with(:version).and_return(true) + allow(bundler_stub_spec).to receive(:respond_to?).with(:gem_dir).and_return(false) + allow(bundler_stub_spec).to receive(:respond_to?).with(:materialize_for_installation).and_return(false) + allow(bundler_stub_spec).to receive_messages(name: 'solargraph', stub: stub_value) + end + context 'with a Bundler::StubSpecification from Bundler / RubyGems' do # this can happen from local gems, which is hard to test # organically @@ -88,25 +108,32 @@ def install_gem gem_name, version before do platform = Gem::Platform::RUBY - gem_stub_spec = Gem::StubSpecification.new('solargraph', '123', platform, spec_fetcher) real_spec = instance_double(Gem::Specification) - bundler_stub_spec = Bundler::StubSpecification.new('solargraph', '123', platform, spec_fetcher) - specish_objects = [bundler_stub_spec] - lockfile = instance_double(Pathname) - locked_gems = instance_double(Bundler::LockfileParser, specs: specish_objects) - definition = instance_double(Bundler::Definition, - locked_gems: locked_gems, - lockfile: lockfile) - # specish_objects = Bundler.definition.locked_gems.specs - allow(Bundler).to receive(:definition).and_return(definition) - allow(lockfile).to receive(:to_s).and_return(dir_path) - allow(bundler_stub_spec).to receive(:respond_to?).with(:name).and_return(true) - allow(bundler_stub_spec).to receive(:respond_to?).with(:version).and_return(true) - allow(bundler_stub_spec).to receive(:respond_to?).with(:gem_dir).and_return(false) - allow(bundler_stub_spec).to receive(:respond_to?).with(:materialize_for_installation).and_return(false) - allow(bundler_stub_spec).to receive_messages(name: 'solargraph', stub: gem_stub_spec) + allow(real_spec).to receive(:name).and_return('solargraph') + gem_stub_spec = Gem::StubSpecification.new('solargraph', '123', platform, spec_fetcher) + configure_bundler_spec(gem_stub_spec) allow(gem_stub_spec).to receive_messages(name: 'solargraph', version: '123', spec: real_spec) + end + + it 'returns a single spec' do + expect(specs.size).to eq(1) + end + + it 'resolves to the right known gem' do + expect(specs.map(&:name)).to eq(['solargraph']) + end + end + + context 'with a Bundler::StubSpecification that resolves straight to Gem::Specification' do + # have seen different behavior with different versions of rubygems/bundler + + let(:require) { 'solargraph' } + let(:spec_fetcher) { instance_double(Gem::SpecFetcher) } + let(:real_spec) { instance_double(Gem::Specification, name: 'solargraph', version: '123') } + + before do allow(real_spec).to receive(:name).and_return('solargraph') + configure_bundler_spec(real_spec) end it 'returns a single spec' do From 4e76133ea36393e7392ff99ec65d9161cf226a3f Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Tue, 29 Jul 2025 17:12:45 -0400 Subject: [PATCH 225/400] Fix spec --- spec/workspace/gemspecs_resolve_require_spec.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/spec/workspace/gemspecs_resolve_require_spec.rb b/spec/workspace/gemspecs_resolve_require_spec.rb index 682251f78..f62ece83b 100644 --- a/spec/workspace/gemspecs_resolve_require_spec.rb +++ b/spec/workspace/gemspecs_resolve_require_spec.rb @@ -129,10 +129,9 @@ def configure_bundler_spec stub_value let(:require) { 'solargraph' } let(:spec_fetcher) { instance_double(Gem::SpecFetcher) } - let(:real_spec) { instance_double(Gem::Specification, name: 'solargraph', version: '123') } + let(:real_spec) { Gem::Specification.new('solargraph', '123') } before do - allow(real_spec).to receive(:name).and_return('solargraph') configure_bundler_spec(real_spec) end From 84ca5a37b37e0fab11a48cb31f98c660e1da4013 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Wed, 30 Jul 2025 08:09:46 -0400 Subject: [PATCH 226/400] Fix example in spec --- spec/shell_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/shell_spec.rb b/spec/shell_spec.rb index 8a73b291b..3cdc97276 100644 --- a/spec/shell_spec.rb +++ b/spec/shell_spec.rb @@ -141,7 +141,7 @@ def bundle_exec(*cmd) it 'has a well set up test environment' do output = bundle_exec('bundle', 'list') - expect(output).to include('language_server-protocol') + expect(output).to include('reverse_markdown') end it 'caches all without erroring out' do From 2a8f62af3858522b2a7cf7fed691eca7821dec8b Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Thu, 31 Jul 2025 08:53:47 -0400 Subject: [PATCH 227/400] Document gems command --- lib/solargraph/shell.rb | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/lib/solargraph/shell.rb b/lib/solargraph/shell.rb index 2eedca90a..29d397966 100755 --- a/lib/solargraph/shell.rb +++ b/lib/solargraph/shell.rb @@ -109,7 +109,30 @@ def cache gem, version = nil # ' end - desc 'gems [GEM[=VERSION]]', 'Cache documentation for installed gems' + desc 'gems [GEM[=VERSION]...] [STDLIB...] [core]', 'Cache documentation for + installed libraries' + long_desc %( This command will cache the + generated type documentation for the specified libraries. While + Solargraph will generate this on the fly when needed, it takes + time. This command will generate it in advance, which can be + useful for CI scenarios. + + With no arguments, it will cache all libraries in the current + workspace. If a gem or standard library name is specified, it + will cache that library's type documentation. + + An equals sign after a gem will allow a specific gem version + to be cached. + + The 'core' argument can be used to cache the type + documentation for the core Ruby libraries. + + If the library is already cached, it will be rebuilt if the + --rebuild option is set. + + Cached documentation is stored in #{PinCache.base_dir}, which + can be stored between CI runs. + ) option :rebuild, type: :boolean, desc: 'Rebuild existing documentation', default: false # @param names [Array] # @return [void] From 834e5d9f94b089dd129094601f6bfb543860ca4b Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Sun, 3 Aug 2025 19:11:01 -0400 Subject: [PATCH 228/400] Improve test speed --- lib/solargraph/api_map.rb | 23 ---- lib/solargraph/shell.rb | 10 +- lib/solargraph/workspace.rb | 13 +- spec/api_map/api_map_method_spec.rb | 45 ------- spec/api_map_spec.rb | 27 ---- spec/pin_cache_spec.rb | 52 ++++++++ spec/shell_spec.rb | 196 +++++++++------------------- spec/workspace_spec.rb | 37 ++++++ spec/yardoc_spec.rb | 4 +- 9 files changed, 171 insertions(+), 236 deletions(-) diff --git a/lib/solargraph/api_map.rb b/lib/solargraph/api_map.rb index 71169157c..d5fd46dc9 100755 --- a/lib/solargraph/api_map.rb +++ b/lib/solargraph/api_map.rb @@ -196,29 +196,6 @@ def cache_all_for_doc_map! out @doc_map.cache_doc_map_gems!(out) end - # @param out [IO, nil] - # @param rebuild [Boolean] - # @return [void] - def cache_all_for_workspace! out, rebuild: false - workspace&.cache_all_for_workspace!(out, rebuild: rebuild) - end - - # @param name [String] - # @param version [String, nil] - # - # @return [Gem::Specification, nil] - def find_gem name, version = nil - gemspecs.find_gem(name, version) - end - - # @param gemspec [Gem::Specification] - # @param rebuild [Boolean] - # @param out [IO, nil] - # @return [void] - def cache_gem gemspec, rebuild: false, out: nil - @doc_map&.cache(gemspec, rebuild: rebuild, out: out) - end - class << self include Logging end diff --git a/lib/solargraph/shell.rb b/lib/solargraph/shell.rb index 29d397966..8dd74a36f 100755 --- a/lib/solargraph/shell.rb +++ b/lib/solargraph/shell.rb @@ -137,9 +137,11 @@ def cache gem, version = nil # @param names [Array] # @return [void] def gems *names - api_map = ApiMap.load('.') + # print time with ms + workspace = Solargraph::Workspace.new('.') + if names.empty? - api_map.cache_all_for_workspace!($stdout, rebuild: options[:rebuild]) + workspace.cache_all_for_workspace!($stdout, rebuild: options[:rebuild]) else $stderr.puts("Caching these gems: #{names}") names.each do |name| @@ -148,11 +150,11 @@ def gems *names next end - gemspec = api_map.find_gem(*name.split('=')) + gemspec = workspace.find_gem(*name.split('=')) if gemspec.nil? warn "Gem '#{name}' not found" else - api_map.cache_gem(gemspec, rebuild: options[:rebuild], out: $stdout) + workspace.cache_gem(gemspec, rebuild: options[:rebuild], out: $stdout) end end $stderr.puts "Documentation cached for #{names.count} gems." diff --git a/lib/solargraph/workspace.rb b/lib/solargraph/workspace.rb index fa138bf13..6beeddc82 100644 --- a/lib/solargraph/workspace.rb +++ b/lib/solargraph/workspace.rb @@ -198,6 +198,14 @@ def rbs_collection_config_path end end + # @param name [String] + # @param version [String, nil] + # + # @return [Gem::Specification, nil] + def find_gem name, version = nil + gemspecs.find_gem(name, version) + end + # @param out [IO, nil] output stream for logging # @param rebuild [Boolean] whether to rebuild the pins even if they are cached # @return [void] @@ -212,13 +220,13 @@ def cache_all_for_workspace! out, rebuild: false specs.each do |spec| pin_cache.cache_gem(gemspec: spec, rebuild: rebuild, out: out) unless pin_cache.cached?(spec) end - out.puts "Documentation cached for all #{specs.length} gems." + out&.puts "Documentation cached for all #{specs.length} gems." # do this after so that we prefer stdlib requires from gems, # which are likely to be newer and have more pins pin_cache.cache_all_stdlibs(out: out) - out.puts "Documentation cached for core, standard library and gems." + out&.puts "Documentation cached for core, standard library and gems." end # Synchronize the workspace from the provided updater. @@ -292,7 +300,6 @@ def require_plugins def read_rbs_collection_path return unless rbs_collection_config_path - # @sg-ignore path = YAML.load_file(rbs_collection_config_path)&.fetch('path') # make fully qualified File.expand_path(path, directory) diff --git a/spec/api_map/api_map_method_spec.rb b/spec/api_map/api_map_method_spec.rb index 91899a40c..73fc6a35c 100644 --- a/spec/api_map/api_map_method_spec.rb +++ b/spec/api_map/api_map_method_spec.rb @@ -1,51 +1,6 @@ # frozen_string_literal: true describe Solargraph::ApiMap do - describe '#cache_all_for_workspace!' do - context 'with workspace' do - subject(:api_map) { described_class.load(Dir.pwd) } - - let(:out) { StringIO.new } - - it 'processes the request' do - api_map.cache_all_for_workspace!(out, rebuild: false) - - expect(out.string).to include('Documentation cached') - end - end - - context 'with no workspace' do - subject(:api_map) { described_class.new } - - it 'ignores the request' do - expect { api_map.cache_all_for_workspace!(nil, rebuild: false) }.not_to raise_error - end - end - end - - describe '#cache_gem' do - context 'with no workspace' do - subject(:api_map) { described_class.new } - - let(:out) { StringIO.new } - - it 'ignores the request' do - expect { api_map.cache_gem('backport', out: out) }.not_to raise_error - end - end - - context 'with workspace' do - subject(:api_map) { described_class.load(Dir.pwd) } - - let(:out) { StringIO.new } - - it 'processes the request' do - backport = Gem::Specification.find_by_name('backport') - expect { api_map.cache_gem(backport, out: out) }.not_to raise_error - end - end - end - describe '.load_with_cache' do it 'loads the API map with cache' do Solargraph::PinCache.uncache_core diff --git a/spec/api_map_spec.rb b/spec/api_map_spec.rb index 185b30be7..3a3664770 100755 --- a/spec/api_map_spec.rb +++ b/spec/api_map_spec.rb @@ -14,33 +14,6 @@ expect(pins.map(&:path)).to include('String#upcase') end - describe '.load_with_cache' do - context 'without core already cached' do - before do - Solargraph::PinCache.uncache_core(out: nil) - end - - it 'automatically caches core' do - api_map = described_class.load_with_cache(Dir.pwd, out: nil) - pins = api_map.get_methods('String') - expect(pins.map(&:path)).to include('String#upcase') - end - end - - context 'without gem already cached' do - before do - gemspec = @api_map.find_gem('rubocop') # rubocop:disable RSpec/InstanceVariable - @api_map.workspace.uncache_gem(gemspec) - end - - it 'automatically caches gems' do - api_map = described_class.load_with_cache(Dir.pwd, out: nil) - pins = api_map.get_methods('RuboCop::Cop::Base') - expect(pins.map(&:path)).to include('RuboCop::Cop::Base#active_support_extensions_enabled?') - end - end - end - it 'returns core classes' do pins = @api_map.get_constants('') expect(pins.map(&:path)).to include('String') diff --git a/spec/pin_cache_spec.rb b/spec/pin_cache_spec.rb index 825f0facb..0f507e286 100644 --- a/spec/pin_cache_spec.rb +++ b/spec/pin_cache_spec.rb @@ -11,6 +11,35 @@ yard_plugins: []) end + describe '#cached?' do + it 'returns true for a gem that is cached' do + gemspec = Gem::Specification.find_by_name('backport') + expect(pin_cache.cached?(gemspec)).to be true + end + + it 'returns false for a gem that is not cached' do + gemspec = Gem::Specification.new.tap do |spec| + spec.name = 'nonexistent' + spec.version = '0.0.1' + end + expect(pin_cache.cached?(gemspec)).to be false + end + end + + describe '.core?' do + it 'returns true when core pins exist' do + allow(File).to receive(:file?).with(%r{.*/core.ser$}).and_return(true) + + expect(described_class.core?).to be true + end + + it "returns true when core pins don't" do + allow(File).to receive(:file?).with(%r{.*/core.ser$}).and_return(false) + + expect(described_class.core?).to be false + end + end + describe '#possible_stdlibs' do it 'is tolerant of less usual Ruby installations' do stub_const('Gem::RUBYGEMS_DIR', nil) @@ -19,6 +48,16 @@ end end + describe '#cache_all_stdlibs' do + it 'creates stdlibmaps' do + allow(Solargraph::RbsMap::StdlibMap).to receive(:new).and_return(instance_double(Solargraph::RbsMap::StdlibMap)) + + pin_cache.cache_all_stdlibs + + expect(Solargraph::RbsMap::StdlibMap).to have_received(:new).at_least(:once) + end + end + describe '#cache_gem' do context 'with an already in-memory gem' do let(:backport_gemspec) { Gem::Specification.find_by_name('backport') } @@ -50,6 +89,19 @@ end end + context 'with the rebuild flag' do + before do + allow(Solargraph::Yardoc).to receive(:build_docs) + end + + it 'chooses not to use YARD' do + parser_gemspec = Gem::Specification.find_by_name('parser') + pin_cache.cache_gem(gemspec: parser_gemspec, rebuild: true, out: nil) + # if this fails, you may not have run `bundle exec rbs collection update` + expect(Solargraph::Yardoc).not_to have_received(:build_docs) + end + end + context 'with a stdlib gem' do let(:gem_name) { 'logger' } diff --git a/spec/shell_spec.rb b/spec/shell_spec.rb index 3cdc97276..3861b9e57 100644 --- a/spec/shell_spec.rb +++ b/spec/shell_spec.rb @@ -4,37 +4,19 @@ require 'open3' describe Solargraph::Shell do - let(:shell) { described_class.new } - - let(:temp_dir) { Dir.mktmpdir } - - before do - File.open(File.join(temp_dir, 'Gemfile'), 'w') do |file| - file.puts "source 'https://rubygems.org'" - file.puts "gem 'solargraph', path: '#{File.expand_path('..', __dir__)}'" - end - Bundler.with_unbundled_env do - output, status = Open3.capture2e('bundle install', chdir: temp_dir) - raise "Failure installing bundle: #{output}" unless status.success? - end - end + let(:shell) { described_class.new } # @type cmd [Array] # @return [String] def bundle_exec(*cmd) # run the command in the temporary directory with bundle exec Bundler.with_unbundled_env do - output, status = Open3.capture2e("bundle exec #{cmd.join(' ')}", chdir: temp_dir) + output, status = Open3.capture2e("bundle exec #{cmd.join(' ')}") expect(status.success?).to be(true), "Command failed: #{output}" output end end - after do - # remove the temporary directory after the tests - FileUtils.rm_rf(temp_dir) - end - describe '--version' do let(:output) { bundle_exec('solargraph', '--version') } @@ -66,139 +48,101 @@ def bundle_exec(*cmd) end describe 'scan' do - it 'scans without erroring out' do - output = capture_stdout do - shell.options = { directory: 'spec/fixtures/workspace' } - shell.scan - end + context 'with mocked dependencies' do + let(:api_map) { instance_double(Solargraph::ApiMap) } - expect(output).to include('Scanned ').and include(' seconds.') - end - end - - describe 'typecheck' do - it 'typechecks without erroring out' do - output = capture_stdout do - old_options = shell.options - shell.options = { level: 'normal', directory: '.', **old_options } - shell.typecheck('Gemfile') + before do + allow(Solargraph::ApiMap).to receive(:load_with_cache).and_return(api_map) end - expect(output).to include('Typecheck finished in') - end + it 'scans without erroring out' do + allow(api_map).to receive(:pins).and_return([]) + output = capture_stdout do + shell.options = { directory: 'spec/fixtures/workspace' } + shell.scan + end - it 'caches a gem if needed before typechecking' do - capture_both do - shell.uncache('backport') + expect(output).to include('Scanned ').and include(' seconds.') end - - output = capture_both do - shell.options = { level: 'normal', directory: Dir.pwd } - shell.typecheck('Gemfile') - end - - expect(output).to include('Caching ').and include('backport') end + end - it 'logs if it takes a certain amount of time to cache gems' do - capture_both do - shell.uncache('backport') - end + describe 'typecheck' do + context 'with mocked dependencies' do + let(:type_checker) { instance_double(Solargraph::TypeChecker) } + let(:api_map) { instance_double(Solargraph::ApiMap) } - allow_any_instance_of(Solargraph::PinCache) # rubocop:disable RSpec/AnyInstance - .to receive(:cache_gem) - .and_wrap_original do |original, *args, **kwargs| - sleep(0.5) # simulate a slow cache - original.call(*args, **kwargs) + before do + allow(Solargraph::ApiMap).to receive(:load_with_cache).and_return(api_map) + allow(Solargraph::TypeChecker).to receive(:new).and_return(type_checker) + allow(type_checker).to receive(:problems).and_return([]) end - output = capture_both do - shell.options = { level: 'normal', directory: Dir.pwd } - shell.typecheck('Gemfile') - end + it 'typechecks without erroring out' do + output = capture_stdout do + shell.options = { level: 'normal', directory: '.' } + shell.typecheck('Gemfile') + end - expect(output).to include('Built ').and include(' ms') + expect(output).to include('Typecheck finished in') + end end end describe 'gems' do - it 'complains when gem does not exist' do - output = capture_both do - shell.gems('nonexistentgem') - end + context 'without mocked ApiMap' do + it 'complains when gem does not exist' do + output = capture_both do + shell.gems('nonexistentgem') + end - expect(output).to include("Gem 'nonexistentgem' not found") - end - - it 'caches core without erroring out' do - capture_both do - shell.uncache('core') + expect(output).to include("Gem 'nonexistentgem' not found") end - expect { shell.cache('core') }.not_to raise_error - end - - it 'has a well set up test environment' do - output = bundle_exec('bundle', 'list') + it 'caches core without erroring out' do + capture_both do + shell.uncache('core') + end - expect(output).to include('reverse_markdown') - end + expect { shell.cache('core') }.not_to raise_error + end - it 'caches all without erroring out' do - output = bundle_exec('solargraph', 'gems') + it 'gives sensible error for gem that does not exist' do + output = capture_both do + shell.gems('solargraph123') + end - expect(output).to include('Documentation cached for all') + expect(output).to include("Gem 'solargraph123' not found") + end end - it 'caches single gem without erroring out' do - capture_both do - shell.uncache('backport') - end + context 'with mocked Workspace' do + let(:workspace) { instance_double(Solargraph::Workspace) } + let(:gemspec) { instance_double(Gem::Specification, name: 'backport') } - output = capture_both do - shell.gems('backport') + before do + allow(Solargraph::Workspace).to receive(:new).and_return(workspace) end - expect(output).to include('Caching').and include('backport') - end + it 'caches all without erroring out' do + allow(workspace).to receive(:cache_all_for_workspace!) - it 'gives sensible error for gem that does not exist' do - output = capture_both do - shell.gems('solargraph123') - end + _output = capture_both { shell.gems } - expect(output).to include("Gem 'solargraph123' not found") - end - - it 'caches all gems as needed' do - shell = described_class.new - _output = capture_stdout do - shell.uncache('backport') + expect(workspace).to have_received(:cache_all_for_workspace!) end - _output = capture_stdout do - shell.gems - end + it 'caches single gem without erroring out' do + allow(workspace).to receive(:find_gem).with('backport').and_return(gemspec) + allow(workspace).to receive(:cache_gem) - api_map = Solargraph::ApiMap.load(Dir.pwd) - methods = api_map.get_method_stack('Backport::Adapter', 'remote') - expect(methods.first.return_type.tag).to eq('Hash{Symbol => String, Integer}') - end + capture_both do + shell.options = { rebuild: false } + shell.gems('backport') + end - it 'caches a YARD-using gem and loads pins' do - shell = described_class.new - _output = capture_stdout do - shell.uncache('backport') + expect(workspace).to have_received(:cache_gem).with(gemspec, out: an_instance_of(StringIO), rebuild: false) end - - _output = capture_stdout do - shell.options = { rebuild: true } - shell.gems('backport', 'thor') - end - - api_map = Solargraph::ApiMap.load(Dir.pwd) - methods = api_map.get_method_stack('Backport::Adapter', 'remote') - expect(methods.first.return_type.tag).to eq('Hash{Symbol => String, Integer}') end end @@ -215,17 +159,5 @@ def bundle_exec(*cmd) expect { call }.to output(/not found/).to_stderr end end - - it 'caches gem without erroring out' do - _output = capture_stdout do - shell.uncache('backport') - end - - output = capture_both do - shell.cache('backport') - end - - expect(output).to include('Caching').and include('backport') - end end end diff --git a/spec/workspace_spec.rb b/spec/workspace_spec.rb index 2e9203fb7..74d232a31 100644 --- a/spec/workspace_spec.rb +++ b/spec/workspace_spec.rb @@ -128,4 +128,41 @@ Solargraph::Workspace.new('./path', config) }.not_to raise_error end + + describe '#cache_all_for_workspace!' do + let(:pin_cache) { instance_double(Solargraph::PinCache) } + let(:gemspecs) { instance_double(Solargraph::Workspace::Gemspecs) } + + before do + allow(Solargraph::Workspace::Gemspecs).to receive(:new).and_return(gemspecs) + allow(Solargraph::PinCache).to receive(:cache_core) + allow(Solargraph::PinCache).to receive(:possible_stdlibs) + allow(Solargraph::PinCache).to receive(:new).and_return(pin_cache) + allow(pin_cache).to receive(:cache_gem) + allow(pin_cache).to receive(:cache_all_stdlibs) + end + + it 'caches core pins' do + allow(Solargraph::PinCache).to receive(:core?).and_return(false) + allow(gemspecs).to receive(:all_gemspecs_from_bundle).and_return([]) + allow(pin_cache).to receive(:possible_stdlibs).and_return([]) + + workspace.cache_all_for_workspace!(nil, rebuild: false) + + expect(Solargraph::PinCache).to have_received(:cache_core).with(out: nil) + end + + it 'caches gems' do + gemspec = instance_double(Gem::Specification, name: 'test_gem', version: '1.0.0') + allow(Solargraph::PinCache).to receive(:core?).and_return(true) + allow(gemspecs).to receive(:all_gemspecs_from_bundle).and_return([gemspec]) + allow(pin_cache).to receive(:cached?).with(gemspec).and_return(false) + allow(pin_cache).to receive(:possible_stdlibs).and_return([]) + + workspace.cache_all_for_workspace!(nil, rebuild: false) + + expect(pin_cache).to have_received(:cache_gem) + .with(gemspec: gemspec, rebuild: false, out: nil) + end + end end diff --git a/spec/yardoc_spec.rb b/spec/yardoc_spec.rb index 9096ab0e3..7fadab2bf 100644 --- a/spec/yardoc_spec.rb +++ b/spec/yardoc_spec.rb @@ -38,8 +38,8 @@ end describe '#build_docs' do - let(:api_map) { Solargraph::ApiMap.load(Dir.pwd) } - let(:gemspec) { api_map.find_gem('rubocop') } + let(:workspace) { Solargraph::Workspace.new(Dir.pwd) } + let(:gemspec) { workspace.find_gem('rubocop') } let(:output) { '' } before do From 4558a10ac8b7dab9954bae0889994cfa5873e4d4 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Sun, 3 Aug 2025 19:19:21 -0400 Subject: [PATCH 229/400] Fix up .rubocop_todo.yml --- .rubocop_todo.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 3f3f654e9..762cd5dca 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config --no-exclude-limit --no-offense-counts --no-auto-gen-timestamp` -# using RuboCop version 1.79.0. +# using RuboCop version 1.79.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 From 1bf5a448b0c3f279c64ed61e3ab30c0d25d00b3e Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Mon, 4 Aug 2025 08:49:51 -0400 Subject: [PATCH 230/400] Add mocking to spec for reliability --- spec/pin_cache_spec.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/spec/pin_cache_spec.rb b/spec/pin_cache_spec.rb index 0f507e286..96023fa1f 100644 --- a/spec/pin_cache_spec.rb +++ b/spec/pin_cache_spec.rb @@ -13,6 +13,9 @@ describe '#cached?' do it 'returns true for a gem that is cached' do + allow(File).to receive(:file?).with(%r{.*stdlib/backport.ser$}).and_return(false) + allow(File).to receive(:file?).with(%r{.*combined/backport-.*.ser$}).and_return(true) + gemspec = Gem::Specification.find_by_name('backport') expect(pin_cache.cached?(gemspec)).to be true end From 990cf2f8180331f59b07b35aa2a7182bfb0fb674 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Mon, 4 Aug 2025 09:47:41 -0400 Subject: [PATCH 231/400] Revert kwarg change on method used by (specs in) solargraph-rails --- lib/solargraph/api_map.rb | 2 +- lib/solargraph/shell.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/solargraph/api_map.rb b/lib/solargraph/api_map.rb index d5fd46dc9..23146e3b8 100755 --- a/lib/solargraph/api_map.rb +++ b/lib/solargraph/api_map.rb @@ -210,7 +210,7 @@ class << self # @param directory [String] workspace directory # @param out [IO] The output stream for messages # @return [ApiMap] - def self.load_with_cache directory, out: $stderr + def self.load_with_cache directory, out = $stderr api_map = load(directory) if api_map.uncached_gemspecs.empty? logger.info { "All gems cached for #{directory}" } diff --git a/lib/solargraph/shell.rb b/lib/solargraph/shell.rb index 8dd74a36f..7c5ea0fd9 100755 --- a/lib/solargraph/shell.rb +++ b/lib/solargraph/shell.rb @@ -206,7 +206,7 @@ def reporters # @return [void] def typecheck *files directory = File.realpath(options[:directory]) - api_map = Solargraph::ApiMap.load_with_cache(directory, out: $stdout) + api_map = Solargraph::ApiMap.load_with_cache(directory, $stdout) probcount = 0 if files.empty? files = api_map.source_maps.map(&:filename) From daec55a0178381bcad1f2d0b70a13306a9767e0b Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Mon, 4 Aug 2025 10:22:07 -0400 Subject: [PATCH 232/400] Revert kwarg change on method used by (specs in) solargraph-rails --- spec/type_checker/levels/strict_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/type_checker/levels/strict_spec.rb b/spec/type_checker/levels/strict_spec.rb index c92a76874..13c20e85f 100644 --- a/spec/type_checker/levels/strict_spec.rb +++ b/spec/type_checker/levels/strict_spec.rb @@ -59,7 +59,7 @@ def bar(a); end require 'kramdown-parser-gfm' Kramdown::Parser::GFM.undefined_call ), 'test.rb') - api_map = Solargraph::ApiMap.load_with_cache('.', out: nil) + api_map = Solargraph::ApiMap.load_with_cache('.', nil) api_map.catalog Solargraph::Bench.new(source_maps: [source_map], external_requires: ['kramdown-parser-gfm']) checker = Solargraph::TypeChecker.new('test.rb', api_map: api_map, level: :strict) expect(checker.problems).to be_empty From 24cd253c359d3f15e479a052633c1f2d1b73675d Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Mon, 4 Aug 2025 12:42:57 -0400 Subject: [PATCH 233/400] More specs --- spec/library_spec.rb | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/spec/library_spec.rb b/spec/library_spec.rb index 76128fedb..92129db3e 100644 --- a/spec/library_spec.rb +++ b/spec/library_spec.rb @@ -155,6 +155,42 @@ def bar end describe '#references_from' do + it "collects references to a new method on a constant from assignment of Class.new" do + workspace = Solargraph::Workspace.new('*') + library = Solargraph::Library.new(workspace) + src1 = Solargraph::Source.load_string(%( + Foo.new + ), 'file1.rb', 0) + library.merge src1 + src2 = Solargraph::Source.load_string(%( + Foo = Class.new + ), 'file2.rb', 0) + library.merge src2 + library.catalog + locs = library.references_from('file1.rb', 1, 12) + expect(locs.map { |l| [l.filename, l.range.start.line] }) + .to eq([["file1.rb", 1]]) + end + + it "collects references to a new method to a constant from assignment" do + workspace = Solargraph::Workspace.new('*') + library = Solargraph::Library.new(workspace) + src1 = Solargraph::Source.load_string(%( + Foo.new + ), 'file1.rb', 0) + library.merge src1 + src2 = Solargraph::Source.load_string(%( + class Foo + end + blah = Foo.new + ), 'file2.rb', 0) + library.merge src2 + library.catalog + locs = library.references_from('file2.rb', 3, 21) + expect(locs.map { |l| [l.filename, l.range.start.line] }) + .to eq([["file1.rb", 1], ["file2.rb", 3]]) + end + it "collects references to an instance method symbol" do workspace = Solargraph::Workspace.new('*') library = Solargraph::Library.new(workspace) From bf430f091e591b9c8a851f40f04665faf08778cf Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Mon, 4 Aug 2025 17:07:39 -0400 Subject: [PATCH 234/400] Catch potential bad-path issue --- lib/solargraph/yardoc.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/solargraph/yardoc.rb b/lib/solargraph/yardoc.rb index 96e39816e..c117ec856 100644 --- a/lib/solargraph/yardoc.rb +++ b/lib/solargraph/yardoc.rb @@ -21,7 +21,12 @@ def build_docs gem_yardoc_path, yard_plugins, gemspec yard_plugins.each { |plugin| cmd << " --plugin #{plugin}" } Solargraph.logger.debug { "Running: #{cmd}" } # @todo set these up to run in parallel - # + unless File.exist?(gemspec.gem_dir) + Solargraph.logger.info { "Bad info from gemspec - #{gemspec.gem_dir} does not exist" } + Solargraph.logger.info stdout_and_stderr_str + return + end + # @sg-ignore stdout_and_stderr_str, status = Open3.capture2e(current_bundle_env_tweaks, cmd, chdir: gemspec.gem_dir) return if status.success? From 67d3f94518540befcf1732ca149f442bdfc744a3 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Mon, 4 Aug 2025 17:09:37 -0400 Subject: [PATCH 235/400] Drop bad line --- lib/solargraph/yardoc.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/solargraph/yardoc.rb b/lib/solargraph/yardoc.rb index c117ec856..a474c8d17 100644 --- a/lib/solargraph/yardoc.rb +++ b/lib/solargraph/yardoc.rb @@ -23,7 +23,6 @@ def build_docs gem_yardoc_path, yard_plugins, gemspec # @todo set these up to run in parallel unless File.exist?(gemspec.gem_dir) Solargraph.logger.info { "Bad info from gemspec - #{gemspec.gem_dir} does not exist" } - Solargraph.logger.info stdout_and_stderr_str return end From 17883a2549ec72f49341c5555b7876a7fd1bef6c Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Mon, 4 Aug 2025 17:18:26 -0400 Subject: [PATCH 236/400] Fix call to ApiMap --- spec/api_map_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/api_map_spec.rb b/spec/api_map_spec.rb index 3a3664770..573a10e86 100755 --- a/spec/api_map_spec.rb +++ b/spec/api_map_spec.rb @@ -6,7 +6,7 @@ # avoid performance hit of doing this many times # rubocop:disable RSpec/InstanceVariable before :all do # rubocop:disable RSpec/BeforeAfterAll - @api_map = described_class.load_with_cache(Dir.pwd, out: nil) + @api_map = described_class.load_with_cache(Dir.pwd, nil) end it 'returns core methods' do From 0cf4006dd3208b40ce88ced3f7f509f7f0f6581b Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Mon, 4 Aug 2025 17:34:35 -0400 Subject: [PATCH 237/400] Test error andler --- spec/yardoc_spec.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/spec/yardoc_spec.rb b/spec/yardoc_spec.rb index 7fadab2bf..03ae76475 100644 --- a/spec/yardoc_spec.rb +++ b/spec/yardoc_spec.rb @@ -52,6 +52,15 @@ expect(File.exist?(File.join(gem_yardoc_path, 'complete'))).to be true end + it 'bails quietly if directory given does not exist' do + allow(File).to receive(:exist?).and_return(false) + + expect do + described_class.build_docs(gem_yardoc_path, [], gemspec) + end.not_to raise_error + end + + it 'is idempotent' do described_class.build_docs(gem_yardoc_path, [], gemspec) described_class.build_docs(gem_yardoc_path, [], gemspec) # second time From 8a045e29ad42aef8a93da7573f20b90c3148e267 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Mon, 4 Aug 2025 17:37:21 -0400 Subject: [PATCH 238/400] Drop blank line --- spec/yardoc_spec.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/spec/yardoc_spec.rb b/spec/yardoc_spec.rb index 03ae76475..e2fa5b89b 100644 --- a/spec/yardoc_spec.rb +++ b/spec/yardoc_spec.rb @@ -60,7 +60,6 @@ end.not_to raise_error end - it 'is idempotent' do described_class.build_docs(gem_yardoc_path, [], gemspec) described_class.build_docs(gem_yardoc_path, [], gemspec) # second time From dc4f82f786485d4ea5664e6b34fa06460acd5343 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Tue, 5 Aug 2025 08:13:29 -0400 Subject: [PATCH 239/400] Tweak timeout in spec --- spec/library_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/library_spec.rb b/spec/library_spec.rb index 92129db3e..5e5ad577e 100644 --- a/spec/library_spec.rb +++ b/spec/library_spec.rb @@ -44,7 +44,7 @@ def foo(adapter) end ), 'file.rb', 0) completion = nil - Timeout.timeout(10) do + Timeout.timeout(15) do # give Solargraph time to cache the gem while (completion = library.completions_at('file.rb', 5, 19)).pins.empty? sleep 0.25 From 2bf7f31cfec3d65d679486b00d7e0d2072251f3d Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Tue, 5 Aug 2025 12:35:37 -0400 Subject: [PATCH 240/400] Move away from Set due to Ruby 3.0 failure --- lib/solargraph/workspace/gemspecs.rb | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/lib/solargraph/workspace/gemspecs.rb b/lib/solargraph/workspace/gemspecs.rb index e99a751b5..421b4f063 100644 --- a/lib/solargraph/workspace/gemspecs.rb +++ b/lib/solargraph/workspace/gemspecs.rb @@ -109,22 +109,30 @@ def find_gem name, version = nil, out: $stderr def fetch_dependencies gemspec, out: $stderr gemspecs = all_gemspecs_from_bundle + # @type [Hash{String => Gem::Specification}] + deps_so_far = {} + # @param runtime_dep [Gem::Dependency] - # @param deps [Set] - gem_dep_gemspecs = only_runtime_dependencies(gemspec).each_with_object(Set.new) do |runtime_dep, deps| + # @param deps [Hash{String => Gem::Specification}] + gem_dep_gemspecs = only_runtime_dependencies(gemspec).each_with_object(deps_so_far) do |runtime_dep, deps| + next if deps[runtime_dep.name] + Solargraph.logger.info "Adding #{runtime_dep.name} dependency for #{gemspec.name}" dep = gemspecs.find { |dep| dep.name == runtime_dep.name } dep ||= Gem::Specification.find_by_name(runtime_dep.name, runtime_dep.requirement) rescue Gem::MissingSpecError dep = resolve_gem_ignoring_local_bundle runtime_dep.name, out: out ensure - deps.merge fetch_dependencies(dep, out: out) if dep && deps.add?(dep) - end.to_a.compact + next unless dep + + fetch_dependencies(dep, out: out).each { |sub_dep| deps[sub_dep.name] ||= sub_dep } + deps[dep.name] ||= dep + end # RBS tracks implicit dependencies, like how the YAML standard # library implies pulling in the psych library. stdlib_deps = RbsMap::StdlibMap.stdlib_dependencies(gemspec.name, gemspec.version) || [] stdlib_dep_gemspecs = stdlib_deps.map { |dep| find_gem(dep['name'], dep['version']) }.compact - (gem_dep_gemspecs + stdlib_dep_gemspecs).uniq(&:name) + (gem_dep_gemspecs.values.compact + stdlib_dep_gemspecs).uniq(&:name) end # Returns all gemspecs directly depended on by this workspace's From 5c83d0f432c65f3fc07daf527b4542e30b1ca0af Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Tue, 5 Aug 2025 12:41:10 -0400 Subject: [PATCH 241/400] Add new RuboCop failure from new RuboCop --- .rubocop_todo.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 762cd5dca..0d8953664 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config --no-exclude-limit --no-offense-counts --no-auto-gen-timestamp` -# using RuboCop version 1.79.1. +# using RuboCop version 1.79.2. # 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 @@ -2127,6 +2127,7 @@ Style/RedundantInterpolation: # This cop supports safe autocorrection (--autocorrect). Style/RedundantParentheses: Exclude: + - 'lib/solargraph/diagnostics/type_check.rb' - 'lib/solargraph/language_server/message/initialize.rb' - 'lib/solargraph/parser/parser_gem/node_chainer.rb' - 'lib/solargraph/pin/method.rb' From cf532b6158fde64097ad7776d3875bd0473c69eb Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Tue, 19 Aug 2025 11:51:07 -0400 Subject: [PATCH 242/400] Ratchet rubocop todo file --- .rubocop_todo.yml | 172 +--------------------------------------------- 1 file changed, 1 insertion(+), 171 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index f9686413c..9c61d760c 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -107,7 +107,6 @@ Layout/ElseAlignment: # Configuration parameters: EmptyLineBetweenMethodDefs, EmptyLineBetweenClassDefs, EmptyLineBetweenModuleDefs, DefLikeMacros, AllowAdjacentOneLineDefs, NumberOfEmptyLines. Layout/EmptyLineBetweenDefs: Exclude: - - 'lib/solargraph/doc_map.rb' - 'lib/solargraph/language_server/message/initialize.rb' - 'lib/solargraph/pin/delegated_method.rb' @@ -116,7 +115,6 @@ Layout/EmptyLines: Exclude: - 'lib/solargraph/bench.rb' - 'lib/solargraph/complex_type/unique_type.rb' - - 'lib/solargraph/doc_map.rb' - 'lib/solargraph/language_server/message/extended/check_gem_version.rb' - 'lib/solargraph/language_server/message/initialize.rb' - 'lib/solargraph/pin/delegated_method.rb' @@ -252,7 +250,6 @@ Layout/IndentationWidth: - 'lib/solargraph/parser/parser_gem/node_processors/block_node.rb' - 'lib/solargraph/pin/method.rb' - 'lib/solargraph/pin/namespace.rb' - - 'lib/solargraph/rbs_map.rb' - 'lib/solargraph/shell.rb' - 'lib/solargraph/source/chain/call.rb' - 'lib/solargraph/source_map/clip.rb' @@ -306,7 +303,6 @@ Layout/MultilineMethodCallIndentation: # SupportedStyles: aligned, indented Layout/MultilineOperationIndentation: Exclude: - - 'lib/solargraph/api_map.rb' - 'lib/solargraph/language_server/host/dispatch.rb' - 'lib/solargraph/source.rb' @@ -348,7 +344,6 @@ Layout/SpaceAroundOperators: - 'lib/solargraph/source_map/clip.rb' - 'lib/solargraph/workspace/config.rb' - 'spec/library_spec.rb' - - 'spec/yard_map/mapper_spec.rb' # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces. @@ -523,7 +518,6 @@ Lint/DuplicateMethods: - 'lib/solargraph/pin/base.rb' - 'lib/solargraph/pin/signature.rb' - 'lib/solargraph/rbs_map.rb' - - 'lib/solargraph/rbs_map/core_map.rb' - 'lib/solargraph/source/chain/link.rb' # Configuration parameters: AllowComments, AllowEmptyLambdas. @@ -544,6 +538,7 @@ Lint/EmptyClass: # Configuration parameters: AllowComments. Lint/EmptyFile: Exclude: + - '.pryrc' - 'spec/fixtures/vendored/vendor/do_not_use.gemspec' # This cop supports unsafe autocorrection (--autocorrect-all). @@ -644,7 +639,6 @@ Lint/UnusedMethodArgument: - 'lib/solargraph/convention/base.rb' - 'lib/solargraph/diagnostics/base.rb' - 'lib/solargraph/diagnostics/update_errors.rb' - - 'lib/solargraph/doc_map.rb' - 'lib/solargraph/pin/namespace.rb' - 'lib/solargraph/rbs_map/conversions.rb' - 'lib/solargraph/source.rb' @@ -664,12 +658,6 @@ Lint/UnusedMethodArgument: - 'lib/solargraph/source/chain/z_super.rb' - 'spec/doc_map_spec.rb' -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AutoCorrect, ContextCreatingMethods, MethodCreatingMethods. -Lint/UselessAccessModifier: - Exclude: - - 'lib/solargraph/api_map.rb' - # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AutoCorrect. Lint/UselessAssignment: @@ -714,7 +702,6 @@ Metrics/AbcSize: - 'lib/solargraph/api_map.rb' - 'lib/solargraph/api_map/source_to_yard.rb' - 'lib/solargraph/complex_type.rb' - - 'lib/solargraph/doc_map.rb' - 'lib/solargraph/language_server/host.rb' - 'lib/solargraph/language_server/message/initialize.rb' - 'lib/solargraph/library.rb' @@ -785,7 +772,6 @@ Metrics/ModuleLength: Exclude: - 'lib/solargraph/complex_type/type_methods.rb' - 'lib/solargraph/parser/parser_gem/node_methods.rb' - - 'lib/solargraph/pin_cache.rb' # Configuration parameters: Max, CountKeywordArgs, MaxOptionalParameters. Metrics/ParameterLists: @@ -832,7 +818,6 @@ Naming/MemoizedInstanceVariableName: - 'lib/solargraph/convention/gemfile.rb' - 'lib/solargraph/convention/gemspec.rb' - 'lib/solargraph/convention/rakefile.rb' - - 'lib/solargraph/doc_map.rb' - 'lib/solargraph/rbs_map.rb' - 'lib/solargraph/workspace.rb' @@ -886,7 +871,6 @@ Naming/VariableName: RSpec/Be: Exclude: - 'spec/rbs_map/stdlib_map_spec.rb' - - 'spec/rbs_map_spec.rb' - 'spec/source/source_chainer_spec.rb' # This cop supports unsafe autocorrection (--autocorrect-all). @@ -909,7 +893,6 @@ RSpec/BeforeAfterAll: - '**/spec/rails_helper.rb' - '**/spec/support/**/*.rb' - 'spec/api_map_spec.rb' - - 'spec/doc_map_spec.rb' - 'spec/language_server/host/dispatch_spec.rb' - 'spec/language_server/protocol_spec.rb' @@ -922,10 +905,6 @@ RSpec/ContextWording: - 'spec/pin/method_spec.rb' - 'spec/pin/parameter_spec.rb' - 'spec/pin/symbol_spec.rb' - - 'spec/type_checker/levels/normal_spec.rb' - - 'spec/type_checker/levels/strict_spec.rb' - - 'spec/type_checker/levels/strong_spec.rb' - - 'spec/type_checker/levels/typed_spec.rb' # Configuration parameters: IgnoredMetadata. RSpec/DescribeClass: @@ -946,7 +925,6 @@ RSpec/DescribedClass: - 'spec/api_map/cache_spec.rb' - 'spec/api_map/source_to_yard_spec.rb' - 'spec/api_map/store_spec.rb' - - 'spec/api_map_spec.rb' - 'spec/diagnostics/base_spec.rb' - 'spec/diagnostics/require_not_found_spec.rb' - 'spec/diagnostics/rubocop_helpers_spec.rb' @@ -955,7 +933,6 @@ RSpec/DescribedClass: - 'spec/diagnostics/update_errors_spec.rb' - 'spec/diagnostics_spec.rb' - 'spec/doc_map_spec.rb' - - 'spec/gem_pins_spec.rb' - 'spec/language_server/host/diagnoser_spec.rb' - 'spec/language_server/host/dispatch_spec.rb' - 'spec/language_server/host/message_worker_spec.rb' @@ -1101,7 +1078,6 @@ RSpec/ImplicitExpect: RSpec/InstanceVariable: Exclude: - 'spec/api_map/config_spec.rb' - - 'spec/api_map_spec.rb' - 'spec/diagnostics/require_not_found_spec.rb' - 'spec/language_server/host/dispatch_spec.rb' - 'spec/language_server/host_spec.rb' @@ -1140,8 +1116,6 @@ RSpec/MultipleExpectations: - 'spec/diagnostics/type_check_spec.rb' - 'spec/diagnostics/update_errors_spec.rb' - 'spec/diagnostics_spec.rb' - - 'spec/doc_map_spec.rb' - - 'spec/gem_pins_spec.rb' - 'spec/language_server/host/message_worker_spec.rb' - 'spec/language_server/host_spec.rb' - 'spec/language_server/message/completion_item/resolve_spec.rb' @@ -1168,7 +1142,6 @@ RSpec/MultipleExpectations: - 'spec/rbs_map/core_map_spec.rb' - 'spec/rbs_map/stdlib_map_spec.rb' - 'spec/rbs_map_spec.rb' - - 'spec/shell_spec.rb' - 'spec/source/chain/call_spec.rb' - 'spec/source/chain/class_variable_spec.rb' - 'spec/source/chain/global_variable_spec.rb' @@ -1215,7 +1188,6 @@ RSpec/NoExpectationExample: # SupportedStyles: not_to, to_not RSpec/NotToNot: Exclude: - - 'spec/api_map_spec.rb' - 'spec/rbs_map/core_map_spec.rb' RSpec/PendingWithoutReason: @@ -1251,7 +1223,6 @@ RSpec/RemoveConst: RSpec/RepeatedDescription: Exclude: - - 'spec/api_map_spec.rb' - 'spec/language_server/protocol_spec.rb' - 'spec/parser/node_methods_spec.rb' - 'spec/source/chain/call_spec.rb' @@ -1275,107 +1246,6 @@ RSpec/ScatteredLet: Exclude: - 'spec/complex_type_spec.rb' -# Configuration parameters: Include, CustomTransform, IgnoreMethods, IgnoreMetadata. -# Include: **/*_spec.rb -RSpec/SpecFilePathFormat: - Exclude: - - '**/spec/routing/**/*' - - 'spec/api_map/cache_spec.rb' - - 'spec/api_map/config_spec.rb' - - 'spec/api_map/source_to_yard_spec.rb' - - 'spec/api_map/store_spec.rb' - - 'spec/api_map_spec.rb' - - 'spec/convention/activesupport_concern_spec.rb' - - 'spec/convention/struct_definition_spec.rb' - - 'spec/convention_spec.rb' - - 'spec/diagnostics/base_spec.rb' - - 'spec/diagnostics/require_not_found_spec.rb' - - 'spec/diagnostics/rubocop_helpers_spec.rb' - - 'spec/diagnostics/rubocop_spec.rb' - - 'spec/diagnostics/type_check_spec.rb' - - 'spec/diagnostics/update_errors_spec.rb' - - 'spec/diagnostics_spec.rb' - - 'spec/doc_map_spec.rb' - - 'spec/gem_pins_spec.rb' - - 'spec/language_server/host/diagnoser_spec.rb' - - 'spec/language_server/host/dispatch_spec.rb' - - 'spec/language_server/host/message_worker_spec.rb' - - 'spec/language_server/host_spec.rb' - - 'spec/language_server/message/completion_item/resolve_spec.rb' - - 'spec/language_server/message/extended/check_gem_version_spec.rb' - - 'spec/language_server/message/initialize_spec.rb' - - 'spec/language_server/message/text_document/definition_spec.rb' - - 'spec/language_server/message/text_document/formatting_spec.rb' - - 'spec/language_server/message/text_document/hover_spec.rb' - - 'spec/language_server/message/text_document/rename_spec.rb' - - 'spec/language_server/message/text_document/type_definition_spec.rb' - - 'spec/language_server/message/workspace/did_change_configuration_spec.rb' - - 'spec/language_server/message/workspace/did_change_watched_files_spec.rb' - - 'spec/language_server/message_spec.rb' - - 'spec/language_server/transport/adapter_spec.rb' - - 'spec/language_server/transport/data_reader_spec.rb' - - 'spec/language_server/uri_helpers_spec.rb' - - 'spec/library_spec.rb' - - 'spec/logging_spec.rb' - - 'spec/parser/flow_sensitive_typing_spec.rb' - - 'spec/parser/node_methods_spec.rb' - - 'spec/parser/node_processor_spec.rb' - - 'spec/parser_spec.rb' - - 'spec/pin/base_spec.rb' - - 'spec/pin/base_variable_spec.rb' - - 'spec/pin/block_spec.rb' - - 'spec/pin/constant_spec.rb' - - 'spec/pin/delegated_method_spec.rb' - - 'spec/pin/documenting_spec.rb' - - 'spec/pin/instance_variable_spec.rb' - - 'spec/pin/keyword_spec.rb' - - 'spec/pin/local_variable_spec.rb' - - 'spec/pin/method_spec.rb' - - 'spec/pin/namespace_spec.rb' - - 'spec/pin/parameter_spec.rb' - - 'spec/pin/search_spec.rb' - - 'spec/pin/symbol_spec.rb' - - 'spec/position_spec.rb' - - 'spec/rbs_map/conversions_spec.rb' - - 'spec/rbs_map/core_map_spec.rb' - - 'spec/rbs_map/stdlib_map_spec.rb' - - 'spec/rbs_map_spec.rb' - - 'spec/shell_spec.rb' - - 'spec/source/chain/array_spec.rb' - - 'spec/source/chain/call_spec.rb' - - 'spec/source/chain/class_variable_spec.rb' - - 'spec/source/chain/constant_spec.rb' - - 'spec/source/chain/global_variable_spec.rb' - - 'spec/source/chain/head_spec.rb' - - 'spec/source/chain/instance_variable_spec.rb' - - 'spec/source/chain/link_spec.rb' - - 'spec/source/chain/literal_spec.rb' - - 'spec/source/chain/z_super_spec.rb' - - 'spec/source/chain_spec.rb' - - 'spec/source/change_spec.rb' - - 'spec/source/cursor_spec.rb' - - 'spec/source/source_chainer_spec.rb' - - 'spec/source/updater_spec.rb' - - 'spec/source_map/clip_spec.rb' - - 'spec/source_map/mapper_spec.rb' - - 'spec/source_map_spec.rb' - - 'spec/source_spec.rb' - - 'spec/type_checker/checks_spec.rb' - - 'spec/type_checker/levels/normal_spec.rb' - - 'spec/type_checker/levels/strict_spec.rb' - - 'spec/type_checker/levels/strong_spec.rb' - - 'spec/type_checker/levels/typed_spec.rb' - - 'spec/type_checker/rules_spec.rb' - - 'spec/type_checker_spec.rb' - - 'spec/workspace/config_spec.rb' - - 'spec/workspace_spec.rb' - - 'spec/yard_map/mapper/to_method_spec.rb' - - 'spec/yard_map/mapper_spec.rb' - -RSpec/StubbedMock: - Exclude: - - 'spec/language_server/host/message_worker_spec.rb' - # Configuration parameters: IgnoreNameless, IgnoreSymbolicNames. RSpec/VerifiedDoubles: Exclude: @@ -1774,7 +1644,6 @@ Style/FrozenStringLiteralComment: - 'spec/api_map/cache_spec.rb' - 'spec/api_map/config_spec.rb' - 'spec/api_map/source_to_yard_spec.rb' - - 'spec/api_map_spec.rb' - 'spec/complex_type_spec.rb' - 'spec/convention/struct_definition_spec.rb' - 'spec/convention_spec.rb' @@ -1846,7 +1715,6 @@ Style/FrozenStringLiteralComment: - 'spec/rbs_map/core_map_spec.rb' - 'spec/rbs_map/stdlib_map_spec.rb' - 'spec/rbs_map_spec.rb' - - 'spec/shell_spec.rb' - 'spec/source/chain/array_spec.rb' - 'spec/source/chain/call_spec.rb' - 'spec/source/chain/class_variable_spec.rb' @@ -1895,7 +1763,6 @@ Style/GuardClause: - 'lib/solargraph/api_map.rb' - 'lib/solargraph/library.rb' - 'lib/solargraph/parser/parser_gem/node_processors/send_node.rb' - - 'lib/solargraph/pin_cache.rb' - 'lib/solargraph/range.rb' - 'lib/solargraph/rbs_map/conversions.rb' - 'lib/solargraph/source.rb' @@ -1945,17 +1812,12 @@ Style/IfInsideElse: # This cop supports safe autocorrection (--autocorrect). Style/IfUnlessModifier: Exclude: - - 'lib/solargraph/api_map.rb' - - 'lib/solargraph/api_map/index.rb' - 'lib/solargraph/complex_type.rb' - 'lib/solargraph/complex_type/unique_type.rb' - - 'lib/solargraph/doc_map.rb' - 'lib/solargraph/language_server/message/completion_item/resolve.rb' - 'lib/solargraph/language_server/message/initialize.rb' - 'lib/solargraph/language_server/message/text_document/completion.rb' - 'lib/solargraph/language_server/message/text_document/hover.rb' - - 'lib/solargraph/library.rb' - - 'lib/solargraph/parser/parser_gem/class_methods.rb' - 'lib/solargraph/parser/parser_gem/node_chainer.rb' - 'lib/solargraph/parser/parser_gem/node_methods.rb' - 'lib/solargraph/parser/parser_gem/node_processors/sclass_node.rb' @@ -1976,7 +1838,6 @@ Style/IfUnlessModifier: - 'lib/solargraph/source_map/clip.rb' - 'lib/solargraph/source_map/mapper.rb' - 'lib/solargraph/type_checker.rb' - - 'lib/solargraph/workspace.rb' - 'lib/solargraph/workspace/config.rb' - 'lib/solargraph/yard_map/helpers.rb' - 'lib/solargraph/yard_map/mapper/to_method.rb' @@ -2026,7 +1887,6 @@ Style/MethodDefParentheses: - 'lib/solargraph/convention/struct_definition/struct_assignment_node.rb' - 'lib/solargraph/convention/struct_definition/struct_definition_node.rb' - 'lib/solargraph/diagnostics/rubocop_helpers.rb' - - 'lib/solargraph/doc_map.rb' - 'lib/solargraph/equality.rb' - 'lib/solargraph/gem_pins.rb' - 'lib/solargraph/language_server/host/message_worker.rb' @@ -2063,7 +1923,6 @@ Style/MethodDefParentheses: - 'lib/solargraph/type_checker.rb' - 'lib/solargraph/type_checker/checks.rb' - 'lib/solargraph/yard_map/helpers.rb' - - 'lib/solargraph/yardoc.rb' - 'spec/doc_map_spec.rb' - 'spec/fixtures/rdoc-lib/lib/example.rb' - 'spec/source_map_spec.rb' @@ -2071,7 +1930,6 @@ Style/MethodDefParentheses: - 'spec/type_checker/levels/normal_spec.rb' - 'spec/type_checker/levels/strict_spec.rb' - 'spec/type_checker/levels/strong_spec.rb' - - 'spec/type_checker/levels/typed_spec.rb' Style/MultilineBlockChain: Exclude: @@ -2130,13 +1988,6 @@ Style/NegatedIfElseCondition: - 'lib/solargraph/shell.rb' - 'lib/solargraph/type_checker.rb' -# This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AllowedMethods. -# AllowedMethods: be, be_a, be_an, be_between, be_falsey, be_kind_of, be_instance_of, be_truthy, be_within, eq, eql, end_with, include, match, raise_error, respond_to, start_with -Style/NestedParenthesizedCalls: - Exclude: - - 'lib/solargraph/type_checker.rb' - # This cop supports safe autocorrection (--autocorrect). Style/NestedTernaryOperator: Exclude: @@ -2232,7 +2083,6 @@ Style/RedundantBegin: - 'lib/solargraph/shell.rb' - 'lib/solargraph/source/cursor.rb' - 'lib/solargraph/source/encoding_fixes.rb' - - 'lib/solargraph/type_checker.rb' - 'lib/solargraph/workspace.rb' # This cop supports safe autocorrection (--autocorrect). @@ -2246,12 +2096,6 @@ Style/RedundantFreeze: - 'lib/solargraph/complex_type.rb' - 'lib/solargraph/source_map/mapper.rb' -# This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: AutoCorrect, AllowComments. -Style/RedundantInitialize: - Exclude: - - 'lib/solargraph/rbs_map/core_map.rb' - # This cop supports unsafe autocorrection (--autocorrect-all). Style/RedundantInterpolation: Exclude: @@ -2295,7 +2139,6 @@ Style/RedundantReturn: Exclude: - 'lib/solargraph/api_map.rb' - 'lib/solargraph/complex_type/type_methods.rb' - - 'lib/solargraph/doc_map.rb' - 'lib/solargraph/parser/parser_gem/node_methods.rb' - 'lib/solargraph/source/chain/z_super.rb' @@ -2332,7 +2175,6 @@ Style/RescueStandardError: Style/SafeNavigation: Exclude: - 'lib/solargraph/api_map/index.rb' - - 'lib/solargraph/doc_map.rb' - 'lib/solargraph/language_server/message/completion_item/resolve.rb' - 'lib/solargraph/language_server/request.rb' - 'lib/solargraph/language_server/transport/data_reader.rb' @@ -2340,15 +2182,9 @@ Style/SafeNavigation: - 'lib/solargraph/pin/base.rb' - 'lib/solargraph/pin/conversions.rb' - 'lib/solargraph/pin/method.rb' - - 'lib/solargraph/pin_cache.rb' - 'lib/solargraph/range.rb' - 'lib/solargraph/type_checker.rb' -# Configuration parameters: Max. -Style/SafeNavigationChainLength: - Exclude: - - 'lib/solargraph/doc_map.rb' - # This cop supports unsafe autocorrection (--autocorrect-all). Style/SlicingWithRange: Exclude: @@ -2413,7 +2249,6 @@ Style/StringLiterals: - 'lib/solargraph/complex_type.rb' - 'lib/solargraph/complex_type/unique_type.rb' - 'lib/solargraph/convention/struct_definition.rb' - - 'lib/solargraph/doc_map.rb' - 'lib/solargraph/language_server/host.rb' - 'lib/solargraph/language_server/message/extended/document_gems.rb' - 'lib/solargraph/language_server/message/extended/download_core.rb' @@ -2648,7 +2483,6 @@ YARD/MismatchName: Exclude: - 'lib/solargraph/complex_type.rb' - 'lib/solargraph/complex_type/unique_type.rb' - - 'lib/solargraph/gem_pins.rb' - 'lib/solargraph/language_server/host.rb' - 'lib/solargraph/language_server/host/dispatch.rb' - 'lib/solargraph/language_server/request.rb' @@ -2691,7 +2525,6 @@ Layout/LineLength: - 'lib/solargraph/complex_type.rb' - 'lib/solargraph/complex_type/unique_type.rb' - 'lib/solargraph/convention/data_definition.rb' - - 'lib/solargraph/doc_map.rb' - 'lib/solargraph/gem_pins.rb' - 'lib/solargraph/language_server/host.rb' - 'lib/solargraph/language_server/message/extended/check_gem_version.rb' @@ -2736,10 +2569,8 @@ Layout/LineLength: - 'lib/solargraph/source_map/clip.rb' - 'lib/solargraph/source_map/mapper.rb' - 'lib/solargraph/type_checker.rb' - - 'lib/solargraph/workspace.rb' - 'lib/solargraph/workspace/config.rb' - 'lib/solargraph/yard_map/mapper/to_method.rb' - - 'spec/api_map_spec.rb' - 'spec/complex_type_spec.rb' - 'spec/language_server/message/completion_item/resolve_spec.rb' - 'spec/language_server/message/extended/check_gem_version_spec.rb' @@ -2749,4 +2580,3 @@ Layout/LineLength: - 'spec/source/chain_spec.rb' - 'spec/source_map/clip_spec.rb' - 'spec/source_map_spec.rb' - - 'spec/workspace_spec.rb' From 07e8fde1778744630d5df052ff8525f885f98978 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Tue, 19 Aug 2025 11:56:50 -0400 Subject: [PATCH 243/400] Bump pin caching --- spec/library_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/library_spec.rb b/spec/library_spec.rb index 7d2a2fef7..0cf6084e9 100644 --- a/spec/library_spec.rb +++ b/spec/library_spec.rb @@ -44,7 +44,7 @@ def foo(adapter) end ), 'file.rb', 0) completion = nil - Timeout.timeout(20) do + Timeout.timeout(25) do # give Solargraph time to cache the gem while (completion = library.completions_at('file.rb', 5, 19)).pins.empty? sleep 0.25 From 30c2831cc0efa80c38d6d5c7da4ed19ef8618fa0 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Tue, 19 Aug 2025 12:16:21 -0400 Subject: [PATCH 244/400] Drop .pryrc from file --- .rubocop_todo.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 9c61d760c..bfdba89a7 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -538,7 +538,6 @@ Lint/EmptyClass: # Configuration parameters: AllowComments. Lint/EmptyFile: Exclude: - - '.pryrc' - 'spec/fixtures/vendored/vendor/do_not_use.gemspec' # This cop supports unsafe autocorrection (--autocorrect-all). From c208f5c99d7e12d5c778d3290a5ee32c9f905b1b Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Tue, 19 Aug 2025 12:31:37 -0400 Subject: [PATCH 245/400] Drop dead code --- lib/solargraph/pin_cache.rb | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/lib/solargraph/pin_cache.rb b/lib/solargraph/pin_cache.rb index 2c4649cda..0f49290d3 100644 --- a/lib/solargraph/pin_cache.rb +++ b/lib/solargraph/pin_cache.rb @@ -639,18 +639,6 @@ def core? def cache_core out: $stderr RbsMap::CoreMap.new.cache_core(out: out) end - - # @return [Array, nil] - def load_core - load(core_path) - end - - private - - # @param path [String] - def exist? *path - File.file? File.join(*path) - end end end end From eb25912754e69f6dc9258a1f80e5cdae3bd02411 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Tue, 19 Aug 2025 13:22:15 -0400 Subject: [PATCH 246/400] Debug --- spec/pin_cache_spec.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/pin_cache_spec.rb b/spec/pin_cache_spec.rb index 96023fa1f..41434e1f4 100644 --- a/spec/pin_cache_spec.rb +++ b/spec/pin_cache_spec.rb @@ -88,7 +88,7 @@ parser_gemspec = Gem::Specification.find_by_name('parser') pin_cache.cache_gem(gemspec: parser_gemspec, out: nil) # if this fails, you may not have run `bundle exec rbs collection update` - expect(Solargraph::Yardoc).not_to have_received(:build_docs) + expect(Solargraph::Yardoc).not_to have_received(:build_docs).with(any_args) end end @@ -101,7 +101,7 @@ parser_gemspec = Gem::Specification.find_by_name('parser') pin_cache.cache_gem(gemspec: parser_gemspec, rebuild: true, out: nil) # if this fails, you may not have run `bundle exec rbs collection update` - expect(Solargraph::Yardoc).not_to have_received(:build_docs) + expect(Solargraph::Yardoc).not_to have_received(:build_docs).with(any_args) end end @@ -137,7 +137,7 @@ pin_cache.cache_gem(gemspec: yaml_gemspec, out: nil) # match arguments with regexp using rspec-matchers syntax - expect(File).to have_received(:write).with(%r{combined/base64-.*-export.ser$}, any_args).once + expect(File).to have_received(:write).with(%r{combined/base64-.*-export.ser$}, any_args, mode: 'wb').once end end end From 81f6b1c7cb880add7fbfda17d08d448c9b01dce9 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Tue, 19 Aug 2025 14:00:16 -0400 Subject: [PATCH 247/400] Ensure rbs collection update is run in rspec tests --- .github/workflows/rspec.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/rspec.yml b/.github/workflows/rspec.yml index 37068f0d7..44a008f8c 100644 --- a/.github/workflows/rspec.yml +++ b/.github/workflows/rspec.yml @@ -47,7 +47,8 @@ jobs: - name: Install gems run: | bundle install - bundle update rbs # use latest available for this Ruby version + - name: Install types + run: bundle exec rbs collection update - name: Run tests run: bundle exec rake spec undercover: From dbacbe51bd65efef83f6c9e52af5454c54aa0e18 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Tue, 19 Aug 2025 14:06:01 -0400 Subject: [PATCH 248/400] Exclude a test combination --- .github/workflows/rspec.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/rspec.yml b/.github/workflows/rspec.yml index 44a008f8c..e97224f7a 100644 --- a/.github/workflows/rspec.yml +++ b/.github/workflows/rspec.yml @@ -23,12 +23,15 @@ jobs: matrix: ruby-version: ['3.0', '3.1', '3.2', '3.3', '3.4', 'head'] rbs-version: ['3.6.1', '3.9.4', '4.0.0.dev.4'] - # Ruby 3.0 doesn't work with RBS 3.9.4 or 4.0.0.dev.4 exclude: + # Ruby 3.0 doesn't work with RBS 3.9.4 or 4.0.0.dev.4 - ruby-version: '3.0' rbs-version: '3.9.4' - ruby-version: '3.0' rbs-version: '4.0.0.dev.4' + # Missing require in 'rbs collection update' + - ruby-version: 'head' + rbs-version: '4.0.0.dev.4' steps: - uses: actions/checkout@v3 - name: Set up Ruby From 09062ceca6a9398d12316346c7d4a4d03858d8b6 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Tue, 19 Aug 2025 14:26:40 -0400 Subject: [PATCH 249/400] Update excluded scenarios --- .github/workflows/rspec.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/rspec.yml b/.github/workflows/rspec.yml index e97224f7a..a025d5eee 100644 --- a/.github/workflows/rspec.yml +++ b/.github/workflows/rspec.yml @@ -29,9 +29,14 @@ jobs: rbs-version: '3.9.4' - ruby-version: '3.0' rbs-version: '4.0.0.dev.4' - # Missing require in 'rbs collection update' + # Missing require in 'rbs collection update' - hopefully + # fixed in next RBS release - ruby-version: 'head' rbs-version: '4.0.0.dev.4' + - ruby-version: 'head' + rbs-version: '3.9.4' + - ruby-version: 'head' + rbs-version: '3.6.1' steps: - uses: actions/checkout@v3 - name: Set up Ruby From 35ff86b2486ff64c9c794d37ece9cc33afb0e3b0 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Tue, 19 Aug 2025 15:53:35 -0400 Subject: [PATCH 250/400] Fix missing coverage --- lib/solargraph/pin_cache.rb | 10 ---------- spec/pin_cache_spec.rb | 15 ++++++++++++++- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/lib/solargraph/pin_cache.rb b/lib/solargraph/pin_cache.rb index 0f49290d3..b9f384438 100644 --- a/lib/solargraph/pin_cache.rb +++ b/lib/solargraph/pin_cache.rb @@ -1,4 +1,3 @@ -require 'yard-activesupport-concern' require 'fileutils' require 'rbs' require 'rubygems' @@ -466,15 +465,6 @@ def work_dir File.join(base_dir, "ruby-#{RUBY_VERSION}", "rbs-#{RBS::VERSION}", "solargraph-#{Solargraph::VERSION}") end - # @param gemspec [Gem::Specification] - # @return [String] - def yardoc_path gemspec - File.join(base_dir, - "yard-#{YARD::VERSION}", - "yard-activesupport-concern-#{YARD::ActiveSupport::Concern::VERSION}", - "#{gemspec.name}-#{gemspec.version}.yardoc") - end - # @return [String] def stdlib_path File.join(work_dir, 'stdlib') diff --git a/spec/pin_cache_spec.rb b/spec/pin_cache_spec.rb index 41434e1f4..3370f1fd1 100644 --- a/spec/pin_cache_spec.rb +++ b/spec/pin_cache_spec.rb @@ -8,7 +8,7 @@ described_class.new(rbs_collection_path: '.gem_rbs_collection', rbs_collection_config_path: 'rbs_collection.yaml', directory: Dir.pwd, - yard_plugins: []) + yard_plugins: ['activesupport-concern']) end describe '#cached?' do @@ -92,6 +92,19 @@ end end + context 'with an installed gem' do + before do + Solargraph::Shell.new.gems('kramdown') + end + + it 'uncaches when asked' do + gemspec = Gem::Specification.find_by_name('kramdown') + expect do + pin_cache.uncache_gem(gemspec, out: nil) + end.not_to raise_error + end + end + context 'with the rebuild flag' do before do allow(Solargraph::Yardoc).to receive(:build_docs) From 542bcb78969f60d27d4f3cce899fd4041d9c407d Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Tue, 19 Aug 2025 16:13:12 -0400 Subject: [PATCH 251/400] Fix spec --- spec/pin_cache_spec.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/pin_cache_spec.rb b/spec/pin_cache_spec.rb index 3370f1fd1..0a11686f5 100644 --- a/spec/pin_cache_spec.rb +++ b/spec/pin_cache_spec.rb @@ -14,7 +14,7 @@ describe '#cached?' do it 'returns true for a gem that is cached' do allow(File).to receive(:file?).with(%r{.*stdlib/backport.ser$}).and_return(false) - allow(File).to receive(:file?).with(%r{.*combined/backport-.*.ser$}).and_return(true) + allow(File).to receive(:file?).with(%r{.*combined/.*/backport-.*.ser$}).and_return(true) gemspec = Gem::Specification.find_by_name('backport') expect(pin_cache.cached?(gemspec)).to be true @@ -132,7 +132,7 @@ pin_cache.cache_gem(gemspec: yaml_gemspec, out: nil) # match arguments with regexp using rspec-matchers syntax - expect(File).to have_received(:write).with(%r{combined/logger-.*-stdlib.ser$}, any_args).once + expect(File).to have_received(:write).with(%r{combined/.*/logger-.*-stdlib.ser$}, any_args).once end end @@ -150,7 +150,7 @@ pin_cache.cache_gem(gemspec: yaml_gemspec, out: nil) # match arguments with regexp using rspec-matchers syntax - expect(File).to have_received(:write).with(%r{combined/base64-.*-export.ser$}, any_args, mode: 'wb').once + expect(File).to have_received(:write).with(%r{combined/.*/base64-.*-export.ser$}, any_args, mode: 'wb').once end end end From b0f05177b0b13fcf61f81dac2d2a6004b714c7bc Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Tue, 19 Aug 2025 17:24:29 -0400 Subject: [PATCH 252/400] Debug --- .github/workflows/plugins.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/plugins.yml b/.github/workflows/plugins.yml index b0f22ec3e..29baec75f 100644 --- a/.github/workflows/plugins.yml +++ b/.github/workflows/plugins.yml @@ -29,14 +29,15 @@ jobs: echo 'gem "solargraph-rails"' > .Gemfile echo 'gem "solargraph-rspec"' >> .Gemfile bundle install + bundle update rbs - name: Configure to use plugins run: | bundle exec solargraph config yq -yi '.plugins += ["solargraph-rails"]' .solargraph.yml yq -yi '.plugins += ["solargraph-rspec"]' .solargraph.yml - name: Install gem types - run: bundle exec rbs collection install + run: bundle exec rbs collection update - name: Ensure typechecking still works run: bundle exec solargraph typecheck --level typed - name: Ensure specs still run - run: bundle exec rake spec + run: bundle exec rspec From 68b294a1f2c26ac013ea7585ba6b27825fae03e4 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Tue, 19 Aug 2025 17:24:54 -0400 Subject: [PATCH 253/400] Debug --- .github/workflows/plugins.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/plugins.yml b/.github/workflows/plugins.yml index 29baec75f..3afb0bb44 100644 --- a/.github/workflows/plugins.yml +++ b/.github/workflows/plugins.yml @@ -40,4 +40,4 @@ jobs: - name: Ensure typechecking still works run: bundle exec solargraph typecheck --level typed - name: Ensure specs still run - run: bundle exec rspec + run: bundle exec rspec --fail-fast From c2689739e511b25cdfa807369eb72e736b8aa8a9 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Wed, 20 Aug 2025 09:10:25 -0400 Subject: [PATCH 254/400] Fix rspec integration --- spec/doc_map_spec.rb | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/spec/doc_map_spec.rb b/spec/doc_map_spec.rb index fe06277eb..2ea86e7f9 100644 --- a/spec/doc_map_spec.rb +++ b/spec/doc_map_spec.rb @@ -39,7 +39,18 @@ end it 'tracks unresolved requires' do - expect(doc_map.unresolved_requires).to eq(['not_a_gem']) + # These are auto-required by solargraph-rspec in case the bundle + # includes these gems. In our case, it doesn't! + unprovided_solargraph_rspec_requires = [ + 'rspec-rails', + 'actionmailer', + 'activerecord', + 'shoulda-matchers', + 'rspec-sidekiq', + 'airborne' + ] + expect(doc_map.unresolved_requires - unprovided_solargraph_rspec_requires) + .to eq(['not_a_gem']) end end From 6abaefc3ea1e03eb51604baaf0e790c434be23ae Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Wed, 20 Aug 2025 10:03:44 -0400 Subject: [PATCH 255/400] Another solargraph-rspec fix --- spec/doc_map_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/doc_map_spec.rb b/spec/doc_map_spec.rb index 2ea86e7f9..4c9bd3de7 100644 --- a/spec/doc_map_spec.rb +++ b/spec/doc_map_spec.rb @@ -81,9 +81,9 @@ it 'tracks uncached_gemspecs' do pincache = instance_double(Solargraph::PinCache) uncached_gemspec = Gem::Specification.new('uncached_gem', '1.0.0') + allow(workspace).to receive_messages(resolve_require: [], fresh_pincache: pincache) allow(workspace).to receive(:resolve_require).with('uncached_gem').and_return([uncached_gemspec]) allow(workspace).to receive(:fetch_dependencies).with(uncached_gemspec, out: out).and_return([]) - allow(workspace).to receive(:fresh_pincache).and_return(pincache) allow(pincache).to receive(:deserialize_combined_pin_cache).with(uncached_gemspec).and_return(nil) expect(doc_map.uncached_gemspecs).to eq([uncached_gemspec]) end From 98ec2eb7266fe81e42804366f612531251e89598 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Wed, 20 Aug 2025 11:44:35 -0400 Subject: [PATCH 256/400] Handle BundleNotFoundError --- lib/solargraph/workspace/gemspecs.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/solargraph/workspace/gemspecs.rb b/lib/solargraph/workspace/gemspecs.rb index ffe6776d9..9777355b1 100644 --- a/lib/solargraph/workspace/gemspecs.rb +++ b/lib/solargraph/workspace/gemspecs.rb @@ -323,6 +323,10 @@ def all_gemspecs_from_external_bundle query_external_bundle(command).map do |name, version| resolve_gem_ignoring_local_bundle(name, version) end.compact + rescue Solargraph::BundleNotFoundError => e + Solargraph.logger.info e.message + Solargraph.logger.debug e.backtrace.join("\n") + [] end end From 2e3b867756c727dd0dde74d4a65a4c165338ea07 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Wed, 20 Aug 2025 12:10:57 -0400 Subject: [PATCH 257/400] Use rspec-time-guard to debug slow specs --- solargraph.gemspec | 1 + spec/library_spec.rb | 11 ++++------- spec/spec_helper.rb | 7 +++++++ 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/solargraph.gemspec b/solargraph.gemspec index e6bb9394a..56dd78e48 100755 --- a/solargraph.gemspec +++ b/solargraph.gemspec @@ -48,6 +48,7 @@ Gem::Specification.new do |s| s.add_development_dependency 'public_suffix', '~> 3.1' s.add_development_dependency 'rake', '~> 13.2' s.add_development_dependency 'rspec', '~> 3.5' + s.add_development_dependency 'rspec-time-guard', '~> 0.2.0' s.add_development_dependency 'rubocop-rake', '~> 0.7' s.add_development_dependency 'rubocop-rspec', '~> 3.6' s.add_development_dependency 'rubocop-yard', '~> 1.0' diff --git a/spec/library_spec.rb b/spec/library_spec.rb index 0cf6084e9..63b36d82a 100644 --- a/spec/library_spec.rb +++ b/spec/library_spec.rb @@ -1,6 +1,5 @@ require 'tmpdir' require 'yard' -require 'timeout' describe Solargraph::Library do it "does not open created files in the workspace" do @@ -32,7 +31,7 @@ Solargraph::Shell.new.uncache('backport') end - it "returns a Completion" do + it "returns a Completion", time_limit_seconds: 50 do library = Solargraph::Library.new(Solargraph::Workspace.new(Dir.pwd, Solargraph::Workspace::Config.new)) library.attach Solargraph::Source.load_string(%( @@ -44,11 +43,9 @@ def foo(adapter) end ), 'file.rb', 0) completion = nil - Timeout.timeout(25) do - # give Solargraph time to cache the gem - while (completion = library.completions_at('file.rb', 5, 19)).pins.empty? - sleep 0.25 - end + # give Solargraph time to cache the gem + while (completion = library.completions_at('file.rb', 5, 19)).pins.empty? + sleep 0.25 end expect(completion).to be_a(Solargraph::SourceMap::Completion) expect(completion.pins.map(&:name)).to include('remote') diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index bdc8be36a..097aca550 100755 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,5 +1,6 @@ require 'bundler/setup' require 'webmock/rspec' +require 'rspec_time_guard' WebMock.disable_net_connect!(allow_localhost: true) unless ENV['SIMPLECOV_DISABLED'] # set up lcov reporting for undercover @@ -27,6 +28,12 @@ # Allow use of --only-failures with rspec, handy for local development c.example_status_persistence_file_path = 'rspec-examples.txt' end +RspecTimeGuard.setup +RspecTimeGuard.configure do |config| + config.global_time_limit_seconds = 60 + config.continue_on_timeout = false +end + require 'solargraph' # execute any logging blocks to make sure they don't blow up Solargraph::Logging.logger.sev_threshold = Logger::DEBUG From d20e1d96272b5aa8813cb3ae228db32ad0de07f8 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Wed, 20 Aug 2025 12:33:10 -0400 Subject: [PATCH 258/400] Fix spec glitches --- spec/api_map/api_map_method_spec.rb | 12 ++++++++---- .../message/text_document/definition_spec.rb | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/spec/api_map/api_map_method_spec.rb b/spec/api_map/api_map_method_spec.rb index 73fc6a35c..704a67431 100644 --- a/spec/api_map/api_map_method_spec.rb +++ b/spec/api_map/api_map_method_spec.rb @@ -1,12 +1,16 @@ # frozen_string_literal: true +require 'tmpdir' + describe Solargraph::ApiMap do describe '.load_with_cache' do - it 'loads the API map with cache' do + it 'loads the API map with cache', time_limit_seconds: 120 do Solargraph::PinCache.uncache_core - output = capture_both do - described_class.load_with_cache(Dir.pwd) + output = Dir.mktmpdir do |dir| + capture_both do + described_class.load_with_cache(dir) + end end expect(output).to include('aching RBS pins for Ruby core') @@ -15,7 +19,7 @@ describe '#get_method_stack' do let(:out) { StringIO.new } - let(:api_map) { described_class.load_with_cache(Dir.pwd, out: out) } + let(:api_map) { described_class.load_with_cache(Dir.pwd, out) } context 'with stdlib that has vital dependencies' do let(:method_stack) { api_map.get_method_stack('YAML', 'safe_load', scope: :class) } diff --git a/spec/language_server/message/text_document/definition_spec.rb b/spec/language_server/message/text_document/definition_spec.rb index 72ff77f1e..beebb48de 100644 --- a/spec/language_server/message/text_document/definition_spec.rb +++ b/spec/language_server/message/text_document/definition_spec.rb @@ -21,7 +21,7 @@ expect(message.result.first[:uri]).to eq(other_uri) end - it 'finds definitions of require paths' do + it 'finds definitions of require paths', time_limit_seconds: 120 do path = File.absolute_path('spec/fixtures/workspace') host = Solargraph::LanguageServer::Host.new host.prepare(path) From 629ee5bdc1329764ea6f3d97db919ad1feb13bad Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Wed, 20 Aug 2025 12:44:08 -0400 Subject: [PATCH 259/400] Bump timeout on spec --- spec/api_map/api_map_method_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/api_map/api_map_method_spec.rb b/spec/api_map/api_map_method_spec.rb index 704a67431..8c38b808b 100644 --- a/spec/api_map/api_map_method_spec.rb +++ b/spec/api_map/api_map_method_spec.rb @@ -17,7 +17,7 @@ end end - describe '#get_method_stack' do + describe '#get_method_stack', time_limit_seconds: 120 do let(:out) { StringIO.new } let(:api_map) { described_class.load_with_cache(Dir.pwd, out) } From 2671de56aedad453feeda6745864ba42666be478 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Wed, 20 Aug 2025 13:40:22 -0400 Subject: [PATCH 260/400] Avoid using operator- on Gem::Specification https://github.com/castwide/solargraph/actions/runs/17104765774/job/48510666106?pr=1006 --- lib/solargraph/doc_map.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/solargraph/doc_map.rb b/lib/solargraph/doc_map.rb index 81e92b559..fecf94d5d 100644 --- a/lib/solargraph/doc_map.rb +++ b/lib/solargraph/doc_map.rb @@ -89,7 +89,12 @@ def unresolved_requires # @return [Set] # @param out [IO] def dependencies out: $stderr - @dependencies ||= (gemspecs.flat_map { |spec| workspace.fetch_dependencies(spec, out: out) } - gemspecs).to_set + @dependencies ||= + begin + all_deps = gemspecs.flat_map { |spec| workspace.fetch_dependencies(spec, out: out) } + existing_gems = gemspecs.map(&:name) + all_deps.reject { |gemspec| existing_gems.include? gemspec.name } + end end # Cache gem documentation if needed for this doc_map From d118208dadb2eef3295566dfc430b84412b9635b Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Wed, 20 Aug 2025 13:45:59 -0400 Subject: [PATCH 261/400] Fix typechecking issue --- lib/solargraph/doc_map.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/solargraph/doc_map.rb b/lib/solargraph/doc_map.rb index fecf94d5d..d9d64b5b0 100644 --- a/lib/solargraph/doc_map.rb +++ b/lib/solargraph/doc_map.rb @@ -93,7 +93,7 @@ def dependencies out: $stderr begin all_deps = gemspecs.flat_map { |spec| workspace.fetch_dependencies(spec, out: out) } existing_gems = gemspecs.map(&:name) - all_deps.reject { |gemspec| existing_gems.include? gemspec.name } + all_deps.reject { |gemspec| existing_gems.include? gemspec.name }.to_set end end From d16773100be1f56a24133e935e14d96f744da1cf Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Wed, 20 Aug 2025 14:27:10 -0400 Subject: [PATCH 262/400] Debug specs --- spec/language_server/host_spec.rb | 2 +- spec/language_server/protocol_spec.rb | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/spec/language_server/host_spec.rb b/spec/language_server/host_spec.rb index 40c8b7292..bccf00a87 100644 --- a/spec/language_server/host_spec.rb +++ b/spec/language_server/host_spec.rb @@ -247,7 +247,7 @@ def initialize(foo); end expect(symbols).not_to be_empty end - it "opens a file outside of prepared libraries" do + it "opens a file outside of prepared libraries", time_limit_seconds: 120 do @host.prepare(File.absolute_path(File.join('spec', 'fixtures', 'workspace'))) @host.open('file:///file.rb', 'class Foo; end', 1) symbols = @host.document_symbols('file:///file.rb') diff --git a/spec/language_server/protocol_spec.rb b/spec/language_server/protocol_spec.rb index 0b54729b5..e238865af 100644 --- a/spec/language_server/protocol_spec.rb +++ b/spec/language_server/protocol_spec.rb @@ -34,7 +34,7 @@ def stop end end -describe Protocol, order: :defined do +describe Protocol, order: :defined, fail_fast: true do before :all do @protocol = Protocol.new(Solargraph::LanguageServer::Host.new) end @@ -173,7 +173,12 @@ def bar baz item = response['result']['items'].select{|h| h['label'] == 'bar'}.first @protocol.request 'completionItem/resolve', item response = @protocol.response - expect(response['result']['documentation']['value']).to include('bar method') + expect(response).not_to be_nil + expect(response['error']).to be_nil + expect(response['result']).to be_a(Hash) + expect(response['result']['documentation']['value']).to include('bar method'), Proc.new do + "Response was not correct: #{response.inspect}" + end end it 'suppresses FileNotFoundError in textDocument/completion' do From 0dc01e437700a8cc32da189103729078ea5255a5 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Wed, 20 Aug 2025 15:20:00 -0400 Subject: [PATCH 263/400] Fix issue with not being in directory workspace --- lib/solargraph/library.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/solargraph/library.rb b/lib/solargraph/library.rb index d764a25a9..c111614a5 100644 --- a/lib/solargraph/library.rb +++ b/lib/solargraph/library.rb @@ -600,8 +600,11 @@ def cache_next_gemspec logger.info "Caching #{spec.name} #{spec.version}" Thread.new do report_cache_progress spec.name, pending + kwargs = {} + kwargs[:chdir] = workspace.directory.to_s if workspace.directory && !workspace.directory.empty? # @sg-ignore Unresolved call to capture3 - _o, e, s = Open3.capture3(workspace.command_path, 'cache', spec.name, spec.version.to_s) + _o, e, s = Open3.capture3(workspace.command_path, 'cache', spec.name, spec.version.to_s, + chdir: workspace.directory.to_s) if s.success? logger.info "Cached #{spec.name} #{spec.version}" else From c615ce9343ea851c5588d80ca69326fd146f4ad3 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Wed, 20 Aug 2025 15:21:12 -0400 Subject: [PATCH 264/400] Fix linting issue --- spec/language_server/protocol_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/language_server/protocol_spec.rb b/spec/language_server/protocol_spec.rb index e238865af..8904eb1b3 100644 --- a/spec/language_server/protocol_spec.rb +++ b/spec/language_server/protocol_spec.rb @@ -34,7 +34,7 @@ def stop end end -describe Protocol, order: :defined, fail_fast: true do +describe Protocol, order: :defined do before :all do @protocol = Protocol.new(Solargraph::LanguageServer::Host.new) end From 62e00ea4a8d613c3193c2469820e72e2834dc4c9 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Wed, 20 Aug 2025 15:32:03 -0400 Subject: [PATCH 265/400] Fix invalid spec --- spec/language_server/protocol_spec.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/spec/language_server/protocol_spec.rb b/spec/language_server/protocol_spec.rb index 8904eb1b3..4306fe7a7 100644 --- a/spec/language_server/protocol_spec.rb +++ b/spec/language_server/protocol_spec.rb @@ -176,9 +176,7 @@ def bar baz expect(response).not_to be_nil expect(response['error']).to be_nil expect(response['result']).to be_a(Hash) - expect(response['result']['documentation']['value']).to include('bar method'), Proc.new do - "Response was not correct: #{response.inspect}" - end + expect(response['result']['documentation']['value']).to include('bar method') end it 'suppresses FileNotFoundError in textDocument/completion' do From 8672a5ea301507ee7f22f41acdf2e82fef0dae20 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Wed, 20 Aug 2025 15:48:03 -0400 Subject: [PATCH 266/400] Fix time limit --- spec/api_map/api_map_method_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/api_map/api_map_method_spec.rb b/spec/api_map/api_map_method_spec.rb index 8c38b808b..17bca8446 100644 --- a/spec/api_map/api_map_method_spec.rb +++ b/spec/api_map/api_map_method_spec.rb @@ -17,7 +17,7 @@ end end - describe '#get_method_stack', time_limit_seconds: 120 do + describe '#get_method_stack', time_limit_seconds: 240 do let(:out) { StringIO.new } let(:api_map) { described_class.load_with_cache(Dir.pwd, out) } From 5d27b40ceb77a9d31b88e30a6081824f48cb3df3 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Wed, 20 Aug 2025 15:48:13 -0400 Subject: [PATCH 267/400] Fix expectations in face of solargraph-rspec requires --- spec/source_map/clip_spec.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/spec/source_map/clip_spec.rb b/spec/source_map/clip_spec.rb index 0f83331ec..a0bf1956a 100644 --- a/spec/source_map/clip_spec.rb +++ b/spec/source_map/clip_spec.rb @@ -1644,10 +1644,12 @@ def foo; end api_map = Solargraph::ApiMap.new.map(source) array_names = api_map.clip_at('test.rb', [5, 22]).complete.pins.map(&:name) - expect(array_names).to eq(["byteindex", "byterindex", "bytes", "bytesize", "byteslice", "bytesplice"]) + # other methods may come in via plugin default requires + expect(array_names).to include("byteindex", "byterindex", "bytes", "bytesize", "byteslice", "bytesplice") string_names = api_map.clip_at('test.rb', [6, 22]).complete.pins.map(&:name) - expect(string_names).to eq(['upcase', 'upcase!', 'upto']) + # other methods may come in via plugin default requires + expect(string_names).to include('upcase', 'upcase!', 'upto') end it 'completes global methods defined in top level scope inside class when referenced inside a namespace' do From 8e3c1480a0e0ddfbe1963fcdda0a9299a6b425b8 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Wed, 20 Aug 2025 15:55:26 -0400 Subject: [PATCH 268/400] Ratchet rubocop todo file --- .rubocop_todo.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index bfdba89a7..6df8abedd 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -2448,7 +2448,6 @@ Style/WordArray: - 'spec/pin/method_spec.rb' - 'spec/source/cursor_spec.rb' - 'spec/source/source_chainer_spec.rb' - - 'spec/source_map/clip_spec.rb' - 'spec/source_map/mapper_spec.rb' - 'spec/source_map_spec.rb' - 'spec/source_spec.rb' From f505318f3802ffa99d834e630c0ffd5c56022377 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Wed, 20 Aug 2025 15:59:12 -0400 Subject: [PATCH 269/400] Fix spec bug --- lib/solargraph/library.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/solargraph/library.rb b/lib/solargraph/library.rb index c111614a5..27e268299 100644 --- a/lib/solargraph/library.rb +++ b/lib/solargraph/library.rb @@ -604,7 +604,7 @@ def cache_next_gemspec kwargs[:chdir] = workspace.directory.to_s if workspace.directory && !workspace.directory.empty? # @sg-ignore Unresolved call to capture3 _o, e, s = Open3.capture3(workspace.command_path, 'cache', spec.name, spec.version.to_s, - chdir: workspace.directory.to_s) + **kwargs) if s.success? logger.info "Cached #{spec.name} #{spec.version}" else From 65843fd7c8177282d5416d5f9ea561e7ba065575 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Wed, 20 Aug 2025 16:00:28 -0400 Subject: [PATCH 270/400] Debug spec failure --- spec/language_server/message/text_document/rename_spec.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/spec/language_server/message/text_document/rename_spec.rb b/spec/language_server/message/text_document/rename_spec.rb index 32fb6d011..d43793716 100644 --- a/spec/language_server/message/text_document/rename_spec.rb +++ b/spec/language_server/message/text_document/rename_spec.rb @@ -55,6 +55,9 @@ def foo(bar) } }) rename.process + expect(rename.result).not_to be_nil + expect(rename.result[:changes]).not_to be_nil + expect(rename.result[:changes]['file:///file.rb']).not_to be_nil expect(rename.result[:changes]['file:///file.rb'].length).to eq(3) end From cb0178b13f6570daf310d8e9655060784ad02b04 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Wed, 20 Aug 2025 17:28:47 -0400 Subject: [PATCH 271/400] Reproduce bug with spec --- .../message/text_document/definition_spec.rb | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/spec/language_server/message/text_document/definition_spec.rb b/spec/language_server/message/text_document/definition_spec.rb index beebb48de..b6c98b99b 100644 --- a/spec/language_server/message/text_document/definition_spec.rb +++ b/spec/language_server/message/text_document/definition_spec.rb @@ -1,4 +1,33 @@ describe Solargraph::LanguageServer::Message::TextDocument::Definition do + it 'prepares empty directory' do + Dir.mktmpdir do |dir| + host = Solargraph::LanguageServer::Host.new + test_rb_path = File.join(dir, 'test.rb') + thing_rb_path = File.join(dir, 'thing.rb') + FileUtils.cp('spec/fixtures/workspace/lib/other.rb', test_rb_path) + FileUtils.cp('spec/fixtures/workspace/lib/thing.rb', thing_rb_path) + host.prepare(dir) + sleep 0.1 until host.libraries.all?(&:mapped?) + host.catalog + file_uri = Solargraph::LanguageServer::UriHelpers.file_to_uri(test_rb_path) + other_uri = Solargraph::LanguageServer::UriHelpers.file_to_uri(thing_rb_path) + message = Solargraph::LanguageServer::Message::TextDocument::Definition + .new(host, { + 'params' => { + 'textDocument' => { + 'uri' => file_uri + }, + 'position' => { + 'line' => 4, + 'character' => 10 + } + } + }) + message.process + expect(message.result.first[:uri]).to eq(other_uri) + end + end + it 'finds definitions of methods' do host = Solargraph::LanguageServer::Host.new host.prepare('spec/fixtures/workspace') From 5844b75253cc98c6c96e8f8a55e73b2a548d116c Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Wed, 20 Aug 2025 18:19:08 -0400 Subject: [PATCH 272/400] Restore test command --- .github/workflows/plugins.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/plugins.yml b/.github/workflows/plugins.yml index 3afb0bb44..633ce563d 100644 --- a/.github/workflows/plugins.yml +++ b/.github/workflows/plugins.yml @@ -40,4 +40,4 @@ jobs: - name: Ensure typechecking still works run: bundle exec solargraph typecheck --level typed - name: Ensure specs still run - run: bundle exec rspec --fail-fast + run: bundle exec rake spec From 585f914d91e7fa4bc146850b75f52116149ac25f Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Thu, 21 Aug 2025 07:00:56 -0400 Subject: [PATCH 273/400] Add explicit reset_pins! method --- lib/solargraph/doc_map.rb | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/lib/solargraph/doc_map.rb b/lib/solargraph/doc_map.rb index d9d64b5b0..f35a98af3 100644 --- a/lib/solargraph/doc_map.rb +++ b/lib/solargraph/doc_map.rb @@ -19,15 +19,6 @@ class DocMap attr_reader :global_environ - # @return [Array] - def uncached_gemspecs - if @uncached_gemspecs.nil? - @uncached_gemspecs = [] - pins # force lazy-loaded pin lookup - end - @uncached_gemspecs - end - # @return [Workspace] # @return [Workspace, nil] attr_reader :workspace @@ -43,11 +34,25 @@ def initialize requires, workspace, out: $stderr @out = out end + # @return [Array] + def uncached_gemspecs + if @uncached_gemspecs.nil? + @uncached_gemspecs = [] + pins # force lazy-loaded pin lookup + end + @uncached_gemspecs + end + # @return [Array] def pins @pins ||= load_serialized_gem_pins + global_environ.pins end + def reset_pins! + @uncached_gemspecs = nil + @pins = nil + end + # @return [Solargraph::PinCache] def pin_cache @pin_cache ||= workspace.fresh_pincache @@ -76,8 +81,7 @@ def cache_doc_map_gems! out if (milliseconds > 500) && uncached_gemspecs.any? && out && uncached_gemspecs.any? out.puts "Built #{uncached_gemspecs.length} gems in #{milliseconds} ms" end - @uncached_gemspecs = nil - @pins = nil + reset_pins! end # @return [Array] From ddca860641e4033f566414178d26c4bf84d9b471 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Thu, 21 Aug 2025 07:01:28 -0400 Subject: [PATCH 274/400] Revert formatting --- lib/solargraph/library.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/solargraph/library.rb b/lib/solargraph/library.rb index 27e268299..8fecef2a2 100644 --- a/lib/solargraph/library.rb +++ b/lib/solargraph/library.rb @@ -249,7 +249,7 @@ def references_from filename, line, column, strip: false, only: false return [] unless pin result = [] files = if only - [api_map.source_map(filename)] + [api_map.source_map(filename)] else (workspace.sources + (@current ? [@current] : [])) end From 0082b431bf941c698399be99175bd295683260d2 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Thu, 21 Aug 2025 07:01:36 -0400 Subject: [PATCH 275/400] Revert run tests command --- .github/workflows/rspec.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/rspec.yml b/.github/workflows/rspec.yml index a025d5eee..34d915bec 100644 --- a/.github/workflows/rspec.yml +++ b/.github/workflows/rspec.yml @@ -79,6 +79,6 @@ jobs: - name: Install types run: bundle exec rbs collection update - name: Run tests - run: bundle exec rspec + run: bundle exec rake spec - name: Check PR coverage run: bundle exec rake undercover From 40bdb5a5fc3364760815bc9f7aa84a8ad92443ee Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Thu, 21 Aug 2025 07:11:09 -0400 Subject: [PATCH 276/400] Fix annotation --- lib/solargraph/doc_map.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/solargraph/doc_map.rb b/lib/solargraph/doc_map.rb index f35a98af3..eef2d4dbf 100644 --- a/lib/solargraph/doc_map.rb +++ b/lib/solargraph/doc_map.rb @@ -48,6 +48,7 @@ def pins @pins ||= load_serialized_gem_pins + global_environ.pins end + # @return [void] def reset_pins! @uncached_gemspecs = nil @pins = nil From 390aed271f9246c5f0d2387e0778b75391b0d147 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Thu, 21 Aug 2025 07:50:38 -0400 Subject: [PATCH 277/400] Cache global environ pins --- lib/solargraph/doc_map.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/solargraph/doc_map.rb b/lib/solargraph/doc_map.rb index eef2d4dbf..5306fecf6 100644 --- a/lib/solargraph/doc_map.rb +++ b/lib/solargraph/doc_map.rb @@ -43,9 +43,14 @@ def uncached_gemspecs @uncached_gemspecs end + # @return [Array] + def global_environ_pins + @global_environ_pins ||= global_environ.pins + end + # @return [Array] def pins - @pins ||= load_serialized_gem_pins + global_environ.pins + @pins ||= load_serialized_gem_pins + global_environ_pins end # @return [void] From 4ee8c007ee48d86baa7043f9800c87af6e936535 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Thu, 21 Aug 2025 08:11:34 -0400 Subject: [PATCH 278/400] Add convention-based requires more lazily --- lib/solargraph/doc_map.rb | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/lib/solargraph/doc_map.rb b/lib/solargraph/doc_map.rb index 5306fecf6..77986d44f 100644 --- a/lib/solargraph/doc_map.rb +++ b/lib/solargraph/doc_map.rb @@ -13,12 +13,6 @@ module Solargraph class DocMap include Logging - # @return [Array] - attr_reader :requires - alias required requires - - attr_reader :global_environ - # @return [Workspace] # @return [Workspace, nil] attr_reader :workspace @@ -27,13 +21,21 @@ class DocMap # @param workspace [Workspace] # @param out [IO, nil] output stream for logging def initialize requires, workspace, out: $stderr - @requires = requires.compact + @provided_requires = requires.compact @workspace = workspace - @global_environ = Convention.for_global(self) - @requires.concat @global_environ.requires if @global_environ @out = out end + def global_environ + @global_environ ||= Convention.for_global(self) + end + + # @return [Array] + def requires + @requires ||= @provided_requires + (global_environ&.requires || []) + end + alias required requires + # @return [Array] def uncached_gemspecs if @uncached_gemspecs.nil? From c2d1674f862b94865f2b74d8ed121b518ffe0f98 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Thu, 21 Aug 2025 08:18:00 -0400 Subject: [PATCH 279/400] Rely on workspace to own global environ --- lib/solargraph/doc_map.rb | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/lib/solargraph/doc_map.rb b/lib/solargraph/doc_map.rb index 77986d44f..43a4a9520 100644 --- a/lib/solargraph/doc_map.rb +++ b/lib/solargraph/doc_map.rb @@ -14,7 +14,6 @@ class DocMap include Logging # @return [Workspace] - # @return [Workspace, nil] attr_reader :workspace # @param requires [Array] @@ -26,13 +25,9 @@ def initialize requires, workspace, out: $stderr @out = out end - def global_environ - @global_environ ||= Convention.for_global(self) - end - # @return [Array] def requires - @requires ||= @provided_requires + (global_environ&.requires || []) + @requires ||= @provided_requires + (workspace.global_environ&.requires || []) end alias required requires From 25624dc7b9ebe6137ec2bbb58fae1a156c418af4 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Thu, 21 Aug 2025 08:30:06 -0400 Subject: [PATCH 280/400] Rely on workspace to own global environ --- lib/solargraph/doc_map.rb | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/lib/solargraph/doc_map.rb b/lib/solargraph/doc_map.rb index 43a4a9520..750eee375 100644 --- a/lib/solargraph/doc_map.rb +++ b/lib/solargraph/doc_map.rb @@ -40,14 +40,9 @@ def uncached_gemspecs @uncached_gemspecs end - # @return [Array] - def global_environ_pins - @global_environ_pins ||= global_environ.pins - end - # @return [Array] def pins - @pins ||= load_serialized_gem_pins + global_environ_pins + @pins ||= load_serialized_gem_pins + (workspace.global_environ&.pins || []) end # @return [void] From 14bdb8cf6898a579562b982a3ddf2b73f76e1999 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Thu, 21 Aug 2025 08:43:01 -0400 Subject: [PATCH 281/400] Ratchet .rubocop_todo.yml --- .rubocop_todo.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 6df8abedd..139f5de09 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -2501,7 +2501,6 @@ YARD/MismatchName: - 'lib/solargraph/pin/until.rb' - 'lib/solargraph/pin/while.rb' - 'lib/solargraph/pin_cache.rb' - - 'lib/solargraph/source/chain.rb' - 'lib/solargraph/source/chain/call.rb' - 'lib/solargraph/source/chain/z_super.rb' - 'lib/solargraph/type_checker.rb' From a16fcc1c4e4951ccac3f66de330b220b99d7052a Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Thu, 21 Aug 2025 08:58:18 -0400 Subject: [PATCH 282/400] Fix specs --- spec/doc_map_spec.rb | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/spec/doc_map_spec.rb b/spec/doc_map_spec.rb index 4c9bd3de7..3eeb932ea 100644 --- a/spec/doc_map_spec.rb +++ b/spec/doc_map_spec.rb @@ -82,6 +82,7 @@ pincache = instance_double(Solargraph::PinCache) uncached_gemspec = Gem::Specification.new('uncached_gem', '1.0.0') allow(workspace).to receive_messages(resolve_require: [], fresh_pincache: pincache) + allow(workspace).to receive(:global_environ).and_return(Solargraph::Environ.new) allow(workspace).to receive(:resolve_require).with('uncached_gem').and_return([uncached_gemspec]) allow(workspace).to receive(:fetch_dependencies).with(uncached_gemspec, out: out).and_return([]) allow(pincache).to receive(:deserialize_combined_pin_cache).with(uncached_gemspec).and_return(nil) @@ -133,22 +134,26 @@ end end - it 'includes convention requires from environ' do - dummy_convention = Class.new(Solargraph::Convention::Base) do - def global(doc_map) - Solargraph::Environ.new( - requires: ['convention_gem1', 'convention_gem2'] - ) - end - end + context 'with convention' do + let(:pre_cache) { false } - Solargraph::Convention.register dummy_convention + it 'includes convention requires from environ' do + dummy_convention = Class.new(Solargraph::Convention::Base) do + def global(doc_map) + Solargraph::Environ.new( + requires: ['convention_gem1', 'convention_gem2'] + ) + end + end - doc_map = Solargraph::DocMap.new(['original_gem'], workspace) + Solargraph::Convention.register dummy_convention - expect(doc_map.requires).to include('original_gem', 'convention_gem1', 'convention_gem2') + doc_map = Solargraph::DocMap.new(['original_gem'], workspace) - # Clean up the registered convention - Solargraph::Convention.deregister dummy_convention + expect(doc_map.requires).to include('original_gem', 'convention_gem1', 'convention_gem2') + ensure + # Clean up the registered convention + Solargraph::Convention.deregister dummy_convention + end end end From 247c1395d1d245b6ff80e78af9fcd978cd2c815d Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Thu, 21 Aug 2025 09:39:49 -0400 Subject: [PATCH 283/400] Time rspec and rails plugins separately --- .github/workflows/plugins.yml | 62 +++++++++++++++++++++++++++++++++-- 1 file changed, 60 insertions(+), 2 deletions(-) diff --git a/.github/workflows/plugins.yml b/.github/workflows/plugins.yml index 633ce563d..9bd6d979c 100644 --- a/.github/workflows/plugins.yml +++ b/.github/workflows/plugins.yml @@ -1,4 +1,4 @@ -name: Plugin Backwards Compatibility Tests +name: Plugin on: push: @@ -10,7 +10,7 @@ permissions: contents: read jobs: - test: + regression: runs-on: ubuntu-latest steps: @@ -41,3 +41,61 @@ jobs: run: bundle exec solargraph typecheck --level typed - name: Ensure specs still run run: bundle exec rake spec + rails: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: '3.0' + bundler-cache: false + - uses: awalsh128/cache-apt-pkgs-action@latest + with: + packages: yq + version: 1.0 + - name: Install gems + run: | + echo 'gem "solargraph-rails"' > .Gemfile + bundle install + bundle update rbs + - name: Configure to use plugins + run: | + bundle exec solargraph config + yq -yi '.plugins += ["solargraph-rails]' .solargraph.yml + - name: Install gem types + run: bundle exec rbs collection update + - name: Ensure typechecking still works + run: bundle exec solargraph typecheck --level typed + - name: Ensure specs still run + run: bundle exec rake spec + rspec: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: '3.0' + bundler-cache: false + - uses: awalsh128/cache-apt-pkgs-action@latest + with: + packages: yq + version: 1.0 + - name: Install gems + run: | + echo 'gem "solargraph-rspec"' >> .Gemfile + bundle install + bundle update rbs + - name: Configure to use plugins + run: | + bundle exec solargraph config + yq -yi '.plugins += ["solargraph-rspec"]' .solargraph.yml + - name: Install gem types + run: bundle exec rbs collection update + - name: Ensure typechecking still works + run: bundle exec solargraph typecheck --level typed + - name: Ensure specs still run + run: bundle exec rake spec From bd8e64d907873e1b06f1cc6313a62227fc4debce Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Thu, 21 Aug 2025 09:44:31 -0400 Subject: [PATCH 284/400] Fix syntax --- .github/workflows/plugins.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/plugins.yml b/.github/workflows/plugins.yml index 9bd6d979c..3f306a166 100644 --- a/.github/workflows/plugins.yml +++ b/.github/workflows/plugins.yml @@ -63,7 +63,7 @@ jobs: - name: Configure to use plugins run: | bundle exec solargraph config - yq -yi '.plugins += ["solargraph-rails]' .solargraph.yml + yq -yi '.plugins += ["solargraph-rails"]' .solargraph.yml - name: Install gem types run: bundle exec rbs collection update - name: Ensure typechecking still works From fdf9c7d17812b11c7a6ed436c359f11dffafff1e Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Thu, 21 Aug 2025 10:03:56 -0400 Subject: [PATCH 285/400] Add to unprovided solargraph-rspec requires --- spec/doc_map_spec.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spec/doc_map_spec.rb b/spec/doc_map_spec.rb index 3eeb932ea..cdf12d75a 100644 --- a/spec/doc_map_spec.rb +++ b/spec/doc_map_spec.rb @@ -47,7 +47,8 @@ 'activerecord', 'shoulda-matchers', 'rspec-sidekiq', - 'airborne' + 'airborne', + 'activesupport' ] expect(doc_map.unresolved_requires - unprovided_solargraph_rspec_requires) .to eq(['not_a_gem']) From 767d3d26ece9da2e7aec9b796dcfdccc348bc87a Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Mon, 25 Aug 2025 14:31:34 -0400 Subject: [PATCH 286/400] Debug CI failure --- lib/solargraph/api_map.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/solargraph/api_map.rb b/lib/solargraph/api_map.rb index 277c03025..a9084e893 100755 --- a/lib/solargraph/api_map.rb +++ b/lib/solargraph/api_map.rb @@ -695,6 +695,10 @@ def resolve_method_aliases pins, visibility = [:public, :private, :protected] resolved = resolve_method_alias(pin) next nil if resolved.respond_to?(:visibility) && !visibility.include?(resolved.visibility) resolved + rescue Solargraph::ComplexTypeError => e + logger.warn "ComplexTypeError while resolving #{pin.inspect}: #{e.message}" + raise e + end end.compact logger.debug do "ApiMap#resolve_method_aliases(pins=#{pins.map(&:name)}, visibility=#{visibility}) => #{with_resolved_aliases.map(&:name)}" From 8772f061e96d4f130bfa638e362a4611ef85bdc5 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Mon, 25 Aug 2025 14:38:31 -0400 Subject: [PATCH 287/400] Fix syntax --- lib/solargraph/api_map.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/solargraph/api_map.rb b/lib/solargraph/api_map.rb index a9084e893..2f2c26092 100755 --- a/lib/solargraph/api_map.rb +++ b/lib/solargraph/api_map.rb @@ -698,7 +698,6 @@ def resolve_method_aliases pins, visibility = [:public, :private, :protected] rescue Solargraph::ComplexTypeError => e logger.warn "ComplexTypeError while resolving #{pin.inspect}: #{e.message}" raise e - end end.compact logger.debug do "ApiMap#resolve_method_aliases(pins=#{pins.map(&:name)}, visibility=#{visibility}) => #{with_resolved_aliases.map(&:name)}" From 3f363e5b00b01fea34bb58e4c38b2e63324f6129 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Mon, 25 Aug 2025 14:51:26 -0400 Subject: [PATCH 288/400] RuboCop fixes --- .rubocop_todo.yml | 44 ++++++++++----------------------------- lib/solargraph/api_map.rb | 2 -- 2 files changed, 11 insertions(+), 35 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 139f5de09..bd7ce6f6f 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,51 +1,44 @@ # This configuration was generated by # `rubocop --auto-gen-config --no-exclude-limit --no-offense-counts --no-auto-gen-timestamp` -# using RuboCop version 1.79.2. +# using RuboCop version 1.80.0. # 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. # This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: Include. -# Include: **/*.gemspec Gemspec/AddRuntimeDependency: Exclude: - 'solargraph.gemspec' # This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: Severity, Include. -# Include: **/*.gemspec +# Configuration parameters: Severity. Gemspec/DeprecatedAttributeAssignment: Exclude: - 'solargraph.gemspec' - 'spec/fixtures/rdoc-lib/rdoc-lib.gemspec' -# Configuration parameters: EnforcedStyle, AllowedGems, Include. +# Configuration parameters: EnforcedStyle, AllowedGems. # SupportedStyles: Gemfile, gems.rb, gemspec -# Include: **/*.gemspec, **/Gemfile, **/gems.rb Gemspec/DevelopmentDependencies: Exclude: - 'solargraph.gemspec' # This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: TreatCommentsAsGroupSeparators, ConsiderPunctuation, Include. -# Include: **/*.gemspec +# Configuration parameters: TreatCommentsAsGroupSeparators, ConsiderPunctuation. Gemspec/OrderedDependencies: Exclude: - 'solargraph.gemspec' # This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: Severity, Include. -# Include: **/*.gemspec +# Configuration parameters: Severity. Gemspec/RequireMFA: Exclude: - 'solargraph.gemspec' - 'spec/fixtures/rdoc-lib/rdoc-lib.gemspec' - 'spec/fixtures/rubocop-custom-version/specifications/rubocop-0.0.0.gemspec' -# Configuration parameters: Severity, Include. -# Include: **/*.gemspec +# Configuration parameters: Severity. Gemspec/RequiredRubyVersion: Exclude: - 'spec/fixtures/rdoc-lib/rdoc-lib.gemspec' @@ -77,7 +70,6 @@ Layout/ClosingHeredocIndentation: # Configuration parameters: AllowForAlignment. Layout/CommentIndentation: Exclude: - - 'lib/solargraph/api_map.rb' - 'lib/solargraph/language_server/host.rb' - 'lib/solargraph/parser/parser_gem/node_methods.rb' - 'lib/solargraph/source_map/mapper.rb' @@ -99,7 +91,6 @@ Layout/ElseAlignment: - 'lib/solargraph/source/chain/call.rb' - 'lib/solargraph/source_map/clip.rb' - 'lib/solargraph/source_map/mapper.rb' - - 'lib/solargraph/type_checker.rb' - 'lib/solargraph/type_checker/rules.rb' - 'lib/solargraph/yard_map/mapper.rb' @@ -157,7 +148,6 @@ Layout/EndAlignment: - 'lib/solargraph/source/chain/call.rb' - 'lib/solargraph/source_map/clip.rb' - 'lib/solargraph/source_map/mapper.rb' - - 'lib/solargraph/type_checker.rb' - 'lib/solargraph/type_checker/rules.rb' - 'lib/solargraph/yard_map/mapper.rb' @@ -394,7 +384,6 @@ Layout/SpaceBeforeComma: # SupportedStylesForEmptyBraces: space, no_space Layout/SpaceInsideBlockBraces: Exclude: - - 'lib/solargraph/api_map.rb' - 'lib/solargraph/api_map/store.rb' - 'lib/solargraph/diagnostics/update_errors.rb' - 'lib/solargraph/language_server/host.rb' @@ -565,7 +554,6 @@ Lint/NonAtomicFileOperation: # This cop supports safe autocorrection (--autocorrect). Lint/ParenthesesAsGroupedExpression: Exclude: - - 'lib/solargraph.rb' - 'lib/solargraph/parser/parser_gem/node_chainer.rb' - 'spec/language_server/host_spec.rb' - 'spec/source_map/clip_spec.rb' @@ -621,7 +609,7 @@ Lint/UnmodifiedReduceAccumulator: - 'lib/solargraph/pin/method.rb' # This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AutoCorrect, IgnoreEmptyBlocks, AllowUnusedKeywordArguments. +# Configuration parameters: IgnoreEmptyBlocks, AllowUnusedKeywordArguments. Lint/UnusedBlockArgument: Exclude: - 'lib/solargraph/language_server/message/workspace/did_change_workspace_folders.rb' @@ -629,7 +617,7 @@ Lint/UnusedBlockArgument: - 'spec/language_server/transport/data_reader_spec.rb' # This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AutoCorrect, AllowUnusedKeywordArguments, IgnoreEmptyMethods, IgnoreNotImplementedMethods, NotImplementedExceptions. +# Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods, IgnoreNotImplementedMethods, NotImplementedExceptions. # NotImplementedExceptions: NotImplementedError Lint/UnusedMethodArgument: Exclude: @@ -658,10 +646,8 @@ Lint/UnusedMethodArgument: - 'spec/doc_map_spec.rb' # This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AutoCorrect. Lint/UselessAssignment: Exclude: - - 'lib/solargraph/api_map.rb' - 'lib/solargraph/doc_map.rb' - 'lib/solargraph/language_server/message/extended/check_gem_version.rb' - 'lib/solargraph/language_server/message/extended/document_gems.rb' @@ -690,7 +676,6 @@ Lint/UselessConstantScoping: - 'lib/solargraph/rbs_map/conversions.rb' # This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: AutoCorrect. Lint/UselessMethodDefinition: Exclude: - 'lib/solargraph/pin/signature.rb' @@ -745,6 +730,7 @@ Metrics/ClassLength: # Configuration parameters: AllowedMethods, AllowedPatterns, Max. Metrics/CyclomaticComplexity: Exclude: + - 'lib/solargraph/api_map.rb' - 'lib/solargraph/api_map/source_to_yard.rb' - 'lib/solargraph/complex_type.rb' - 'lib/solargraph/parser/parser_gem/node_chainer.rb' @@ -764,7 +750,6 @@ Metrics/MethodLength: - 'lib/solargraph/parser/parser_gem/node_chainer.rb' - 'lib/solargraph/source/chain/call.rb' - 'lib/solargraph/source_map/mapper.rb' - - 'lib/solargraph/type_checker.rb' # Configuration parameters: CountComments, Max, CountAsOne. Metrics/ModuleLength: @@ -991,7 +976,6 @@ RSpec/DescribedClass: - 'spec/yard_map/mapper_spec.rb' # This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: AutoCorrect. RSpec/EmptyExampleGroup: Exclude: - 'spec/convention_spec.rb' @@ -1036,7 +1020,6 @@ RSpec/ExampleLength: # DisallowedExamples: works RSpec/ExampleWording: Exclude: - - 'spec/convention/struct_definition_spec.rb' - 'spec/pin/base_spec.rb' - 'spec/pin/method_spec.rb' @@ -1092,7 +1075,6 @@ RSpec/LeakyConstantDeclaration: - 'spec/complex_type_spec.rb' # This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AutoCorrect. RSpec/LetBeforeExamples: Exclude: - 'spec/complex_type_spec.rb' @@ -1240,7 +1222,6 @@ RSpec/RepeatedExample: - 'spec/type_checker/levels/strict_spec.rb' # This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AutoCorrect. RSpec/ScatteredLet: Exclude: - 'spec/complex_type_spec.rb' @@ -1489,7 +1470,6 @@ Style/Documentation: - 'lib/solargraph/parser.rb' - 'lib/solargraph/parser/comment_ripper.rb' - 'lib/solargraph/parser/flow_sensitive_typing.rb' - - 'lib/solargraph/parser/node_methods.rb' - 'lib/solargraph/parser/node_processor/base.rb' - 'lib/solargraph/parser/parser_gem.rb' - 'lib/solargraph/parser/parser_gem/class_methods.rb' @@ -1575,7 +1555,7 @@ Style/EmptyLambdaParameter: - 'spec/rbs_map/core_map_spec.rb' # This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: AutoCorrect, EnforcedStyle. +# Configuration parameters: EnforcedStyle. # SupportedStyles: compact, expanded Style/EmptyMethod: Exclude: @@ -1630,7 +1610,6 @@ Style/FrozenStringLiteralComment: - 'lib/solargraph/parser.rb' - 'lib/solargraph/parser/comment_ripper.rb' - 'lib/solargraph/parser/flow_sensitive_typing.rb' - - 'lib/solargraph/parser/node_methods.rb' - 'lib/solargraph/parser/parser_gem.rb' - 'lib/solargraph/parser/snippet.rb' - 'lib/solargraph/pin/breakable.rb' @@ -1894,7 +1873,6 @@ Style/MethodDefParentheses: - 'lib/solargraph/location.rb' - 'lib/solargraph/parser/comment_ripper.rb' - 'lib/solargraph/parser/flow_sensitive_typing.rb' - - 'lib/solargraph/parser/node_methods.rb' - 'lib/solargraph/parser/node_processor/base.rb' - 'lib/solargraph/parser/parser_gem/flawed_builder.rb' - 'lib/solargraph/parser/parser_gem/node_chainer.rb' @@ -2098,7 +2076,6 @@ Style/RedundantFreeze: # This cop supports unsafe autocorrection (--autocorrect-all). Style/RedundantInterpolation: Exclude: - - 'lib/solargraph/api_map/store.rb' - 'lib/solargraph/parser/parser_gem/node_chainer.rb' - 'lib/solargraph/source_map/mapper.rb' @@ -2568,6 +2545,7 @@ Layout/LineLength: - 'lib/solargraph/type_checker.rb' - 'lib/solargraph/workspace/config.rb' - 'lib/solargraph/yard_map/mapper/to_method.rb' + - 'spec/api_map_spec.rb' - 'spec/complex_type_spec.rb' - 'spec/language_server/message/completion_item/resolve_spec.rb' - 'spec/language_server/message/extended/check_gem_version_spec.rb' diff --git a/lib/solargraph/api_map.rb b/lib/solargraph/api_map.rb index 2f2c26092..b4d202729 100755 --- a/lib/solargraph/api_map.rb +++ b/lib/solargraph/api_map.rb @@ -1015,8 +1015,6 @@ def prefer_non_nil_variables pins include Logging - private - # @param alias_pin [Pin::MethodAlias] # @return [Pin::Method, nil] def resolve_method_alias(alias_pin) From 11ec2dd0d2b6dd8d8a6946f2b1c0977863d59449 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Mon, 25 Aug 2025 14:51:46 -0400 Subject: [PATCH 289/400] Spec timeout adjustment --- spec/api_map/api_map_method_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/api_map/api_map_method_spec.rb b/spec/api_map/api_map_method_spec.rb index f03479ff1..e8036be44 100644 --- a/spec/api_map/api_map_method_spec.rb +++ b/spec/api_map/api_map_method_spec.rb @@ -154,7 +154,7 @@ class B let(:method_stack) { api_map.get_method_stack('YAML', 'safe_load', scope: :class) } - it 'handles the YAML gem aliased to Psych' do + it 'handles the YAML gem aliased to Psych', time_limit_seconds: 120 do expect(method_stack).not_to be_empty end end From 5996f75e34a2ce28026c6b3d81574de10e2ff768 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Thu, 28 Aug 2025 12:14:24 -0400 Subject: [PATCH 290/400] Fix crash while generating activesupport pins Fixes https://github.com/castwide/solargraph/issues/1042 --- lib/solargraph/api_map.rb | 3 +- lib/solargraph/api_map/store.rb | 3 +- lib/solargraph/rbs_map/conversions.rb | 4 +- spec/api_map/api_map_method_spec.rb | 39 +++++++++++++++++++ spec/rbs_map/conversions_spec.rb | 55 ++++++++++++++++++++------- 5 files changed, 86 insertions(+), 18 deletions(-) diff --git a/lib/solargraph/api_map.rb b/lib/solargraph/api_map.rb index 89ed3a308..c141e0ace 100755 --- a/lib/solargraph/api_map.rb +++ b/lib/solargraph/api_map.rb @@ -1010,7 +1010,8 @@ def resolve_method_alias(alias_pin) # Search each ancestor for the original method ancestors.each do |ancestor_fqns| - ancestor_fqns = ComplexType.parse(ancestor_fqns).force_rooted.namespace + ancestor_fqns = ComplexType.try_parse(ancestor_fqns).force_rooted.namespace + next if ancestor_fqns.nil? ancestor_method_path = "#{ancestor_fqns}#{alias_pin.scope == :instance ? '#' : '.'}#{alias_pin.original}" # Search for the original method in the ancestor diff --git a/lib/solargraph/api_map/store.rb b/lib/solargraph/api_map/store.rb index 6479e6039..fa9a7a118 100644 --- a/lib/solargraph/api_map/store.rb +++ b/lib/solargraph/api_map/store.rb @@ -72,7 +72,8 @@ def get_methods fqns, scope: :instance, visibility: [:public] # @return [String, nil] def get_superclass fq_tag raise "Do not prefix fully qualified tags with '::' - #{fq_tag.inspect}" if fq_tag.start_with?('::') - sub = ComplexType.parse(fq_tag) + sub = ComplexType.try_parse(fq_tag) + return nil if sub.nil? return sub.simplify_literals.name if sub.literal? return 'Boolean' if %w[TrueClass FalseClass].include?(fq_tag) fqns = sub.namespace diff --git a/lib/solargraph/rbs_map/conversions.rb b/lib/solargraph/rbs_map/conversions.rb index 657ea982f..78c819d84 100644 --- a/lib/solargraph/rbs_map/conversions.rb +++ b/lib/solargraph/rbs_map/conversions.rb @@ -699,13 +699,13 @@ def method_type_to_tag type # @return [ComplexType::UniqueType] def build_type(type_name, type_args = []) base = RBS_TO_YARD_TYPE[type_name.relative!.to_s] || type_name.relative!.to_s - params = type_args.map { |a| other_type_to_tag(a) }.reject { |t| t == 'undefined' }.map do |t| + params = type_args.map { |a| other_type_to_tag(a) }.map do |t| ComplexType.try_parse(t).force_rooted end if base == 'Hash' && params.length == 2 ComplexType::UniqueType.new(base, [params.first], [params.last], rooted: true, parameters_type: :hash) else - ComplexType::UniqueType.new(base, [], params, rooted: true, parameters_type: :list) + ComplexType::UniqueType.new(base, [], params.reject(&:undefined?), rooted: true, parameters_type: :list) end end diff --git a/spec/api_map/api_map_method_spec.rb b/spec/api_map/api_map_method_spec.rb index a3adc9b94..9eac7f754 100644 --- a/spec/api_map/api_map_method_spec.rb +++ b/spec/api_map/api_map_method_spec.rb @@ -150,5 +150,44 @@ class B expect(method_stack).not_to be_empty end end + + context 'with alias to invalid type type' do + before do + sub_pin = Solargraph::Pin::Namespace.new( + type: :class, + name: 'Sub', + closure: Solargraph::Pin::ROOT_PIN, + source: :spec + ) + + superclass_ref_pin = Solargraph::Pin::Reference::Superclass.new( + closure: sub_pin, + name: 'Hash', + source: :spec + ) + + method_alias_pin = Solargraph::Pin::MethodAlias.new( + name: 'meth_alias', + original: '[]', + closure: sub_pin, + scope: :instance, + source: :spec + ) + + api_map.index [sub_pin, method_alias_pin, superclass_ref_pin] + end + + it 'does not crash looking at superclass method' do + expect { api_map.get_method_stack('Hash', '[]', scope: :instance) }.not_to raise_error + end + + it 'does not crash looking at subclass method' do + expect { api_map.get_method_stack('Sub', '[]', scope: :instance) }.not_to raise_error + end + + it 'does not crash looking at subclass alias' do + expect { api_map.get_method_stack('Sub', 'meth_alias', scope: :instance) }.not_to raise_error + end + end end end diff --git a/spec/rbs_map/conversions_spec.rb b/spec/rbs_map/conversions_spec.rb index 09c203687..ce800c29f 100644 --- a/spec/rbs_map/conversions_spec.rb +++ b/spec/rbs_map/conversions_spec.rb @@ -8,26 +8,15 @@ end end - let(:rbs_repo) do - RBS::Repository.new(no_stdlib: false) - end - - let(:loader) do - RBS::EnvironmentLoader.new(core_root: nil, repository: rbs_repo) - end - let(:conversions) do + loader = RBS::EnvironmentLoader.new(core_root: nil, repository: RBS::Repository.new(no_stdlib: false)) + loader.add(path: Pathname(temp_dir)) Solargraph::RbsMap::Conversions.new(loader: loader) end - let(:pins) do - conversions.pins - end - before do rbs_file = File.join(temp_dir, 'foo.rbs') File.write(rbs_file, rbs) - loader.add(path: Pathname(temp_dir)) end attr_reader :temp_dir @@ -41,7 +30,7 @@ def bar: () -> untyped RBS end - subject(:method_pin) { pins.find { |pin| pin.path == 'Foo#bar' } } + subject(:method_pin) { conversions.pins.find { |pin| pin.path == 'Foo#bar' } } it { should_not be_nil } @@ -51,4 +40,42 @@ def bar: () -> untyped expect(method_pin.return_type.tag).to eq('undefined') end end + + # https://github.com/castwide/solargraph/issues/1042 + context 'with Hash superclass with untyped value and alias' do + let(:rbs) do + <<~RBS + class Sub < Hash[Symbol, untyped] + alias meth_alias [] + end + RBS + end + + let(:api_map) { Solargraph::ApiMap.new } + + let(:sup_method_stack) { api_map.get_method_stack('Hash{Symbol => undefined}', '[]', scope: :instance) } + + let(:sub_alias_stack) { api_map.get_method_stack('Sub', 'meth_alias', scope: :instance) } + + before do + api_map.index conversions.pins + end + + it 'does not crash looking at superclass method' do + expect { sup_method_stack }.not_to raise_error + end + + it 'does not crash looking at alias' do + expect { sub_alias_stack }.not_to raise_error + end + + it 'finds superclass method pin return type' do + expect(sup_method_stack.map(&:return_type).map(&:rooted_tags).uniq).to eq(['undefined']) + end + + it 'finds superclass method pin parameter type' do + expect(sup_method_stack.flat_map(&:signatures).flat_map(&:parameters).map(&:return_type).map(&:rooted_tags) + .uniq).to eq(['Symbol']) + end + end end From 10e3a482efb3a64f6e659ef698b6490574b8eaaf Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Thu, 28 Aug 2025 21:37:14 -0400 Subject: [PATCH 291/400] Lengthen timeout on spec --- spec/language_server/protocol_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/language_server/protocol_spec.rb b/spec/language_server/protocol_spec.rb index 4306fe7a7..5c64383c6 100644 --- a/spec/language_server/protocol_spec.rb +++ b/spec/language_server/protocol_spec.rb @@ -434,7 +434,7 @@ def bar baz expect(response['result']['available']).to be_a(String) end - it "handles $/solargraph/documentGems" do + it "handles $/solargraph/documentGems", time_limit_seconds: 120 do @protocol.request '$/solargraph/documentGems', {} response = @protocol.response expect(response['error']).to be_nil From 07793d79a82781de3b4829697dfdf4ea9b378d7b Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Thu, 28 Aug 2025 22:08:31 -0400 Subject: [PATCH 292/400] Fix merge --- lib/solargraph/api_map/store.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/solargraph/api_map/store.rb b/lib/solargraph/api_map/store.rb index fd211d87d..cde27abb9 100644 --- a/lib/solargraph/api_map/store.rb +++ b/lib/solargraph/api_map/store.rb @@ -138,6 +138,11 @@ def namespace_pins pins_by_class(Solargraph::Pin::Namespace) end + # @return [Enumerable] + def constant_pins + pins_by_class(Solargraph::Pin::Constant) + end + # @return [Enumerable] def method_pins pins_by_class(Solargraph::Pin::Method) From 826c2ebacf1e2b515c5be58bcccbc5058916af9e Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Thu, 28 Aug 2025 22:10:21 -0400 Subject: [PATCH 293/400] Fix merge --- spec/api_map_spec.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/spec/api_map_spec.rb b/spec/api_map_spec.rb index e537f0681..e7021c35e 100755 --- a/spec/api_map_spec.rb +++ b/spec/api_map_spec.rb @@ -8,6 +8,7 @@ before :all do @api_map = described_class.load_with_cache(Dir.pwd, nil) end + # rubocop:enable RSpec/InstanceVariable it 'returns core methods' do pins = @api_map.get_methods('String') # rubocop:disable RSpec/InstanceVariable From 3ba525a86c8ed6ca5e55848090b1f59f2e63ff5a Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Thu, 28 Aug 2025 22:17:31 -0400 Subject: [PATCH 294/400] Fix merge --- spec/api_map_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/api_map_spec.rb b/spec/api_map_spec.rb index e7021c35e..4dbeb2809 100755 --- a/spec/api_map_spec.rb +++ b/spec/api_map_spec.rb @@ -8,7 +8,6 @@ before :all do @api_map = described_class.load_with_cache(Dir.pwd, nil) end - # rubocop:enable RSpec/InstanceVariable it 'returns core methods' do pins = @api_map.get_methods('String') # rubocop:disable RSpec/InstanceVariable @@ -824,4 +823,5 @@ def baz clip = api_map.clip_at('test.rb', [11, 10]) expect(clip.infer.to_s).to eq('Symbol') end + # rubocop:enable RSpec/InstanceVariable end From ea4a3c93e90baf02ee05e26d8bd2fa23997307b0 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Fri, 29 Aug 2025 08:28:56 -0400 Subject: [PATCH 295/400] Fix type issue --- lib/solargraph/workspace/gemspecs.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/solargraph/workspace/gemspecs.rb b/lib/solargraph/workspace/gemspecs.rb index d381d3ba2..e032b70ad 100644 --- a/lib/solargraph/workspace/gemspecs.rb +++ b/lib/solargraph/workspace/gemspecs.rb @@ -266,7 +266,7 @@ def auto_required_gemspecs_from_external_bundle '.select { |dep| dep.groups.include?(:default) && dep.should_include? }' \ '.map(&:name)' # @sg-ignore - # @type [Array] + # @type [Array] dep_names = query_external_bundle command all_gemspecs_from_bundle.select { |gemspec| dep_names.include?(gemspec.name) } From e87c8e658f6013a45fada0800db07082d231dbfb Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Fri, 29 Aug 2025 08:44:56 -0400 Subject: [PATCH 296/400] Fix merge issue --- lib/solargraph/api_map/index.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/solargraph/api_map/index.rb b/lib/solargraph/api_map/index.rb index adb4e858e..09922cd68 100644 --- a/lib/solargraph/api_map/index.rb +++ b/lib/solargraph/api_map/index.rb @@ -39,7 +39,7 @@ def path_pin_hash def pins_by_class klass # @type [Set] s = Set.new - # @sg-ignore Need to handle block parameter destructuring + # @sg-ignore need to support destructured args in block @pin_select_cache[klass] ||= pin_class_hash.each_with_object(s) { |(key, o), n| n.merge(o) if key <= klass } end From e41023d553399875a444906ff34681e846b25080 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Fri, 29 Aug 2025 08:47:41 -0400 Subject: [PATCH 297/400] Fix merge issue --- lib/solargraph/api_map/store.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/solargraph/api_map/store.rb b/lib/solargraph/api_map/store.rb index cde27abb9..e5edcffe1 100644 --- a/lib/solargraph/api_map/store.rb +++ b/lib/solargraph/api_map/store.rb @@ -17,7 +17,7 @@ def pins index.pins end - # @param pinsets [Array>] + # @param pinsets [Array>] # @return [Boolean] True if the index was updated def update *pinsets return catalog(pinsets) if pinsets.length != @pinsets.length From d0caf440fae33e58183f62dde801c3987e7629a1 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Fri, 29 Aug 2025 09:31:27 -0400 Subject: [PATCH 298/400] Rebaseline .rubocop_todo.yml --- .rubocop_todo.yml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index bd7ce6f6f..0af0d7a2d 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config --no-exclude-limit --no-offense-counts --no-auto-gen-timestamp` -# using RuboCop version 1.80.0. +# using RuboCop version 1.80.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 @@ -384,6 +384,7 @@ Layout/SpaceBeforeComma: # SupportedStylesForEmptyBraces: space, no_space Layout/SpaceInsideBlockBraces: Exclude: + - 'lib/solargraph/api_map.rb' - 'lib/solargraph/api_map/store.rb' - 'lib/solargraph/diagnostics/update_errors.rb' - 'lib/solargraph/language_server/host.rb' @@ -554,6 +555,7 @@ Lint/NonAtomicFileOperation: # This cop supports safe autocorrection (--autocorrect). Lint/ParenthesesAsGroupedExpression: Exclude: + - 'lib/solargraph.rb' - 'lib/solargraph/parser/parser_gem/node_chainer.rb' - 'spec/language_server/host_spec.rb' - 'spec/source_map/clip_spec.rb' @@ -648,6 +650,7 @@ Lint/UnusedMethodArgument: # This cop supports safe autocorrection (--autocorrect). Lint/UselessAssignment: Exclude: + - 'lib/solargraph/api_map.rb' - 'lib/solargraph/doc_map.rb' - 'lib/solargraph/language_server/message/extended/check_gem_version.rb' - 'lib/solargraph/language_server/message/extended/document_gems.rb' @@ -730,7 +733,6 @@ Metrics/ClassLength: # Configuration parameters: AllowedMethods, AllowedPatterns, Max. Metrics/CyclomaticComplexity: Exclude: - - 'lib/solargraph/api_map.rb' - 'lib/solargraph/api_map/source_to_yard.rb' - 'lib/solargraph/complex_type.rb' - 'lib/solargraph/parser/parser_gem/node_chainer.rb' @@ -1020,6 +1022,7 @@ RSpec/ExampleLength: # DisallowedExamples: works RSpec/ExampleWording: Exclude: + - 'spec/convention/struct_definition_spec.rb' - 'spec/pin/base_spec.rb' - 'spec/pin/method_spec.rb' @@ -1470,6 +1473,7 @@ Style/Documentation: - 'lib/solargraph/parser.rb' - 'lib/solargraph/parser/comment_ripper.rb' - 'lib/solargraph/parser/flow_sensitive_typing.rb' + - 'lib/solargraph/parser/node_methods.rb' - 'lib/solargraph/parser/node_processor/base.rb' - 'lib/solargraph/parser/parser_gem.rb' - 'lib/solargraph/parser/parser_gem/class_methods.rb' @@ -1610,6 +1614,7 @@ Style/FrozenStringLiteralComment: - 'lib/solargraph/parser.rb' - 'lib/solargraph/parser/comment_ripper.rb' - 'lib/solargraph/parser/flow_sensitive_typing.rb' + - 'lib/solargraph/parser/node_methods.rb' - 'lib/solargraph/parser/parser_gem.rb' - 'lib/solargraph/parser/snippet.rb' - 'lib/solargraph/pin/breakable.rb' @@ -1873,6 +1878,7 @@ Style/MethodDefParentheses: - 'lib/solargraph/location.rb' - 'lib/solargraph/parser/comment_ripper.rb' - 'lib/solargraph/parser/flow_sensitive_typing.rb' + - 'lib/solargraph/parser/node_methods.rb' - 'lib/solargraph/parser/node_processor/base.rb' - 'lib/solargraph/parser/parser_gem/flawed_builder.rb' - 'lib/solargraph/parser/parser_gem/node_chainer.rb' @@ -2076,6 +2082,7 @@ Style/RedundantFreeze: # This cop supports unsafe autocorrection (--autocorrect-all). Style/RedundantInterpolation: Exclude: + - 'lib/solargraph/api_map/store.rb' - 'lib/solargraph/parser/parser_gem/node_chainer.rb' - 'lib/solargraph/source_map/mapper.rb' From 6acfa0c54a806da203daf30765c7a99a67066f16 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Sat, 30 Aug 2025 09:06:14 -0400 Subject: [PATCH 299/400] RuboCop todo file stability To avoid merge conflicts and contributors having to deal with non-intuitive RuboCop todo changes: * Lock down development versions of RuboCop and plugins so that unrelated PRs aren't affected by newly implemented RuboCop rules. * Exclude rule entirely if more than 5 files violate it today, so that PRs are less likely to cause todo file changes unless they are specifically targeted at cleanup. * Clarify guidance on RuboCop todo file in CI error message. * Fix to hopefully ensure guidance always appears in CI error message. --- .github/workflows/linting.yml | 6 +- .rubocop.yml | 1 - .rubocop_todo.yml | 1588 ++------------------------------- solargraph.gemspec | 13 +- 4 files changed, 98 insertions(+), 1510 deletions(-) diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml index 8abbf51ef..aa22ce22c 100644 --- a/.github/workflows/linting.yml +++ b/.github/workflows/linting.yml @@ -115,11 +115,13 @@ jobs: - name: Run RuboCop against todo file continue-on-error: true run: | - bundle exec rubocop --auto-gen-config --no-exclude-limit --no-offense-counts --no-auto-gen-timestamp + cmd="bundle exec rubocop --auto-gen-config --exclude-limit=5 --no-offense-counts --no-auto-gen-timestampxb*com" + ${cmd:?} + set +e if [ -n "$(git status --porcelain)" ] then git status --porcelain git diff -u . - >&2 echo "Please fix deltas if bad or run 'bundle exec rubocop --auto-gen-config --no-exclude-limit --no-offense-counts --no-auto-gen-timestamp' and push up changes if good" + >&2 echo "Please address any new issues, then run '${cmd:?}' and push up any improvements" exit 1 fi diff --git a/.rubocop.yml b/.rubocop.yml index a73324db2..c7643c3c6 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -34,7 +34,6 @@ Metrics/ParameterLists: Max: 7 CountKeywordArgs: false - # we tend to use @@ and the risk doesn't seem high Style/ClassVars: Enabled: false diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index f3f0069f3..bf6b2272a 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,5 +1,5 @@ # This configuration was generated by -# `rubocop --auto-gen-config --no-exclude-limit --no-offense-counts --no-auto-gen-timestamp` +# `rubocop --auto-gen-config --exclude-limit 5 --no-offense-counts --no-auto-gen-timestamp` # using RuboCop version 1.79.2. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. @@ -83,23 +83,7 @@ Layout/CommentIndentation: # This cop supports safe autocorrection (--autocorrect). Layout/ElseAlignment: - Exclude: - - 'lib/solargraph.rb' - - 'lib/solargraph/api_map/store.rb' - - 'lib/solargraph/diagnostics/rubocop.rb' - - 'lib/solargraph/language_server/message/extended/check_gem_version.rb' - - 'lib/solargraph/library.rb' - - 'lib/solargraph/parser/parser_gem/node_methods.rb' - - 'lib/solargraph/parser/parser_gem/node_processors/block_node.rb' - - 'lib/solargraph/pin/method.rb' - - 'lib/solargraph/pin/namespace.rb' - - 'lib/solargraph/rbs_map.rb' - - 'lib/solargraph/shell.rb' - - 'lib/solargraph/source/chain/call.rb' - - 'lib/solargraph/source_map/clip.rb' - - 'lib/solargraph/source_map/mapper.rb' - - 'lib/solargraph/type_checker/rules.rb' - - 'lib/solargraph/yard_map/mapper.rb' + Enabled: false # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EmptyLineBetweenMethodDefs, EmptyLineBetweenClassDefs, EmptyLineBetweenModuleDefs, DefLikeMacros, AllowAdjacentOneLineDefs, NumberOfEmptyLines. @@ -111,18 +95,7 @@ Layout/EmptyLineBetweenDefs: # This cop supports safe autocorrection (--autocorrect). Layout/EmptyLines: - Exclude: - - 'lib/solargraph/bench.rb' - - 'lib/solargraph/complex_type/unique_type.rb' - - 'lib/solargraph/doc_map.rb' - - 'lib/solargraph/language_server/message/extended/check_gem_version.rb' - - 'lib/solargraph/language_server/message/initialize.rb' - - 'lib/solargraph/pin/delegated_method.rb' - - 'lib/solargraph/rbs_map/conversions.rb' - - 'spec/complex_type_spec.rb' - - 'spec/pin/local_variable_spec.rb' - - 'spec/pin/symbol_spec.rb' - - 'spec/type_checker/levels/strict_spec.rb' + Enabled: false # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle. @@ -142,23 +115,7 @@ Layout/EmptyLinesAroundModuleBody: # Configuration parameters: EnforcedStyleAlignWith, Severity. # SupportedStylesAlignWith: keyword, variable, start_of_line Layout/EndAlignment: - Exclude: - - 'lib/solargraph.rb' - - 'lib/solargraph/api_map/store.rb' - - 'lib/solargraph/diagnostics/rubocop.rb' - - 'lib/solargraph/language_server/message/extended/check_gem_version.rb' - - 'lib/solargraph/library.rb' - - 'lib/solargraph/parser/parser_gem/node_methods.rb' - - 'lib/solargraph/parser/parser_gem/node_processors/block_node.rb' - - 'lib/solargraph/pin/method.rb' - - 'lib/solargraph/pin/namespace.rb' - - 'lib/solargraph/rbs_map.rb' - - 'lib/solargraph/shell.rb' - - 'lib/solargraph/source/chain/call.rb' - - 'lib/solargraph/source_map/clip.rb' - - 'lib/solargraph/source_map/mapper.rb' - - 'lib/solargraph/type_checker/rules.rb' - - 'lib/solargraph/yard_map/mapper.rb' + Enabled: false # Configuration parameters: EnforcedStyle. # SupportedStyles: native, lf, crlf @@ -172,13 +129,7 @@ Layout/EndOfLine: # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowForAlignment, AllowBeforeTrailingComments, ForceEqualSignAlignment. Layout/ExtraSpacing: - Exclude: - - 'lib/solargraph/parser/parser_gem/node_processors/opasgn_node.rb' - - 'lib/solargraph/pin/closure.rb' - - 'lib/solargraph/pin/local_variable.rb' - - 'lib/solargraph/rbs_map/conversions.rb' - - 'lib/solargraph/type_checker.rb' - - 'spec/spec_helper.rb' + Enabled: false # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle, IndentationWidth. @@ -203,22 +154,7 @@ Layout/FirstArrayElementIndentation: # Configuration parameters: EnforcedStyle, IndentationWidth. # SupportedStyles: special_inside_parentheses, consistent, align_braces Layout/FirstHashElementIndentation: - Exclude: - - 'lib/solargraph/language_server/message/extended/check_gem_version.rb' - - 'lib/solargraph/language_server/message/extended/document_gems.rb' - - 'lib/solargraph/language_server/message/text_document/completion.rb' - - 'lib/solargraph/language_server/message/text_document/rename.rb' - - 'lib/solargraph/language_server/message/text_document/signature_help.rb' - - 'lib/solargraph/pin/base_variable.rb' - - 'spec/language_server/host_spec.rb' - - 'spec/language_server/message/completion_item/resolve_spec.rb' - - 'spec/language_server/message/initialize_spec.rb' - - 'spec/language_server/message/text_document/definition_spec.rb' - - 'spec/language_server/message/text_document/formatting_spec.rb' - - 'spec/language_server/message/text_document/hover_spec.rb' - - 'spec/language_server/message/text_document/rename_spec.rb' - - 'spec/language_server/message/text_document/type_definition_spec.rb' - - 'spec/language_server/message/workspace/did_change_watched_files_spec.rb' + Enabled: false # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowMultipleStyles, EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle. @@ -239,27 +175,7 @@ Layout/HeredocIndentation: # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: Width, AllowedPatterns. Layout/IndentationWidth: - Exclude: - - 'lib/solargraph.rb' - - 'lib/solargraph/api_map/store.rb' - - 'lib/solargraph/diagnostics/rubocop.rb' - - 'lib/solargraph/language_server/message/extended/check_gem_version.rb' - - 'lib/solargraph/library.rb' - - 'lib/solargraph/parser/parser_gem/node_methods.rb' - - 'lib/solargraph/parser/parser_gem/node_processors/block_node.rb' - - 'lib/solargraph/pin/method.rb' - - 'lib/solargraph/pin/namespace.rb' - - 'lib/solargraph/rbs_map.rb' - - 'lib/solargraph/shell.rb' - - 'lib/solargraph/source/chain/call.rb' - - 'lib/solargraph/source_map/clip.rb' - - 'lib/solargraph/source_map/mapper.rb' - - 'lib/solargraph/type_checker.rb' - - 'lib/solargraph/type_checker/rules.rb' - - 'lib/solargraph/yard_map/mapper.rb' - - 'spec/api_map/config_spec.rb' - - 'spec/shell_spec.rb' - - 'spec/source_map/mapper_spec.rb' + Enabled: false # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowDoxygenCommentStyle, AllowGemfileRubyComment, AllowRBSInlineAnnotation, AllowSteepAnnotation. @@ -289,14 +205,7 @@ Layout/MultilineMethodCallBraceLayout: # Configuration parameters: EnforcedStyle, IndentationWidth. # SupportedStyles: aligned, indented, indented_relative_to_receiver Layout/MultilineMethodCallIndentation: - Exclude: - - 'lib/solargraph/api_map.rb' - - 'lib/solargraph/diagnostics/type_check.rb' - - 'lib/solargraph/language_server/message/completion_item/resolve.rb' - - 'lib/solargraph/language_server/message/text_document/hover.rb' - - 'lib/solargraph/library.rb' - - 'lib/solargraph/pin/search.rb' - - 'lib/solargraph/type_checker.rb' + Enabled: false # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle, IndentationWidth. @@ -316,13 +225,7 @@ Layout/SpaceAfterComma: # Configuration parameters: EnforcedStyle. # SupportedStyles: space, no_space Layout/SpaceAroundEqualsInParameterDefault: - Exclude: - - 'lib/solargraph/pin/base.rb' - - 'lib/solargraph/pin/base_variable.rb' - - 'lib/solargraph/pin/callable.rb' - - 'lib/solargraph/pin/closure.rb' - - 'lib/solargraph/pin/local_variable.rb' - - 'lib/solargraph/pin/parameter.rb' + Enabled: false # This cop supports safe autocorrection (--autocorrect). Layout/SpaceAroundKeyword: @@ -334,56 +237,14 @@ Layout/SpaceAroundKeyword: # SupportedStylesForExponentOperator: space, no_space # SupportedStylesForRationalLiterals: space, no_space Layout/SpaceAroundOperators: - Exclude: - - 'lib/solargraph/library.rb' - - 'lib/solargraph/parser/parser_gem/node_methods.rb' - - 'lib/solargraph/pin/local_variable.rb' - - 'lib/solargraph/source.rb' - - 'lib/solargraph/source/change.rb' - - 'lib/solargraph/source/cursor.rb' - - 'lib/solargraph/source/source_chainer.rb' - - 'lib/solargraph/source_map/clip.rb' - - 'lib/solargraph/workspace/config.rb' - - 'spec/library_spec.rb' - - 'spec/yard_map/mapper_spec.rb' + Enabled: false # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces. # SupportedStyles: space, no_space # SupportedStylesForEmptyBraces: space, no_space Layout/SpaceBeforeBlockBraces: - Exclude: - - 'lib/solargraph/api_map.rb' - - 'lib/solargraph/api_map/store.rb' - - 'lib/solargraph/diagnostics/rubocop.rb' - - 'lib/solargraph/diagnostics/update_errors.rb' - - 'lib/solargraph/language_server/host.rb' - - 'lib/solargraph/library.rb' - - 'lib/solargraph/parser/parser_gem/node_methods.rb' - - 'lib/solargraph/parser/parser_gem/node_processors/and_node.rb' - - 'lib/solargraph/parser/parser_gem/node_processors/if_node.rb' - - 'lib/solargraph/parser/parser_gem/node_processors/send_node.rb' - - 'lib/solargraph/pin/base.rb' - - 'lib/solargraph/source.rb' - - 'lib/solargraph/source/chain/call.rb' - - 'lib/solargraph/source/chain/class_variable.rb' - - 'lib/solargraph/source/chain/constant.rb' - - 'lib/solargraph/source/chain/global_variable.rb' - - 'lib/solargraph/source/chain/instance_variable.rb' - - 'lib/solargraph/source/chain/variable.rb' - - 'lib/solargraph/source/source_chainer.rb' - - 'lib/solargraph/source_map/clip.rb' - - 'lib/solargraph/source_map/mapper.rb' - - 'lib/solargraph/workspace/config.rb' - - 'spec/language_server/host_spec.rb' - - 'spec/language_server/protocol_spec.rb' - - 'spec/library_spec.rb' - - 'spec/pin/constant_spec.rb' - - 'spec/pin/instance_variable_spec.rb' - - 'spec/rbs_map/core_map_spec.rb' - - 'spec/source_map/mapper_spec.rb' - - 'spec/source_map_spec.rb' - - 'spec/source_spec.rb' + Enabled: false # This cop supports safe autocorrection (--autocorrect). Layout/SpaceBeforeComma: @@ -395,28 +256,7 @@ Layout/SpaceBeforeComma: # SupportedStyles: space, no_space # SupportedStylesForEmptyBraces: space, no_space Layout/SpaceInsideBlockBraces: - Exclude: - - 'lib/solargraph/api_map.rb' - - 'lib/solargraph/api_map/store.rb' - - 'lib/solargraph/diagnostics/update_errors.rb' - - 'lib/solargraph/language_server/host.rb' - - 'lib/solargraph/parser/parser_gem/node_methods.rb' - - 'lib/solargraph/parser/parser_gem/node_processors/and_node.rb' - - 'lib/solargraph/parser/parser_gem/node_processors/if_node.rb' - - 'lib/solargraph/parser/parser_gem/node_processors/send_node.rb' - - 'lib/solargraph/source/chain/call.rb' - - 'lib/solargraph/source/chain/class_variable.rb' - - 'lib/solargraph/source/chain/global_variable.rb' - - 'lib/solargraph/source/chain/instance_variable.rb' - - 'lib/solargraph/source/chain/variable.rb' - - 'lib/solargraph/source/source_chainer.rb' - - 'lib/solargraph/source_map/mapper.rb' - - 'spec/language_server/protocol_spec.rb' - - 'spec/library_spec.rb' - - 'spec/pin/constant_spec.rb' - - 'spec/rbs_map/core_map_spec.rb' - - 'spec/source_map/mapper_spec.rb' - - 'spec/source_spec.rb' + Enabled: false # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces. @@ -455,13 +295,7 @@ Lint/AmbiguousBlockAssociation: # This cop supports safe autocorrection (--autocorrect). Lint/AmbiguousOperator: - Exclude: - - 'lib/solargraph/api_map.rb' - - 'lib/solargraph/complex_type.rb' - - 'lib/solargraph/language_server/message/workspace/did_change_watched_files.rb' - - 'lib/solargraph/parser/parser_gem/class_methods.rb' - - 'lib/solargraph/pin/constant.rb' - - 'lib/solargraph/pin/method.rb' + Enabled: false # This cop supports safe autocorrection (--autocorrect). Lint/AmbiguousOperatorPrecedence: @@ -472,15 +306,7 @@ Lint/AmbiguousOperatorPrecedence: # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: RequireParenthesesForMethodChains. Lint/AmbiguousRange: - Exclude: - - 'lib/solargraph/library.rb' - - 'lib/solargraph/parser/parser_gem/node_methods.rb' - - 'lib/solargraph/source.rb' - - 'lib/solargraph/source/change.rb' - - 'lib/solargraph/source/cursor.rb' - - 'lib/solargraph/source/source_chainer.rb' - - 'lib/solargraph/source_map/clip.rb' - - 'spec/library_spec.rb' + Enabled: false # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: AllowSafeAssignment. @@ -514,14 +340,7 @@ Lint/DuplicateBranch: - 'lib/solargraph/rbs_map/conversions.rb' Lint/DuplicateMethods: - Exclude: - - 'lib/solargraph/complex_type.rb' - - 'lib/solargraph/location.rb' - - 'lib/solargraph/pin/base.rb' - - 'lib/solargraph/pin/signature.rb' - - 'lib/solargraph/rbs_map.rb' - - 'lib/solargraph/rbs_map/core_map.rb' - - 'lib/solargraph/source/chain/link.rb' + Enabled: false # Configuration parameters: AllowComments, AllowEmptyLambdas. Lint/EmptyBlock: @@ -530,13 +349,7 @@ Lint/EmptyBlock: # Configuration parameters: AllowComments. Lint/EmptyClass: - Exclude: - - 'spec/fixtures/rubocop-validation-error/app.rb' - - 'spec/fixtures/workspace-with-gemfile/lib/other.rb' - - 'spec/fixtures/workspace/lib/other.rb' - - 'spec/fixtures/workspace/lib/something.rb' - - 'spec/fixtures/workspace_folders/folder1/app.rb' - - 'spec/fixtures/workspace_folders/folder2/app.rb' + Enabled: false # Configuration parameters: AllowComments. Lint/EmptyFile: @@ -635,31 +448,7 @@ Lint/UnusedBlockArgument: # Configuration parameters: AutoCorrect, AllowUnusedKeywordArguments, IgnoreEmptyMethods, IgnoreNotImplementedMethods, NotImplementedExceptions. # NotImplementedExceptions: NotImplementedError Lint/UnusedMethodArgument: - Exclude: - - 'lib/solargraph.rb' - - 'lib/solargraph/complex_type/type_methods.rb' - - 'lib/solargraph/convention/base.rb' - - 'lib/solargraph/diagnostics/base.rb' - - 'lib/solargraph/diagnostics/update_errors.rb' - - 'lib/solargraph/doc_map.rb' - - 'lib/solargraph/pin/namespace.rb' - - 'lib/solargraph/rbs_map/conversions.rb' - - 'lib/solargraph/source.rb' - - 'lib/solargraph/source/chain.rb' - - 'lib/solargraph/source/chain/block_symbol.rb' - - 'lib/solargraph/source/chain/block_variable.rb' - - 'lib/solargraph/source/chain/call.rb' - - 'lib/solargraph/source/chain/class_variable.rb' - - 'lib/solargraph/source/chain/constant.rb' - - 'lib/solargraph/source/chain/global_variable.rb' - - 'lib/solargraph/source/chain/hash.rb' - - 'lib/solargraph/source/chain/head.rb' - - 'lib/solargraph/source/chain/instance_variable.rb' - - 'lib/solargraph/source/chain/link.rb' - - 'lib/solargraph/source/chain/literal.rb' - - 'lib/solargraph/source/chain/variable.rb' - - 'lib/solargraph/source/chain/z_super.rb' - - 'spec/doc_map_spec.rb' + Enabled: false # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AutoCorrect, ContextCreatingMethods, MethodCreatingMethods. @@ -670,30 +459,7 @@ Lint/UselessAccessModifier: # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AutoCorrect. Lint/UselessAssignment: - Exclude: - - 'lib/solargraph/api_map.rb' - - 'lib/solargraph/doc_map.rb' - - 'lib/solargraph/language_server/message/extended/check_gem_version.rb' - - 'lib/solargraph/language_server/message/extended/document_gems.rb' - - 'lib/solargraph/language_server/message/text_document/completion.rb' - - 'lib/solargraph/parser/parser_gem/node_processors/send_node.rb' - - 'lib/solargraph/pin/method.rb' - - 'lib/solargraph/pin/parameter.rb' - - 'lib/solargraph/rbs_map/conversions.rb' - - 'lib/solargraph/source.rb' - - 'lib/solargraph/source/chain/call.rb' - - 'lib/solargraph/source/source_chainer.rb' - - 'lib/solargraph/source_map/mapper.rb' - - 'lib/solargraph/type_checker.rb' - - 'spec/fixtures/long_squiggly_heredoc.rb' - - 'spec/fixtures/rubocop-unused-variable-error/app.rb' - - 'spec/fixtures/unicode.rb' - - 'spec/language_server/host_spec.rb' - - 'spec/language_server/protocol_spec.rb' - - 'spec/library_spec.rb' - - 'spec/pin/namespace_spec.rb' - - 'spec/source/chain/call_spec.rb' - - 'spec/source_map/mapper_spec.rb' + Enabled: false Lint/UselessConstantScoping: Exclude: @@ -707,43 +473,16 @@ Lint/UselessMethodDefinition: # Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes, Max. Metrics/AbcSize: - Exclude: - - 'lib/solargraph/api_map.rb' - - 'lib/solargraph/api_map/source_to_yard.rb' - - 'lib/solargraph/complex_type.rb' - - 'lib/solargraph/doc_map.rb' - - 'lib/solargraph/language_server/host.rb' - - 'lib/solargraph/language_server/message/initialize.rb' - - 'lib/solargraph/library.rb' - - 'lib/solargraph/parser/parser_gem/node_chainer.rb' - - 'lib/solargraph/parser/parser_gem/node_processors/sclass_node.rb' - - 'lib/solargraph/parser/parser_gem/node_processors/send_node.rb' - - 'lib/solargraph/pin/method.rb' - - 'lib/solargraph/rbs_map/conversions.rb' - - 'lib/solargraph/source/chain/call.rb' - - 'lib/solargraph/source/source_chainer.rb' - - 'lib/solargraph/source_map/clip.rb' - - 'lib/solargraph/source_map/mapper.rb' - - 'lib/solargraph/type_checker.rb' + Enabled: false -# Configuration parameters: CountComments, Max, CountAsOne, AllowedMethods, AllowedPatterns, inherit_mode. +# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns, inherit_mode. # AllowedMethods: refine Metrics/BlockLength: - Exclude: - - 'lib/solargraph/api_map.rb' - - 'lib/solargraph/api_map/source_to_yard.rb' - - 'lib/solargraph/complex_type.rb' - - 'lib/solargraph/convention/struct_definition.rb' - - 'lib/solargraph/parser/parser_gem/node_processors/send_node.rb' - - 'lib/solargraph/source/chain/call.rb' - - 'lib/solargraph/type_checker.rb' + Max: 54 -# Configuration parameters: CountBlocks, CountModifierForms, Max. +# Configuration parameters: CountBlocks, CountModifierForms. Metrics/BlockNesting: - Exclude: - - 'lib/solargraph/source/source_chainer.rb' - - 'lib/solargraph/source_map/clip.rb' - - 'lib/solargraph/type_checker.rb' + Max: 5 # Configuration parameters: CountComments, Max, CountAsOne. Metrics/ClassLength: @@ -755,33 +494,15 @@ Metrics/ClassLength: # Configuration parameters: AllowedMethods, AllowedPatterns, Max. Metrics/CyclomaticComplexity: - Exclude: - - 'lib/solargraph/api_map/source_to_yard.rb' - - 'lib/solargraph/complex_type.rb' - - 'lib/solargraph/parser/parser_gem/node_chainer.rb' - - 'lib/solargraph/pin/method.rb' - - 'lib/solargraph/rbs_map/conversions.rb' - - 'lib/solargraph/source/chain/call.rb' - - 'lib/solargraph/source/source_chainer.rb' - - 'lib/solargraph/source_map/mapper.rb' - - 'lib/solargraph/type_checker.rb' + Enabled: false # Configuration parameters: CountComments, Max, CountAsOne, AllowedMethods, AllowedPatterns. Metrics/MethodLength: - Exclude: - - 'lib/solargraph/api_map.rb' - - 'lib/solargraph/complex_type.rb' - - 'lib/solargraph/convention/struct_definition.rb' - - 'lib/solargraph/parser/parser_gem/node_chainer.rb' - - 'lib/solargraph/source/chain/call.rb' - - 'lib/solargraph/source_map/mapper.rb' + Enabled: false -# Configuration parameters: CountComments, Max, CountAsOne. +# Configuration parameters: CountComments, CountAsOne. Metrics/ModuleLength: - Exclude: - - 'lib/solargraph/complex_type/type_methods.rb' - - 'lib/solargraph/parser/parser_gem/node_methods.rb' - - 'lib/solargraph/pin_cache.rb' + Max: 169 # Configuration parameters: Max, CountKeywordArgs, MaxOptionalParameters. Metrics/ParameterLists: @@ -794,13 +515,7 @@ Metrics/ParameterLists: # Configuration parameters: AllowedMethods, AllowedPatterns, Max. Metrics/PerceivedComplexity: - Exclude: - - 'lib/solargraph/complex_type.rb' - - 'lib/solargraph/parser/parser_gem/node_chainer.rb' - - 'lib/solargraph/source/chain/call.rb' - - 'lib/solargraph/source/source_chainer.rb' - - 'lib/solargraph/source_map/mapper.rb' - - 'lib/solargraph/type_checker.rb' + Enabled: false Naming/AccessorMethodName: Exclude: @@ -823,41 +538,18 @@ Naming/HeredocDelimiterNaming: # Configuration parameters: EnforcedStyleForLeadingUnderscores. # SupportedStylesForLeadingUnderscores: disallowed, required, optional Naming/MemoizedInstanceVariableName: - Exclude: - - 'lib/solargraph/complex_type/type_methods.rb' - - 'lib/solargraph/convention/gemfile.rb' - - 'lib/solargraph/convention/gemspec.rb' - - 'lib/solargraph/convention/rakefile.rb' - - 'lib/solargraph/doc_map.rb' - - 'lib/solargraph/rbs_map.rb' - - 'lib/solargraph/workspace.rb' + Enabled: false # Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames. # AllowedNames: as, at, by, cc, db, id, if, in, io, ip, of, on, os, pp, to Naming/MethodParameterName: - Exclude: - - 'lib/solargraph/parser/parser_gem/node_chainer.rb' - - 'lib/solargraph/pin/base.rb' - - 'lib/solargraph/range.rb' - - 'lib/solargraph/source.rb' - - 'lib/solargraph/yard_map/mapper/to_method.rb' - - 'lib/solargraph/yard_map/to_method.rb' + Enabled: false # Configuration parameters: Mode, AllowedMethods, AllowedPatterns, AllowBangMethods, WaywardPredicates. # AllowedMethods: call # WaywardPredicates: nonzero? Naming/PredicateMethod: - Exclude: - - 'lib/solargraph/api_map/store.rb' - - 'lib/solargraph/convention/data_definition.rb' - - 'lib/solargraph/convention/struct_definition.rb' - - 'lib/solargraph/language_server/progress.rb' - - 'lib/solargraph/library.rb' - - 'lib/solargraph/parser/node_processor/base.rb' - - 'lib/solargraph/parser/parser_gem/node_processors/send_node.rb' - - 'lib/solargraph/pin/base.rb' - - 'lib/solargraph/pin/local_variable.rb' - - 'lib/solargraph/workspace.rb' + Enabled: false # Configuration parameters: NamePrefix, ForbiddenPrefixes, AllowedMethods, MethodDefinitionMacros, UseSorbetSigs. # NamePrefix: is_, has_, have_, does_ @@ -912,16 +604,7 @@ RSpec/BeforeAfterAll: # Configuration parameters: Prefixes, AllowedPatterns. # Prefixes: when, with, without RSpec/ContextWording: - Exclude: - - 'spec/complex_type_spec.rb' - - 'spec/library_spec.rb' - - 'spec/pin/method_spec.rb' - - 'spec/pin/parameter_spec.rb' - - 'spec/pin/symbol_spec.rb' - - 'spec/type_checker/levels/normal_spec.rb' - - 'spec/type_checker/levels/strict_spec.rb' - - 'spec/type_checker/levels/strong_spec.rb' - - 'spec/type_checker/levels/typed_spec.rb' + Enabled: false # Configuration parameters: IgnoredMetadata. RSpec/DescribeClass: @@ -938,81 +621,11 @@ RSpec/DescribeClass: # Configuration parameters: SkipBlocks, EnforcedStyle, OnlyStaticConstants. # SupportedStyles: described_class, explicit RSpec/DescribedClass: - Exclude: - - 'spec/api_map/cache_spec.rb' - - 'spec/api_map/source_to_yard_spec.rb' - - 'spec/api_map/store_spec.rb' - - 'spec/api_map_spec.rb' - - 'spec/diagnostics/base_spec.rb' - - 'spec/diagnostics/require_not_found_spec.rb' - - 'spec/diagnostics/rubocop_helpers_spec.rb' - - 'spec/diagnostics/rubocop_spec.rb' - - 'spec/diagnostics/type_check_spec.rb' - - 'spec/diagnostics/update_errors_spec.rb' - - 'spec/diagnostics_spec.rb' - - 'spec/doc_map_spec.rb' - - 'spec/gem_pins_spec.rb' - - 'spec/language_server/host/diagnoser_spec.rb' - - 'spec/language_server/host/dispatch_spec.rb' - - 'spec/language_server/host/message_worker_spec.rb' - - 'spec/language_server/host_spec.rb' - - 'spec/language_server/message/completion_item/resolve_spec.rb' - - 'spec/language_server/message/extended/check_gem_version_spec.rb' - - 'spec/language_server/message/initialize_spec.rb' - - 'spec/language_server/message/text_document/definition_spec.rb' - - 'spec/language_server/message/text_document/formatting_spec.rb' - - 'spec/language_server/message/text_document/hover_spec.rb' - - 'spec/language_server/message/text_document/rename_spec.rb' - - 'spec/language_server/message/text_document/type_definition_spec.rb' - - 'spec/language_server/message/workspace/did_change_watched_files_spec.rb' - - 'spec/language_server/message_spec.rb' - - 'spec/language_server/protocol_spec.rb' - - 'spec/language_server/transport/data_reader_spec.rb' - - 'spec/language_server/uri_helpers_spec.rb' - - 'spec/library_spec.rb' - - 'spec/logging_spec.rb' - - 'spec/parser/node_methods_spec.rb' - - 'spec/parser/node_processor_spec.rb' - - 'spec/parser_spec.rb' - - 'spec/pin/base_spec.rb' - - 'spec/pin/delegated_method_spec.rb' - - 'spec/pin/instance_variable_spec.rb' - - 'spec/pin/keyword_spec.rb' - - 'spec/pin/local_variable_spec.rb' - - 'spec/pin/method_spec.rb' - - 'spec/pin/namespace_spec.rb' - - 'spec/pin/parameter_spec.rb' - - 'spec/pin/search_spec.rb' - - 'spec/pin/symbol_spec.rb' - - 'spec/position_spec.rb' - - 'spec/rbs_map/conversions_spec.rb' - - 'spec/rbs_map/core_map_spec.rb' - - 'spec/rbs_map/stdlib_map_spec.rb' - - 'spec/rbs_map_spec.rb' - - 'spec/source/chain/class_variable_spec.rb' - - 'spec/source/chain/global_variable_spec.rb' - - 'spec/source/chain/head_spec.rb' - - 'spec/source/chain/instance_variable_spec.rb' - - 'spec/source/chain/z_super_spec.rb' - - 'spec/source/change_spec.rb' - - 'spec/source/source_chainer_spec.rb' - - 'spec/source/updater_spec.rb' - - 'spec/source_map/mapper_spec.rb' - - 'spec/source_map_spec.rb' - - 'spec/source_spec.rb' - - 'spec/type_checker/checks_spec.rb' - - 'spec/type_checker/levels/normal_spec.rb' - - 'spec/type_checker/levels/strict_spec.rb' - - 'spec/type_checker/rules_spec.rb' - - 'spec/type_checker_spec.rb' - - 'spec/workspace/config_spec.rb' - - 'spec/workspace_spec.rb' - - 'spec/yard_map/mapper/to_method_spec.rb' - - 'spec/yard_map/mapper_spec.rb' - -# This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: AutoCorrect. -RSpec/EmptyExampleGroup: + Enabled: false + +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: AutoCorrect. +RSpec/EmptyExampleGroup: Exclude: - 'spec/convention_spec.rb' @@ -1023,33 +636,7 @@ RSpec/EmptyLineAfterFinalLet: # Configuration parameters: Max, CountAsOne. RSpec/ExampleLength: - Exclude: - - 'spec/api_map_spec.rb' - - 'spec/complex_type_spec.rb' - - 'spec/language_server/host_spec.rb' - - 'spec/language_server/message/initialize_spec.rb' - - 'spec/language_server/message/text_document/definition_spec.rb' - - 'spec/language_server/message/text_document/hover_spec.rb' - - 'spec/language_server/message/text_document/rename_spec.rb' - - 'spec/language_server/message/text_document/type_definition_spec.rb' - - 'spec/language_server/message/workspace/did_change_watched_files_spec.rb' - - 'spec/language_server/protocol_spec.rb' - - 'spec/library_spec.rb' - - 'spec/parser/flow_sensitive_typing_spec.rb' - - 'spec/parser/node_methods_spec.rb' - - 'spec/parser/node_processor_spec.rb' - - 'spec/pin/base_variable_spec.rb' - - 'spec/pin/delegated_method_spec.rb' - - 'spec/pin/local_variable_spec.rb' - - 'spec/pin/parameter_spec.rb' - - 'spec/source/chain/call_spec.rb' - - 'spec/source/chain_spec.rb' - - 'spec/source_map/clip_spec.rb' - - 'spec/source_map/mapper_spec.rb' - - 'spec/source_map_spec.rb' - - 'spec/source_spec.rb' - - 'spec/type_checker/levels/strict_spec.rb' - - 'spec/type_checker_spec.rb' + Enabled: false # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: CustomTransform, IgnoredWords, DisallowedExamples. @@ -1077,15 +664,7 @@ RSpec/ExpectActual: # Configuration parameters: EnforcedStyle. # SupportedStyles: implicit, each, example RSpec/HookArgument: - Exclude: - - 'spec/api_map/config_spec.rb' - - 'spec/diagnostics/require_not_found_spec.rb' - - 'spec/language_server/host/dispatch_spec.rb' - - 'spec/language_server/host_spec.rb' - - 'spec/language_server/message/extended/check_gem_version_spec.rb' - - 'spec/language_server/protocol_spec.rb' - - 'spec/workspace/config_spec.rb' - - 'spec/workspace_spec.rb' + Enabled: false # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: . @@ -1095,13 +674,7 @@ RSpec/ImplicitExpect: # Configuration parameters: AssignmentOnly. RSpec/InstanceVariable: - Exclude: - - 'spec/api_map/config_spec.rb' - - 'spec/api_map_spec.rb' - - 'spec/diagnostics/require_not_found_spec.rb' - - 'spec/language_server/host/dispatch_spec.rb' - - 'spec/language_server/host_spec.rb' - - 'spec/language_server/protocol_spec.rb' + Enabled: false # This cop supports safe autocorrection (--autocorrect). RSpec/LeadingSubject: @@ -1127,89 +700,17 @@ RSpec/MissingExampleGroupArgument: Exclude: - 'spec/diagnostics/rubocop_helpers_spec.rb' -# Configuration parameters: Max. RSpec/MultipleExpectations: - Exclude: - - 'spec/api_map/cache_spec.rb' - - 'spec/api_map/config_spec.rb' - - 'spec/api_map/source_to_yard_spec.rb' - - 'spec/api_map/store_spec.rb' - - 'spec/api_map_spec.rb' - - 'spec/complex_type_spec.rb' - - 'spec/convention/struct_definition_spec.rb' - - 'spec/diagnostics/rubocop_spec.rb' - - 'spec/diagnostics/type_check_spec.rb' - - 'spec/diagnostics/update_errors_spec.rb' - - 'spec/diagnostics_spec.rb' - - 'spec/doc_map_spec.rb' - - 'spec/gem_pins_spec.rb' - - 'spec/language_server/host/message_worker_spec.rb' - - 'spec/language_server/host_spec.rb' - - 'spec/language_server/message/completion_item/resolve_spec.rb' - - 'spec/language_server/message/initialize_spec.rb' - - 'spec/language_server/message/text_document/rename_spec.rb' - - 'spec/language_server/message/workspace/did_change_watched_files_spec.rb' - - 'spec/language_server/protocol_spec.rb' - - 'spec/language_server/transport/adapter_spec.rb' - - 'spec/language_server/transport/data_reader_spec.rb' - - 'spec/library_spec.rb' - - 'spec/parser/flow_sensitive_typing_spec.rb' - - 'spec/parser/node_chainer_spec.rb' - - 'spec/parser/node_methods_spec.rb' - - 'spec/parser/node_processor_spec.rb' - - 'spec/pin/base_spec.rb' - - 'spec/pin/base_variable_spec.rb' - - 'spec/pin/constant_spec.rb' - - 'spec/pin/instance_variable_spec.rb' - - 'spec/pin/local_variable_spec.rb' - - 'spec/pin/method_spec.rb' - - 'spec/pin/namespace_spec.rb' - - 'spec/pin/parameter_spec.rb' - - 'spec/position_spec.rb' - - 'spec/rbs_map/core_map_spec.rb' - - 'spec/rbs_map/stdlib_map_spec.rb' - - 'spec/rbs_map_spec.rb' - - 'spec/shell_spec.rb' - - 'spec/source/chain/call_spec.rb' - - 'spec/source/chain/class_variable_spec.rb' - - 'spec/source/chain/global_variable_spec.rb' - - 'spec/source/chain/head_spec.rb' - - 'spec/source/chain/instance_variable_spec.rb' - - 'spec/source/chain_spec.rb' - - 'spec/source/cursor_spec.rb' - - 'spec/source/source_chainer_spec.rb' - - 'spec/source_map/clip_spec.rb' - - 'spec/source_map/mapper_spec.rb' - - 'spec/source_map/node_processor_spec.rb' - - 'spec/source_map_spec.rb' - - 'spec/source_spec.rb' - - 'spec/type_checker/checks_spec.rb' - - 'spec/type_checker/levels/normal_spec.rb' - - 'spec/type_checker/levels/strict_spec.rb' - - 'spec/type_checker/levels/strong_spec.rb' - - 'spec/type_checker/levels/typed_spec.rb' - - 'spec/type_checker/rules_spec.rb' - - 'spec/workspace/config_spec.rb' - - 'spec/workspace_spec.rb' - - 'spec/yard_map/mapper/to_method_spec.rb' - - 'spec/yard_map/mapper_spec.rb' + Max: 14 -# Configuration parameters: Max, AllowedGroups. +# Configuration parameters: AllowedGroups. RSpec/NestedGroups: - Exclude: - - 'spec/complex_type_spec.rb' + Max: 4 # Configuration parameters: AllowedPatterns. # AllowedPatterns: ^expect_, ^assert_ RSpec/NoExpectationExample: - Exclude: - - 'spec/language_server/protocol_spec.rb' - - 'spec/parser/node_methods_spec.rb' - - 'spec/pin/block_spec.rb' - - 'spec/pin/method_spec.rb' - - 'spec/source/chain/call_spec.rb' - - 'spec/type_checker/checks_spec.rb' - - 'spec/type_checker/levels/typed_spec.rb' + Enabled: false # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle. @@ -1220,18 +721,7 @@ RSpec/NotToNot: - 'spec/rbs_map/core_map_spec.rb' RSpec/PendingWithoutReason: - Exclude: - - 'spec/api_map_spec.rb' - - 'spec/complex_type_spec.rb' - - 'spec/parser/node_chainer_spec.rb' - - 'spec/parser/node_methods_spec.rb' - - 'spec/pin/local_variable_spec.rb' - - 'spec/rbs_map/core_map_spec.rb' - - 'spec/source/chain/call_spec.rb' - - 'spec/source/chain_spec.rb' - - 'spec/source_map/clip_spec.rb' - - 'spec/type_checker/levels/strict_spec.rb' - - 'spec/yard_map/mapper/to_method_spec.rb' + Enabled: false # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: Strict, EnforcedStyle, AllowedExplicitMatchers. @@ -1251,16 +741,7 @@ RSpec/RemoveConst: - 'spec/diagnostics/rubocop_helpers_spec.rb' RSpec/RepeatedDescription: - Exclude: - - 'spec/api_map_spec.rb' - - 'spec/language_server/protocol_spec.rb' - - 'spec/parser/node_methods_spec.rb' - - 'spec/source/chain/call_spec.rb' - - 'spec/source/source_chainer_spec.rb' - - 'spec/source_map/clip_spec.rb' - - 'spec/source_map/mapper_spec.rb' - - 'spec/type_checker/levels/normal_spec.rb' - - 'spec/type_checker/levels/strict_spec.rb' + Enabled: false RSpec/RepeatedExample: Exclude: @@ -1279,99 +760,7 @@ RSpec/ScatteredLet: # Configuration parameters: Include, CustomTransform, IgnoreMethods, IgnoreMetadata. # Include: **/*_spec.rb RSpec/SpecFilePathFormat: - Exclude: - - '**/spec/routing/**/*' - - 'spec/api_map/cache_spec.rb' - - 'spec/api_map/config_spec.rb' - - 'spec/api_map/source_to_yard_spec.rb' - - 'spec/api_map/store_spec.rb' - - 'spec/api_map_spec.rb' - - 'spec/convention/activesupport_concern_spec.rb' - - 'spec/convention/struct_definition_spec.rb' - - 'spec/convention_spec.rb' - - 'spec/diagnostics/base_spec.rb' - - 'spec/diagnostics/require_not_found_spec.rb' - - 'spec/diagnostics/rubocop_helpers_spec.rb' - - 'spec/diagnostics/rubocop_spec.rb' - - 'spec/diagnostics/type_check_spec.rb' - - 'spec/diagnostics/update_errors_spec.rb' - - 'spec/diagnostics_spec.rb' - - 'spec/doc_map_spec.rb' - - 'spec/gem_pins_spec.rb' - - 'spec/language_server/host/diagnoser_spec.rb' - - 'spec/language_server/host/dispatch_spec.rb' - - 'spec/language_server/host/message_worker_spec.rb' - - 'spec/language_server/host_spec.rb' - - 'spec/language_server/message/completion_item/resolve_spec.rb' - - 'spec/language_server/message/extended/check_gem_version_spec.rb' - - 'spec/language_server/message/initialize_spec.rb' - - 'spec/language_server/message/text_document/definition_spec.rb' - - 'spec/language_server/message/text_document/formatting_spec.rb' - - 'spec/language_server/message/text_document/hover_spec.rb' - - 'spec/language_server/message/text_document/rename_spec.rb' - - 'spec/language_server/message/text_document/type_definition_spec.rb' - - 'spec/language_server/message/workspace/did_change_configuration_spec.rb' - - 'spec/language_server/message/workspace/did_change_watched_files_spec.rb' - - 'spec/language_server/message_spec.rb' - - 'spec/language_server/transport/adapter_spec.rb' - - 'spec/language_server/transport/data_reader_spec.rb' - - 'spec/language_server/uri_helpers_spec.rb' - - 'spec/library_spec.rb' - - 'spec/logging_spec.rb' - - 'spec/parser/flow_sensitive_typing_spec.rb' - - 'spec/parser/node_methods_spec.rb' - - 'spec/parser/node_processor_spec.rb' - - 'spec/parser_spec.rb' - - 'spec/pin/base_spec.rb' - - 'spec/pin/base_variable_spec.rb' - - 'spec/pin/block_spec.rb' - - 'spec/pin/constant_spec.rb' - - 'spec/pin/delegated_method_spec.rb' - - 'spec/pin/documenting_spec.rb' - - 'spec/pin/instance_variable_spec.rb' - - 'spec/pin/keyword_spec.rb' - - 'spec/pin/local_variable_spec.rb' - - 'spec/pin/method_spec.rb' - - 'spec/pin/namespace_spec.rb' - - 'spec/pin/parameter_spec.rb' - - 'spec/pin/search_spec.rb' - - 'spec/pin/symbol_spec.rb' - - 'spec/position_spec.rb' - - 'spec/rbs_map/conversions_spec.rb' - - 'spec/rbs_map/core_map_spec.rb' - - 'spec/rbs_map/stdlib_map_spec.rb' - - 'spec/rbs_map_spec.rb' - - 'spec/shell_spec.rb' - - 'spec/source/chain/array_spec.rb' - - 'spec/source/chain/call_spec.rb' - - 'spec/source/chain/class_variable_spec.rb' - - 'spec/source/chain/constant_spec.rb' - - 'spec/source/chain/global_variable_spec.rb' - - 'spec/source/chain/head_spec.rb' - - 'spec/source/chain/instance_variable_spec.rb' - - 'spec/source/chain/link_spec.rb' - - 'spec/source/chain/literal_spec.rb' - - 'spec/source/chain/z_super_spec.rb' - - 'spec/source/chain_spec.rb' - - 'spec/source/change_spec.rb' - - 'spec/source/cursor_spec.rb' - - 'spec/source/source_chainer_spec.rb' - - 'spec/source/updater_spec.rb' - - 'spec/source_map/clip_spec.rb' - - 'spec/source_map/mapper_spec.rb' - - 'spec/source_map_spec.rb' - - 'spec/source_spec.rb' - - 'spec/type_checker/checks_spec.rb' - - 'spec/type_checker/levels/normal_spec.rb' - - 'spec/type_checker/levels/strict_spec.rb' - - 'spec/type_checker/levels/strong_spec.rb' - - 'spec/type_checker/levels/typed_spec.rb' - - 'spec/type_checker/rules_spec.rb' - - 'spec/type_checker_spec.rb' - - 'spec/workspace/config_spec.rb' - - 'spec/workspace_spec.rb' - - 'spec/yard_map/mapper/to_method_spec.rb' - - 'spec/yard_map/mapper_spec.rb' + Enabled: false RSpec/StubbedMock: Exclude: @@ -1379,20 +768,7 @@ RSpec/StubbedMock: # Configuration parameters: IgnoreNameless, IgnoreSymbolicNames. RSpec/VerifiedDoubles: - Exclude: - - 'spec/complex_type_spec.rb' - - 'spec/language_server/host/diagnoser_spec.rb' - - 'spec/language_server/host/message_worker_spec.rb' - - 'spec/language_server/host_spec.rb' - - 'spec/language_server/message/completion_item/resolve_spec.rb' - - 'spec/language_server/message/extended/check_gem_version_spec.rb' - - 'spec/language_server/message/text_document/formatting_spec.rb' - - 'spec/language_server/message/workspace/did_change_watched_files_spec.rb' - - 'spec/language_server/protocol_spec.rb' - - 'spec/source/chain/class_variable_spec.rb' - - 'spec/source/cursor_spec.rb' - - 'spec/source/source_chainer_spec.rb' - - 'spec/workspace_spec.rb' + Enabled: false Security/MarshalLoad: Exclude: @@ -1402,20 +778,7 @@ Security/MarshalLoad: # Configuration parameters: EnforcedStyle, AllowModifiersOnSymbols, AllowModifiersOnAttrs, AllowModifiersOnAliasMethod. # SupportedStyles: inline, group Style/AccessModifierDeclarations: - Exclude: - - 'lib/solargraph/api_map.rb' - - 'lib/solargraph/complex_type.rb' - - 'lib/solargraph/complex_type/unique_type.rb' - - 'lib/solargraph/location.rb' - - 'lib/solargraph/pin/base.rb' - - 'lib/solargraph/position.rb' - - 'lib/solargraph/range.rb' - - 'lib/solargraph/source/chain.rb' - - 'lib/solargraph/source/chain/call.rb' - - 'lib/solargraph/source/chain/hash.rb' - - 'lib/solargraph/source/chain/if.rb' - - 'lib/solargraph/source/chain/link.rb' - - 'lib/solargraph/source/chain/literal.rb' + Enabled: false # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle. @@ -1431,21 +794,7 @@ Style/AccessorGrouping: # Configuration parameters: EnforcedStyle. # SupportedStyles: always, conditionals Style/AndOr: - Exclude: - - 'lib/solargraph/api_map/source_to_yard.rb' - - 'lib/solargraph/complex_type/unique_type.rb' - - 'lib/solargraph/language_server/message/base.rb' - - 'lib/solargraph/page.rb' - - 'lib/solargraph/parser/parser_gem/node_methods.rb' - - 'lib/solargraph/pin/method.rb' - - 'lib/solargraph/pin/parameter.rb' - - 'lib/solargraph/position.rb' - - 'lib/solargraph/source/change.rb' - - 'lib/solargraph/source/cursor.rb' - - 'lib/solargraph/source/source_chainer.rb' - - 'lib/solargraph/source/updater.rb' - - 'lib/solargraph/workspace.rb' - - 'lib/solargraph/yard_map/mapper.rb' + Enabled: false # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowOnlyRestArgument, UseAnonymousForwarding, RedundantRestArgumentNames, RedundantKeywordRestArgumentNames, RedundantBlockArgumentNames. @@ -1464,44 +813,12 @@ Style/ArgumentsForwarding: # FunctionalMethods: let, let!, subject, watch # AllowedMethods: lambda, proc, it Style/BlockDelimiters: - Exclude: - - 'lib/solargraph/api_map/source_to_yard.rb' - - 'lib/solargraph/api_map/store.rb' - - 'lib/solargraph/language_server/host.rb' - - 'lib/solargraph/parser/parser_gem/node_methods.rb' - - 'lib/solargraph/shell.rb' - - 'lib/solargraph/source.rb' - - 'lib/solargraph/source_map/clip.rb' - - 'lib/solargraph/source_map/mapper.rb' - - 'spec/diagnostics/rubocop_spec.rb' - - 'spec/language_server/host_spec.rb' - - 'spec/language_server/message/extended/check_gem_version_spec.rb' - - 'spec/language_server/message/workspace/did_change_watched_files_spec.rb' - - 'spec/language_server/protocol_spec.rb' - - 'spec/language_server/transport/adapter_spec.rb' - - 'spec/language_server/transport/data_reader_spec.rb' - - 'spec/library_spec.rb' - - 'spec/parser/node_processor_spec.rb' - - 'spec/pin/documenting_spec.rb' - - 'spec/position_spec.rb' - - 'spec/source/chain_spec.rb' - - 'spec/source/source_chainer_spec.rb' - - 'spec/source_map/mapper_spec.rb' - - 'spec/source_spec.rb' - - 'spec/type_checker_spec.rb' - - 'spec/workspace_spec.rb' - - 'spec/yard_map/mapper/to_method_spec.rb' + Enabled: false # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: MinBranchesCount. Style/CaseLikeIf: - Exclude: - - 'lib/solargraph/language_server/message/workspace/did_change_watched_files.rb' - - 'lib/solargraph/parser/parser_gem/node_methods.rb' - - 'lib/solargraph/pin/parameter.rb' - - 'lib/solargraph/rbs_map/conversions.rb' - - 'lib/solargraph/source/source_chainer.rb' - - 'lib/solargraph/yard_map/mapper.rb' + Enabled: false # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: EnforcedStyle, EnforcedStyleForClasses, EnforcedStyleForModules. @@ -1509,18 +826,7 @@ Style/CaseLikeIf: # SupportedStylesForClasses: ~, nested, compact # SupportedStylesForModules: ~, nested, compact Style/ClassAndModuleChildren: - Exclude: - - 'lib/solargraph/language_server/message/text_document/definition.rb' - - 'lib/solargraph/language_server/message/text_document/document_highlight.rb' - - 'lib/solargraph/language_server/message/text_document/document_symbol.rb' - - 'lib/solargraph/language_server/message/text_document/prepare_rename.rb' - - 'lib/solargraph/language_server/message/text_document/references.rb' - - 'lib/solargraph/language_server/message/text_document/rename.rb' - - 'lib/solargraph/language_server/message/text_document/type_definition.rb' - - 'lib/solargraph/language_server/message/workspace/did_change_configuration.rb' - - 'lib/solargraph/language_server/message/workspace/did_change_watched_files.rb' - - 'lib/solargraph/language_server/message/workspace/did_change_workspace_folders.rb' - - 'lib/solargraph/language_server/message/workspace/workspace_symbol.rb' + Enabled: false # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: AllowedMethods, AllowedPatterns. @@ -1556,150 +862,13 @@ Style/ConcatArrayLiterals: # SupportedStyles: assign_to_condition, assign_inside_condition Style/ConditionalAssignment: Exclude: + - 'lib/solargraph/api_map/source_to_yard.rb' - 'lib/solargraph/parser/parser_gem/node_processors/defs_node.rb' - 'lib/solargraph/source/chain/call.rb' # Configuration parameters: AllowedConstants. Style/Documentation: - Exclude: - - 'spec/**/*' - - 'test/**/*' - - 'lib/solargraph/api_map/cache.rb' - - 'lib/solargraph/api_map/index.rb' - - 'lib/solargraph/api_map/source_to_yard.rb' - - 'lib/solargraph/convention/data_definition.rb' - - 'lib/solargraph/convention/gemfile.rb' - - 'lib/solargraph/convention/gemspec.rb' - - 'lib/solargraph/convention/rakefile.rb' - - 'lib/solargraph/convention/struct_definition.rb' - - 'lib/solargraph/converters/dd.rb' - - 'lib/solargraph/converters/dl.rb' - - 'lib/solargraph/converters/dt.rb' - - 'lib/solargraph/diagnostics/update_errors.rb' - - 'lib/solargraph/language_server/message/base.rb' - - 'lib/solargraph/language_server/message/cancel_request.rb' - - 'lib/solargraph/language_server/message/client.rb' - - 'lib/solargraph/language_server/message/client/register_capability.rb' - - 'lib/solargraph/language_server/message/completion_item.rb' - - 'lib/solargraph/language_server/message/exit_notification.rb' - - 'lib/solargraph/language_server/message/extended/document.rb' - - 'lib/solargraph/language_server/message/extended/search.rb' - - 'lib/solargraph/language_server/message/initialize.rb' - - 'lib/solargraph/language_server/message/initialized.rb' - - 'lib/solargraph/language_server/message/method_not_found.rb' - - 'lib/solargraph/language_server/message/method_not_implemented.rb' - - 'lib/solargraph/language_server/message/shutdown.rb' - - 'lib/solargraph/language_server/message/text_document.rb' - - 'lib/solargraph/language_server/message/text_document/base.rb' - - 'lib/solargraph/language_server/message/text_document/code_action.rb' - - 'lib/solargraph/language_server/message/text_document/completion.rb' - - 'lib/solargraph/language_server/message/text_document/definition.rb' - - 'lib/solargraph/language_server/message/text_document/did_change.rb' - - 'lib/solargraph/language_server/message/text_document/did_close.rb' - - 'lib/solargraph/language_server/message/text_document/did_open.rb' - - 'lib/solargraph/language_server/message/text_document/did_save.rb' - - 'lib/solargraph/language_server/message/text_document/document_highlight.rb' - - 'lib/solargraph/language_server/message/text_document/document_symbol.rb' - - 'lib/solargraph/language_server/message/text_document/folding_range.rb' - - 'lib/solargraph/language_server/message/text_document/formatting.rb' - - 'lib/solargraph/language_server/message/text_document/hover.rb' - - 'lib/solargraph/language_server/message/text_document/on_type_formatting.rb' - - 'lib/solargraph/language_server/message/text_document/prepare_rename.rb' - - 'lib/solargraph/language_server/message/text_document/references.rb' - - 'lib/solargraph/language_server/message/text_document/rename.rb' - - 'lib/solargraph/language_server/message/text_document/signature_help.rb' - - 'lib/solargraph/language_server/message/text_document/type_definition.rb' - - 'lib/solargraph/language_server/message/workspace.rb' - - 'lib/solargraph/language_server/message/workspace/did_change_configuration.rb' - - 'lib/solargraph/language_server/message/workspace/did_change_watched_files.rb' - - 'lib/solargraph/language_server/message/workspace/did_change_workspace_folders.rb' - - 'lib/solargraph/language_server/message/workspace/workspace_symbol.rb' - - 'lib/solargraph/language_server/request.rb' - - 'lib/solargraph/language_server/transport/data_reader.rb' - - 'lib/solargraph/logging.rb' - - 'lib/solargraph/page.rb' - - 'lib/solargraph/parser.rb' - - 'lib/solargraph/parser/comment_ripper.rb' - - 'lib/solargraph/parser/flow_sensitive_typing.rb' - - 'lib/solargraph/parser/node_methods.rb' - - 'lib/solargraph/parser/node_processor/base.rb' - - 'lib/solargraph/parser/parser_gem.rb' - - 'lib/solargraph/parser/parser_gem/class_methods.rb' - - 'lib/solargraph/parser/parser_gem/node_methods.rb' - - 'lib/solargraph/parser/parser_gem/node_processors.rb' - - 'lib/solargraph/parser/parser_gem/node_processors/alias_node.rb' - - 'lib/solargraph/parser/parser_gem/node_processors/and_node.rb' - - 'lib/solargraph/parser/parser_gem/node_processors/args_node.rb' - - 'lib/solargraph/parser/parser_gem/node_processors/begin_node.rb' - - 'lib/solargraph/parser/parser_gem/node_processors/block_node.rb' - - 'lib/solargraph/parser/parser_gem/node_processors/casgn_node.rb' - - 'lib/solargraph/parser/parser_gem/node_processors/cvasgn_node.rb' - - 'lib/solargraph/parser/parser_gem/node_processors/def_node.rb' - - 'lib/solargraph/parser/parser_gem/node_processors/defs_node.rb' - - 'lib/solargraph/parser/parser_gem/node_processors/gvasgn_node.rb' - - 'lib/solargraph/parser/parser_gem/node_processors/if_node.rb' - - 'lib/solargraph/parser/parser_gem/node_processors/ivasgn_node.rb' - - 'lib/solargraph/parser/parser_gem/node_processors/lvasgn_node.rb' - - 'lib/solargraph/parser/parser_gem/node_processors/masgn_node.rb' - - 'lib/solargraph/parser/parser_gem/node_processors/namespace_node.rb' - - 'lib/solargraph/parser/parser_gem/node_processors/opasgn_node.rb' - - 'lib/solargraph/parser/parser_gem/node_processors/orasgn_node.rb' - - 'lib/solargraph/parser/parser_gem/node_processors/resbody_node.rb' - - 'lib/solargraph/parser/parser_gem/node_processors/sclass_node.rb' - - 'lib/solargraph/parser/parser_gem/node_processors/send_node.rb' - - 'lib/solargraph/parser/parser_gem/node_processors/sym_node.rb' - - 'lib/solargraph/parser/parser_gem/node_processors/until_node.rb' - - 'lib/solargraph/parser/parser_gem/node_processors/while_node.rb' - - 'lib/solargraph/parser/snippet.rb' - - 'lib/solargraph/pin/base_variable.rb' - - 'lib/solargraph/pin/block.rb' - - 'lib/solargraph/pin/callable.rb' - - 'lib/solargraph/pin/closure.rb' - - 'lib/solargraph/pin/common.rb' - - 'lib/solargraph/pin/constant.rb' - - 'lib/solargraph/pin/instance_variable.rb' - - 'lib/solargraph/pin/keyword.rb' - - 'lib/solargraph/pin/local_variable.rb' - - 'lib/solargraph/pin/namespace.rb' - - 'lib/solargraph/pin/parameter.rb' - - 'lib/solargraph/pin/proxy_type.rb' - - 'lib/solargraph/pin/reference.rb' - - 'lib/solargraph/pin/reference/override.rb' - - 'lib/solargraph/pin/reference/require.rb' - - 'lib/solargraph/pin/search.rb' - - 'lib/solargraph/pin/signature.rb' - - 'lib/solargraph/pin/singleton.rb' - - 'lib/solargraph/pin/symbol.rb' - - 'lib/solargraph/pin/until.rb' - - 'lib/solargraph/pin/while.rb' - - 'lib/solargraph/pin_cache.rb' - - 'lib/solargraph/rbs_map.rb' - - 'lib/solargraph/server_methods.rb' - - 'lib/solargraph/shell.rb' - - 'lib/solargraph/source/chain/array.rb' - - 'lib/solargraph/source/chain/block_symbol.rb' - - 'lib/solargraph/source/chain/block_variable.rb' - - 'lib/solargraph/source/chain/class_variable.rb' - - 'lib/solargraph/source/chain/constant.rb' - - 'lib/solargraph/source/chain/global_variable.rb' - - 'lib/solargraph/source/chain/hash.rb' - - 'lib/solargraph/source/chain/if.rb' - - 'lib/solargraph/source/chain/instance_variable.rb' - - 'lib/solargraph/source/chain/link.rb' - - 'lib/solargraph/source/chain/literal.rb' - - 'lib/solargraph/source/chain/or.rb' - - 'lib/solargraph/source/chain/q_call.rb' - - 'lib/solargraph/source/chain/variable.rb' - - 'lib/solargraph/source/chain/z_super.rb' - - 'lib/solargraph/source/encoding_fixes.rb' - - 'lib/solargraph/source_map/data.rb' - - 'lib/solargraph/yard_map/cache.rb' - - 'lib/solargraph/yard_map/helpers.rb' - - 'lib/solargraph/yard_map/mapper.rb' - - 'lib/solargraph/yard_map/mapper/to_constant.rb' - - 'lib/solargraph/yard_map/mapper/to_method.rb' - - 'lib/solargraph/yard_map/mapper/to_namespace.rb' - - 'lib/solargraph/yard_map/to_method.rb' + Enabled: false # This cop supports safe autocorrection (--autocorrect). Style/EmptyLambdaParameter: @@ -1750,136 +919,7 @@ Style/FloatDivision: # Configuration parameters: EnforcedStyle. # SupportedStyles: always, always_true, never Style/FrozenStringLiteralComment: - Exclude: - - '**/*.arb' - - 'Gemfile' - - 'Rakefile' - - 'bin/solargraph' - - 'lib/solargraph/converters/dd.rb' - - 'lib/solargraph/converters/dl.rb' - - 'lib/solargraph/converters/dt.rb' - - 'lib/solargraph/converters/misc.rb' - - 'lib/solargraph/parser.rb' - - 'lib/solargraph/parser/comment_ripper.rb' - - 'lib/solargraph/parser/flow_sensitive_typing.rb' - - 'lib/solargraph/parser/node_methods.rb' - - 'lib/solargraph/parser/parser_gem.rb' - - 'lib/solargraph/parser/snippet.rb' - - 'lib/solargraph/pin/breakable.rb' - - 'lib/solargraph/pin/signature.rb' - - 'lib/solargraph/pin_cache.rb' - - 'lib/solargraph/source/chain/array.rb' - - 'lib/solargraph/source/chain/q_call.rb' - - 'lib/solargraph/yard_map/helpers.rb' - - 'solargraph.gemspec' - - 'spec/api_map/cache_spec.rb' - - 'spec/api_map/config_spec.rb' - - 'spec/api_map/source_to_yard_spec.rb' - - 'spec/api_map_spec.rb' - - 'spec/complex_type_spec.rb' - - 'spec/convention/struct_definition_spec.rb' - - 'spec/convention_spec.rb' - - 'spec/diagnostics/base_spec.rb' - - 'spec/diagnostics/require_not_found_spec.rb' - - 'spec/diagnostics/rubocop_helpers_spec.rb' - - 'spec/diagnostics/type_check_spec.rb' - - 'spec/diagnostics/update_errors_spec.rb' - - 'spec/diagnostics_spec.rb' - - 'spec/fixtures/formattable.rb' - - 'spec/fixtures/long_squiggly_heredoc.rb' - - 'spec/fixtures/rdoc-lib/Gemfile' - - 'spec/fixtures/rdoc-lib/lib/example.rb' - - 'spec/fixtures/rdoc-lib/rdoc-lib.gemspec' - - 'spec/fixtures/rubocop-custom-version/specifications/rubocop-0.0.0.gemspec' - - 'spec/fixtures/rubocop-validation-error/app.rb' - - 'spec/fixtures/unicode.rb' - - 'spec/fixtures/workspace-with-gemfile/Gemfile' - - 'spec/fixtures/workspace-with-gemfile/app.rb' - - 'spec/fixtures/workspace-with-gemfile/lib/other.rb' - - 'spec/fixtures/workspace-with-gemfile/lib/thing.rb' - - 'spec/fixtures/workspace/app.rb' - - 'spec/fixtures/workspace/lib/other.rb' - - 'spec/fixtures/workspace/lib/something.rb' - - 'spec/fixtures/workspace/lib/thing.rb' - - 'spec/fixtures/workspace_folders/folder1/app.rb' - - 'spec/fixtures/workspace_folders/folder2/app.rb' - - 'spec/fixtures/yard_map/attr.rb' - - 'spec/language_server/host/diagnoser_spec.rb' - - 'spec/language_server/host/dispatch_spec.rb' - - 'spec/language_server/host/message_worker_spec.rb' - - 'spec/language_server/host_spec.rb' - - 'spec/language_server/message/completion_item/resolve_spec.rb' - - 'spec/language_server/message/extended/check_gem_version_spec.rb' - - 'spec/language_server/message/initialize_spec.rb' - - 'spec/language_server/message/text_document/definition_spec.rb' - - 'spec/language_server/message/text_document/formatting_spec.rb' - - 'spec/language_server/message/text_document/hover_spec.rb' - - 'spec/language_server/message/text_document/type_definition_spec.rb' - - 'spec/language_server/message/workspace/did_change_watched_files_spec.rb' - - 'spec/language_server/message_spec.rb' - - 'spec/language_server/protocol_spec.rb' - - 'spec/language_server/transport/adapter_spec.rb' - - 'spec/language_server/transport/data_reader_spec.rb' - - 'spec/language_server/uri_helpers_spec.rb' - - 'spec/library_spec.rb' - - 'spec/logging_spec.rb' - - 'spec/parser/node_chainer_spec.rb' - - 'spec/parser/node_methods_spec.rb' - - 'spec/parser/node_processor_spec.rb' - - 'spec/parser_spec.rb' - - 'spec/pin/base_spec.rb' - - 'spec/pin/base_variable_spec.rb' - - 'spec/pin/block_spec.rb' - - 'spec/pin/class_variable_spec.rb' - - 'spec/pin/constant_spec.rb' - - 'spec/pin/delegated_method_spec.rb' - - 'spec/pin/documenting_spec.rb' - - 'spec/pin/instance_variable_spec.rb' - - 'spec/pin/keyword_spec.rb' - - 'spec/pin/local_variable_spec.rb' - - 'spec/pin/method_spec.rb' - - 'spec/pin/namespace_spec.rb' - - 'spec/pin/parameter_spec.rb' - - 'spec/pin/search_spec.rb' - - 'spec/pin/symbol_spec.rb' - - 'spec/position_spec.rb' - - 'spec/rbs_map/conversions_spec.rb' - - 'spec/rbs_map/core_map_spec.rb' - - 'spec/rbs_map/stdlib_map_spec.rb' - - 'spec/rbs_map_spec.rb' - - 'spec/shell_spec.rb' - - 'spec/source/chain/array_spec.rb' - - 'spec/source/chain/call_spec.rb' - - 'spec/source/chain/class_variable_spec.rb' - - 'spec/source/chain/constant_spec.rb' - - 'spec/source/chain/global_variable_spec.rb' - - 'spec/source/chain/head_spec.rb' - - 'spec/source/chain/instance_variable_spec.rb' - - 'spec/source/chain/link_spec.rb' - - 'spec/source/chain/literal_spec.rb' - - 'spec/source/chain/z_super_spec.rb' - - 'spec/source/chain_spec.rb' - - 'spec/source/change_spec.rb' - - 'spec/source/cursor_spec.rb' - - 'spec/source/source_chainer_spec.rb' - - 'spec/source/updater_spec.rb' - - 'spec/source_map/clip_spec.rb' - - 'spec/source_map/mapper_spec.rb' - - 'spec/source_map/node_processor_spec.rb' - - 'spec/source_map_spec.rb' - - 'spec/source_spec.rb' - - 'spec/spec_helper.rb' - - 'spec/type_checker/checks_spec.rb' - - 'spec/type_checker/levels/normal_spec.rb' - - 'spec/type_checker/levels/strict_spec.rb' - - 'spec/type_checker/levels/strong_spec.rb' - - 'spec/type_checker/levels/typed_spec.rb' - - 'spec/type_checker/rules_spec.rb' - - 'spec/type_checker_spec.rb' - - 'spec/workspace/config_spec.rb' - - 'spec/workspace_spec.rb' - - 'spec/yard_map/mapper/to_method_spec.rb' - - 'spec/yard_map/mapper_spec.rb' + Enabled: false # This cop supports unsafe autocorrection (--autocorrect-all). Style/GlobalStdStream: @@ -1892,15 +932,7 @@ Style/GlobalStdStream: # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: MinBodyLength, AllowConsecutiveConditionals. Style/GuardClause: - Exclude: - - 'lib/solargraph/api_map.rb' - - 'lib/solargraph/library.rb' - - 'lib/solargraph/parser/parser_gem/node_processors/send_node.rb' - - 'lib/solargraph/pin_cache.rb' - - 'lib/solargraph/range.rb' - - 'lib/solargraph/rbs_map/conversions.rb' - - 'lib/solargraph/source.rb' - - 'lib/solargraph/workspace.rb' + Enabled: false # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: AllowSplatArgument. @@ -1935,52 +967,11 @@ Style/IdenticalConditionalBranches: # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowIfModifier. Style/IfInsideElse: - Exclude: - - 'lib/solargraph/complex_type/type_methods.rb' - - 'lib/solargraph/language_server/transport/data_reader.rb' - - 'lib/solargraph/parser/parser_gem/node_chainer.rb' - - 'lib/solargraph/parser/parser_gem/node_methods.rb' - - 'lib/solargraph/source_map/clip.rb' - - 'lib/solargraph/type_checker.rb' + Enabled: false # This cop supports safe autocorrection (--autocorrect). Style/IfUnlessModifier: - Exclude: - - 'lib/solargraph/api_map.rb' - - 'lib/solargraph/api_map/index.rb' - - 'lib/solargraph/complex_type.rb' - - 'lib/solargraph/complex_type/unique_type.rb' - - 'lib/solargraph/doc_map.rb' - - 'lib/solargraph/language_server/message/completion_item/resolve.rb' - - 'lib/solargraph/language_server/message/initialize.rb' - - 'lib/solargraph/language_server/message/text_document/completion.rb' - - 'lib/solargraph/language_server/message/text_document/hover.rb' - - 'lib/solargraph/library.rb' - - 'lib/solargraph/parser/parser_gem/class_methods.rb' - - 'lib/solargraph/parser/parser_gem/node_chainer.rb' - - 'lib/solargraph/parser/parser_gem/node_methods.rb' - - 'lib/solargraph/parser/parser_gem/node_processors/sclass_node.rb' - - 'lib/solargraph/pin/base.rb' - - 'lib/solargraph/pin/callable.rb' - - 'lib/solargraph/pin/common.rb' - - 'lib/solargraph/pin/constant.rb' - - 'lib/solargraph/pin/method.rb' - - 'lib/solargraph/pin/parameter.rb' - - 'lib/solargraph/range.rb' - - 'lib/solargraph/rbs_map/conversions.rb' - - 'lib/solargraph/source/chain.rb' - - 'lib/solargraph/source/chain/call.rb' - - 'lib/solargraph/source/change.rb' - - 'lib/solargraph/source/cursor.rb' - - 'lib/solargraph/source/source_chainer.rb' - - 'lib/solargraph/source_map.rb' - - 'lib/solargraph/source_map/clip.rb' - - 'lib/solargraph/source_map/mapper.rb' - - 'lib/solargraph/type_checker.rb' - - 'lib/solargraph/workspace.rb' - - 'lib/solargraph/workspace/config.rb' - - 'lib/solargraph/yard_map/helpers.rb' - - 'lib/solargraph/yard_map/mapper/to_method.rb' + Enabled: false # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle. @@ -2010,69 +1001,8 @@ Style/MapToSet: # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle. # SupportedStyles: require_parentheses, require_no_parentheses, require_no_parentheses_except_multiline -Style/MethodDefParentheses: - Exclude: - - 'lib/solargraph.rb' - - 'lib/solargraph/api_map.rb' - - 'lib/solargraph/api_map/index.rb' - - 'lib/solargraph/api_map/store.rb' - - 'lib/solargraph/complex_type.rb' - - 'lib/solargraph/complex_type/type_methods.rb' - - 'lib/solargraph/complex_type/unique_type.rb' - - 'lib/solargraph/convention.rb' - - 'lib/solargraph/convention/data_definition.rb' - - 'lib/solargraph/convention/data_definition/data_assignment_node.rb' - - 'lib/solargraph/convention/data_definition/data_definition_node.rb' - - 'lib/solargraph/convention/struct_definition.rb' - - 'lib/solargraph/convention/struct_definition/struct_assignment_node.rb' - - 'lib/solargraph/convention/struct_definition/struct_definition_node.rb' - - 'lib/solargraph/diagnostics/rubocop_helpers.rb' - - 'lib/solargraph/doc_map.rb' - - 'lib/solargraph/equality.rb' - - 'lib/solargraph/gem_pins.rb' - - 'lib/solargraph/language_server/host/message_worker.rb' - - 'lib/solargraph/language_server/host/sources.rb' - - 'lib/solargraph/language_server/message/text_document/formatting.rb' - - 'lib/solargraph/location.rb' - - 'lib/solargraph/parser/comment_ripper.rb' - - 'lib/solargraph/parser/flow_sensitive_typing.rb' - - 'lib/solargraph/parser/node_methods.rb' - - 'lib/solargraph/parser/node_processor/base.rb' - - 'lib/solargraph/parser/parser_gem/flawed_builder.rb' - - 'lib/solargraph/parser/parser_gem/node_chainer.rb' - - 'lib/solargraph/parser/parser_gem/node_methods.rb' - - 'lib/solargraph/parser/parser_gem/node_processors/args_node.rb' - - 'lib/solargraph/pin/base.rb' - - 'lib/solargraph/pin/base_variable.rb' - - 'lib/solargraph/pin/block.rb' - - 'lib/solargraph/pin/callable.rb' - - 'lib/solargraph/pin/closure.rb' - - 'lib/solargraph/pin/delegated_method.rb' - - 'lib/solargraph/pin/local_variable.rb' - - 'lib/solargraph/pin/method.rb' - - 'lib/solargraph/pin/parameter.rb' - - 'lib/solargraph/pin_cache.rb' - - 'lib/solargraph/position.rb' - - 'lib/solargraph/range.rb' - - 'lib/solargraph/rbs_map/conversions.rb' - - 'lib/solargraph/shell.rb' - - 'lib/solargraph/source.rb' - - 'lib/solargraph/source/chain/call.rb' - - 'lib/solargraph/source/chain/constant.rb' - - 'lib/solargraph/source_map.rb' - - 'lib/solargraph/source_map/mapper.rb' - - 'lib/solargraph/type_checker.rb' - - 'lib/solargraph/type_checker/checks.rb' - - 'lib/solargraph/yard_map/helpers.rb' - - 'lib/solargraph/yardoc.rb' - - 'spec/doc_map_spec.rb' - - 'spec/fixtures/rdoc-lib/lib/example.rb' - - 'spec/source_map_spec.rb' - - 'spec/spec_helper.rb' - - 'spec/type_checker/levels/normal_spec.rb' - - 'spec/type_checker/levels/strict_spec.rb' - - 'spec/type_checker/levels/strong_spec.rb' - - 'spec/type_checker/levels/typed_spec.rb' +Style/MethodDefParentheses: + Enabled: false Style/MultilineBlockChain: Exclude: @@ -2091,29 +1021,13 @@ Style/MultilineTernaryOperator: # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowMethodComparison, ComparisonsThreshold. Style/MultipleComparison: - Exclude: - - 'lib/solargraph/complex_type.rb' - - 'lib/solargraph/complex_type/type_methods.rb' - - 'lib/solargraph/parser/parser_gem/node_methods.rb' - - 'lib/solargraph/parser/parser_gem/node_processors/send_node.rb' - - 'lib/solargraph/pin/base.rb' - - 'lib/solargraph/pin/method.rb' - - 'lib/solargraph/pin/parameter.rb' - - 'lib/solargraph/source.rb' - - 'lib/solargraph/type_checker.rb' + Enabled: false # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: EnforcedStyle. # SupportedStyles: literals, strict Style/MutableConstant: - Exclude: - - 'lib/solargraph/diagnostics/rubocop.rb' - - 'lib/solargraph/logging.rb' - - 'lib/solargraph/parser/parser_gem/node_methods.rb' - - 'lib/solargraph/rbs_map/conversions.rb' - - 'lib/solargraph/rbs_map/core_fills.rb' - - 'lib/solargraph/yard_map/mapper/to_method.rb' - - 'spec/complex_type_spec.rb' + Enabled: false # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle. @@ -2148,34 +1062,15 @@ Style/Next: - 'lib/solargraph/type_checker/checks.rb' # This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: MinDigits, Strict, AllowedNumbers, AllowedPatterns. +# Configuration parameters: Strict, AllowedNumbers, AllowedPatterns. Style/NumericLiterals: - Exclude: - - 'lib/solargraph/language_server/error_codes.rb' - - 'spec/language_server/protocol_spec.rb' + MinDigits: 6 # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: EnforcedStyle, AllowedMethods, AllowedPatterns. # SupportedStyles: predicate, comparison Style/NumericPredicate: - Exclude: - - 'spec/**/*' - - 'lib/solargraph/api_map.rb' - - 'lib/solargraph/api_map/index.rb' - - 'lib/solargraph/api_map/store.rb' - - 'lib/solargraph/complex_type.rb' - - 'lib/solargraph/complex_type/type_methods.rb' - - 'lib/solargraph/complex_type/unique_type.rb' - - 'lib/solargraph/language_server/message/extended/check_gem_version.rb' - - 'lib/solargraph/library.rb' - - 'lib/solargraph/parser/comment_ripper.rb' - - 'lib/solargraph/pin/delegated_method.rb' - - 'lib/solargraph/pin/method.rb' - - 'lib/solargraph/shell.rb' - - 'lib/solargraph/source/chain/array.rb' - - 'lib/solargraph/source/change.rb' - - 'lib/solargraph/source/source_chainer.rb' - - 'lib/solargraph/workspace.rb' + Enabled: false Style/OpenStructUse: Exclude: @@ -2184,14 +1079,7 @@ Style/OpenStructUse: # Configuration parameters: AllowedMethods. # AllowedMethods: respond_to_missing? Style/OptionalBooleanParameter: - Exclude: - - 'lib/solargraph/api_map.rb' - - 'lib/solargraph/language_server/message/text_document/completion.rb' - - 'lib/solargraph/source/chain.rb' - - 'lib/solargraph/source/chain/hash.rb' - - 'lib/solargraph/source/chain/z_super.rb' - - 'lib/solargraph/source/change.rb' - - 'lib/solargraph/source/updater.rb' + Enabled: false # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowSafeAssignment, AllowInMultilineConditions. @@ -2254,14 +1142,7 @@ Style/RedundantInterpolation: # This cop supports safe autocorrection (--autocorrect). Style/RedundantParentheses: - Exclude: - - 'lib/solargraph/diagnostics/type_check.rb' - - 'lib/solargraph/language_server/message/initialize.rb' - - 'lib/solargraph/parser/parser_gem/node_chainer.rb' - - 'lib/solargraph/pin/method.rb' - - 'lib/solargraph/pin/parameter.rb' - - 'lib/solargraph/source.rb' - - 'lib/solargraph/type_checker.rb' + Enabled: false # This cop supports safe autocorrection (--autocorrect). Style/RedundantRegexpArgument: @@ -2274,13 +1155,7 @@ Style/RedundantRegexpArgument: # This cop supports safe autocorrection (--autocorrect). Style/RedundantRegexpEscape: - Exclude: - - 'lib/solargraph/complex_type.rb' - - 'lib/solargraph/diagnostics/rubocop.rb' - - 'lib/solargraph/language_server/uri_helpers.rb' - - 'lib/solargraph/shell.rb' - - 'lib/solargraph/source_map/clip.rb' - - 'lib/solargraph/source_map/mapper.rb' + Enabled: false # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowMultipleReturnValues. @@ -2294,15 +1169,7 @@ Style/RedundantReturn: # This cop supports safe autocorrection (--autocorrect). Style/RedundantSelf: - Exclude: - - 'lib/solargraph/api_map.rb' - - 'lib/solargraph/equality.rb' - - 'lib/solargraph/location.rb' - - 'lib/solargraph/pin/base.rb' - - 'lib/solargraph/pin/callable.rb' - - 'lib/solargraph/pin/signature.rb' - - 'lib/solargraph/source/chain.rb' - - 'lib/solargraph/source/chain/link.rb' + Enabled: false # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle, AllowInnerSlashes. @@ -2323,19 +1190,7 @@ Style/RescueStandardError: # Configuration parameters: ConvertCodeThatCanStartToReturnNil, AllowedMethods, MaxChainLength. # AllowedMethods: present?, blank?, presence, try, try! Style/SafeNavigation: - Exclude: - - 'lib/solargraph/api_map/index.rb' - - 'lib/solargraph/doc_map.rb' - - 'lib/solargraph/language_server/message/completion_item/resolve.rb' - - 'lib/solargraph/language_server/request.rb' - - 'lib/solargraph/language_server/transport/data_reader.rb' - - 'lib/solargraph/parser/parser_gem/node_processors/send_node.rb' - - 'lib/solargraph/pin/base.rb' - - 'lib/solargraph/pin/conversions.rb' - - 'lib/solargraph/pin/method.rb' - - 'lib/solargraph/pin_cache.rb' - - 'lib/solargraph/range.rb' - - 'lib/solargraph/type_checker.rb' + Enabled: false # Configuration parameters: Max. Style/SafeNavigationChainLength: @@ -2344,36 +1199,12 @@ Style/SafeNavigationChainLength: # This cop supports unsafe autocorrection (--autocorrect-all). Style/SlicingWithRange: - Exclude: - - 'lib/solargraph/api_map.rb' - - 'lib/solargraph/complex_type/unique_type.rb' - - 'lib/solargraph/convention/data_definition/data_definition_node.rb' - - 'lib/solargraph/convention/struct_definition/struct_definition_node.rb' - - 'lib/solargraph/diagnostics/rubocop_helpers.rb' - - 'lib/solargraph/library.rb' - - 'lib/solargraph/parser/parser_gem/node_chainer.rb' - - 'lib/solargraph/parser/parser_gem/node_methods.rb' - - 'lib/solargraph/parser/parser_gem/node_processors/send_node.rb' - - 'lib/solargraph/pin/method.rb' - - 'lib/solargraph/pin/namespace.rb' - - 'lib/solargraph/source.rb' - - 'lib/solargraph/source/chain/constant.rb' - - 'lib/solargraph/source/change.rb' - - 'lib/solargraph/source/cursor.rb' - - 'lib/solargraph/source/source_chainer.rb' - - 'lib/solargraph/source_map/mapper.rb' - - 'lib/solargraph/type_checker/checks.rb' + Enabled: false # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowModifier. Style/SoleNestedConditional: - Exclude: - - 'lib/solargraph/complex_type/unique_type.rb' - - 'lib/solargraph/parser/flow_sensitive_typing.rb' - - 'lib/solargraph/pin/parameter.rb' - - 'lib/solargraph/source.rb' - - 'lib/solargraph/source/source_chainer.rb' - - 'lib/solargraph/type_checker.rb' + Enabled: false # This cop supports safe autocorrection (--autocorrect). Style/StderrPuts: @@ -2384,114 +1215,13 @@ Style/StderrPuts: # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: Mode. Style/StringConcatenation: - Exclude: - - 'lib/solargraph/api_map.rb' - - 'lib/solargraph/api_map/index.rb' - - 'lib/solargraph/pin/base.rb' - - 'lib/solargraph/pin/callable.rb' - - 'lib/solargraph/pin/closure.rb' - - 'lib/solargraph/pin/local_variable.rb' - - 'lib/solargraph/pin/method.rb' - - 'lib/solargraph/pin/namespace.rb' - - 'solargraph.gemspec' + Enabled: false # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline. # SupportedStyles: single_quotes, double_quotes Style/StringLiterals: - Exclude: - - 'Gemfile' - - 'Rakefile' - - 'lib/solargraph/api_map/index.rb' - - 'lib/solargraph/complex_type.rb' - - 'lib/solargraph/complex_type/unique_type.rb' - - 'lib/solargraph/convention/struct_definition.rb' - - 'lib/solargraph/doc_map.rb' - - 'lib/solargraph/language_server/host.rb' - - 'lib/solargraph/language_server/message/extended/document_gems.rb' - - 'lib/solargraph/language_server/message/extended/download_core.rb' - - 'lib/solargraph/language_server/message/initialize.rb' - - 'lib/solargraph/language_server/message/text_document/completion.rb' - - 'lib/solargraph/library.rb' - - 'lib/solargraph/parser/parser_gem/class_methods.rb' - - 'lib/solargraph/parser/parser_gem/node_methods.rb' - - 'lib/solargraph/pin/base.rb' - - 'lib/solargraph/pin/conversions.rb' - - 'lib/solargraph/pin/method.rb' - - 'lib/solargraph/pin/parameter.rb' - - 'lib/solargraph/rbs_map/conversions.rb' - - 'lib/solargraph/server_methods.rb' - - 'lib/solargraph/shell.rb' - - 'lib/solargraph/workspace.rb' - - 'lib/solargraph/yard_map/mapper/to_method.rb' - - 'lib/solargraph/yard_tags.rb' - - 'solargraph.gemspec' - - 'spec/api_map/cache_spec.rb' - - 'spec/api_map/config_spec.rb' - - 'spec/api_map/source_to_yard_spec.rb' - - 'spec/complex_type_spec.rb' - - 'spec/convention/struct_definition_spec.rb' - - 'spec/diagnostics/base_spec.rb' - - 'spec/diagnostics/require_not_found_spec.rb' - - 'spec/diagnostics/rubocop_helpers_spec.rb' - - 'spec/diagnostics/rubocop_spec.rb' - - 'spec/diagnostics/type_check_spec.rb' - - 'spec/diagnostics/update_errors_spec.rb' - - 'spec/diagnostics_spec.rb' - - 'spec/fixtures/rdoc-lib/rdoc-lib.gemspec' - - 'spec/language_server/host/diagnoser_spec.rb' - - 'spec/language_server/host/dispatch_spec.rb' - - 'spec/language_server/host/message_worker_spec.rb' - - 'spec/language_server/host_spec.rb' - - 'spec/language_server/message/completion_item/resolve_spec.rb' - - 'spec/language_server/message/extended/check_gem_version_spec.rb' - - 'spec/language_server/message/initialize_spec.rb' - - 'spec/language_server/message/text_document/rename_spec.rb' - - 'spec/language_server/message_spec.rb' - - 'spec/language_server/protocol_spec.rb' - - 'spec/language_server/transport/adapter_spec.rb' - - 'spec/language_server/transport/data_reader_spec.rb' - - 'spec/library_spec.rb' - - 'spec/logging_spec.rb' - - 'spec/parser/node_chainer_spec.rb' - - 'spec/parser/node_methods_spec.rb' - - 'spec/parser_spec.rb' - - 'spec/pin/base_spec.rb' - - 'spec/pin/base_variable_spec.rb' - - 'spec/pin/constant_spec.rb' - - 'spec/pin/instance_variable_spec.rb' - - 'spec/pin/keyword_spec.rb' - - 'spec/pin/local_variable_spec.rb' - - 'spec/pin/namespace_spec.rb' - - 'spec/pin/symbol_spec.rb' - - 'spec/position_spec.rb' - - 'spec/rbs_map/conversions_spec.rb' - - 'spec/rbs_map/core_map_spec.rb' - - 'spec/rbs_map/stdlib_map_spec.rb' - - 'spec/shell_spec.rb' - - 'spec/source/chain/array_spec.rb' - - 'spec/source/chain/call_spec.rb' - - 'spec/source/chain/class_variable_spec.rb' - - 'spec/source/chain/constant_spec.rb' - - 'spec/source/chain/global_variable_spec.rb' - - 'spec/source/chain/head_spec.rb' - - 'spec/source/chain/instance_variable_spec.rb' - - 'spec/source/chain/link_spec.rb' - - 'spec/source/chain/literal_spec.rb' - - 'spec/source/chain/z_super_spec.rb' - - 'spec/source/chain_spec.rb' - - 'spec/source/change_spec.rb' - - 'spec/source/cursor_spec.rb' - - 'spec/source/source_chainer_spec.rb' - - 'spec/source/updater_spec.rb' - - 'spec/source_map/clip_spec.rb' - - 'spec/source_map/mapper_spec.rb' - - 'spec/source_map_spec.rb' - - 'spec/source_spec.rb' - - 'spec/type_checker/levels/strict_spec.rb' - - 'spec/workspace/config_spec.rb' - - 'spec/workspace_spec.rb' - - 'spec/yard_map/mapper/to_method_spec.rb' + Enabled: false # This cop supports safe autocorrection (--autocorrect). Style/SuperArguments: @@ -2505,35 +1235,13 @@ Style/SuperArguments: # Configuration parameters: EnforcedStyle, MinSize. # SupportedStyles: percent, brackets Style/SymbolArray: - Exclude: - - 'lib/solargraph/api_map.rb' - - 'lib/solargraph/parser/parser_gem/node_chainer.rb' - - 'lib/solargraph/parser/parser_gem/node_methods.rb' - - 'lib/solargraph/parser/parser_gem/node_processors/block_node.rb' - - 'lib/solargraph/parser/parser_gem/node_processors/send_node.rb' - - 'lib/solargraph/pin/method.rb' - - 'lib/solargraph/pin/parameter.rb' - - 'lib/solargraph/shell.rb' - - 'lib/solargraph/source.rb' - - 'lib/solargraph/source/chain/literal.rb' - - 'lib/solargraph/source_map/clip.rb' - - 'lib/solargraph/source_map/mapper.rb' - - 'lib/solargraph/type_checker.rb' - - 'spec/parser/node_methods_spec.rb' - - 'spec/source_map/mapper_spec.rb' + Enabled: false # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: AllowMethodsWithArguments, AllowedMethods, AllowedPatterns, AllowComments. # AllowedMethods: define_method Style/SymbolProc: - Exclude: - - 'lib/solargraph/gem_pins.rb' - - 'lib/solargraph/language_server/message/text_document/hover.rb' - - 'lib/solargraph/language_server/message/text_document/signature_help.rb' - - 'lib/solargraph/parser/flow_sensitive_typing.rb' - - 'lib/solargraph/pin/base.rb' - - 'lib/solargraph/pin/callable.rb' - - 'lib/solargraph/pin/closure.rb' + Enabled: false # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle, AllowSafeAssignment. @@ -2546,19 +1254,7 @@ Style/TernaryParentheses: # Configuration parameters: EnforcedStyleForMultiline. # SupportedStylesForMultiline: comma, consistent_comma, no_comma Style/TrailingCommaInArguments: - Exclude: - - 'lib/solargraph/api_map.rb' - - 'lib/solargraph/parser/node_processor.rb' - - 'lib/solargraph/parser/parser_gem/node_processors/block_node.rb' - - 'lib/solargraph/parser/parser_gem/node_processors/def_node.rb' - - 'lib/solargraph/parser/parser_gem/node_processors/defs_node.rb' - - 'lib/solargraph/parser/parser_gem/node_processors/sclass_node.rb' - - 'lib/solargraph/parser/parser_gem/node_processors/until_node.rb' - - 'lib/solargraph/parser/parser_gem/node_processors/while_node.rb' - - 'lib/solargraph/pin/method.rb' - - 'lib/solargraph/rbs_map/conversions.rb' - - 'lib/solargraph/yard_map/mapper/to_method.rb' - - 'lib/solargraph/yard_map/mapper/to_namespace.rb' + Enabled: false # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyleForMultiline. @@ -2572,13 +1268,7 @@ Style/TrailingCommaInArrayLiteral: # Configuration parameters: EnforcedStyleForMultiline. # SupportedStylesForMultiline: comma, consistent_comma, diff_comma, no_comma Style/TrailingCommaInHashLiteral: - Exclude: - - 'lib/solargraph/pin/base_variable.rb' - - 'lib/solargraph/pin/callable.rb' - - 'lib/solargraph/pin/closure.rb' - - 'lib/solargraph/pin/local_variable.rb' - - 'lib/solargraph/pin/parameter.rb' - - 'lib/solargraph/rbs_map/conversions.rb' + Enabled: false # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: ExactNameMatch, AllowPredicates, AllowDSLWriters, IgnoreClassMethods, AllowedMethods. @@ -2597,20 +1287,7 @@ Style/WhileUntilModifier: # Configuration parameters: EnforcedStyle, MinSize, WordRegex. # SupportedStyles: percent, brackets Style/WordArray: - Exclude: - - 'lib/solargraph/complex_type.rb' - - 'lib/solargraph/complex_type/unique_type.rb' - - 'lib/solargraph/diagnostics/type_check.rb' - - 'lib/solargraph/language_server/message/text_document/formatting.rb' - - 'spec/doc_map_spec.rb' - - 'spec/parser/node_chainer_spec.rb' - - 'spec/pin/method_spec.rb' - - 'spec/source/cursor_spec.rb' - - 'spec/source/source_chainer_spec.rb' - - 'spec/source_map/clip_spec.rb' - - 'spec/source_map/mapper_spec.rb' - - 'spec/source_map_spec.rb' - - 'spec/source_spec.rb' + Enabled: false # This cop supports safe autocorrection (--autocorrect). Style/YAMLFileRead: @@ -2619,13 +1296,7 @@ Style/YAMLFileRead: # This cop supports unsafe autocorrection (--autocorrect-all). Style/ZeroLengthPredicate: - Exclude: - - 'lib/solargraph/api_map.rb' - - 'lib/solargraph/api_map/index.rb' - - 'lib/solargraph/language_server/host.rb' - - 'lib/solargraph/pin/method.rb' - - 'lib/solargraph/source/chain/array.rb' - - 'spec/language_server/protocol_spec.rb' + Enabled: false # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle. @@ -2638,33 +1309,7 @@ YARD/CollectionType: # Configuration parameters: EnforcedStylePrototypeName. # SupportedStylesPrototypeName: before, after YARD/MismatchName: - Exclude: - - 'lib/solargraph/complex_type.rb' - - 'lib/solargraph/complex_type/unique_type.rb' - - 'lib/solargraph/gem_pins.rb' - - 'lib/solargraph/language_server/host.rb' - - 'lib/solargraph/language_server/host/dispatch.rb' - - 'lib/solargraph/language_server/request.rb' - - 'lib/solargraph/parser/parser_gem/node_methods.rb' - - 'lib/solargraph/parser/region.rb' - - 'lib/solargraph/pin/base.rb' - - 'lib/solargraph/pin/base_variable.rb' - - 'lib/solargraph/pin/block.rb' - - 'lib/solargraph/pin/callable.rb' - - 'lib/solargraph/pin/closure.rb' - - 'lib/solargraph/pin/delegated_method.rb' - - 'lib/solargraph/pin/method.rb' - - 'lib/solargraph/pin/namespace.rb' - - 'lib/solargraph/pin/parameter.rb' - - 'lib/solargraph/pin/proxy_type.rb' - - 'lib/solargraph/pin/reference.rb' - - 'lib/solargraph/pin/symbol.rb' - - 'lib/solargraph/pin/until.rb' - - 'lib/solargraph/pin/while.rb' - - 'lib/solargraph/pin_cache.rb' - - 'lib/solargraph/source/chain/call.rb' - - 'lib/solargraph/source/chain/z_super.rb' - - 'lib/solargraph/type_checker.rb' + Enabled: false YARD/TagTypeSyntax: Exclude: @@ -2673,72 +1318,7 @@ YARD/TagTypeSyntax: - 'lib/solargraph/type_checker.rb' # This cop supports safe autocorrection (--autocorrect). -# Configuration parameters: Max, AllowHeredoc, AllowURI, AllowQualifiedName, URISchemes, IgnoreCopDirectives, AllowedPatterns, SplitStrings. +# Configuration parameters: AllowHeredoc, AllowURI, AllowQualifiedName, URISchemes, IgnoreCopDirectives, AllowedPatterns, SplitStrings. # URISchemes: http, https Layout/LineLength: - Exclude: - - 'lib/solargraph/api_map.rb' - - 'lib/solargraph/api_map/source_to_yard.rb' - - 'lib/solargraph/api_map/store.rb' - - 'lib/solargraph/complex_type.rb' - - 'lib/solargraph/complex_type/unique_type.rb' - - 'lib/solargraph/convention/data_definition.rb' - - 'lib/solargraph/doc_map.rb' - - 'lib/solargraph/gem_pins.rb' - - 'lib/solargraph/language_server/host.rb' - - 'lib/solargraph/language_server/message/extended/check_gem_version.rb' - - 'lib/solargraph/language_server/message/extended/download_core.rb' - - 'lib/solargraph/language_server/message/initialize.rb' - - 'lib/solargraph/language_server/message/text_document/completion.rb' - - 'lib/solargraph/language_server/message/text_document/definition.rb' - - 'lib/solargraph/language_server/message/text_document/document_highlight.rb' - - 'lib/solargraph/language_server/message/text_document/prepare_rename.rb' - - 'lib/solargraph/language_server/message/text_document/references.rb' - - 'lib/solargraph/language_server/message/text_document/rename.rb' - - 'lib/solargraph/language_server/message/workspace/did_change_watched_files.rb' - - 'lib/solargraph/library.rb' - - 'lib/solargraph/parser/comment_ripper.rb' - - 'lib/solargraph/parser/flow_sensitive_typing.rb' - - 'lib/solargraph/parser/parser_gem/node_chainer.rb' - - 'lib/solargraph/parser/parser_gem/node_methods.rb' - - 'lib/solargraph/parser/parser_gem/node_processors/and_node.rb' - - 'lib/solargraph/parser/parser_gem/node_processors/if_node.rb' - - 'lib/solargraph/parser/parser_gem/node_processors/ivasgn_node.rb' - - 'lib/solargraph/parser/parser_gem/node_processors/masgn_node.rb' - - 'lib/solargraph/parser/parser_gem/node_processors/send_node.rb' - - 'lib/solargraph/pin/base.rb' - - 'lib/solargraph/pin/callable.rb' - - 'lib/solargraph/pin/common.rb' - - 'lib/solargraph/pin/documenting.rb' - - 'lib/solargraph/pin/method.rb' - - 'lib/solargraph/pin/parameter.rb' - - 'lib/solargraph/rbs_map/conversions.rb' - - 'lib/solargraph/rbs_map/core_fills.rb' - - 'lib/solargraph/shell.rb' - - 'lib/solargraph/source.rb' - - 'lib/solargraph/source/chain.rb' - - 'lib/solargraph/source/chain/call.rb' - - 'lib/solargraph/source/chain/if.rb' - - 'lib/solargraph/source/chain/instance_variable.rb' - - 'lib/solargraph/source/chain/variable.rb' - - 'lib/solargraph/source/cursor.rb' - - 'lib/solargraph/source/encoding_fixes.rb' - - 'lib/solargraph/source/source_chainer.rb' - - 'lib/solargraph/source_map.rb' - - 'lib/solargraph/source_map/clip.rb' - - 'lib/solargraph/source_map/mapper.rb' - - 'lib/solargraph/type_checker.rb' - - 'lib/solargraph/workspace.rb' - - 'lib/solargraph/workspace/config.rb' - - 'lib/solargraph/yard_map/mapper/to_method.rb' - - 'spec/api_map_spec.rb' - - 'spec/complex_type_spec.rb' - - 'spec/language_server/message/completion_item/resolve_spec.rb' - - 'spec/language_server/message/extended/check_gem_version_spec.rb' - - 'spec/language_server/message/text_document/definition_spec.rb' - - 'spec/language_server/protocol_spec.rb' - - 'spec/pin/parameter_spec.rb' - - 'spec/source/chain_spec.rb' - - 'spec/source_map/clip_spec.rb' - - 'spec/source_map_spec.rb' - - 'spec/workspace_spec.rb' + Max: 244 diff --git a/solargraph.gemspec b/solargraph.gemspec index e6bb9394a..7610bb8ea 100755 --- a/solargraph.gemspec +++ b/solargraph.gemspec @@ -48,9 +48,16 @@ Gem::Specification.new do |s| s.add_development_dependency 'public_suffix', '~> 3.1' s.add_development_dependency 'rake', '~> 13.2' s.add_development_dependency 'rspec', '~> 3.5' - s.add_development_dependency 'rubocop-rake', '~> 0.7' - s.add_development_dependency 'rubocop-rspec', '~> 3.6' - s.add_development_dependency 'rubocop-yard', '~> 1.0' + # + # very specific development-time RuboCop version patterns for CI + # stability - feel free to update in an isolated PR + # + # even more specific on RuboCop itself, which is written into _todo + # file. + s.add_development_dependency 'rubocop', '~> 1.79.2.0' + s.add_development_dependency 'rubocop-rake', '~> 0.7.1' + s.add_development_dependency 'rubocop-rspec', '~> 3.6.0' + s.add_development_dependency 'rubocop-yard', '~> 1.0.0' s.add_development_dependency 'simplecov', '~> 0.21' s.add_development_dependency 'simplecov-lcov', '~> 0.8' s.add_development_dependency 'undercover', '~> 0.7' From 61260f346883de89c8dd9c61b205e88f59ae3a8b Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Sat, 30 Aug 2025 10:18:50 -0400 Subject: [PATCH 300/400] Fix merge issue --- .github/workflows/linting.yml | 2 +- .rubocop_todo.yml | 25 +++++++++---------------- lib/solargraph/api_map.rb | 2 -- spec/api_map_spec.rb | 3 --- 4 files changed, 10 insertions(+), 22 deletions(-) diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml index aa22ce22c..b4ef26bfe 100644 --- a/.github/workflows/linting.yml +++ b/.github/workflows/linting.yml @@ -115,7 +115,7 @@ jobs: - name: Run RuboCop against todo file continue-on-error: true run: | - cmd="bundle exec rubocop --auto-gen-config --exclude-limit=5 --no-offense-counts --no-auto-gen-timestampxb*com" + cmd="bundle exec rubocop --auto-gen-config --exclude-limit=5 --no-offense-counts --no-auto-gen-timestamp" ${cmd:?} set +e if [ -n "$(git status --porcelain)" ] diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 7641198af..0ed335f34 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,5 +1,5 @@ # This configuration was generated by -# `rubocop --auto-gen-config --no-exclude-limit --no-offense-counts --no-auto-gen-timestamp` +# `rubocop --auto-gen-config --exclude-limit 5 --no-offense-counts --no-auto-gen-timestamp` # using RuboCop version 1.80.0. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. @@ -121,7 +121,13 @@ Layout/EndOfLine: # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowForAlignment, AllowBeforeTrailingComments, ForceEqualSignAlignment. - Enabled: false +Layout/ExtraSpacing: + Exclude: + - 'lib/solargraph/parser/parser_gem/node_processors/opasgn_node.rb' + - 'lib/solargraph/pin/closure.rb' + - 'lib/solargraph/rbs_map/conversions.rb' + - 'lib/solargraph/type_checker.rb' + - 'spec/spec_helper.rb' # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle, IndentationWidth. @@ -604,9 +610,9 @@ RSpec/DescribeClass: - '**/spec/routing/**/*' - '**/spec/system/**/*' - '**/spec/views/**/*' + - 'spec/api_map_method_spec.rb' - 'spec/complex_type_spec.rb' - 'spec/source_map/node_processor_spec.rb' - - 'spec/api_map_method_spec.rb' # This cop supports unsafe autocorrection (--autocorrect-all). # Configuration parameters: SkipBlocks, EnforcedStyle, OnlyStaticConstants. @@ -633,7 +639,6 @@ RSpec/ExampleLength: # DisallowedExamples: works RSpec/ExampleWording: Exclude: - - 'spec/convention/struct_definition_spec.rb' - 'spec/pin/base_spec.rb' - 'spec/pin/method_spec.rb' @@ -1114,12 +1119,6 @@ Style/RedundantFreeze: - 'lib/solargraph/complex_type.rb' - 'lib/solargraph/source_map/mapper.rb' -# This cop supports unsafe autocorrection (--autocorrect-all). -# Configuration parameters: AllowComments. -Style/RedundantInitialize: - Exclude: - - 'lib/solargraph/rbs_map/core_map.rb' - # This cop supports unsafe autocorrection (--autocorrect-all). Style/RedundantInterpolation: Exclude: @@ -1140,12 +1139,6 @@ Style/RedundantRegexpArgument: - 'spec/diagnostics/rubocop_spec.rb' - 'spec/language_server/host_spec.rb' -# This cop supports safe autocorrection (--autocorrect). -Style/RedundantRegexpCharacterClass: - Exclude: - - 'lib/solargraph/source/cursor.rb' - - 'lib/solargraph/source/source_chainer.rb' - # This cop supports safe autocorrection (--autocorrect). Style/RedundantRegexpEscape: Enabled: false diff --git a/lib/solargraph/api_map.rb b/lib/solargraph/api_map.rb index f58633a0c..ee35dc497 100755 --- a/lib/solargraph/api_map.rb +++ b/lib/solargraph/api_map.rb @@ -753,7 +753,6 @@ def store # @param skip [Set] # @param no_core [Boolean] Skip core classes if true # @return [Array] - # rubocop:disable Metrics/CyclomaticComplexity def inner_get_methods rooted_tag, scope, visibility, deep, skip, no_core = false rooted_type = ComplexType.parse(rooted_tag).force_rooted fqns = rooted_type.namespace @@ -827,7 +826,6 @@ def inner_get_methods rooted_tag, scope, visibility, deep, skip, no_core = false end result end - # rubocop:enable Metrics/CyclomaticComplexity # @param fqns [String] # @param visibility [Array] diff --git a/spec/api_map_spec.rb b/spec/api_map_spec.rb index a612b428e..85e62d507 100755 --- a/spec/api_map_spec.rb +++ b/spec/api_map_spec.rb @@ -1,7 +1,6 @@ require 'tmpdir' describe Solargraph::ApiMap do - # rubocop:disable RSpec/InstanceVariable before :all do @api_map = Solargraph::ApiMap.new end @@ -873,6 +872,4 @@ def c clip = api_map.clip_at('test.rb', [18, 4]) expect(clip.infer.to_s).to eq('Integer') end - - # rubocop:enable RSpec/InstanceVariable end From 8cca17842e82246cbf5cbf2e399352fb14bb438d Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Sat, 30 Aug 2025 13:36:18 -0400 Subject: [PATCH 301/400] Fix comment skew --- lib/solargraph/api_map/index.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/solargraph/api_map/index.rb b/lib/solargraph/api_map/index.rb index 09922cd68..9d96bcfb4 100644 --- a/lib/solargraph/api_map/index.rb +++ b/lib/solargraph/api_map/index.rb @@ -39,7 +39,7 @@ def path_pin_hash def pins_by_class klass # @type [Set] s = Set.new - # @sg-ignore need to support destructured args in block + # @sg-ignore need to support destructured args in blocks @pin_select_cache[klass] ||= pin_class_hash.each_with_object(s) { |(key, o), n| n.merge(o) if key <= klass } end From 7fc5fcd51511954f7e734c7e3ab8ba63b1d2a956 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Sun, 31 Aug 2025 10:14:16 -0400 Subject: [PATCH 302/400] Annotation fixes for strong typechecking --- lib/solargraph/pin/base.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/solargraph/pin/base.rb b/lib/solargraph/pin/base.rb index e6a630562..7f1509d9b 100644 --- a/lib/solargraph/pin/base.rb +++ b/lib/solargraph/pin/base.rb @@ -456,7 +456,7 @@ def nearly? other # Pin equality is determined using the #nearly? method and also # requiring both pins to have the same location. # - # @param other [self] + # @param other [Object] def == other return false unless nearly? other comments == other.comments && location == other.location From b3f39102ed146dbd608863b7ca801bd1dc3427c0 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Sun, 31 Aug 2025 17:52:19 -0400 Subject: [PATCH 303/400] Expand time limit on slow spec --- spec/api_map_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/api_map_spec.rb b/spec/api_map_spec.rb index 4dbeb2809..048007457 100755 --- a/spec/api_map_spec.rb +++ b/spec/api_map_spec.rb @@ -9,7 +9,7 @@ @api_map = described_class.load_with_cache(Dir.pwd, nil) end - it 'returns core methods' do + it 'returns core methods', time_limit_seconds: 120 do pins = @api_map.get_methods('String') # rubocop:disable RSpec/InstanceVariable expect(pins.map(&:path)).to include('String#upcase') end From f623a73ad88f44d3ff6e6873a1682f33a07d431b Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Mon, 1 Sep 2025 07:52:39 -0400 Subject: [PATCH 304/400] Pull in overcommit fix --- lib/solargraph/yardoc.rb | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/lib/solargraph/yardoc.rb b/lib/solargraph/yardoc.rb index 625e41ce4..ed638a7ce 100644 --- a/lib/solargraph/yardoc.rb +++ b/lib/solargraph/yardoc.rb @@ -26,7 +26,7 @@ def cache(yard_plugins, gemspec) # # @sg-ignore RBS gem doesn't reflect that Open3.* also include # kwopts from Process.spawn() - stdout_and_stderr_str, status = Open3.capture2e(cmd, chdir: gemspec.gem_dir) + stdout_and_stderr_str, status = Open3.capture2e(current_bundle_env_tweaks, cmd, chdir: gemspec.gem_dir) unless status.success? Solargraph.logger.warn { "YARD failed running #{cmd.inspect} in #{gemspec.gem_dir}" } Solargraph.logger.info stdout_and_stderr_str @@ -60,5 +60,22 @@ def load!(gemspec) YARD::Registry.load! PinCache.yardoc_path gemspec YARD::Registry.all end + + # If the BUNDLE_GEMFILE environment variable is set, we need to + # make sure it's an absolute path, as we'll be changing + # directories. + # + # 'bundle exec' sets an absolute path here, but at least the + # overcommit gem does not, breaking on-the-fly documention with a + # spawned yardoc command from our current bundle + # + # @return [Hash{String => String}] a hash of environment variables to override + def current_bundle_env_tweaks + tweaks = {} + if ENV['BUNDLE_GEMFILE'] && !ENV['BUNDLE_GEMFILE'].empty? + tweaks['BUNDLE_GEMFILE'] = File.expand_path(ENV['BUNDLE_GEMFILE']) + end + tweaks + end end end From a8b678b1a1abec6a571ad321b4245575541bf969 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Mon, 1 Sep 2025 08:56:57 -0400 Subject: [PATCH 305/400] Add spec --- .rubocop.yml | 3 +++ spec/yardoc_spec.rb | 52 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 spec/yardoc_spec.rb diff --git a/.rubocop.yml b/.rubocop.yml index a73324db2..c17a56410 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -21,6 +21,9 @@ AllCops: - "vendor/**/.*" TargetRubyVersion: 3.0 +RSpec/SpecFilePathFormat: + Enabled: false + Style/MethodDefParentheses: EnforcedStyle: require_no_parentheses diff --git a/spec/yardoc_spec.rb b/spec/yardoc_spec.rb new file mode 100644 index 000000000..34dcad45c --- /dev/null +++ b/spec/yardoc_spec.rb @@ -0,0 +1,52 @@ +# frozen_string_literal: true + +require 'tmpdir' +require 'open3' + +describe Solargraph::Yardoc do + let(:gem_yardoc_path) do + Solargraph::PinCache.yardoc_path gemspec + end + + before do + FileUtils.mkdir_p(gem_yardoc_path) + end + + describe '#cache' do + let(:api_map) { Solargraph::ApiMap.new } + let(:doc_map) { api_map.doc_map } + let(:gemspec) { Gem::Specification.find_by_path('rubocop') } + let(:output) { '' } + + before do + allow(Solargraph.logger).to receive(:warn) + allow(Solargraph.logger).to receive(:info) + FileUtils.rm_rf(gem_yardoc_path) + end + + context 'when given a relative BUNDLE_GEMFILE path' do + around do |example| + # turn absolute BUNDLE_GEMFILE path into relative + existing_gemfile = ENV.fetch('BUNDLE_GEMFILE', nil) + current_dir = Dir.pwd + # remove prefix current_dir from path + ENV['BUNDLE_GEMFILE'] = existing_gemfile.sub("#{current_dir}/", '') + raise 'could not figure out relative path' if Pathname.new(ENV.fetch('BUNDLE_GEMFILE', nil)).absolute? + example.run + ENV['BUNDLE_GEMFILE'] = existing_gemfile + end + + it 'sends Open3 an absolute path' do + called_with = nil + allow(Open3).to receive(:capture2e) do |*args| + called_with = args + ['output', instance_double(Process::Status, success?: true)] + end + + described_class.cache([], gemspec) + + expect(called_with[0]['BUNDLE_GEMFILE']).to start_with('/') + end + end + end +end From 8a25804ed4021da420647dc6b4e69a975c8a223a Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Mon, 1 Sep 2025 09:36:50 -0400 Subject: [PATCH 306/400] Tweak some time limits --- spec/api_map_method_spec.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/api_map_method_spec.rb b/spec/api_map_method_spec.rb index 9d4e4f553..cee8876a9 100644 --- a/spec/api_map_method_spec.rb +++ b/spec/api_map_method_spec.rb @@ -110,15 +110,15 @@ class B end end - describe '#get_method_stack' do + describe '#get_method_stack', time_limit_seconds: 240 do let(:out) { StringIO.new } let(:api_map) { Solargraph::ApiMap.load_with_cache(Dir.pwd, out) } - context 'with stdlib that has vital dependencies' do + context 'with stdlib that has vital dependencies', time_limit_seconds: 240 do let(:external_requires) { ['yaml'] } let(:method_stack) { api_map.get_method_stack('YAML', 'safe_load', scope: :class) } - it 'handles the YAML gem aliased to Psych' do + it 'handles the YAML gem aliased to Psych', time_limit_seconds: 240 do expect(method_stack).not_to be_empty end end From e4e40915fddd53e7be8f90d66a098279bae3b44b Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Mon, 1 Sep 2025 11:33:11 -0400 Subject: [PATCH 307/400] Another set of @sg-ignores --- .../parser_gem/node_processors/sclass_node.rb | 15 ++++++++++++--- .../parser_gem/node_processors/send_node.rb | 2 +- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/lib/solargraph/parser/parser_gem/node_processors/sclass_node.rb b/lib/solargraph/parser/parser_gem/node_processors/sclass_node.rb index e5b049b06..1b573ed93 100644 --- a/lib/solargraph/parser/parser_gem/node_processors/sclass_node.rb +++ b/lib/solargraph/parser/parser_gem/node_processors/sclass_node.rb @@ -7,9 +7,18 @@ module NodeProcessors class SclassNode < Parser::NodeProcessor::Base def process sclass = node.children[0] - if sclass.is_a?(AST::Node) && sclass.type == :self + # @todo Changing Parser::AST::Node to AST::Node below will + # cause type errors at strong level because the combined + # pin for AST::Node#children has return type + # "Array, Array". YARD annotations in AST + # provided the Array, RBS for Array. We + # should probably have a rule to combine "A, A"" + # types to "A" if the "A" comes from YARD, with the + # rationale that folks tend to be less formal with types in + # YARD. + if sclass.is_a?(::Parser::AST::Node) && sclass.type == :self closure = region.closure - elsif sclass.is_a?(AST::Node) && sclass.type == :casgn + elsif sclass.is_a?(::Parser::AST::Node) && sclass.type == :casgn names = [region.closure.namespace, region.closure.name] if sclass.children[0].nil? && names.last != sclass.children[1].to_s names << sclass.children[1].to_s @@ -18,7 +27,7 @@ def process end name = names.reject(&:empty?).join('::') closure = Solargraph::Pin::Namespace.new(name: name, location: region.closure.location, source: :parser) - elsif sclass.is_a?(AST::Node) && sclass.type == :const + elsif sclass.is_a?(::Parser::AST::Node) && sclass.type == :const names = [region.closure.namespace, region.closure.name] also = NodeMethods.unpack_name(sclass) if also != region.closure.name diff --git a/lib/solargraph/parser/parser_gem/node_processors/send_node.rb b/lib/solargraph/parser/parser_gem/node_processors/send_node.rb index cedec1b89..fff3addf6 100644 --- a/lib/solargraph/parser/parser_gem/node_processors/send_node.rb +++ b/lib/solargraph/parser/parser_gem/node_processors/send_node.rb @@ -66,7 +66,7 @@ def process_visibility return process_children end # :nocov: - if child.is_a?(AST::Node) && (child.type == :sym || child.type == :str) + if child.is_a?(::Parser::AST::Node) && (child.type == :sym || child.type == :str) name = child.children[0].to_s matches = pins.select{ |pin| pin.is_a?(Pin::Method) && pin.name == name && pin.namespace == region.closure.full_context.namespace && pin.context.scope == (region.scope || :instance)} matches.each do |pin| From d57402638cb9c68e4938cf3445fba72e9387510a Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Mon, 1 Sep 2025 12:19:42 -0400 Subject: [PATCH 308/400] Type fixes --- lib/solargraph/library.rb | 2 +- lib/solargraph/parser/parser_gem/class_methods.rb | 1 - lib/solargraph/pin/parameter.rb | 1 - 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/solargraph/library.rb b/lib/solargraph/library.rb index c9f908711..0e921283b 100644 --- a/lib/solargraph/library.rb +++ b/lib/solargraph/library.rb @@ -522,7 +522,7 @@ def find_external_requires source_map full = File.join(base, path) filenames[].include?(full) or filenames[].include?(full << ".rb") end - end + end.to_set @external_requires = nil end diff --git a/lib/solargraph/parser/parser_gem/class_methods.rb b/lib/solargraph/parser/parser_gem/class_methods.rb index bd8648dd7..eb6dd3d87 100644 --- a/lib/solargraph/parser/parser_gem/class_methods.rb +++ b/lib/solargraph/parser/parser_gem/class_methods.rb @@ -139,7 +139,6 @@ def string_ranges node end if node.type == :dstr && node.children.last.nil? last = node.children[-2] - # @sg-ignore unless last.nil? rng = Range.from_node(last) pos = Position.new(rng.ending.line, rng.ending.column - 1) diff --git a/lib/solargraph/pin/parameter.rb b/lib/solargraph/pin/parameter.rb index f5c1d3fa1..4441c67ad 100644 --- a/lib/solargraph/pin/parameter.rb +++ b/lib/solargraph/pin/parameter.rb @@ -35,7 +35,6 @@ def combine_with(other, attrs={}) presence: choose(other, :presence), asgn_code: choose(other, :asgn_code), }.merge(attrs) - # @sg-ignore Wrong argument type for Solargraph::Pin::LocalVariable#combine_with: other expected Solargraph::Pin::LocalVariable, received self super(other, new_attrs) end From d927212d863f0d910c33b9024a802dbaf19770a2 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Mon, 1 Sep 2025 12:28:48 -0400 Subject: [PATCH 309/400] Revert --- lib/solargraph/library.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/solargraph/library.rb b/lib/solargraph/library.rb index 0e921283b..c9f908711 100644 --- a/lib/solargraph/library.rb +++ b/lib/solargraph/library.rb @@ -522,7 +522,7 @@ def find_external_requires source_map full = File.join(base, path) filenames[].include?(full) or filenames[].include?(full << ".rb") end - end.to_set + end @external_requires = nil end From 79038e5312cd388a0a9e4bb2bcb1d0fcde8706ba Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Tue, 2 Sep 2025 05:57:06 -0400 Subject: [PATCH 310/400] Fix missing method --- lib/solargraph/pin_cache.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/solargraph/pin_cache.rb b/lib/solargraph/pin_cache.rb index b9f384438..8c47cfef4 100644 --- a/lib/solargraph/pin_cache.rb +++ b/lib/solargraph/pin_cache.rb @@ -629,6 +629,11 @@ def core? def cache_core out: $stderr RbsMap::CoreMap.new.cache_core(out: out) end + + # @param path [String] + def exist? *path + File.file? File.join(*path) + end end end end From 5658f301390206872dd1a7651a79651c00b7636c Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Tue, 2 Sep 2025 08:32:45 -0400 Subject: [PATCH 311/400] Understand "Parser::AST::Node < AST::Node" in RBS Right now the parser gem RBS doesn't get handled correctly; it doesn't mark the AST::Node being inherited from as being rooted, meaning we end up resolving the superclass of Parser::AST::Node to be...Parser::AST::Node. --- lib/solargraph/rbs_map/conversions.rb | 6 +- spec/rbs_map/conversions_spec.rb | 134 +++++++++++++++++--------- 2 files changed, 90 insertions(+), 50 deletions(-) diff --git a/lib/solargraph/rbs_map/conversions.rb b/lib/solargraph/rbs_map/conversions.rb index 566f1513f..f941aeaee 100644 --- a/lib/solargraph/rbs_map/conversions.rb +++ b/lib/solargraph/rbs_map/conversions.rb @@ -163,9 +163,10 @@ def class_decl_to_pin decl generic_defaults[param.name.to_s] = ComplexType.parse(tag).force_rooted end end + class_name = decl.name.relative!.to_s class_pin = Solargraph::Pin::Namespace.new( type: :class, - name: decl.name.relative!.to_s, + name: class_name, closure: Solargraph::Pin::ROOT_PIN, comments: decl.comment&.string, type_location: location_decl_to_pin_location(decl.location), @@ -180,11 +181,12 @@ def class_decl_to_pin decl if decl.super_class type = build_type(decl.super_class.name, decl.super_class.args) generic_values = type.all_params.map(&:to_s) + superclass_name = decl.super_class.name.to_s pins.push Solargraph::Pin::Reference::Superclass.new( type_location: location_decl_to_pin_location(decl.super_class.location), closure: class_pin, generic_values: generic_values, - name: decl.super_class.name.relative!.to_s, + name: superclass_name, source: :rbs ) end diff --git a/spec/rbs_map/conversions_spec.rb b/spec/rbs_map/conversions_spec.rb index ce800c29f..e6322443d 100644 --- a/spec/rbs_map/conversions_spec.rb +++ b/spec/rbs_map/conversions_spec.rb @@ -1,81 +1,119 @@ describe Solargraph::RbsMap::Conversions do - # create a temporary directory with the scope of the spec - around do |example| - require 'tmpdir' - Dir.mktmpdir("rspec-solargraph-") do |dir| - @temp_dir = dir - example.run + context 'with RBS to digest' do + # create a temporary directory with the scope of the spec + around do |example| + require 'tmpdir' + Dir.mktmpdir("rspec-solargraph-") do |dir| + @temp_dir = dir + example.run + end end - end - let(:conversions) do - loader = RBS::EnvironmentLoader.new(core_root: nil, repository: RBS::Repository.new(no_stdlib: false)) - loader.add(path: Pathname(temp_dir)) - Solargraph::RbsMap::Conversions.new(loader: loader) - end + let(:conversions) do + loader = RBS::EnvironmentLoader.new(core_root: nil, repository: RBS::Repository.new(no_stdlib: false)) + loader.add(path: Pathname(temp_dir)) + Solargraph::RbsMap::Conversions.new(loader: loader) + end - before do - rbs_file = File.join(temp_dir, 'foo.rbs') - File.write(rbs_file, rbs) - end + let(:api_map) { Solargraph::ApiMap.new } - attr_reader :temp_dir + before do + rbs_file = File.join(temp_dir, 'foo.rbs') + File.write(rbs_file, rbs) + api_map.index conversions.pins + end + + attr_reader :temp_dir - context 'with untyped response' do - let(:rbs) do - <<~RBS + context 'with untyped response' do + let(:rbs) do + <<~RBS class Foo def bar: () -> untyped end RBS - end + end - subject(:method_pin) { conversions.pins.find { |pin| pin.path == 'Foo#bar' } } + subject(:method_pin) { conversions.pins.find { |pin| pin.path == 'Foo#bar' } } - it { should_not be_nil } + it { should_not be_nil } - it { should be_a(Solargraph::Pin::Method) } + it { should be_a(Solargraph::Pin::Method) } - it 'maps untyped in RBS to undefined in Solargraph 'do - expect(method_pin.return_type.tag).to eq('undefined') + it 'maps untyped in RBS to undefined in Solargraph 'do + expect(method_pin.return_type.tag).to eq('undefined') + end end - end - # https://github.com/castwide/solargraph/issues/1042 - context 'with Hash superclass with untyped value and alias' do - let(:rbs) do - <<~RBS + # https://github.com/castwide/solargraph/issues/1042 + context 'with Hash superclass with untyped value and alias' do + let(:rbs) do + <<~RBS class Sub < Hash[Symbol, untyped] alias meth_alias [] end RBS - end + end - let(:api_map) { Solargraph::ApiMap.new } + let(:sup_method_stack) { api_map.get_method_stack('Hash{Symbol => undefined}', '[]', scope: :instance) } - let(:sup_method_stack) { api_map.get_method_stack('Hash{Symbol => undefined}', '[]', scope: :instance) } + let(:sub_alias_stack) { api_map.get_method_stack('Sub', 'meth_alias', scope: :instance) } - let(:sub_alias_stack) { api_map.get_method_stack('Sub', 'meth_alias', scope: :instance) } + it 'does not crash looking at superclass method' do + expect { sup_method_stack }.not_to raise_error + end - before do - api_map.index conversions.pins - end + it 'does not crash looking at alias' do + expect { sub_alias_stack }.not_to raise_error + end - it 'does not crash looking at superclass method' do - expect { sup_method_stack }.not_to raise_error - end + it 'finds superclass method pin return type' do + expect(sup_method_stack.map(&:return_type).map(&:rooted_tags).uniq).to eq(['undefined']) + end - it 'does not crash looking at alias' do - expect { sub_alias_stack }.not_to raise_error + it 'finds superclass method pin parameter type' do + expect(sup_method_stack.flat_map(&:signatures).flat_map(&:parameters).map(&:return_type).map(&:rooted_tags) + .uniq).to eq(['Symbol']) + end end - it 'finds superclass method pin return type' do - expect(sup_method_stack.map(&:return_type).map(&:rooted_tags).uniq).to eq(['undefined']) + context 'with overlapping module hierarchies and inheritance' do + let(:rbs) do + <<~RBS + module B + class C + def foo: () -> String + end + end + module A + module B + class C < ::B::C + end + end + end + RBS + end + + subject(:method_pin) { api_map.get_method_stack('A::B::C', 'foo').first } + + it { should be_a(Solargraph::Pin::Method) } end + end + + if Gem::Version.new(RBS::VERSION) >= Gem::Version.new('3.9.1') + context 'with method pin for Open3.capture2e' do + it 'accepts chdir kwarg' do + api_map = Solargraph::ApiMap.load_with_cache('.', $stdout) + + method_pin = api_map.pins.find do |pin| + pin.is_a?(Solargraph::Pin::Method) && pin.path == 'Open3.capture2e' + end - it 'finds superclass method pin parameter type' do - expect(sup_method_stack.flat_map(&:signatures).flat_map(&:parameters).map(&:return_type).map(&:rooted_tags) - .uniq).to eq(['Symbol']) + chdir_param = method_pin&.signatures&.flat_map(&:parameters)&.find do |param| # rubocop:disable Style/SafeNavigationChainLength + param.name == 'chdir' + end + expect(chdir_param).not_to be_nil, -> { "Found pin #{method_pin.to_rbs} from #{method_pin.type_location}" } + end end end end From e8672b02880d4d0aa83379208d229a7ada5d5438 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Tue, 2 Sep 2025 08:45:49 -0400 Subject: [PATCH 312/400] Fix spec expectation --- spec/rbs_map/core_map_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/rbs_map/core_map_spec.rb b/spec/rbs_map/core_map_spec.rb index 352d29937..88590925b 100644 --- a/spec/rbs_map/core_map_spec.rb +++ b/spec/rbs_map/core_map_spec.rb @@ -6,7 +6,7 @@ pin = store.get_path_pins("Errno::#{const}").first expect(pin).to be_a(Solargraph::Pin::Namespace) superclass = store.get_superclass(pin.path) - expect(superclass).to eq('SystemCallError') + expect(superclass).to eq('::SystemCallError') end end From 8a8f20cbd9c1079f5d0f2567f9865c34af82ba47 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Tue, 2 Sep 2025 08:59:50 -0400 Subject: [PATCH 313/400] Mark spec as pending --- spec/rbs_map/conversions_spec.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/spec/rbs_map/conversions_spec.rb b/spec/rbs_map/conversions_spec.rb index e6322443d..1df43af26 100644 --- a/spec/rbs_map/conversions_spec.rb +++ b/spec/rbs_map/conversions_spec.rb @@ -103,6 +103,7 @@ class C < ::B::C if Gem::Version.new(RBS::VERSION) >= Gem::Version.new('3.9.1') context 'with method pin for Open3.capture2e' do it 'accepts chdir kwarg' do + pending('https://github.com/castwide/solargraph/pull/1005') api_map = Solargraph::ApiMap.load_with_cache('.', $stdout) method_pin = api_map.pins.find do |pin| From fe5a35f6664ce8c19f5e55e63f3ca8ae9ef3bbe6 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Tue, 2 Sep 2025 09:10:16 -0400 Subject: [PATCH 314/400] Fix merge --- .rubocop.yml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 6420ac08b..72d5ae0a7 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -21,6 +21,8 @@ AllCops: - "vendor/**/.*" TargetRubyVersion: 3.0 +# we don't use the spec/solargraph directory, instead keeping things +# directly under spec. RSpec/SpecFilePathFormat: Enabled: false @@ -37,11 +39,6 @@ Metrics/ParameterLists: Max: 7 CountKeywordArgs: false -# we don't use the spec/solargraph directory, instead keeping things -# directly under spec. -RSpec/SpecFilePathFormat: - Enabled: false - # we tend to use @@ and the risk doesn't seem high Style/ClassVars: Enabled: false From ed5d2de905b6f6d426576c407ecb873be41f8e6f Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Tue, 2 Sep 2025 09:12:18 -0400 Subject: [PATCH 315/400] Drop @sg-ignores --- lib/solargraph/parser/parser_gem/class_methods.rb | 2 -- lib/solargraph/pin/parameter.rb | 1 - 2 files changed, 3 deletions(-) diff --git a/lib/solargraph/parser/parser_gem/class_methods.rb b/lib/solargraph/parser/parser_gem/class_methods.rb index eb6dd3d87..de1110ac9 100644 --- a/lib/solargraph/parser/parser_gem/class_methods.rb +++ b/lib/solargraph/parser/parser_gem/class_methods.rb @@ -81,7 +81,6 @@ def inner_node_references name, top result = [] if top.is_a?(AST::Node) && top.to_s.include?(":#{name}") result.push top if top.children.any? { |c| c.to_s == name } - # @sg-ignore top.children.each { |c| result.concat inner_node_references(name, c) } end result @@ -130,7 +129,6 @@ def node_range node # @param node [Parser::AST::Node] # @return [Array] def string_ranges node - # @sg-ignore return [] unless is_ast_node?(node) result = [] result.push Range.from_node(node) if node.type == :str diff --git a/lib/solargraph/pin/parameter.rb b/lib/solargraph/pin/parameter.rb index 4441c67ad..9f58ec067 100644 --- a/lib/solargraph/pin/parameter.rb +++ b/lib/solargraph/pin/parameter.rb @@ -43,7 +43,6 @@ def keyword? end def kwrestarg? - # @sg-ignore Unresolved call to type decl == :kwrestarg || (assignment && [:HASH, :hash].include?(assignment.type)) end From 83dfd6750b63227aa683e8e6cbd03346c26b3934 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Tue, 2 Sep 2025 09:37:46 -0400 Subject: [PATCH 316/400] Improve more annotations --- lib/solargraph/api_map.rb | 4 +++- lib/solargraph/environ.rb | 2 +- lib/solargraph/library.rb | 2 +- lib/solargraph/pin/callable.rb | 4 +++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/solargraph/api_map.rb b/lib/solargraph/api_map.rb index f58633a0c..537eb3985 100755 --- a/lib/solargraph/api_map.rb +++ b/lib/solargraph/api_map.rb @@ -212,6 +212,7 @@ class << self # # @param directory [String] # @param out [IO] The output stream for messages + # # @return [ApiMap] def self.load_with_cache directory, out api_map = load(directory) @@ -533,7 +534,8 @@ def get_complex_type_methods complex_type, context = '', internal = false # @param name [String] Method name to look up # @param scope [Symbol] :instance or :class # @param visibility [Array] :public, :protected, and/or :private - # @param preserve_generics [Boolean] + # @param preserve_generics [Boolean] True to preserve any + # unresolved generic parameters, false to erase them # @return [Array] def get_method_stack rooted_tag, name, scope: :instance, visibility: [:private, :protected, :public], preserve_generics: false rooted_type = ComplexType.parse(rooted_tag) diff --git a/lib/solargraph/environ.rb b/lib/solargraph/environ.rb index 3d24127c6..639442a04 100644 --- a/lib/solargraph/environ.rb +++ b/lib/solargraph/environ.rb @@ -22,7 +22,7 @@ class Environ # @param requires [Array] # @param domains [Array] # @param pins [Array] - # @param yard_plugins[Array] + # @param yard_plugins [Array] def initialize requires: [], domains: [], pins: [], yard_plugins: [] @requires = requires @domains = domains diff --git a/lib/solargraph/library.rb b/lib/solargraph/library.rb index 9d5162431..b64afa4a0 100644 --- a/lib/solargraph/library.rb +++ b/lib/solargraph/library.rb @@ -580,7 +580,7 @@ def cache_errors def cache_next_gemspec return if @cache_progress - spec = cacheable_specs.first +g spec = cacheable_specs.first return end_cache_progress unless spec pending = api_map.uncached_gemspecs.length - cache_errors.length - 1 diff --git a/lib/solargraph/pin/callable.rb b/lib/solargraph/pin/callable.rb index 504dd4862..8ab1bf733 100644 --- a/lib/solargraph/pin/callable.rb +++ b/lib/solargraph/pin/callable.rb @@ -27,7 +27,8 @@ def method_namespace end # @param other [self] - # @return [Pin::Block, nil] + # + # @return [Pin::Signature, nil] def combine_blocks(other) if block.nil? other.block @@ -61,6 +62,7 @@ def generics end # @param other [self] + # # @return [Array] def choose_parameters(other) raise "Trying to combine two pins with different arities - \nself =#{inspect}, \nother=#{other.inspect}, \n\n self.arity=#{self.arity}, \nother.arity=#{other.arity}" if other.arity != arity From 857dff322331931e9ab1e786b2df1e2dcad7dc7b Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Tue, 2 Sep 2025 10:00:37 -0400 Subject: [PATCH 317/400] Add @sg-ignore --- lib/solargraph/api_map.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/solargraph/api_map.rb b/lib/solargraph/api_map.rb index 706e0c144..739c29ec3 100755 --- a/lib/solargraph/api_map.rb +++ b/lib/solargraph/api_map.rb @@ -364,6 +364,7 @@ def get_instance_variable_pins namespace, scope = :instance # @see Solargraph::Parser::FlowSensitiveTyping#visible_pins # @param (see Solargraph::Parser::FlowSensitiveTyping#visible_pins) + # @sg-ignore Missing @return tag for Solargraph::ApiMap#visible_pins # @return (see Solargraph::Parser::FlowSensitiveTyping#visible_pins) def visible_pins(*args, **kwargs, &blk) Solargraph::Parser::FlowSensitiveTyping.visible_pins(*args, **kwargs, &blk) From 866bd388f48a270b2dec093e595382f592245dd5 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Tue, 2 Sep 2025 10:45:09 -0400 Subject: [PATCH 318/400] More annotation cleanups / fixes --- lib/solargraph/api_map.rb | 1 + lib/solargraph/api_map/index.rb | 1 + lib/solargraph/api_map/store.rb | 8 +++++--- lib/solargraph/pin/base.rb | 2 +- lib/solargraph/rbs_map.rb | 4 ++-- 5 files changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/solargraph/api_map.rb b/lib/solargraph/api_map.rb index 537eb3985..f8702ea2b 100755 --- a/lib/solargraph/api_map.rb +++ b/lib/solargraph/api_map.rb @@ -177,6 +177,7 @@ def clip_at filename, position # Create an ApiMap with a workspace in the specified directory. # # @param directory [String] + # # @return [ApiMap] def self.load directory api_map = new diff --git a/lib/solargraph/api_map/index.rb b/lib/solargraph/api_map/index.rb index a5870ff50..f37480c8d 100644 --- a/lib/solargraph/api_map/index.rb +++ b/lib/solargraph/api_map/index.rb @@ -95,6 +95,7 @@ def deep_clone end # @param new_pins [Enumerable] + # # @return [self] def catalog new_pins # @type [Hash{Class> => Set>}] diff --git a/lib/solargraph/api_map/store.rb b/lib/solargraph/api_map/store.rb index f3e2ed278..61cd820d9 100644 --- a/lib/solargraph/api_map/store.rb +++ b/lib/solargraph/api_map/store.rb @@ -50,7 +50,7 @@ def inspect # @param fqns [String] # @param visibility [Array] - # @return [Enumerable] + # @return [Enumerable] def get_constants fqns, visibility = [:public] namespace_children(fqns).select { |pin| !pin.name.empty? && (pin.is_a?(Pin::Namespace) || pin.is_a?(Pin::Constant)) && visibility.include?(pin.visibility) @@ -126,7 +126,8 @@ def get_instance_variables(fqns, scope = :instance) end # @param fqns [String] - # @return [Enumerable] + # + # @return [Enumerable] def get_class_variables(fqns) namespace_children(fqns).select { |pin| pin.is_a?(Pin::ClassVariable)} end @@ -254,7 +255,8 @@ def index end # @param pinsets [Array>] - # @return [Boolean] + # + # @return [void] def catalog pinsets @pinsets = pinsets # @type [Array] diff --git a/lib/solargraph/pin/base.rb b/lib/solargraph/pin/base.rb index 7f1509d9b..c8c5e6d7f 100644 --- a/lib/solargraph/pin/base.rb +++ b/lib/solargraph/pin/base.rb @@ -338,7 +338,7 @@ def choose_pin_attr_with_same_name(other, attr) # @param other [self] # @param attr [::Symbol] # - # @sg-ignore + # @sg-ignore Missing @return tag for Solargraph::Pin::Base#choose_pin_attr # @return [undefined] def choose_pin_attr(other, attr) # @type [Pin::Base, nil] diff --git a/lib/solargraph/rbs_map.rb b/lib/solargraph/rbs_map.rb index c6c10bac6..803e3677a 100644 --- a/lib/solargraph/rbs_map.rb +++ b/lib/solargraph/rbs_map.rb @@ -23,7 +23,7 @@ class RbsMap attr_reader :rbs_collection_config_path # @param library [String] - # @param version [String, nil + # @param version [String, nil] # @param rbs_collection_config_path [String, Pathname, nil] # @param rbs_collection_paths [Array] def initialize library, version = nil, rbs_collection_config_path: nil, rbs_collection_paths: [] @@ -72,7 +72,7 @@ def cache_key end end - # @param gemspec [Gem::Specification] + # @param gemspec [Gem::Specification, Bundler::LazySpecification] # @param rbs_collection_path [String, Pathname, nil] # @param rbs_collection_config_path [String, Pathname, nil] # @return [RbsMap] From ae56366ad03f0cf2a2d8b3ae000bee79110d5009 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Tue, 2 Sep 2025 10:46:52 -0400 Subject: [PATCH 319/400] Fix typo --- lib/solargraph/library.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/solargraph/library.rb b/lib/solargraph/library.rb index b64afa4a0..9d5162431 100644 --- a/lib/solargraph/library.rb +++ b/lib/solargraph/library.rb @@ -580,7 +580,7 @@ def cache_errors def cache_next_gemspec return if @cache_progress -g spec = cacheable_specs.first + spec = cacheable_specs.first return end_cache_progress unless spec pending = api_map.uncached_gemspecs.length - cache_errors.length - 1 From d16301db0bab62c9865b7411fbf9baa1797e2380 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Tue, 2 Sep 2025 11:02:30 -0400 Subject: [PATCH 320/400] Revert workaround --- .../parser_gem/node_processors/sclass_node.rb | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/lib/solargraph/parser/parser_gem/node_processors/sclass_node.rb b/lib/solargraph/parser/parser_gem/node_processors/sclass_node.rb index 1b573ed93..69ed95214 100644 --- a/lib/solargraph/parser/parser_gem/node_processors/sclass_node.rb +++ b/lib/solargraph/parser/parser_gem/node_processors/sclass_node.rb @@ -7,18 +7,9 @@ module NodeProcessors class SclassNode < Parser::NodeProcessor::Base def process sclass = node.children[0] - # @todo Changing Parser::AST::Node to AST::Node below will - # cause type errors at strong level because the combined - # pin for AST::Node#children has return type - # "Array, Array". YARD annotations in AST - # provided the Array, RBS for Array. We - # should probably have a rule to combine "A, A"" - # types to "A" if the "A" comes from YARD, with the - # rationale that folks tend to be less formal with types in - # YARD. - if sclass.is_a?(::Parser::AST::Node) && sclass.type == :self + if sclass.is_a?(::AST::Node) && sclass.type == :self closure = region.closure - elsif sclass.is_a?(::Parser::AST::Node) && sclass.type == :casgn + elsif sclass.is_a?(::AST::Node) && sclass.type == :casgn names = [region.closure.namespace, region.closure.name] if sclass.children[0].nil? && names.last != sclass.children[1].to_s names << sclass.children[1].to_s @@ -27,7 +18,7 @@ def process end name = names.reject(&:empty?).join('::') closure = Solargraph::Pin::Namespace.new(name: name, location: region.closure.location, source: :parser) - elsif sclass.is_a?(::Parser::AST::Node) && sclass.type == :const + elsif sclass.is_a?(::AST::Node) && sclass.type == :const names = [region.closure.namespace, region.closure.name] also = NodeMethods.unpack_name(sclass) if also != region.closure.name From 43e1752cf7c8f2c28abe120011d6fb1986daca47 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Tue, 2 Sep 2025 11:21:29 -0400 Subject: [PATCH 321/400] Drop alias lookup code --- lib/solargraph/api_map.rb | 8 -------- lib/solargraph/api_map/store.rb | 5 ----- 2 files changed, 13 deletions(-) diff --git a/lib/solargraph/api_map.rb b/lib/solargraph/api_map.rb index 98650e636..090e645ba 100755 --- a/lib/solargraph/api_map.rb +++ b/lib/solargraph/api_map.rb @@ -548,14 +548,6 @@ def get_method_stack rooted_tag, name, scope: :instance, visibility: [:private, get_methods(rooted_tag, scope: scope, visibility: visibility).select { |p| p.name == name } end methods = erase_generics(namespace_pin, rooted_type, methods) unless preserve_generics - if methods.empty? && namespace_pin.nil? - # namespace may be set by an alias - constant = store.constant_pins.find { |c| c.name == fqns && visibility.include?(c.visibility) } - if constant - return get_method_stack(constant.return_type.tag, name, scope: scope, visibility: visibility, - preserve_generics: preserve_generics) - end - end methods end diff --git a/lib/solargraph/api_map/store.rb b/lib/solargraph/api_map/store.rb index 296e88b49..90263455a 100644 --- a/lib/solargraph/api_map/store.rb +++ b/lib/solargraph/api_map/store.rb @@ -148,11 +148,6 @@ def namespace_pins pins_by_class(Solargraph::Pin::Namespace) end - # @return [Enumerable] - def constant_pins - pins_by_class(Solargraph::Pin::Constant) - end - # @return [Enumerable] def method_pins pins_by_class(Solargraph::Pin::Method) From cd0a23c762b4cabbff8fcba29c56a2268de1624b Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Tue, 2 Sep 2025 12:04:21 -0400 Subject: [PATCH 322/400] Fix merge --- .../parser_gem/node_processors/sclass_node.rb | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/solargraph/parser/parser_gem/node_processors/sclass_node.rb b/lib/solargraph/parser/parser_gem/node_processors/sclass_node.rb index 69ed95214..1b573ed93 100644 --- a/lib/solargraph/parser/parser_gem/node_processors/sclass_node.rb +++ b/lib/solargraph/parser/parser_gem/node_processors/sclass_node.rb @@ -7,9 +7,18 @@ module NodeProcessors class SclassNode < Parser::NodeProcessor::Base def process sclass = node.children[0] - if sclass.is_a?(::AST::Node) && sclass.type == :self + # @todo Changing Parser::AST::Node to AST::Node below will + # cause type errors at strong level because the combined + # pin for AST::Node#children has return type + # "Array, Array". YARD annotations in AST + # provided the Array, RBS for Array. We + # should probably have a rule to combine "A, A"" + # types to "A" if the "A" comes from YARD, with the + # rationale that folks tend to be less formal with types in + # YARD. + if sclass.is_a?(::Parser::AST::Node) && sclass.type == :self closure = region.closure - elsif sclass.is_a?(::AST::Node) && sclass.type == :casgn + elsif sclass.is_a?(::Parser::AST::Node) && sclass.type == :casgn names = [region.closure.namespace, region.closure.name] if sclass.children[0].nil? && names.last != sclass.children[1].to_s names << sclass.children[1].to_s @@ -18,7 +27,7 @@ def process end name = names.reject(&:empty?).join('::') closure = Solargraph::Pin::Namespace.new(name: name, location: region.closure.location, source: :parser) - elsif sclass.is_a?(::AST::Node) && sclass.type == :const + elsif sclass.is_a?(::Parser::AST::Node) && sclass.type == :const names = [region.closure.namespace, region.closure.name] also = NodeMethods.unpack_name(sclass) if also != region.closure.name From 5c90bbc91ca2894c0408c2918ed9cfd8183bdce5 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Tue, 2 Sep 2025 12:12:04 -0400 Subject: [PATCH 323/400] Fix long line --- lib/solargraph/doc_map.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/solargraph/doc_map.rb b/lib/solargraph/doc_map.rb index 5fe5e03f9..64ab926bc 100644 --- a/lib/solargraph/doc_map.rb +++ b/lib/solargraph/doc_map.rb @@ -177,10 +177,10 @@ def load_serialized_gem_pins @uncached_yard_gemspecs = [] @uncached_rbs_collection_gemspecs = [] with_gemspecs, without_gemspecs = required_gems_map.partition { |_, v| v } - # @sg-ignore Wrong argument type for Hash.[]: arg_0 expected _ToHash), undefined>, received Array)> + # @sg-ignore Need support for RBS duck interfaces like _ToHash # @type [Array] paths = Hash[without_gemspecs].keys - # @sg-ignore Wrong argument type for Hash.[]: arg_0 expected _ToHash), undefined>, received Array)> + # @sg-ignore Need support for RBS duck interfaces like _ToHash # @type [Array] gemspecs = Hash[with_gemspecs].values.flatten.compact + dependencies.to_a From 06e0c0796c4abdcfa755bc163c14a62d00bc8058 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Tue, 2 Sep 2025 12:43:58 -0400 Subject: [PATCH 324/400] Lint fixes --- .rubocop_todo.yml | 7 +------ lib/solargraph/library.rb | 1 + lib/solargraph/workspace/gemspecs.rb | 1 + lib/solargraph/workspace/require_paths.rb | 1 + 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 0af0d7a2d..84471b1ba 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -64,7 +64,6 @@ Layout/BlockAlignment: Layout/ClosingHeredocIndentation: Exclude: - 'spec/diagnostics/rubocop_spec.rb' - - 'spec/rbs_map/conversions_spec.rb' # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowForAlignment. @@ -166,7 +165,6 @@ Layout/ExtraSpacing: Exclude: - 'lib/solargraph/parser/parser_gem/node_processors/opasgn_node.rb' - 'lib/solargraph/pin/closure.rb' - - 'lib/solargraph/pin/local_variable.rb' - 'lib/solargraph/rbs_map/conversions.rb' - 'lib/solargraph/type_checker.rb' - 'spec/spec_helper.rb' @@ -224,7 +222,6 @@ Layout/HashAlignment: Layout/HeredocIndentation: Exclude: - 'spec/diagnostics/rubocop_spec.rb' - - 'spec/rbs_map/conversions_spec.rb' - 'spec/yard_map/mapper/to_method_spec.rb' # This cop supports safe autocorrection (--autocorrect). @@ -326,7 +323,6 @@ Layout/SpaceAroundOperators: Exclude: - 'lib/solargraph/library.rb' - 'lib/solargraph/parser/parser_gem/node_methods.rb' - - 'lib/solargraph/pin/local_variable.rb' - 'lib/solargraph/source.rb' - 'lib/solargraph/source/change.rb' - 'lib/solargraph/source/cursor.rb' @@ -900,6 +896,7 @@ RSpec/DescribeClass: - '**/spec/routing/**/*' - '**/spec/system/**/*' - '**/spec/views/**/*' + - 'spec/api_map_method_spec.rb' - 'spec/complex_type_spec.rb' - 'spec/source_map/node_processor_spec.rb' @@ -1022,7 +1019,6 @@ RSpec/ExampleLength: # DisallowedExamples: works RSpec/ExampleWording: Exclude: - - 'spec/convention/struct_definition_spec.rb' - 'spec/pin/base_spec.rb' - 'spec/pin/method_spec.rb' @@ -2552,7 +2548,6 @@ Layout/LineLength: - 'lib/solargraph/type_checker.rb' - 'lib/solargraph/workspace/config.rb' - 'lib/solargraph/yard_map/mapper/to_method.rb' - - 'spec/api_map_spec.rb' - 'spec/complex_type_spec.rb' - 'spec/language_server/message/completion_item/resolve_spec.rb' - 'spec/language_server/message/extended/check_gem_version_spec.rb' diff --git a/lib/solargraph/library.rb b/lib/solargraph/library.rb index c9f908711..82701ced5 100644 --- a/lib/solargraph/library.rb +++ b/lib/solargraph/library.rb @@ -603,6 +603,7 @@ def cache_next_gemspec report_cache_progress spec.name, pending kwargs = {} kwargs[:chdir] = workspace.directory.to_s if workspace.directory && !workspace.directory.empty? + # @sg-ignore https://github.com/castwide/solargraph/pull/1005 _o, e, s = Open3.capture3(workspace.command_path, 'cache', spec.name, spec.version.to_s, **kwargs) if s.success? diff --git a/lib/solargraph/workspace/gemspecs.rb b/lib/solargraph/workspace/gemspecs.rb index af9858da8..29295a45a 100644 --- a/lib/solargraph/workspace/gemspecs.rb +++ b/lib/solargraph/workspace/gemspecs.rb @@ -200,6 +200,7 @@ def query_external_bundle command 'ruby', '-e', "require 'bundler'; require 'json'; Dir.chdir('#{directory}') { puts begin; #{command}; end.to_json }" ] + # @sg-ignore https://github.com/castwide/solargraph/pull/1005 o, e, s = Open3.capture3(*cmd) if s.success? Solargraph.logger.debug "External bundle: #{o}" diff --git a/lib/solargraph/workspace/require_paths.rb b/lib/solargraph/workspace/require_paths.rb index c8eea161b..8ba873d96 100644 --- a/lib/solargraph/workspace/require_paths.rb +++ b/lib/solargraph/workspace/require_paths.rb @@ -76,6 +76,7 @@ def require_path_from_gemspec_file gemspec_file_path "spec = eval(File.read('#{gemspec_file_path}'), TOPLEVEL_BINDING, '#{gemspec_file_path}'); " \ 'return unless Gem::Specification === spec; ' \ 'puts({name: spec.name, paths: spec.require_paths}.to_json)'] + # @sg-ignore https://github.com/castwide/solargraph/pull/1005 o, e, s = Open3.capture3(*cmd) if s.success? begin From 383605f3013a7a9c6b7f14df3aeffa204221c474 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Tue, 2 Sep 2025 13:25:50 -0400 Subject: [PATCH 325/400] Drop unneeded change --- lib/solargraph/parser/parser_gem/class_methods.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/solargraph/parser/parser_gem/class_methods.rb b/lib/solargraph/parser/parser_gem/class_methods.rb index de1110ac9..717423316 100644 --- a/lib/solargraph/parser/parser_gem/class_methods.rb +++ b/lib/solargraph/parser/parser_gem/class_methods.rb @@ -74,8 +74,8 @@ def references source, name end # @param name [String] - # @param top [Parser::AST::Node] - # @return [Array] + # @param top [AST::Node] + # @return [Array] def inner_node_references name, top # @type [Array] result = [] @@ -112,7 +112,7 @@ def version parser.version end - # @param node [Object] + # @param node [BasicObject] # @return [Boolean] def is_ast_node? node node.is_a?(::Parser::AST::Node) From 14c1fe7eacec5f792a34d1428ec8e4bada2ec77e Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Wed, 3 Sep 2025 23:05:35 -0400 Subject: [PATCH 326/400] Fix comment --- .github/workflows/rspec.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/rspec.yml b/.github/workflows/rspec.yml index e54534417..d2e486f32 100644 --- a/.github/workflows/rspec.yml +++ b/.github/workflows/rspec.yml @@ -30,7 +30,7 @@ jobs: - ruby-version: '3.0' rbs-version: '4.0.0.dev.4' # Missing require in 'rbs collection update' - hopefully - # fixed in next RBS release + # fixed in next RBS dev release - ruby-version: 'head' rbs-version: '4.0.0.dev.4' - ruby-version: 'head' From efbe6eddba0a48ff8426f093309e441a3f54166d Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Wed, 3 Sep 2025 23:12:22 -0400 Subject: [PATCH 327/400] Fix merge issue --- spec/language_server/host/message_worker_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/language_server/host/message_worker_spec.rb b/spec/language_server/host/message_worker_spec.rb index 9e5ce5721..5e5bef481 100644 --- a/spec/language_server/host/message_worker_spec.rb +++ b/spec/language_server/host/message_worker_spec.rb @@ -2,8 +2,8 @@ it "handle requests on queue" do host = double(Solargraph::LanguageServer::Host) message = {'method' => '$/example'} - allow(host).to receive(:receive).with(message).and_return(nil) + worker = Solargraph::LanguageServer::Host::MessageWorker.new(host) worker.queue(message) expect(worker.messages).to eq [message] From bb0f6079024f1e28ee9f12c26bbc626fe475d2ce Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Sat, 6 Sep 2025 14:18:16 -0400 Subject: [PATCH 328/400] Rerun rubocop todo --- .rubocop_todo.yml | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 0ed335f34..c55a29039 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -64,7 +64,6 @@ Layout/BlockAlignment: Layout/ClosingHeredocIndentation: Exclude: - 'spec/diagnostics/rubocop_spec.rb' - - 'spec/rbs_map/conversions_spec.rb' # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowForAlignment. @@ -167,7 +166,6 @@ Layout/HashAlignment: Layout/HeredocIndentation: Exclude: - 'spec/diagnostics/rubocop_spec.rb' - - 'spec/rbs_map/conversions_spec.rb' - 'spec/yard_map/mapper/to_method_spec.rb' # This cop supports safe autocorrection (--autocorrect). @@ -685,10 +683,13 @@ RSpec/LetBeforeExamples: Exclude: - 'spec/complex_type_spec.rb' -# Configuration parameters: . +# Configuration parameters: EnforcedStyle. # SupportedStyles: have_received, receive RSpec/MessageSpies: - EnforcedStyle: receive + Exclude: + - 'spec/doc_map_spec.rb' + - 'spec/language_server/host/diagnoser_spec.rb' + - 'spec/language_server/host/message_worker_spec.rb' RSpec/MissingExampleGroupArgument: Exclude: @@ -750,10 +751,6 @@ RSpec/ScatteredLet: Exclude: - 'spec/complex_type_spec.rb' -# Configuration parameters: CustomTransform, IgnoreMethods, IgnoreMetadata. -RSpec/SpecFilePathFormat: - Enabled: false - RSpec/StubbedMock: Exclude: - 'spec/language_server/host/message_worker_spec.rb' From 66f44dceba2c16ea6b30b429ff07775f855278c3 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Sat, 6 Sep 2025 21:54:03 -0400 Subject: [PATCH 329/400] Fix RuboCop issues --- spec/api_map_spec.rb | 2 +- spec/yard_map/mapper_spec.rb | 2 +- spec/yardoc_spec.rb | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/api_map_spec.rb b/spec/api_map_spec.rb index acd31314e..a8f83aad9 100755 --- a/spec/api_map_spec.rb +++ b/spec/api_map_spec.rb @@ -9,7 +9,7 @@ end it 'returns core methods', time_limit_seconds: 120 do - pins = @api_map.get_methods('String') # rubocop:disable RSpec/InstanceVariable + pins = @api_map.get_methods('String') expect(pins.map(&:path)).to include('String#upcase') end diff --git a/spec/yard_map/mapper_spec.rb b/spec/yard_map/mapper_spec.rb index 450b459e4..8b355e7ca 100644 --- a/spec/yard_map/mapper_spec.rb +++ b/spec/yard_map/mapper_spec.rb @@ -4,7 +4,7 @@ end def pins_with require - doc_map = Solargraph::DocMap.new([require], @api_map.workspace, out: nil) # rubocop:disable RSpec/InstanceVariable + doc_map = Solargraph::DocMap.new([require], @api_map.workspace, out: nil) doc_map.cache_doc_map_gems!(nil) doc_map.pins end diff --git a/spec/yardoc_spec.rb b/spec/yardoc_spec.rb index 2e821498e..6e7171afe 100644 --- a/spec/yardoc_spec.rb +++ b/spec/yardoc_spec.rb @@ -9,11 +9,11 @@ testobj.run ensure - FileUtils.remove_entry(@tmpdir) # rubocop:disable RSpec/InstanceVariable + FileUtils.remove_entry(@tmpdir) end let(:gem_yardoc_path) do - File.join(@tmpdir, 'solargraph', 'yardoc', 'test_gem') # rubocop:disable RSpec/InstanceVariable + File.join(@tmpdir, 'solargraph', 'yardoc', 'test_gem') end before do From 7c60506c0dd73dd92632cbd498d729fe20d9dd4e Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Sun, 7 Sep 2025 00:15:06 -0400 Subject: [PATCH 330/400] Resolve merge issue --- lib/solargraph/workspace.rb | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/solargraph/workspace.rb b/lib/solargraph/workspace.rb index 75869575b..553dab986 100644 --- a/lib/solargraph/workspace.rb +++ b/lib/solargraph/workspace.rb @@ -53,24 +53,11 @@ def config @config ||= Solargraph::Workspace::Config.new(directory) end - # @param out [IO, nil] output stream for logging - # @param gemspec [Gem::Specification] - # @return [Array] - def fetch_dependencies gemspec, out: $stderr - gemspecs.fetch_dependencies(gemspec, out: out) - end - # @return [Solargraph::PinCache] def pin_cache @pin_cache ||= fresh_pincache end - # @param require [String] The string sent to 'require' in the code to resolve, e.g. 'rails', 'bundler/require' - # @return [Array] - def resolve_require require - gemspecs.resolve_require(require) - end - # @param stdlib_name [String] # # @return [Array] @@ -115,6 +102,19 @@ def yard_plugins @yard_plugins ||= global_environ.yard_plugins.sort.uniq end + # @param out [IO, nil] output stream for logging + # @param gemspec [Gem::Specification] + # @return [Array] + def fetch_dependencies gemspec, out: $stderr + gemspecs.fetch_dependencies(gemspec, out: out) + end + + # @param require [String] The string sent to 'require' in the code to resolve, e.g. 'rails', 'bundler/require' + # @return [Array] + def resolve_require require + gemspecs.resolve_require(require) + end + # Merge the source. A merge will update the existing source for the file # or add it to the sources if the workspace is configured to include it. # The source is ignored if the configuration excludes it. From 1241c17cca65fe27dc75cecb35bee2a9e107918b Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Sun, 7 Sep 2025 00:19:43 -0400 Subject: [PATCH 331/400] Resolve merge issue --- lib/solargraph/doc_map.rb | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/solargraph/doc_map.rb b/lib/solargraph/doc_map.rb index 9b8069bf3..f9fe57d27 100644 --- a/lib/solargraph/doc_map.rb +++ b/lib/solargraph/doc_map.rb @@ -16,15 +16,6 @@ class DocMap # @return [Workspace] attr_reader :workspace - # @param requires [Array] - # @param workspace [Workspace] - # @param out [IO, nil] output stream for logging - def initialize requires, workspace, out: $stderr - @provided_requires = requires.compact - @workspace = workspace - @out = out - end - # @return [Array] def requires @requires ||= @provided_requires + (workspace.global_environ&.requires || []) @@ -40,6 +31,15 @@ def uncached_gemspecs @uncached_gemspecs end + # @param requires [Array] + # @param workspace [Workspace] + # @param out [IO, nil] output stream for logging + def initialize requires, workspace, out: $stderr + @provided_requires = requires.compact + @workspace = workspace + @out = out + end + # @return [Array] def pins @pins ||= load_serialized_gem_pins + (workspace.global_environ&.pins || []) @@ -166,7 +166,7 @@ def load_serialized_gem_pins out: @out # @return [Hash{String => Array}] def required_gems_map - @required_gems_map ||= requires.to_h { |require| [require, workspace.resolve_require(require)] } + @required_gems_map ||= requires.to_h { |path| [path, workspace.resolve_require(path)] } end def inspect From 184f2e6b189614555c6b9d82a330e7f9c16a23d7 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Sun, 7 Sep 2025 00:24:24 -0400 Subject: [PATCH 332/400] Resolve merge issue --- lib/solargraph/api_map.rb | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/lib/solargraph/api_map.rb b/lib/solargraph/api_map.rb index 92e876229..d60a7f763 100755 --- a/lib/solargraph/api_map.rb +++ b/lib/solargraph/api_map.rb @@ -45,13 +45,13 @@ def self.reset_core out: nil # # @param other [Object] - def eql? other + def eql?(other) self.class == other.class && equality_fields == other.equality_fields end # @param other [Object] - def == other + def ==(other) self.eql?(other) end @@ -125,8 +125,10 @@ def catalog bench [self.class, @source_map_hash, implicit, @doc_map, @unresolved_requires] end - # @return [DocMap, nil] - attr_reader :doc_map + # @return [DocMap] + def doc_map + @doc_map ||= DocMap.new([], Workspace.new('.')) + end # @return [::Array] def uncached_gemspecs @@ -687,9 +689,6 @@ def resolve_method_aliases pins, visibility = [:public, :private, :protected] resolved = resolve_method_alias(pin) next nil if resolved.respond_to?(:visibility) && !visibility.include?(resolved.visibility) resolved - rescue Solargraph::ComplexTypeError => e - logger.warn "ComplexTypeError while resolving #{pin.inspect}: #{e.message}" - raise e end.compact logger.debug do "ApiMap#resolve_method_aliases(pins=#{pins.map(&:name)}, visibility=#{visibility}) => #{with_resolved_aliases.map(&:name)}" From 04dd24df2afdfa953cbfd98b07d9a15e16ef0f0b Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Sun, 7 Sep 2025 00:26:07 -0400 Subject: [PATCH 333/400] Resolve merge issue --- lib/solargraph/api_map/index.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/solargraph/api_map/index.rb b/lib/solargraph/api_map/index.rb index c28fbbaab..0d3d3481d 100644 --- a/lib/solargraph/api_map/index.rb +++ b/lib/solargraph/api_map/index.rb @@ -160,7 +160,9 @@ def map_overrides pins = path_pin_hash[ovr.name] logger.debug { "ApiMap::Index#map_overrides: pins for path=#{ovr.name}: #{pins}" } pins.each do |pin| - new_pin = (path_pin_hash[pin.path.sub(/#initialize/, '.new')].first if pin.path.end_with?('#initialize')) + new_pin = if pin.path.end_with?('#initialize') + path_pin_hash[pin.path.sub(/#initialize/, '.new')].first + end (ovr.tags.map(&:tag_name) + ovr.delete).uniq.each do |tag| pin.docstring.delete_tags tag new_pin.docstring.delete_tags tag if new_pin From 837d7f67872f47619200320bafb7d80da9abad95 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Sun, 7 Sep 2025 16:57:05 -0400 Subject: [PATCH 334/400] Force build --- .github/workflows/rspec.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/rspec.yml b/.github/workflows/rspec.yml index ecc3d9771..bfa6dce07 100644 --- a/.github/workflows/rspec.yml +++ b/.github/workflows/rspec.yml @@ -48,8 +48,8 @@ jobs: run: | bundle install bundle update rbs # use latest available for this Ruby version - - name: Run tests - run: bundle exec rake spec +# - name: Run tests +# run: bundle exec rake spec undercover: runs-on: ubuntu-latest steps: From a4208e71241a3b2e5e2f9198d8d135a065bd7ea4 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Sun, 7 Sep 2025 17:10:41 -0400 Subject: [PATCH 335/400] Restore --- .github/workflows/rspec.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/rspec.yml b/.github/workflows/rspec.yml index bfa6dce07..ecc3d9771 100644 --- a/.github/workflows/rspec.yml +++ b/.github/workflows/rspec.yml @@ -48,8 +48,8 @@ jobs: run: | bundle install bundle update rbs # use latest available for this Ruby version -# - name: Run tests -# run: bundle exec rake spec + - name: Run tests + run: bundle exec rake spec undercover: runs-on: ubuntu-latest steps: From b66f2ac85a8d5599e36decc6a24fce36eed2f382 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Sun, 7 Sep 2025 17:14:22 -0400 Subject: [PATCH 336/400] install -> update with rbs collection --- .github/workflows/plugins.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/plugins.yml b/.github/workflows/plugins.yml index 730882e30..b013abd3b 100644 --- a/.github/workflows/plugins.yml +++ b/.github/workflows/plugins.yml @@ -164,7 +164,7 @@ jobs: cd ${RAILS_DIR} bundle install bundle exec --gemfile ../../Gemfile rbs --version - bundle exec --gemfile ../../Gemfile rbs collection install + bundle exec --gemfile ../../Gemfile rbs collection update cd ../../ # bundle exec rbs collection init # bundle exec rbs collection install From a09a9af2bc797134fac776c370ce4fcc2c6db121 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Sun, 7 Sep 2025 17:25:05 -0400 Subject: [PATCH 337/400] Try Ruby 3.2 --- .github/workflows/plugins.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/plugins.yml b/.github/workflows/plugins.yml index b013abd3b..af9997846 100644 --- a/.github/workflows/plugins.yml +++ b/.github/workflows/plugins.yml @@ -144,7 +144,8 @@ jobs: uses: ruby/setup-ruby@v1 with: # solargraph-rails supports Ruby 3.0+ - ruby-version: '3.0' + # RBS 3.9 supports Ruby 3.2+ + ruby-version: '3.2' bundler-cache: false bundler: latest env: @@ -164,7 +165,7 @@ jobs: cd ${RAILS_DIR} bundle install bundle exec --gemfile ../../Gemfile rbs --version - bundle exec --gemfile ../../Gemfile rbs collection update + bundle exec --gemfile ../../Gemfile rbs collection install cd ../../ # bundle exec rbs collection init # bundle exec rbs collection install From 6fc8febcdd4cb9515785e0f85788497ad8923ae7 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Sun, 7 Sep 2025 17:44:39 -0400 Subject: [PATCH 338/400] Update solargraph --- .github/workflows/plugins.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/plugins.yml b/.github/workflows/plugins.yml index af9997846..ef9fe0155 100644 --- a/.github/workflows/plugins.yml +++ b/.github/workflows/plugins.yml @@ -158,8 +158,7 @@ jobs: export BUNDLE_PATH cd ../solargraph-rails echo "gem 'solargraph', path: '${GITHUB_WORKSPACE:?}'" >> Gemfile - bundle install - bundle update rbs + bundle update solargraph rbs RAILS_DIR="$(pwd)/spec/rails7" export RAILS_DIR cd ${RAILS_DIR} From 388c170d76531530012eb1dff32579a059e3bda6 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Sun, 7 Sep 2025 17:45:56 -0400 Subject: [PATCH 339/400] Re-add bundle install --- .github/workflows/plugins.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/plugins.yml b/.github/workflows/plugins.yml index ef9fe0155..a97b27c7c 100644 --- a/.github/workflows/plugins.yml +++ b/.github/workflows/plugins.yml @@ -158,6 +158,7 @@ jobs: export BUNDLE_PATH cd ../solargraph-rails echo "gem 'solargraph', path: '${GITHUB_WORKSPACE:?}'" >> Gemfile + bundle install bundle update solargraph rbs RAILS_DIR="$(pwd)/spec/rails7" export RAILS_DIR From f80b73a020dd405addf8f56d2317e31614c2f8da Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Sun, 7 Sep 2025 17:58:16 -0400 Subject: [PATCH 340/400] Drop MATRIX_SOLARGRAPH_VERSION --- .github/workflows/plugins.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/plugins.yml b/.github/workflows/plugins.yml index a97b27c7c..4dedbd93f 100644 --- a/.github/workflows/plugins.yml +++ b/.github/workflows/plugins.yml @@ -149,7 +149,6 @@ jobs: bundler-cache: false bundler: latest env: - MATRIX_SOLARGRAPH_VERSION: '>=0.56.0.pre1' MATRIX_RAILS_VERSION: "7.0" - name: Install gems run: | @@ -170,7 +169,6 @@ jobs: # bundle exec rbs collection init # bundle exec rbs collection install env: - MATRIX_SOLARGRAPH_VERSION: '>=0.56.0.pre1' MATRIX_RAILS_VERSION: "7.0" MATRIX_RAILS_MAJOR_VERSION: '7' - name: Run specs @@ -184,5 +182,4 @@ jobs: bundle info yard ALLOW_IMPROVEMENTS=true bundle exec rake spec env: - MATRIX_SOLARGRAPH_VERSION: '>=0.56.0.pre1' MATRIX_RAILS_VERSION: "7.0" From ce2bee62f20628f33f1e9abb98f7faf96f69166f Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Sun, 7 Sep 2025 18:09:04 -0400 Subject: [PATCH 341/400] Drop debugging changes --- .github/workflows/plugins.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/plugins.yml b/.github/workflows/plugins.yml index 4dedbd93f..b5984f3cb 100644 --- a/.github/workflows/plugins.yml +++ b/.github/workflows/plugins.yml @@ -144,8 +144,7 @@ jobs: uses: ruby/setup-ruby@v1 with: # solargraph-rails supports Ruby 3.0+ - # RBS 3.9 supports Ruby 3.2+ - ruby-version: '3.2' + ruby-version: '3.0' bundler-cache: false bundler: latest env: @@ -158,7 +157,7 @@ jobs: cd ../solargraph-rails echo "gem 'solargraph', path: '${GITHUB_WORKSPACE:?}'" >> Gemfile bundle install - bundle update solargraph rbs + bundle update rbs RAILS_DIR="$(pwd)/spec/rails7" export RAILS_DIR cd ${RAILS_DIR} From dbe9a3edc5291e6cf50632560893306ee074a79f Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Sun, 7 Sep 2025 18:40:51 -0400 Subject: [PATCH 342/400] Update expectations from master branch --- .rubocop_todo.yml | 11 ----------- spec/convention_spec.rb | 2 -- 2 files changed, 13 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index c55a29039..89f703d23 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -280,7 +280,6 @@ Layout/TrailingWhitespace: Exclude: - 'lib/solargraph/language_server/message/client/register_capability.rb' - 'spec/api_map/config_spec.rb' - - 'spec/convention_spec.rb' # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: AllowedMethods, AllowedPatterns. @@ -338,11 +337,6 @@ Lint/DuplicateBranch: Lint/DuplicateMethods: Enabled: false -# Configuration parameters: AllowComments, AllowEmptyLambdas. -Lint/EmptyBlock: - Exclude: - - 'spec/convention_spec.rb' - # Configuration parameters: AllowComments. Lint/EmptyClass: Enabled: false @@ -618,11 +612,6 @@ RSpec/DescribeClass: RSpec/DescribedClass: Enabled: false -# This cop supports unsafe autocorrection (--autocorrect-all). -RSpec/EmptyExampleGroup: - Exclude: - - 'spec/convention_spec.rb' - # This cop supports safe autocorrection (--autocorrect). RSpec/EmptyLineAfterFinalLet: Exclude: diff --git a/spec/convention_spec.rb b/spec/convention_spec.rb index 98a8f41bf..b6f4fc52e 100644 --- a/spec/convention_spec.rb +++ b/spec/convention_spec.rb @@ -1,5 +1,4 @@ describe Solargraph::Convention do - # rubocop:disable RSpec/ExampleLength, RSpec/MultipleExpectations it 'newly defined pins are resolved by ApiMap after file changes' do filename = 'test.rb' @@ -106,5 +105,4 @@ def local _source_map described_class.unregister updated_dummy_convention end - # rubocop:enable RSpec/ExampleLength, RSpec/MultipleExpectations end From 50c8e0ac385429de28b5e27b42df295d540386df Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Mon, 8 Sep 2025 13:56:45 -0400 Subject: [PATCH 343/400] Drop clutter from diff --- spec/api_map_spec.rb | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/spec/api_map_spec.rb b/spec/api_map_spec.rb index a8f83aad9..62fde4c59 100755 --- a/spec/api_map_spec.rb +++ b/spec/api_map_spec.rb @@ -1,11 +1,8 @@ -# frozen_string_literal: true - require 'tmpdir' describe Solargraph::ApiMap do - # avoid performance hit of doing this many times before :all do - @api_map = described_class.load_with_cache(Dir.pwd, nil) + @api_map = Solargraph::ApiMap.load_with_cache(Dir.pwd, nil) end it 'returns core methods', time_limit_seconds: 120 do @@ -196,7 +193,7 @@ def prot end it 'adds Object instance methods to duck types' do - api_map = described_class.new + api_map = Solargraph::ApiMap.new type = Solargraph::ComplexType.parse('#foo') pins = api_map.get_complex_type_methods(type) expect(pins.any? { |p| p.namespace == 'BasicObject' }).to be(true) @@ -437,14 +434,14 @@ class Sup xit 'understands tuples inherit from regular arrays' do method_pins = @api_map.get_method_stack("Array(1, 2, 'a')", 'include?') method_pin = method_pins.first - expect(method_pin).not_to be_nil + expect(method_pin).to_not be_nil expect(method_pin.path).to eq('Array#include?') parameter_type = method_pin.signatures.first.parameters.first.return_type expect(parameter_type.rooted_tags).to eq("1, 2, 'a'") end it 'loads workspaces from directories' do - api_map = described_class.load('spec/fixtures/workspace') + api_map = Solargraph::ApiMap.load('spec/fixtures/workspace') expect(api_map.source_map(File.absolute_path('spec/fixtures/workspace/app.rb'))).to be_a(Solargraph::SourceMap) end @@ -534,7 +531,7 @@ module Includer expect(fqns).to eq('Foo::Bar') end - it 'understands type parameters' do + it 'handles multiple type parameters without losing cache coherence' do tag = @api_map.qualify('Array') expect(tag).to eq('Array') tag = @api_map.qualify('Array') @@ -758,17 +755,17 @@ def bar; end end it 'can qualify "Boolean"' do - api_map = described_class.new + api_map = Solargraph::ApiMap.new expect(api_map.qualify('Boolean')).to eq('Boolean') end it 'knows that true is a "subtype" of Boolean' do - api_map = described_class.new + api_map = Solargraph::ApiMap.new expect(api_map.super_and_sub?('Boolean', 'true')).to be(true) end it 'knows that false is a "subtype" of Boolean' do - api_map = described_class.new + api_map = Solargraph::ApiMap.new expect(api_map.super_and_sub?('Boolean', 'false')).to be(true) end @@ -784,7 +781,7 @@ class Foo alias baz foo end )).pins - # api_map = described_class.new(pins: yard_pins + source_pins) + # api_map = Solargraph::ApiMap.new(pins: yard_pins + source_pins) @api_map.index yard_pins + source_pins baz = @api_map.get_method_stack('Foo', 'baz').first expect(baz).to be_a(Solargraph::Pin::Method) @@ -796,7 +793,7 @@ class Foo mixin = Solargraph::Pin::Reference::Include.new( name: 'defined?(DidYouMean::SpellChecker) && defined?(DidYouMean::Correctable)', closure: closure ) - api_map = described_class.new(pins: [closure, mixin]) + api_map = Solargraph::ApiMap.new(pins: [closure, mixin]) expect(api_map.get_method_stack('Foo', 'foo')).to be_empty end @@ -817,7 +814,7 @@ def baz end ), 'test.rb') - api_map = described_class.new.map(source) + api_map = Solargraph::ApiMap.new.map(source) clip = api_map.clip_at('test.rb', [11, 10]) expect(clip.infer.to_s).to eq('Symbol') @@ -844,7 +841,7 @@ def c end ), 'test.rb') - api_map = described_class.new.map(source) + api_map = Solargraph::ApiMap.new.map(source) clip = api_map.clip_at('test.rb', [16, 8]) expect(clip.infer.to_s).to eq('Integer') end @@ -872,7 +869,7 @@ def c end ), 'test.rb') - api_map = described_class.new.map(source) + api_map = Solargraph::ApiMap.new.map(source) clip = api_map.clip_at('test.rb', [18, 4]) expect(clip.infer.to_s).to eq('Integer') From 2b02f98fe245979e383c5629aa480d77b3453795 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Mon, 8 Sep 2025 13:58:41 -0400 Subject: [PATCH 344/400] Fix bug --- lib/solargraph/shell.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/solargraph/shell.rb b/lib/solargraph/shell.rb index 54c3a8cc1..a7f37b8c0 100755 --- a/lib/solargraph/shell.rb +++ b/lib/solargraph/shell.rb @@ -246,7 +246,7 @@ def scan # @type [Solargraph::ApiMap, nil] api_map = nil time = Benchmark.measure { - api_map = Solargraph::ApiMap.load_with_cache(directory, out: $stdout) + api_map = Solargraph::ApiMap.load_with_cache(directory, out) api_map.pins.each do |pin| begin puts pin_description(pin) if options[:verbose] From 925b259b7dcaa99a8856431498b2e4002b1f4fad Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Mon, 8 Sep 2025 14:04:25 -0400 Subject: [PATCH 345/400] Reduce small diffs --- spec/api_map_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/api_map_spec.rb b/spec/api_map_spec.rb index 62fde4c59..90eac5cd9 100755 --- a/spec/api_map_spec.rb +++ b/spec/api_map_spec.rb @@ -841,7 +841,7 @@ def c end ), 'test.rb') - api_map = Solargraph::ApiMap.new.map(source) + api_map = described_class.new.map(source) clip = api_map.clip_at('test.rb', [16, 8]) expect(clip.infer.to_s).to eq('Integer') end @@ -869,7 +869,7 @@ def c end ), 'test.rb') - api_map = Solargraph::ApiMap.new.map(source) + api_map = described_class.new.map(source) clip = api_map.clip_at('test.rb', [18, 4]) expect(clip.infer.to_s).to eq('Integer') From 451998f1fe1eeb38593058ef0519f49fefe56d31 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Mon, 8 Sep 2025 14:05:35 -0400 Subject: [PATCH 346/400] Fix merge mistake --- spec/shell_spec.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/spec/shell_spec.rb b/spec/shell_spec.rb index 65e429d4b..bf53f174d 100644 --- a/spec/shell_spec.rb +++ b/spec/shell_spec.rb @@ -18,9 +18,11 @@ def bundle_exec(*cmd) # run the command in the temporary directory with bundle exec - output, status = Open3.capture2e("bundle exec #{cmd.join(' ')}", chdir: temp_dir) - expect(status.success?).to be(true), "Command failed: #{output}" - output + Bundler.with_unbundled_env do + output, status = Open3.capture2e("bundle exec #{cmd.join(' ')}", chdir: temp_dir) + expect(status.success?).to be(true), "Command failed: #{output}" + output + end end after do From 60404b2423ac0b51d3eb25780d79e71b178ecb6a Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Mon, 8 Sep 2025 14:07:48 -0400 Subject: [PATCH 347/400] Drop small diff --- lib/solargraph/library.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/solargraph/library.rb b/lib/solargraph/library.rb index 82701ced5..159c8dbd9 100644 --- a/lib/solargraph/library.rb +++ b/lib/solargraph/library.rb @@ -512,7 +512,7 @@ def source_map_external_require_hash # @param source_map [SourceMap] # @return [void] def find_external_requires source_map - # @type [Set] + # @type [Enumerable] new_set = source_map.requires.map(&:name).to_set # return if new_set == source_map_external_require_hash[source_map.filename] _filenames = nil From deefea7e52142c0f104cd428807efe112e2b04d1 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Mon, 8 Sep 2025 14:08:45 -0400 Subject: [PATCH 348/400] Drop small diff --- spec/language_server/message/text_document/rename_spec.rb | 3 --- 1 file changed, 3 deletions(-) diff --git a/spec/language_server/message/text_document/rename_spec.rb b/spec/language_server/message/text_document/rename_spec.rb index d43793716..32fb6d011 100644 --- a/spec/language_server/message/text_document/rename_spec.rb +++ b/spec/language_server/message/text_document/rename_spec.rb @@ -55,9 +55,6 @@ def foo(bar) } }) rename.process - expect(rename.result).not_to be_nil - expect(rename.result[:changes]).not_to be_nil - expect(rename.result[:changes]['file:///file.rb']).not_to be_nil expect(rename.result[:changes]['file:///file.rb'].length).to eq(3) end From 462d836e4135330cadafa6f24a994c4b1f33b578 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Mon, 8 Sep 2025 15:09:50 -0400 Subject: [PATCH 349/400] Revert unrelated small changes --- spec/type_checker/levels/strict_spec.rb | 4 ++-- spec/type_checker/levels/strong_spec.rb | 2 +- spec/type_checker/levels/typed_spec.rb | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/spec/type_checker/levels/strict_spec.rb b/spec/type_checker/levels/strict_spec.rb index f9a062714..7e57cb7cf 100644 --- a/spec/type_checker/levels/strict_spec.rb +++ b/spec/type_checker/levels/strict_spec.rb @@ -1,5 +1,5 @@ describe Solargraph::TypeChecker do - context 'when checking at strict level' do + context 'strict level' do # @return [Solargraph::TypeChecker] def type_checker(code) Solargraph::TypeChecker.load_string(code, 'test.rb', :strict) @@ -61,7 +61,7 @@ def bar(a); end require 'kramdown-parser-gfm' Kramdown::Parser::GFM.undefined_call ), 'test.rb') - api_map = Solargraph::ApiMap.load_with_cache('.', nil) + api_map = Solargraph::ApiMap.load_with_cache('.', $stdout) api_map.catalog Solargraph::Bench.new(source_maps: [source_map], external_requires: ['kramdown-parser-gfm']) checker = Solargraph::TypeChecker.new('test.rb', api_map: api_map, level: :strict) expect(checker.problems).to be_empty diff --git a/spec/type_checker/levels/strong_spec.rb b/spec/type_checker/levels/strong_spec.rb index 572769d2c..a03e6eb5d 100644 --- a/spec/type_checker/levels/strong_spec.rb +++ b/spec/type_checker/levels/strong_spec.rb @@ -1,5 +1,5 @@ describe Solargraph::TypeChecker do - context 'when tracking at strong level' do + context 'strong level' do def type_checker(code) Solargraph::TypeChecker.load_string(code, 'test.rb', :strong) end diff --git a/spec/type_checker/levels/typed_spec.rb b/spec/type_checker/levels/typed_spec.rb index 3f84867da..b10bbd42c 100644 --- a/spec/type_checker/levels/typed_spec.rb +++ b/spec/type_checker/levels/typed_spec.rb @@ -1,6 +1,6 @@ describe Solargraph::TypeChecker do - context 'when checking at typed level' do - def type_checker code + context 'typed level' do + def type_checker(code) Solargraph::TypeChecker.load_string(code, 'test.rb', :typed) end From 098424d2622c2b363e0b19e95abd885873c6d018 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Mon, 8 Sep 2025 15:18:04 -0400 Subject: [PATCH 350/400] Revert unrelated small changes --- spec/api_map_spec.rb | 2 +- spec/shell_spec.rb | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/spec/api_map_spec.rb b/spec/api_map_spec.rb index 90eac5cd9..9354be06c 100755 --- a/spec/api_map_spec.rb +++ b/spec/api_map_spec.rb @@ -2,7 +2,7 @@ describe Solargraph::ApiMap do before :all do - @api_map = Solargraph::ApiMap.load_with_cache(Dir.pwd, nil) + @api_map = Solargraph::ApiMap.new end it 'returns core methods', time_limit_seconds: 120 do diff --git a/spec/shell_spec.rb b/spec/shell_spec.rb index bf53f174d..b0675034d 100644 --- a/spec/shell_spec.rb +++ b/spec/shell_spec.rb @@ -16,6 +16,8 @@ raise "Failure installing bundle: #{output}" unless status.success? end + # @type cmd [Array] + # @return [String] def bundle_exec(*cmd) # run the command in the temporary directory with bundle exec Bundler.with_unbundled_env do From f08f8ff580a396b18708360b9e81086d8c7a1cb7 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Tue, 9 Sep 2025 11:22:12 -0400 Subject: [PATCH 351/400] Fix combined gem cache implementation --- lib/solargraph/pin_cache.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/solargraph/pin_cache.rb b/lib/solargraph/pin_cache.rb index 8c47cfef4..d48873c53 100644 --- a/lib/solargraph/pin_cache.rb +++ b/lib/solargraph/pin_cache.rb @@ -119,7 +119,8 @@ def uncache_gem gemspec, out: nil PinCache.uncache(yard_gem_path(gemspec), out: out) uncache_by_prefix(rbs_collection_pins_path_prefix(gemspec), out: out) uncache_by_prefix(combined_path_prefix(gemspec), out: out) - combined_pins_in_memory.delete([gemspec.name, gemspec.version]) + rbs_version_cache_key = lookup_rbs_version_cache_key(gemspec) + combined_pins_in_memory.delete([gemspec.name, gemspec.version, rbs_version_cache_key]) end # @param gemspec [Gem::Specification, Bundler::LazySpecification] @@ -380,7 +381,11 @@ def combined_gem? gemspec, hash # @param hash [String, nil] # @return [Array, nil] def load_combined_gem gemspec, hash - PinCache.load(combined_path(gemspec, hash)) + cached = combined_pins_in_memory[[gemspec.name, gemspec.version, hash]] + return cached if cached + loaded = PinCache.load(combined_path(gemspec, hash)) + combined_pins_in_memory[[gemspec.name, gemspec.version, hash]] = loaded if loaded + loaded end # @param gemspec [Gem::Specification] From 802bcccf47ab9c1f583c1869b248cb9c60e80c93 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Tue, 9 Sep 2025 11:37:37 -0400 Subject: [PATCH 352/400] Fix quoting in shell_spec.rb --- spec/shell_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/shell_spec.rb b/spec/shell_spec.rb index b0675034d..e105f5799 100644 --- a/spec/shell_spec.rb +++ b/spec/shell_spec.rb @@ -10,7 +10,7 @@ before do File.open(File.join(temp_dir, 'Gemfile'), 'w') do |file| file.puts "source 'https://rubygems.org'" - file.puts "gem 'solargraph', path: #{File.expand_path('..', __dir__)}" + file.puts "gem 'solargraph', path: '#{File.expand_path('..', __dir__)}'" end output, status = Open3.capture2e("bundle install", chdir: temp_dir) raise "Failure installing bundle: #{output}" unless status.success? From db71d611485c0b14435cdfbc64fdd625fb294a68 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Tue, 9 Sep 2025 11:41:27 -0400 Subject: [PATCH 353/400] Fix solargraph scan issue --- lib/solargraph/shell.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/solargraph/shell.rb b/lib/solargraph/shell.rb index a7f37b8c0..99a14aa06 100755 --- a/lib/solargraph/shell.rb +++ b/lib/solargraph/shell.rb @@ -246,7 +246,7 @@ def scan # @type [Solargraph::ApiMap, nil] api_map = nil time = Benchmark.measure { - api_map = Solargraph::ApiMap.load_with_cache(directory, out) + api_map = Solargraph::ApiMap.load_with_cache(directory, $stderr) api_map.pins.each do |pin| begin puts pin_description(pin) if options[:verbose] From bf7335df4bb996ba375ee0974911a4b6aebc51cd Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Tue, 9 Sep 2025 11:45:24 -0400 Subject: [PATCH 354/400] rubocop todo fixes --- .rubocop_todo.yml | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 645d532ee..a9e1ef33a 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -342,6 +342,7 @@ Lint/EmptyClass: # Configuration parameters: AllowComments. Lint/EmptyFile: Exclude: + - 'lib/solargraph/foo.rb' - 'spec/fixtures/vendored/vendor/do_not_use.gemspec' # This cop supports unsafe autocorrection (--autocorrect-all). @@ -582,12 +583,7 @@ RSpec/BeforeAfterAll: # Configuration parameters: Prefixes, AllowedPatterns. # Prefixes: when, with, without RSpec/ContextWording: - Exclude: - - 'spec/complex_type_spec.rb' - - 'spec/library_spec.rb' - - 'spec/pin/method_spec.rb' - - 'spec/pin/parameter_spec.rb' - - 'spec/pin/symbol_spec.rb' + Enabled: false # Configuration parameters: IgnoredMetadata. RSpec/DescribeClass: @@ -688,6 +684,7 @@ RSpec/NoExpectationExample: # SupportedStyles: not_to, to_not RSpec/NotToNot: Exclude: + - 'spec/api_map_spec.rb' - 'spec/rbs_map/core_map_spec.rb' RSpec/PendingWithoutReason: From dba134d22b970784a51afa3113e7c91808e63739 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Tue, 9 Sep 2025 12:19:29 -0400 Subject: [PATCH 355/400] Update time limits --- spec/workspace/gemspecs_fetch_dependencies_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/workspace/gemspecs_fetch_dependencies_spec.rb b/spec/workspace/gemspecs_fetch_dependencies_spec.rb index 9a21f967c..186217dae 100644 --- a/spec/workspace/gemspecs_fetch_dependencies_spec.rb +++ b/spec/workspace/gemspecs_fetch_dependencies_spec.rb @@ -67,7 +67,7 @@ context 'with gem that exists in our bundle' do let(:gem_name) { 'undercover' } - it 'finds dependencies' do + it 'finds dependencies', time_limit_seconds: 120 do expect(deps.map(&:name)).to include('ast') end end @@ -75,7 +75,7 @@ context 'with gem does not exist in our bundle' do let(:gem_name) { 'activerecord' } - it 'gives a useful message' do + it 'gives a useful message', time_limit_seconds: 120 do dep_names = nil output = capture_both { dep_names = deps.map(&:name) } expect(output).to include('Please install the gem activerecord') From f22f21a58bfdf8ac6d0d1bcec8c94101631fb0e3 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Tue, 9 Sep 2025 12:24:59 -0400 Subject: [PATCH 356/400] Handle Ruby 3.0 issue --- lib/solargraph/workspace/gemspecs.rb | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/lib/solargraph/workspace/gemspecs.rb b/lib/solargraph/workspace/gemspecs.rb index 29295a45a..d78c8b231 100644 --- a/lib/solargraph/workspace/gemspecs.rb +++ b/lib/solargraph/workspace/gemspecs.rb @@ -162,8 +162,19 @@ def to_gem_specification specish # print time including milliseconds self.class.gem_specification_cache[specish] ||= case specish when Gem::Specification + @@warned_on_rubygems ||= false + if specish.respond_to?(:identifier) + specish + else + # see https://github.com/castwide/solargraph/actions/runs/17588131738/job/49961580698?pr=1006 - happened on Ruby 3.0 + unless @@warned_on_rubygems + logger.warn "Incomplete Gem::Specification encountered - recommend upgrading rubygems" + @@warned_on_rubygems = true + end + nil + end # yay! - specish + when Bundler::LazySpecification # materializing didn't work. Let's look in the local # rubygems without bundler's help @@ -180,8 +191,7 @@ def to_gem_specification specish to_gem_specification(specish) end else - @@warned_on_gem_type ||= - false + @@warned_on_gem_type ||= false unless @@warned_on_gem_type logger.warn 'Unexpected type while resolving gem: ' \ "#{specish.class}" From 80c5fccc58e9eaf2d0a64f410686665d1168cd6a Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Tue, 9 Sep 2025 12:38:54 -0400 Subject: [PATCH 357/400] Drop unbundled environment --- spec/shell_spec.rb | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/spec/shell_spec.rb b/spec/shell_spec.rb index e105f5799..0c6e3f933 100644 --- a/spec/shell_spec.rb +++ b/spec/shell_spec.rb @@ -20,10 +20,9 @@ # @return [String] def bundle_exec(*cmd) # run the command in the temporary directory with bundle exec - Bundler.with_unbundled_env do - output, status = Open3.capture2e("bundle exec #{cmd.join(' ')}", chdir: temp_dir) - expect(status.success?).to be(true), "Command failed: #{output}" - output + output, status = Open3.capture2e("bundle exec #{cmd.join(' ')}", chdir: temp_dir) + expect(status.success?).to be(true), "Command failed: #{output}" + output end end From ca488e2c2aa3efeb8ec0ed8a16ef6abfb377d9d0 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Tue, 9 Sep 2025 12:40:30 -0400 Subject: [PATCH 358/400] Drop unbundled environment --- spec/shell_spec.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/spec/shell_spec.rb b/spec/shell_spec.rb index 0c6e3f933..f5eeb5734 100644 --- a/spec/shell_spec.rb +++ b/spec/shell_spec.rb @@ -23,7 +23,6 @@ def bundle_exec(*cmd) output, status = Open3.capture2e("bundle exec #{cmd.join(' ')}", chdir: temp_dir) expect(status.success?).to be(true), "Command failed: #{output}" output - end end after do From 10a15740ce3ac51dede443089d0d53be53db2073 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Tue, 9 Sep 2025 16:52:21 -0400 Subject: [PATCH 359/400] Revert marginal changes --- spec/language_server/protocol_spec.rb | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/spec/language_server/protocol_spec.rb b/spec/language_server/protocol_spec.rb index 5c64383c6..6f4e70a80 100644 --- a/spec/language_server/protocol_spec.rb +++ b/spec/language_server/protocol_spec.rb @@ -34,7 +34,7 @@ def stop end end -describe Protocol, order: :defined do +describe Protocol do before :all do @protocol = Protocol.new(Solargraph::LanguageServer::Host.new) end @@ -173,9 +173,6 @@ def bar baz item = response['result']['items'].select{|h| h['label'] == 'bar'}.first @protocol.request 'completionItem/resolve', item response = @protocol.response - expect(response).not_to be_nil - expect(response['error']).to be_nil - expect(response['result']).to be_a(Hash) expect(response['result']['documentation']['value']).to include('bar method') end From 5f7df18a7614e46e6538e90a002e8321e903f844 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Tue, 9 Sep 2025 17:00:00 -0400 Subject: [PATCH 360/400] Remove unrelated changes --- spec/spec_helper.rb | 3 --- 1 file changed, 3 deletions(-) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 5e3879a67..9648528e5 100755 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -5,10 +5,7 @@ unless ENV['SIMPLECOV_DISABLED'] # set up lcov reporting for undercover require 'simplecov' - require 'simplecov-lcov' require 'undercover/simplecov_formatter' - SimpleCov::Formatter::LcovFormatter.config.report_with_single_file = true - SimpleCov.formatter = SimpleCov::Formatter::LcovFormatter SimpleCov.start do cname = ENV.fetch('TEST_COVERAGE_COMMAND_NAME', 'ad-hoc') command_name cname From 14772df1f28e4ee150ba4f8b22d614cdcba2c723 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Wed, 10 Sep 2025 17:51:05 -0400 Subject: [PATCH 361/400] Revert not-actually-needed Location change --- lib/solargraph/location.rb | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/solargraph/location.rb b/lib/solargraph/location.rb index 749cfbc0d..713b4fef1 100644 --- a/lib/solargraph/location.rb +++ b/lib/solargraph/location.rb @@ -7,13 +7,13 @@ module Solargraph class Location include Equality - # @return [String, nil] + # @return [String] attr_reader :filename # @return [Solargraph::Range] attr_reader :range - # @param filename [String, nil] + # @param filename [String] # @param range [Solargraph::Range] def initialize filename, range @filename = filename @@ -31,8 +31,6 @@ def <=>(other) if filename == other.filename range <=> other.range else - return -1 if filename.nil? - return 1 if other.filename.nil? filename <=> other.filename end end From 03443a47df8b466cc50247deaf7f5adad288c182 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Wed, 10 Sep 2025 21:48:53 -0400 Subject: [PATCH 362/400] Revert spec change --- spec/source_map/clip_spec.rb | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/spec/source_map/clip_spec.rb b/spec/source_map/clip_spec.rb index a0bf1956a..49774fdc7 100644 --- a/spec/source_map/clip_spec.rb +++ b/spec/source_map/clip_spec.rb @@ -1644,12 +1644,10 @@ def foo; end api_map = Solargraph::ApiMap.new.map(source) array_names = api_map.clip_at('test.rb', [5, 22]).complete.pins.map(&:name) - # other methods may come in via plugin default requires - expect(array_names).to include("byteindex", "byterindex", "bytes", "bytesize", "byteslice", "bytesplice") + expect(array_names).to eq("byteindex", "byterindex", "bytes", "bytesize", "byteslice", "bytesplice") string_names = api_map.clip_at('test.rb', [6, 22]).complete.pins.map(&:name) - # other methods may come in via plugin default requires - expect(string_names).to include('upcase', 'upcase!', 'upto') + expect(string_names).to eq('upcase', 'upcase!', 'upto') end it 'completes global methods defined in top level scope inside class when referenced inside a namespace' do From 78d630d5a8442d14f437b4c2d5d54c83c4cbbafc Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Wed, 10 Sep 2025 21:50:03 -0400 Subject: [PATCH 363/400] Revert spec change --- spec/source_map/clip_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/source_map/clip_spec.rb b/spec/source_map/clip_spec.rb index 49774fdc7..0f83331ec 100644 --- a/spec/source_map/clip_spec.rb +++ b/spec/source_map/clip_spec.rb @@ -1644,10 +1644,10 @@ def foo; end api_map = Solargraph::ApiMap.new.map(source) array_names = api_map.clip_at('test.rb', [5, 22]).complete.pins.map(&:name) - expect(array_names).to eq("byteindex", "byterindex", "bytes", "bytesize", "byteslice", "bytesplice") + expect(array_names).to eq(["byteindex", "byterindex", "bytes", "bytesize", "byteslice", "bytesplice"]) string_names = api_map.clip_at('test.rb', [6, 22]).complete.pins.map(&:name) - expect(string_names).to eq('upcase', 'upcase!', 'upto') + expect(string_names).to eq(['upcase', 'upcase!', 'upto']) end it 'completes global methods defined in top level scope inside class when referenced inside a namespace' do From 5ac0a894d140df5d4344dffbd50b0559d400a2f1 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Thu, 11 Sep 2025 07:17:13 -0400 Subject: [PATCH 364/400] Reduce diff --- lib/solargraph/shell.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/solargraph/shell.rb b/lib/solargraph/shell.rb index 99a14aa06..535aaaf27 100755 --- a/lib/solargraph/shell.rb +++ b/lib/solargraph/shell.rb @@ -170,7 +170,8 @@ def gems *names # @return [void] def uncache *gems raise ArgumentError, 'No gems specified.' if gems.empty? - workspace = Workspace.new('.') + workspace = Solargraph::Workspace.new(Dir.pwd) + gems.each do |gem| if gem == 'core' PinCache.uncache_core(out: $stdout) @@ -246,7 +247,7 @@ def scan # @type [Solargraph::ApiMap, nil] api_map = nil time = Benchmark.measure { - api_map = Solargraph::ApiMap.load_with_cache(directory, $stderr) + api_map = Solargraph::ApiMap.load_with_cache(directory, $stdout) api_map.pins.each do |pin| begin puts pin_description(pin) if options[:verbose] From 65a69113a2e0bf100a9a6a7b25705a3144c30d38 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Thu, 11 Sep 2025 07:19:59 -0400 Subject: [PATCH 365/400] Reduce diff --- spec/workspace_spec.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/spec/workspace_spec.rb b/spec/workspace_spec.rb index 74d232a31..e7615c9c8 100644 --- a/spec/workspace_spec.rb +++ b/spec/workspace_spec.rb @@ -122,8 +122,7 @@ end it 'rescues errors loading files into sources' do - config = double(:Config, directory: './path', calculated: ['./path/does_not_exist.rb'], max_files: 5000, - require_paths: [], plugins: []) + config = double(:Config, directory: './path', calculated: ['./path/does_not_exist.rb'], max_files: 5000, require_paths: [], plugins: []) expect { Solargraph::Workspace.new('./path', config) }.not_to raise_error From a9716095708165fa4e938d60aa10431f2d927680 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Tue, 30 Sep 2025 16:31:00 -0400 Subject: [PATCH 366/400] Fix merge issues --- .rubocop_todo.yml | 11 ++--------- lib/solargraph/library.rb | 1 - lib/solargraph/workspace/gemspecs.rb | 1 - lib/solargraph/yardoc.rb | 1 - spec/workspace_spec.rb | 2 +- spec/yard_map/mapper_spec.rb | 5 +---- 6 files changed, 4 insertions(+), 17 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 9358d7aaa..f6ba62afb 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -34,7 +34,6 @@ Gemspec/OrderedDependencies: # Configuration parameters: Severity. Gemspec/RequireMFA: Exclude: - - 'solargraph.gemspec' - 'spec/fixtures/rdoc-lib/rdoc-lib.gemspec' - 'spec/fixtures/rubocop-custom-version/specifications/rubocop-0.0.0.gemspec' @@ -81,6 +80,7 @@ Layout/ElseAlignment: # Configuration parameters: EmptyLineBetweenMethodDefs, EmptyLineBetweenClassDefs, EmptyLineBetweenModuleDefs, DefLikeMacros, AllowAdjacentOneLineDefs, NumberOfEmptyLines. Layout/EmptyLineBetweenDefs: Exclude: + - 'lib/solargraph/doc_map.rb' - 'lib/solargraph/language_server/message/initialize.rb' - 'lib/solargraph/pin/delegated_method.rb' @@ -334,7 +334,6 @@ Lint/EmptyClass: # Configuration parameters: AllowComments. Lint/EmptyFile: Exclude: - - 'lib/solargraph/foo.rb' - 'spec/fixtures/vendored/vendor/do_not_use.gemspec' # This cop supports unsafe autocorrection (--autocorrect-all). @@ -1104,6 +1103,7 @@ Style/RedundantRegexpEscape: Style/RedundantReturn: Exclude: - 'lib/solargraph/complex_type/type_methods.rb' + - 'lib/solargraph/doc_map.rb' - 'lib/solargraph/parser/parser_gem/node_methods.rb' - 'lib/solargraph/source/chain/z_super.rb' @@ -1131,14 +1131,11 @@ Style/RescueStandardError: # AllowedMethods: present?, blank?, presence, try, try! Style/SafeNavigation: Enabled: false -<<<<<<< HEAD -======= # Configuration parameters: Max. Style/SafeNavigationChainLength: Exclude: - 'lib/solargraph/doc_map.rb' ->>>>>>> origin/master # This cop supports unsafe autocorrection (--autocorrect-all). Style/SlicingWithRange: @@ -1239,15 +1236,11 @@ Style/YAMLFileRead: # This cop supports unsafe autocorrection (--autocorrect-all). Style/ZeroLengthPredicate: -<<<<<<< HEAD - Enabled: false -======= Exclude: - 'lib/solargraph/language_server/host.rb' - 'lib/solargraph/pin/method.rb' - 'lib/solargraph/source/chain/array.rb' - 'spec/language_server/protocol_spec.rb' ->>>>>>> origin/master # This cop supports safe autocorrection (--autocorrect). # Configuration parameters: EnforcedStyle. diff --git a/lib/solargraph/library.rb b/lib/solargraph/library.rb index 8e39ebabd..e788dfaa4 100644 --- a/lib/solargraph/library.rb +++ b/lib/solargraph/library.rb @@ -603,7 +603,6 @@ def cache_next_gemspec report_cache_progress spec.name, pending kwargs = {} kwargs[:chdir] = workspace.directory.to_s if workspace.directory && !workspace.directory.empty? - # @sg-ignore https://github.com/castwide/solargraph/pull/1005 _o, e, s = Open3.capture3(workspace.command_path, 'cache', spec.name, spec.version.to_s, **kwargs) if s.success? diff --git a/lib/solargraph/workspace/gemspecs.rb b/lib/solargraph/workspace/gemspecs.rb index d78c8b231..bed157d2e 100644 --- a/lib/solargraph/workspace/gemspecs.rb +++ b/lib/solargraph/workspace/gemspecs.rb @@ -210,7 +210,6 @@ def query_external_bundle command 'ruby', '-e', "require 'bundler'; require 'json'; Dir.chdir('#{directory}') { puts begin; #{command}; end.to_json }" ] - # @sg-ignore https://github.com/castwide/solargraph/pull/1005 o, e, s = Open3.capture3(*cmd) if s.success? Solargraph.logger.debug "External bundle: #{o}" diff --git a/lib/solargraph/yardoc.rb b/lib/solargraph/yardoc.rb index ffe7da4c3..50f212f13 100644 --- a/lib/solargraph/yardoc.rb +++ b/lib/solargraph/yardoc.rb @@ -28,7 +28,6 @@ def build_docs gem_yardoc_path, yard_plugins, gemspec return end - # @sg-ignore stdout_and_stderr_str, status = Open3.capture2e(current_bundle_env_tweaks, cmd, chdir: gemspec.gem_dir) return if status.success? Solargraph.logger.warn { "YARD failed running #{cmd.inspect} in #{gemspec.gem_dir}" } diff --git a/spec/workspace_spec.rb b/spec/workspace_spec.rb index d32e64ea0..e5a782848 100644 --- a/spec/workspace_spec.rb +++ b/spec/workspace_spec.rb @@ -124,7 +124,7 @@ it 'ignores gemspecs in excluded directories' do # vendor/**/* is excluded by default workspace = Solargraph::Workspace.new('spec/fixtures/vendored') - expect(workspace.require_paths).to eq(['spec/fixtures/vendored/lib']) + expect(workspace.require_paths).to eq([File.absolute_path('spec/fixtures/vendored/lib')]) end it 'rescues errors loading files into sources' do diff --git a/spec/yard_map/mapper_spec.rb b/spec/yard_map/mapper_spec.rb index 64c12fc82..022d37913 100644 --- a/spec/yard_map/mapper_spec.rb +++ b/spec/yard_map/mapper_spec.rb @@ -66,10 +66,7 @@ def pins_with require it 'adds corect gates' do # Asssuming the ast gem exists because it's a known dependency - gemspec = Gem::Specification.find_by_name('ast') - Solargraph::Yardoc.cache([], gemspec) - pins = Solargraph::YardMap::Mapper.new(Solargraph::Yardoc.load!(gemspec)).map - pin = pins.find do |pin| + pin = pins_with('ast').find do |pin| pin.is_a?(Solargraph::Pin::Namespace) && pin.name == 'Mixin' && pin.closure.path == 'AST::Processor' end expect(pin.gates).to eq(['AST::Processor::Mixin', 'AST::Processor', 'AST', '']) From 988f9f68a82bc2a4af94b71d92599a02b95655b2 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Tue, 30 Sep 2025 16:44:32 -0400 Subject: [PATCH 367/400] Test fixups now that we get more gems installed for types --- spec/source_map/clip_spec.rb | 2 +- spec/yard_map/mapper_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/source_map/clip_spec.rb b/spec/source_map/clip_spec.rb index ee7e4bcfa..c524e23f6 100644 --- a/spec/source_map/clip_spec.rb +++ b/spec/source_map/clip_spec.rb @@ -1648,7 +1648,7 @@ def foo; end expect(array_names).to eq(["byteindex", "byterindex", "bytes", "bytesize", "byteslice", "bytesplice"]) string_names = api_map.clip_at('test.rb', [6, 22]).complete.pins.map(&:name) - expect(string_names).to eq(['upcase', 'upcase!', 'upto']) + expect(string_names).to include('upcase', 'upcase!', 'upto') end it 'completes global methods defined in top level scope inside class when referenced inside a namespace' do diff --git a/spec/yard_map/mapper_spec.rb b/spec/yard_map/mapper_spec.rb index 022d37913..3dbf8ecc3 100644 --- a/spec/yard_map/mapper_spec.rb +++ b/spec/yard_map/mapper_spec.rb @@ -64,7 +64,7 @@ def pins_with require expect(inc).to be_a(Solargraph::Pin::Reference::Include) end - it 'adds corect gates' do + it 'adds correct gates' do # Asssuming the ast gem exists because it's a known dependency pin = pins_with('ast').find do |pin| pin.is_a?(Solargraph::Pin::Namespace) && pin.name == 'Mixin' && pin.closure.path == 'AST::Processor' From 17578dbfb21b62982223ea065113aae2ee535684 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Tue, 7 Oct 2025 19:09:17 -0400 Subject: [PATCH 368/400] Adjust TODO --- lib/solargraph/workspace.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/solargraph/workspace.rb b/lib/solargraph/workspace.rb index 553dab986..aa885e2f5 100644 --- a/lib/solargraph/workspace.rb +++ b/lib/solargraph/workspace.rb @@ -23,7 +23,8 @@ class Workspace attr_reader :gemnames alias source_gems gemnames - # @param directory [String] TODO: Document and test '' and '*' semantics + # @todo Remove '' and '*' special cases + # @param directory [String] # @param config [Config, nil] # @param server [Hash] def initialize directory = '', config = nil, server = {} From 95ed300a4fceceaf4b0b95baef7701a1e0bc30aa Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Tue, 13 Jan 2026 05:08:14 -0500 Subject: [PATCH 369/400] Avoid rbs pollution (#1146) We were using the sig/shims directory for some internally helpful shims; unfortunately that exported them during gem installs, causing https://github.com/castwide/solargraph/issues/1144 --- {sig => rbs}/shims/ast/0/node.rbs | 0 {sig => rbs}/shims/ast/2.4/.rbs_meta.yaml | 0 {sig => rbs}/shims/ast/2.4/ast.rbs | 0 {sig => rbs}/shims/parser/3.2.0.1/builders/default.rbs | 0 {sig => rbs}/shims/parser/3.2.0.1/manifest.yaml | 0 {sig => rbs}/shims/parser/3.2.0.1/parser.rbs | 0 {sig => rbs}/shims/parser/3.2.0.1/polyfill.rbs | 0 {sig => rbs}/shims/thor/1.2.0.1/.rbs_meta.yaml | 0 {sig => rbs}/shims/thor/1.2.0.1/manifest.yaml | 0 {sig => rbs}/shims/thor/1.2.0.1/thor.rbs | 0 rbs_collection.yaml | 2 +- 11 files changed, 1 insertion(+), 1 deletion(-) rename {sig => rbs}/shims/ast/0/node.rbs (100%) rename {sig => rbs}/shims/ast/2.4/.rbs_meta.yaml (100%) rename {sig => rbs}/shims/ast/2.4/ast.rbs (100%) rename {sig => rbs}/shims/parser/3.2.0.1/builders/default.rbs (100%) rename {sig => rbs}/shims/parser/3.2.0.1/manifest.yaml (100%) rename {sig => rbs}/shims/parser/3.2.0.1/parser.rbs (100%) rename {sig => rbs}/shims/parser/3.2.0.1/polyfill.rbs (100%) rename {sig => rbs}/shims/thor/1.2.0.1/.rbs_meta.yaml (100%) rename {sig => rbs}/shims/thor/1.2.0.1/manifest.yaml (100%) rename {sig => rbs}/shims/thor/1.2.0.1/thor.rbs (100%) diff --git a/sig/shims/ast/0/node.rbs b/rbs/shims/ast/0/node.rbs similarity index 100% rename from sig/shims/ast/0/node.rbs rename to rbs/shims/ast/0/node.rbs diff --git a/sig/shims/ast/2.4/.rbs_meta.yaml b/rbs/shims/ast/2.4/.rbs_meta.yaml similarity index 100% rename from sig/shims/ast/2.4/.rbs_meta.yaml rename to rbs/shims/ast/2.4/.rbs_meta.yaml diff --git a/sig/shims/ast/2.4/ast.rbs b/rbs/shims/ast/2.4/ast.rbs similarity index 100% rename from sig/shims/ast/2.4/ast.rbs rename to rbs/shims/ast/2.4/ast.rbs diff --git a/sig/shims/parser/3.2.0.1/builders/default.rbs b/rbs/shims/parser/3.2.0.1/builders/default.rbs similarity index 100% rename from sig/shims/parser/3.2.0.1/builders/default.rbs rename to rbs/shims/parser/3.2.0.1/builders/default.rbs diff --git a/sig/shims/parser/3.2.0.1/manifest.yaml b/rbs/shims/parser/3.2.0.1/manifest.yaml similarity index 100% rename from sig/shims/parser/3.2.0.1/manifest.yaml rename to rbs/shims/parser/3.2.0.1/manifest.yaml diff --git a/sig/shims/parser/3.2.0.1/parser.rbs b/rbs/shims/parser/3.2.0.1/parser.rbs similarity index 100% rename from sig/shims/parser/3.2.0.1/parser.rbs rename to rbs/shims/parser/3.2.0.1/parser.rbs diff --git a/sig/shims/parser/3.2.0.1/polyfill.rbs b/rbs/shims/parser/3.2.0.1/polyfill.rbs similarity index 100% rename from sig/shims/parser/3.2.0.1/polyfill.rbs rename to rbs/shims/parser/3.2.0.1/polyfill.rbs diff --git a/sig/shims/thor/1.2.0.1/.rbs_meta.yaml b/rbs/shims/thor/1.2.0.1/.rbs_meta.yaml similarity index 100% rename from sig/shims/thor/1.2.0.1/.rbs_meta.yaml rename to rbs/shims/thor/1.2.0.1/.rbs_meta.yaml diff --git a/sig/shims/thor/1.2.0.1/manifest.yaml b/rbs/shims/thor/1.2.0.1/manifest.yaml similarity index 100% rename from sig/shims/thor/1.2.0.1/manifest.yaml rename to rbs/shims/thor/1.2.0.1/manifest.yaml diff --git a/sig/shims/thor/1.2.0.1/thor.rbs b/rbs/shims/thor/1.2.0.1/thor.rbs similarity index 100% rename from sig/shims/thor/1.2.0.1/thor.rbs rename to rbs/shims/thor/1.2.0.1/thor.rbs diff --git a/rbs_collection.yaml b/rbs_collection.yaml index 898239cac..d94e1c896 100644 --- a/rbs_collection.yaml +++ b/rbs_collection.yaml @@ -2,7 +2,7 @@ sources: - type: local name: shims - path: sig/shims + path: rbs/shims - type: git name: ruby/gem_rbs_collection From ce12a5f63cba2e72b04453c756751a3fafb2d0a0 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Tue, 13 Jan 2026 05:11:44 -0500 Subject: [PATCH 370/400] Fix 'solargraph pin --references ClassName' private method call (#1150) --- lib/solargraph/api_map.rb | 12 ++++++------ spec/shell_spec.rb | 32 +++++++++++++++++++++++++++++++- 2 files changed, 37 insertions(+), 7 deletions(-) diff --git a/lib/solargraph/api_map.rb b/lib/solargraph/api_map.rb index cc3031ea5..6c0da316e 100755 --- a/lib/solargraph/api_map.rb +++ b/lib/solargraph/api_map.rb @@ -711,6 +711,12 @@ def inner_get_methods_from_reference(fq_reference_tag, namespace_pin, type, scop methods end + # @param fq_sub_tag [String] + # @return [String, nil] + def qualify_superclass fq_sub_tag + store.qualify_superclass fq_sub_tag + end + private # A hash of source maps with filename keys. @@ -804,12 +810,6 @@ def path_macros @path_macros ||= {} end - # @param fq_sub_tag [String] - # @return [String, nil] - def qualify_superclass fq_sub_tag - store.qualify_superclass fq_sub_tag - end - # Get the namespace's type (Class or Module). # # @param fqns [String] A fully qualified namespace diff --git a/spec/shell_spec.rb b/spec/shell_spec.rb index b9dc6b327..3b8dc0426 100644 --- a/spec/shell_spec.rb +++ b/spec/shell_spec.rb @@ -57,7 +57,37 @@ def bundle_exec(*cmd) end end - describe 'pin' do + describe 'pin on a class' do + let(:api_map) { instance_double(Solargraph::ApiMap) } + let(:string_pin) { instance_double(Solargraph::Pin::Namespace, name: 'String') } + + before do + allow(Solargraph::ApiMap).to receive(:load_with_cache).and_return(api_map) + allow(Solargraph::Pin::Namespace).to receive(:===).with(string_pin).and_return(true) + allow(string_pin).to receive(:return_type).and_return(Solargraph::ComplexType.parse('String')) + allow(api_map).to receive(:get_path_pins).with('String').and_return([string_pin]) + end + + context 'with --references option' do + let(:object_pin) { instance_double(Solargraph::Pin::Namespace, name: 'Object') } + + before do + allow(Solargraph::Pin::Namespace).to receive(:===).with(object_pin).and_return(true) + allow(api_map).to receive(:qualify_superclass).with('String').and_return('Object') + allow(api_map).to receive(:get_path_pins).with('Object').and_return([object_pin]) + end + + it 'prints a pin with info' do + out = capture_both do + shell.options = { references: true } + shell.pin('String') + end + expect(out).to include('# Superclass:') + end + end + end + + describe 'pin on a method' do let(:api_map) { instance_double(Solargraph::ApiMap) } let(:to_s_pin) { instance_double(Solargraph::Pin::Method, return_type: Solargraph::ComplexType.parse('String')) } From 5ae55584e399822af0a12b386229acffdd9bd7bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lek=C3=AB=20Mula?= Date: Wed, 14 Jan 2026 01:47:12 +0100 Subject: [PATCH 371/400] Improve memory efficiency of Position class (#1054) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Use each_line instead of text.lines Avoid allocating additional strings, instead use sliced substrings * gitignore vendor/cache * Remove redundant end_with? Co-authored-by: Jean Boussier * Remove benchamrks https://github.com/castwide/solargraph/pull/1054#discussion_r2312388042 * String#index(offset:) FTW 🚀 https://github.com/castwide/solargraph/pull/1054#issuecomment-3240029936 Co-authored-by: Jean Boussier * fix rubocop --------- Co-authored-by: Jean Boussier --- .gitignore | 1 + lib/solargraph/position.rb | 32 +++++++++++++++++++++----------- spec/position_spec.rb | 16 ++++++++++++++++ 3 files changed, 38 insertions(+), 11 deletions(-) diff --git a/.gitignore b/.gitignore index 2819165b1..75510d96b 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ coverage /Makefile /.pryrc /.rspec-local +vendor/cache diff --git a/lib/solargraph/position.rb b/lib/solargraph/position.rb index 74606f142..e47ed8bc8 100644 --- a/lib/solargraph/position.rb +++ b/lib/solargraph/position.rb @@ -58,8 +58,22 @@ def inspect # @return [Integer] def self.to_offset text, position return 0 if text.empty? - # @sg-ignore Unresolved call to + on Integer - text.lines[0...position.line].sum(&:length) + position.character + newline_index = -1 + cursor = 0 + line = -1 + + last_line_index = 0 + while (newline_index = text.index("\n", newline_index + 1)) && line <= position.line + line += 1 + break if line == position.line + line_length = newline_index - last_line_index + + cursor += line_length.zero? ? 1 : line_length + + last_line_index = newline_index + end + + cursor + position.character end # Get a numeric offset for the specified text and a position identified @@ -81,16 +95,12 @@ def self.line_char_to_offset text, line, character def self.from_offset text, offset cursor = 0 line = 0 - character = nil - text.lines.each do |l| - line_length = l.length - char_length = l.chomp.length - if cursor + char_length >= offset - character = offset - cursor - break - end - cursor += line_length + character = offset + newline_index = -1 + + while (newline_index = text.index("\n", newline_index + 1)) && newline_index < offset line += 1 + character = offset - newline_index - 1 end character = 0 if character.nil? and (cursor - offset).between?(0, 1) raise InvalidOffsetError if character.nil? diff --git a/spec/position_spec.rb b/spec/position_spec.rb index fa30cf7d9..88dedcd26 100644 --- a/spec/position_spec.rb +++ b/spec/position_spec.rb @@ -12,6 +12,22 @@ expect(orig).to be(norm) end + it 'finds offset from position' do + text = "\n class Foo\n def bar baz, boo = 'boo'\n end\n end\n " + expect(Solargraph::Position.to_offset(text, Solargraph::Position.new(0, 0))).to eq(0) + expect(Solargraph::Position.to_offset(text, Solargraph::Position.new(0, 4))).to eq(4) + expect(Solargraph::Position.to_offset(text, Solargraph::Position.new(2, 12))).to eq(29) + expect(Solargraph::Position.to_offset(text, Solargraph::Position.new(2, 27))).to eq(44) + end + + it 'constructs position from offset' do + text = "\n class Foo\n def bar baz, boo = 'boo'\n end\n end\n " + expect(Solargraph::Position.from_offset(text, 0)).to eq(Solargraph::Position.new(0, 0)) + expect(Solargraph::Position.from_offset(text, 4)).to eq(Solargraph::Position.new(1, 3)) + expect(Solargraph::Position.from_offset(text, 29)).to eq(Solargraph::Position.new(2, 12)) + expect(Solargraph::Position.from_offset(text, 44)).to eq(Solargraph::Position.new(2, 27)) + end + it "raises an error for objects that cannot be normalized" do expect { Solargraph::Position.normalize('0, 1') From 4c05f2806078c3433b08ce3703eeb8a34e9325fc Mon Sep 17 00:00:00 2001 From: Fred Snyder Date: Wed, 14 Jan 2026 03:15:31 -0500 Subject: [PATCH 372/400] Raise InvalidOffsetError for offsets > text (#1155) * Raise InvalidOffsetError for offsets > text * Linting * Fix fencepost error * Additional fencepost test * Document exception --- lib/solargraph/position.rb | 15 +++++++++------ spec/position_spec.rb | 13 +++++++++++++ 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/lib/solargraph/position.rb b/lib/solargraph/position.rb index e47ed8bc8..a0d7bbc2e 100644 --- a/lib/solargraph/position.rb +++ b/lib/solargraph/position.rb @@ -58,22 +58,21 @@ def inspect # @return [Integer] def self.to_offset text, position return 0 if text.empty? + newline_index = -1 - cursor = 0 line = -1 - last_line_index = 0 + while (newline_index = text.index("\n", newline_index + 1)) && line <= position.line line += 1 break if line == position.line - line_length = newline_index - last_line_index - - cursor += line_length.zero? ? 1 : line_length + line_length = newline_index - last_line_index last_line_index = newline_index end - cursor + position.character + last_line_index += 1 if position.line > 0 + last_line_index + position.character end # Get a numeric offset for the specified text and a position identified @@ -89,10 +88,14 @@ def self.line_char_to_offset text, line, character # Get a position for the specified text and offset. # + # @raise [InvalidOffsetError] if the offset is outside the text range + # # @param text [String] # @param offset [Integer] # @return [Position] def self.from_offset text, offset + raise InvalidOffsetError if offset > text.length + cursor = 0 line = 0 character = offset diff --git a/spec/position_spec.rb b/spec/position_spec.rb index 88dedcd26..e8dab1960 100644 --- a/spec/position_spec.rb +++ b/spec/position_spec.rb @@ -18,6 +18,7 @@ expect(Solargraph::Position.to_offset(text, Solargraph::Position.new(0, 4))).to eq(4) expect(Solargraph::Position.to_offset(text, Solargraph::Position.new(2, 12))).to eq(29) expect(Solargraph::Position.to_offset(text, Solargraph::Position.new(2, 27))).to eq(44) + expect(Solargraph::Position.to_offset(text, Solargraph::Position.new(3, 8))).to eq(58) end it 'constructs position from offset' do @@ -33,4 +34,16 @@ Solargraph::Position.normalize('0, 1') }.to raise_error(ArgumentError) end + + it 'avoids fencepost errors' do + text = " class Foo\n def bar baz, boo = 'boo'\n end\n end\n " + offset = Solargraph::Position.to_offset(text, Solargraph::Position.new(3, 6)) + expect(offset).to eq(67) + end + + it 'avoids fencepost errors with multiple blank lines' do + text = " class Foo\n def bar baz, boo = 'boo'\n\n end\n end\n " + offset = Solargraph::Position.to_offset(text, Solargraph::Position.new(4, 6)) + expect(offset).to eq(68) + end end From 676da4c4cec040d735a9a54265c91dc91ec462bb Mon Sep 17 00:00:00 2001 From: Fred Snyder Date: Mon, 19 Jan 2026 07:26:26 -0500 Subject: [PATCH 373/400] Release 0.58.2 --- CHANGELOG.md | 8 +++++++- lib/solargraph/version.rb | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 315ba0c73..e07381830 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ +## 0.58.2 - January 19, 2026 +- Avoid rbs pollution (#1146) +- Fix 'solargraph pin --references ClassName' private method call (#1150) +- Improve memory efficiency of Position class (#1054) +- Raise InvalidOffsetError for offsets > text (#1155) + ## 0.58.1 - January 2, 2026 -- Normalize line endings to LF (#1142) +- Normalize line endings to LF (#1142) ## 0.58.0 - January 1, 2026 - Faster constant resolution (#1083) diff --git a/lib/solargraph/version.rb b/lib/solargraph/version.rb index 5bb8e52f8..11dd7e1ff 100755 --- a/lib/solargraph/version.rb +++ b/lib/solargraph/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module Solargraph - VERSION = '0.58.1' + VERSION = '0.58.2' end From f83cb3243728543e34f74424eaaeaf8f9a45a97e Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Tue, 27 Jan 2026 11:21:07 -0500 Subject: [PATCH 374/400] Quick fix --- solargraph.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/solargraph.gemspec b/solargraph.gemspec index ebafc843d..5bf452aeb 100755 --- a/solargraph.gemspec +++ b/solargraph.gemspec @@ -30,7 +30,7 @@ Gem::Specification.new do |s| s.add_runtime_dependency 'ast', '~> 2.4.3' s.add_runtime_dependency 'backport', '~> 1.2' s.add_runtime_dependency 'benchmark', '~> 0.4' - s.add_runtime_dependency 'bundler', '~> 2.0' + s.add_runtime_dependency 'bundler', '>= 2' s.add_runtime_dependency 'diff-lcs', '~> 1.4' s.add_runtime_dependency 'jaro_winkler', '~> 1.6', '>= 1.6.1' s.add_runtime_dependency 'kramdown', '~> 2.3' From 2e8140ca3688e9418aa1aa78d030ca5685d1f771 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Tue, 27 Jan 2026 11:34:10 -0500 Subject: [PATCH 375/400] Merge in master branch --- .gitattributes | 2 + .github/workflows/plugins.yml | 88 +++++++---- .github/workflows/rspec.yml | 38 ++--- .github/workflows/typecheck.yml | 4 +- .gitignore | 1 + .rubocop_todo.yml | 2 +- CHANGELOG.md | 36 +++++ Rakefile | 2 +- bin/solargraph | 3 + lib/solargraph/api_map.rb | 30 ++-- lib/solargraph/api_map/constants.rb | 69 +++++---- lib/solargraph/api_map/index.rb | 36 ++++- lib/solargraph/api_map/source_to_yard.rb | 7 +- lib/solargraph/api_map/store.rb | 16 +- lib/solargraph/complex_type.rb | 16 ++ lib/solargraph/complex_type/type_methods.rb | 5 + lib/solargraph/complex_type/unique_type.rb | 6 + .../convention/active_support_concern.rb | 2 +- lib/solargraph/diagnostics/rubocop_helpers.rb | 5 +- lib/solargraph/equality.rb | 1 + lib/solargraph/language_server/host.rb | 1 + .../message/text_document/formatting.rb | 2 + lib/solargraph/language_server/progress.rb | 2 +- lib/solargraph/library.rb | 2 +- lib/solargraph/location.rb | 1 + lib/solargraph/page.rb | 1 - lib/solargraph/parser/node_methods.rb | 97 ------------ .../parser/parser_gem/node_methods.rb | 1 + .../parser_gem/node_processors/and_node.rb | 1 + .../parser_gem/node_processors/opasgn_node.rb | 2 + .../parser_gem/node_processors/send_node.rb | 5 +- lib/solargraph/pin/base.rb | 2 + lib/solargraph/pin/base_variable.rb | 8 +- lib/solargraph/pin/block.rb | 1 + lib/solargraph/pin/callable.rb | 2 + lib/solargraph/pin/delegated_method.rb | 1 - lib/solargraph/pin/local_variable.rb | 3 - lib/solargraph/pin/method.rb | 18 ++- lib/solargraph/pin/parameter.rb | 4 + lib/solargraph/pin/proxy_type.rb | 5 +- lib/solargraph/pin/reference.rb | 13 +- lib/solargraph/pin/search.rb | 3 + lib/solargraph/position.rb | 36 +++-- lib/solargraph/range.rb | 4 + lib/solargraph/rbs_map/conversions.rb | 13 ++ lib/solargraph/shell.rb | 83 ++++++++++- lib/solargraph/source.rb | 2 +- lib/solargraph/source/chain.rb | 2 + lib/solargraph/source/chain/call.rb | 6 +- lib/solargraph/source/chain/if.rb | 2 +- lib/solargraph/source/chain/link.rb | 2 +- lib/solargraph/source/chain/or.rb | 2 +- lib/solargraph/source/encoding_fixes.rb | 46 +++--- lib/solargraph/source_map.rb | 4 +- lib/solargraph/source_map/mapper.rb | 2 - lib/solargraph/type_checker.rb | 32 +++- lib/solargraph/type_checker/rules.rb | 32 ++-- lib/solargraph/version.rb | 2 +- lib/solargraph/workspace.rb | 6 + lib/solargraph/workspace/config.rb | 18 +++ lib/solargraph/workspace/require_paths.rb | 1 - lib/solargraph/yard_map/mapper/to_method.rb | 3 +- lib/solargraph/yard_map/to_method.rb | 3 +- lib/solargraph/yardoc.rb | 6 +- {sig => rbs}/shims/ast/0/node.rbs | 0 {sig => rbs}/shims/ast/2.4/.rbs_meta.yaml | 0 {sig => rbs}/shims/ast/2.4/ast.rbs | 0 .../shims/parser/3.2.0.1/builders/default.rbs | 0 .../shims/parser/3.2.0.1/manifest.yaml | 0 {sig => rbs}/shims/parser/3.2.0.1/parser.rbs | 0 .../shims/parser/3.2.0.1/polyfill.rbs | 0 .../shims/thor/1.2.0.1/.rbs_meta.yaml | 0 {sig => rbs}/shims/thor/1.2.0.1/manifest.yaml | 0 {sig => rbs}/shims/thor/1.2.0.1/thor.rbs | 0 rbs_collection.yaml | 2 +- solargraph.gemspec | 3 +- spec/api_map/constants_spec.rb | 25 ++++ spec/convention/activesupport_concern_spec.rb | 96 ++++++++++++ spec/gem_pins_spec.rb | 5 + spec/pin/parameter_spec.rb | 28 ++++ spec/position_spec.rb | 29 ++++ spec/rbs_map/stdlib_map_spec.rb | 9 -- spec/shell_spec.rb | 141 ++++++++++++++++++ spec/source/chain/call_spec.rb | 37 +++++ spec/type_checker/levels/strong_spec.rb | 75 ++++++++++ spec/type_checker/rules_spec.rb | 8 +- spec/yardoc_spec.rb | 2 +- 87 files changed, 1000 insertions(+), 311 deletions(-) create mode 100644 .gitattributes delete mode 100644 lib/solargraph/parser/node_methods.rb rename {sig => rbs}/shims/ast/0/node.rbs (100%) rename {sig => rbs}/shims/ast/2.4/.rbs_meta.yaml (100%) rename {sig => rbs}/shims/ast/2.4/ast.rbs (100%) rename {sig => rbs}/shims/parser/3.2.0.1/builders/default.rbs (100%) rename {sig => rbs}/shims/parser/3.2.0.1/manifest.yaml (100%) rename {sig => rbs}/shims/parser/3.2.0.1/parser.rbs (100%) rename {sig => rbs}/shims/parser/3.2.0.1/polyfill.rbs (100%) rename {sig => rbs}/shims/thor/1.2.0.1/.rbs_meta.yaml (100%) rename {sig => rbs}/shims/thor/1.2.0.1/manifest.yaml (100%) rename {sig => rbs}/shims/thor/1.2.0.1/thor.rbs (100%) diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 000000000..890203bb4 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +*.rb text eol=lf +bin/* text eol=lf diff --git a/.github/workflows/plugins.yml b/.github/workflows/plugins.yml index b5984f3cb..c7ad72cb4 100644 --- a/.github/workflows/plugins.yml +++ b/.github/workflows/plugins.yml @@ -23,7 +23,7 @@ jobs: - name: Set up Ruby uses: ruby/setup-ruby@v1 with: - ruby-version: '3.0' + ruby-version: 3.4 bundler-cache: true - uses: awalsh128/cache-apt-pkgs-action@latest with: @@ -54,7 +54,7 @@ jobs: - name: Set up Ruby uses: ruby/setup-ruby@v1 with: - ruby-version: '3.0' + ruby-version: 3.4 bundler-cache: false - uses: awalsh128/cache-apt-pkgs-action@latest with: @@ -83,7 +83,7 @@ jobs: - name: Set up Ruby uses: ruby/setup-ruby@v1 with: - ruby-version: '3.0' + ruby-version: 3.4 bundler-cache: false - uses: awalsh128/cache-apt-pkgs-action@latest with: @@ -105,30 +105,64 @@ jobs: - name: Ensure specs still run run: bundle exec rake spec - # run_solargraph_rspec_specs: - # # check out solargraph-rspec as well as this project, and point the former to use the latter as a local gem - # runs-on: ubuntu-latest - # steps: - # - uses: actions/checkout@v3 - # - name: clone https://github.com/lekemula/solargraph-rspec/ - # run: | - # cd .. - # git clone https://github.com/lekemula/solargraph-rspec.git - # cd solargraph-rspec - # - name: Set up Ruby - # uses: ruby/setup-ruby@v1 - # with: - # ruby-version: '3.0' - # bundler-cache: false - # - name: Install gems - # run: | - # cd ../solargraph-rspec - # echo "gem 'solargraph', path: '../solargraph'" >> Gemfile - # bundle install - # - name: Run specs - # run: | - # cd ../solargraph-rspec - # bundle exec rake spec + run_solargraph_rspec_specs: + # check out solargraph-rspec as well as this project, and point the former to use the latter as a local gem + runs-on: ubuntu-latest + env: + SOLARGRAPH_CACHE: ${{ github.workspace }}/../solargraph-rspec/vendor/solargraph/cache + BUNDLE_PATH: ${{ github.workspace }}/../solargraph-rspec/vendor/bundle + steps: + - uses: actions/checkout@v3 + - name: clone https://github.com/lekemula/solargraph-rspec/ + run: | + cd .. + # git clone https://github.com/lekemula/solargraph-rspec.git + + # pending https://github.com/lekemula/solargraph-rspec/pull/30 + git clone https://github.com/apiology/solargraph-rspec.git + cd solargraph-rspec + git checkout reset_closures + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: '3.1' + rubygems: latest + bundler-cache: false + - name: Install gems + run: | + set -x + + cd ../solargraph-rspec + echo "gem 'solargraph', path: '../solargraph'" >> Gemfile + bundle config path ${{ env.BUNDLE_PATH }} + bundle install --jobs 4 --retry 3 + bundle exec appraisal install + # @todo some kind of appraisal/bundle conflict? + # https://github.com/castwide/solargraph/actions/runs/19038710934/job/54369767122?pr=1116 + # /home/runner/work/solargraph/solargraph-rspec/vendor/bundle/ruby/3.1.0/gems/bundler-2.6.9/lib/bundler/runtime.rb:317:in + # `check_for_activated_spec!': You have already activated date + # 3.5.0, but your Gemfile requires date 3.4.1. Prepending + # `bundle exec` to your command may solve + # this. (Gem::LoadError) + bundle exec appraisal update date + # For some reason on ruby 3.1 it defaults to an old version: 1.3.2 + # https://github.com/lekemula/solargraph-rspec/actions/runs/17814581205/job/50645370316?pr=22 + # We update manually to the latest + bundle exec appraisal update rspec-rails + - name: Configure .solargraph.yml + run: | + cd ../solargraph-rspec + cp .solargraph.yml.example .solargraph.yml + - name: Solargraph generate RSpec gems YARD and RBS pins + run: | + cd ../solargraph-rspec + bundle exec appraisal rbs collection update + rspec_gems=$(bundle exec appraisal ruby -r './lib/solargraph-rspec' -e 'puts Solargraph::Rspec::Gems.gem_names.join(" ")' 2>/dev/null | tail -n1) + bundle exec appraisal solargraph gems $rspec_gems + - name: Run specs + run: | + cd ../solargraph-rspec + bundle exec appraisal rspec --format progress run_solargraph_rails_specs: # check out solargraph-rails as well as this project, and point the former to use the latter as a local gem diff --git a/.github/workflows/rspec.yml b/.github/workflows/rspec.yml index d2e486f32..c82ade49b 100644 --- a/.github/workflows/rspec.yml +++ b/.github/workflows/rspec.yml @@ -21,28 +21,30 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - ruby-version: ['3.0', '3.1', '3.2', '3.3', '3.4', 'head'] - rbs-version: ['3.6.1', '3.9.4', '4.0.0.dev.4'] + ruby-version: ['3.0', '3.1', '3.2', '3.3', '3.4', '4.0'] + rbs-version: ['3.6.1', '3.9.5', '4.0.0.dev.4'] + # Ruby 3.0 doesn't work with RBS 3.9.4 or 4.0.0.dev.4 exclude: - # Ruby 3.0 doesn't work with RBS 3.9.4 or 4.0.0.dev.4 - ruby-version: '3.0' - rbs-version: '3.9.4' + rbs-version: '3.9.5' - ruby-version: '3.0' rbs-version: '4.0.0.dev.4' # Missing require in 'rbs collection update' - hopefully - # fixed in next RBS dev release - - ruby-version: 'head' - rbs-version: '4.0.0.dev.4' - - ruby-version: 'head' - rbs-version: '3.9.4' - - ruby-version: 'head' + # fixed in next RBS release + - ruby-version: '4.0' rbs-version: '3.6.1' + - ruby-version: '4.0' + rbs-version: '4.0.0.dev.4' steps: - uses: actions/checkout@v3 - name: Set up Ruby uses: ruby/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby-version }} + # see https://github.com/castwide/solargraph/actions/runs/19391419903/job/55485410493?pr=1119 + # + # match version in Gemfile.lock and use same version below + bundler: 2.5.23 bundler-cache: false - name: Set rbs version run: echo "gem 'rbs', '${{ matrix.rbs-version }}'" >> .Gemfile @@ -54,9 +56,13 @@ jobs: run: echo "gem 'tsort'" >> .Gemfile - name: Install gems run: | - bundle install - - name: Install types - run: bundle exec rbs collection update + bundle _2.5.23_ install + bundle update rbs # use latest available for this Ruby version + bundle list + bundle exec solargraph pin 'Bundler::Dsl#source' + - name: Update types + run: | + bundle exec rbs collection update - name: Run tests run: bundle exec rake spec undercover: @@ -73,11 +79,7 @@ jobs: ruby-version: '3.4' bundler-cache: false - name: Install gems - run: | - bundle install - bundle update rbs # use latest available for this Ruby version - - name: Install types - run: bundle exec rbs collection update + run: bundle install - name: Run tests run: bundle exec rake spec - name: Check PR coverage diff --git a/.github/workflows/typecheck.yml b/.github/workflows/typecheck.yml index 0ae8a3d8a..f40977acf 100644 --- a/.github/workflows/typecheck.yml +++ b/.github/workflows/typecheck.yml @@ -18,7 +18,7 @@ permissions: jobs: solargraph_typed: - name: Solargraph / typed + name: Solargraph / strong runs-on: ubuntu-latest @@ -36,4 +36,4 @@ jobs: - name: Install gem types run: bundle exec rbs collection install - name: Typecheck self - run: SOLARGRAPH_ASSERTS=on bundle exec solargraph typecheck --level typed + run: SOLARGRAPH_ASSERTS=on bundle exec solargraph typecheck --level strong diff --git a/.gitignore b/.gitignore index 2819165b1..75510d96b 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ coverage /Makefile /.pryrc /.rspec-local +vendor/cache diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index f6ba62afb..30e806572 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -450,7 +450,7 @@ Metrics/AbcSize: # Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns, inherit_mode. # AllowedMethods: refine Metrics/BlockLength: - Max: 54 + Max: 56 # Configuration parameters: CountBlocks, CountModifierForms. Metrics/BlockNesting: diff --git a/CHANGELOG.md b/CHANGELOG.md index d40a57517..e07381830 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,39 @@ +## 0.58.2 - January 19, 2026 +- Avoid rbs pollution (#1146) +- Fix 'solargraph pin --references ClassName' private method call (#1150) +- Improve memory efficiency of Position class (#1054) +- Raise InvalidOffsetError for offsets > text (#1155) + +## 0.58.1 - January 2, 2026 +- Normalize line endings to LF (#1142) + +## 0.58.0 - January 1, 2026 +- Faster constant resolution (#1083) +- [regression] Handle RBS static method aliases (#1094) +- More type fills and shims (#1005) +- Fix resolution in blocks in type checker (#890) +- Annotation fixes for strong typechecking (#1057) +- Remove dead code (#1077) +- Fix flakey spec (#1080) +- Fix bad sexpr generation in op_asgn (#1089) +- Opt-in for MFA requirement (#730) +- [regression] Fix resolution issues with namespaces from YARD (#1097) +- Improve a pin combination case around selfy types (#1024) +- Rescue reference errors in hosts (#1105) +- Relax bundler runtime dependency version constraint to support newer versions (#1125) +- Remove stale Pathname test (#1135) +- Enable strong type checking in CI (#928) +- Stale sg-ignore +- Use rbs 3.9.5 in tests (#1136) +- Drop broken 'namespaces' method (#1065) +- Add ActiveRecord example from RBS (#1074) +- Keep workspace directories as absolute paths (#1076) +- Handle bad gem_dir from gemspec object (#1079) +- Test for absolute require paths (#1137) +- [regression] Fix resolution of ambiguous argument types (#1098) +- Remove sg-ignore for String#=~ (#1138) +- Allow levels to be changed for typechecking rules in .solargraph.yml (#1126) + ## 0.57.0 - September 16, 2025 - Support ActiveSupport::Concern pattern for class methods (#948) - More CI checks (#996) diff --git a/Rakefile b/Rakefile index d731fc786..c83d9ab6b 100755 --- a/Rakefile +++ b/Rakefile @@ -9,7 +9,7 @@ task :console do end desc "Run the type checker" -task typecheck: [:typecheck_typed] +task typecheck: [:typecheck_strong] desc "Run the type checker at typed level - return code issues provable without annotations being correct" task :typecheck_typed do diff --git a/bin/solargraph b/bin/solargraph index d85561700..248dc42fd 100755 --- a/bin/solargraph +++ b/bin/solargraph @@ -1,5 +1,8 @@ #!/usr/bin/env ruby +# turn off warning diagnostics from Ruby +$VERBOSE=nil + require 'solargraph' Solargraph::Shell.start(ARGV) diff --git a/lib/solargraph/api_map.rb b/lib/solargraph/api_map.rb index f77d2bf1a..8658a212e 100755 --- a/lib/solargraph/api_map.rb +++ b/lib/solargraph/api_map.rb @@ -48,6 +48,7 @@ def self.reset_core out: nil # @param other [Object] def eql?(other) self.class == other.class && + # @sg-ignore Flow sensitive typing needs to handle self.class == other.class equality_fields == other.equality_fields end @@ -661,7 +662,7 @@ def super_and_sub?(sup, sub) # # @return [Boolean] def type_include?(host_ns, module_ns) - store.get_includes(host_ns).map { |inc_tag| inc_tag.parametrized_tag.name }.include?(module_ns) + store.get_includes(host_ns).map { |inc_tag| inc_tag.type.name }.include?(module_ns) end # @param pins [Enumerable] @@ -720,6 +721,12 @@ def inner_get_methods_from_reference(fq_reference_tag, namespace_pin, type, scop methods end + # @param fq_sub_tag [String] + # @return [String, nil] + def qualify_superclass fq_sub_tag + store.qualify_superclass fq_sub_tag + end + private # A hash of source maps with filename keys. @@ -777,17 +784,8 @@ def inner_get_methods rooted_tag, scope, visibility, deep, skip, no_core = false if scope == :instance store.get_includes(fqns).reverse.each do |ref| - const = get_constants('', *ref.closure.gates).find { |pin| pin.path.end_with? ref.name } - if const.is_a?(Pin::Namespace) - result.concat inner_get_methods(const.path, scope, visibility, deep, skip, true) - elsif const.is_a?(Pin::Constant) - type = const.infer(self) - result.concat inner_get_methods(type.namespace, scope, visibility, deep, skip, true) if type.defined? - else - referenced_tag = ref.parametrized_tag - next unless referenced_tag.defined? - result.concat inner_get_methods_from_reference(referenced_tag.to_s, namespace_pin, rooted_type, scope, visibility, deep, skip, true) - end + in_tag = dereference(ref) + result.concat inner_get_methods_from_reference(in_tag, namespace_pin, rooted_type, scope, visibility, deep, skip, true) end rooted_sc_tag = qualify_superclass(rooted_tag) unless rooted_sc_tag.nil? @@ -797,7 +795,7 @@ def inner_get_methods rooted_tag, scope, visibility, deep, skip, no_core = false else logger.info { "ApiMap#inner_get_methods(#{fqns}, #{scope}, #{visibility}, #{deep}, #{skip}) - looking for get_extends() from #{fqns}" } store.get_extends(fqns).reverse.each do |em| - fqem = store.constants.dereference(em) + fqem = dereference(em) result.concat inner_get_methods(fqem, :instance, visibility, deep, skip, true) unless fqem.nil? end rooted_sc_tag = qualify_superclass(rooted_tag) @@ -824,12 +822,6 @@ def path_macros @path_macros ||= {} end - # @param fq_sub_tag [String] - # @return [String, nil] - def qualify_superclass fq_sub_tag - store.qualify_superclass fq_sub_tag - end - # Get the namespace's type (Class or Module). # # @param fqns [String] A fully qualified namespace diff --git a/lib/solargraph/api_map/constants.rb b/lib/solargraph/api_map/constants.rb index 0df8d83ce..8dcaf1945 100644 --- a/lib/solargraph/api_map/constants.rb +++ b/lib/solargraph/api_map/constants.rb @@ -12,14 +12,23 @@ def initialize store # Resolve a name to a fully qualified namespace or constant. # - # `Constants#resolve` is similar to `Constants#qualify`` in that its - # purpose is to find fully qualified (absolute) namespaces, except - # `#resolve`` is only concerned with real namespaces. It disregards - # parametrized types and special types like literals, self, and Boolean. + # `Constants#resolve` finds fully qualified (absolute) + # namespaces based on relative names and the open gates + # (namespaces) provided. Names must be runtime-visible (erased) + # non-literal types, non-duck, non-signature types - e.g., + # TrueClass, NilClass, Integer and Hash instead of true, nil, + # 96, or Hash{String => Symbol} # - # @param name [String] - # @param gates [Array, String>] - # @return [String, nil] + # Note: You may want to be using #qualify. Notably, #resolve: + # - does not handle anything with type parameters + # - will not gracefully handle nil, self and Boolean + # - will return a constant name instead of following its assignment + # + # @param name [String] Namespace which may relative and not be rooted. + # @param gates [Array, String>] Namespaces to search while resolving the name + # + # @return [String, nil] fully qualified namespace (i.e., is + # absolute, but will not start with ::) def resolve(name, *gates) return store.get_path_pins(name[2..]).first&.path if name.start_with?('::') @@ -39,39 +48,49 @@ def resolve(name, *gates) # @param pin [Pin::Reference] # @return [String, nil] def dereference pin - resolve(pin.name, pin.reference_gates) + qualify_type(pin.type, *pin.reference_gates)&.tag end # Collect a list of all constants defined in the specified gates. # # @param gates [Array, String>] - # @return [Array] + # @return [Array] def collect(*gates) flat = gates.flatten cached_collect[flat] || collect_and_cache(flat) end - # Determine a fully qualified namespace for a given name referenced - # from the specified open gates. This method will search in each gate - # until it finds a match for the name. + # Determine a fully qualified namespace for a given tag + # referenced from the specified open gates. This method will + # search in each gate until it finds a match for the name. # - # @param name [String, nil] The namespace to match + # @param tag [String, nil] The type to match # @param gates [Array] # @return [String, nil] fully qualified tag - def qualify name, *gates - return name if ['Boolean', 'self', nil].include?(name) + def qualify tag, *gates + type = ComplexType.try_parse(tag) + qualify_type(type, *gates)&.tag + end + + # @param type [ComplexType, nil] The type to match + # @param gates [Array] + # + # @return [ComplexType, nil] A new rooted ComplexType + def qualify_type type, *gates + return nil if type.nil? + return type if type.selfy? || type.literal? || type.tag == 'nil' || type.interface? || + type.tag == 'Boolean' gates.push '' unless gates.include?('') - fqns = resolve(name, gates) + fqns = resolve(type.rooted_namespace, *gates) return unless fqns pin = store.get_path_pins(fqns).first if pin.is_a?(Pin::Constant) const = Solargraph::Parser::NodeMethods.unpack_name(pin.assignment) return unless const - resolve(const, pin.gates) - else - fqns + fqns = resolve(const, *pin.gates) end + type.recreate(new_name: fqns, make_rooted: true) end # @return [void] @@ -126,7 +145,7 @@ def complex_resolve name, gates, internal resolved = simple_resolve(name, gate, internal) return [resolved, gates[(idx + 1)..]] if resolved store.get_ancestor_references(gate).each do |ref| - return ref.name.sub(/^::/, '') if ref.name.end_with?("::#{name}") + return ref.name.sub(/^::/, '') if ref.name.end_with?("::#{name}") && ref.name.start_with?('::') mixin = resolve(ref.name, ref.reference_gates) next unless mixin @@ -155,7 +174,7 @@ def simple_resolve name, gate, internal end # @param gates [Array] - # @return [Array] + # @return [Array] def collect_and_cache gates skip = Set.new cached_collect[gates] = gates.flat_map do |gate| @@ -168,7 +187,7 @@ def cached_resolve @cached_resolve ||= {} end - # @return [Hash{Array => Array}] + # @return [Hash{Array => Array}] def cached_collect @cached_collect ||= {} end @@ -213,7 +232,7 @@ def inner_qualify name, root, skip return fqns if store.namespace_exists?(fqns) incs = store.get_includes(roots.join('::')) incs.each do |inc| - foundinc = inner_qualify(name, inc.parametrized_tag.to_s, skip) + foundinc = inner_qualify(name, inc.type.to_s, skip) possibles.push foundinc unless foundinc.nil? end roots.pop @@ -221,7 +240,7 @@ def inner_qualify name, root, skip if possibles.empty? incs = store.get_includes('') incs.each do |inc| - foundinc = inner_qualify(name, inc.parametrized_tag.to_s, skip) + foundinc = inner_qualify(name, inc.type.to_s, skip) possibles.push foundinc unless foundinc.nil? end end @@ -233,7 +252,7 @@ def inner_qualify name, root, skip # @param fqns [String] # @param visibility [Array] # @param skip [Set] - # @return [Array] + # @return [Array] def inner_get_constants fqns, visibility, skip return [] if fqns.nil? || skip.include?(fqns) skip.add fqns diff --git a/lib/solargraph/api_map/index.rb b/lib/solargraph/api_map/index.rb index d5f5f1821..ebc8eefcd 100644 --- a/lib/solargraph/api_map/index.rb +++ b/lib/solargraph/api_map/index.rb @@ -17,16 +17,22 @@ def pins # @return [Hash{String => Array}] def namespace_hash + # @param h [String] + # @param k [Array] @namespace_hash ||= Hash.new { |h, k| h[k] = [] } end # @return [Hash{String => Array}] def pin_class_hash + # @param h [String] + # @param k [Array] @pin_class_hash ||= Hash.new { |h, k| h[k] = [] } end # @return [Hash{String => Array}] def path_pin_hash + # @param h [String] + # @param k [Array] @path_pin_hash ||= Hash.new { |h, k| h[k] = [] } end @@ -42,26 +48,36 @@ def pins_by_class klass # @return [Hash{String => Array}] def include_references + # @param h [String] + # @param k [Array] @include_references ||= Hash.new { |h, k| h[k] = [] } end # @return [Hash{String => Array}] def include_reference_pins + # @param h [String] + # @param k [Array] @include_reference_pins ||= Hash.new { |h, k| h[k] = [] } end # @return [Hash{String => Array}] def extend_references + # @param h [String] + # @param k [Array] @extend_references ||= Hash.new { |h, k| h[k] = [] } end # @return [Hash{String => Array}] def prepend_references + # @param h [String] + # @param k [Array] @prepend_references ||= Hash.new { |h, k| h[k] = [] } end # @return [Hash{String => Array}] def superclass_references + # @param h [String] + # @param k [Array] @superclass_references ||= Hash.new { |h, k| h[k] = [] } end @@ -99,12 +115,18 @@ def catalog new_pins @pin_select_cache = {} pins.concat new_pins set = new_pins.to_set + # @param k [String] + # @param v [Set] set.classify(&:class) - .map { |k, v| pin_class_hash[k].concat v.to_a } + .map { |k, v| pin_class_hash[k].concat v.to_a } + # @param k [String] + # @param v [Set] set.classify(&:namespace) - .map { |k, v| namespace_hash[k].concat v.to_a } + .map { |k, v| namespace_hash[k].concat v.to_a } + # @param k [String] + # @param v [Set] set.classify(&:path) - .map { |k, v| path_pin_hash[k].concat v.to_a } + .map { |k, v| path_pin_hash[k].concat v.to_a } @namespaces = path_pin_hash.keys.compact.to_set map_references Pin::Reference::Include, include_references map_references Pin::Reference::Prepend, prepend_references @@ -114,10 +136,13 @@ def catalog new_pins self end - # @param klass [Class] - # @param hash [Hash{String => Array}] + # @generic T + # @param klass [Class>] + # @param hash [Hash{String => generic}] + # # @return [void] def map_references klass, hash + # @param pin [generic] pins_by_class(klass).each do |pin| hash[pin.namespace].push pin end @@ -125,6 +150,7 @@ def map_references klass, hash # @return [void] def map_overrides + # @param ovr [Pin::Reference::Override] pins_by_class(Pin::Reference::Override).each do |ovr| logger.debug { "ApiMap::Index#map_overrides: Looking at override #{ovr} for #{ovr.name}" } pins = path_pin_hash[ovr.name] diff --git a/lib/solargraph/api_map/source_to_yard.rb b/lib/solargraph/api_map/source_to_yard.rb index ccbed3eb6..55452582b 100644 --- a/lib/solargraph/api_map/source_to_yard.rb +++ b/lib/solargraph/api_map/source_to_yard.rb @@ -32,11 +32,13 @@ def rake_yard store next end if pin.type == :class + # @param obj [YARD::CodeObjects::RootObject] code_object_map[pin.path] ||= YARD::CodeObjects::ClassObject.new(root_code_object, pin.path) { |obj| next if pin.location.nil? || pin.location.filename.nil? obj.add_file(pin.location.filename, pin.location.range.start.line, !pin.comments.empty?) } else + # @param obj [YARD::CodeObjects::RootObject] code_object_map[pin.path] ||= YARD::CodeObjects::ModuleObject.new(root_code_object, pin.path) { |obj| next if pin.location.nil? || pin.location.filename.nil? obj.add_file(pin.location.filename, pin.location.range.start.line, !pin.comments.empty?) @@ -46,13 +48,13 @@ def rake_yard store store.get_includes(pin.path).each do |ref| include_object = code_object_at(pin.path, YARD::CodeObjects::ClassObject) unless include_object.nil? || include_object.nil? - include_object.instance_mixins.push code_object_map[ref.parametrized_tag.to_s] + include_object.instance_mixins.push code_object_map[ref.type.to_s] end end store.get_extends(pin.path).each do |ref| extend_object = code_object_at(pin.path, YARD::CodeObjects::ClassObject) next unless extend_object - code_object = code_object_map[ref.parametrized_tag.to_s] + code_object = code_object_map[ref.type.to_s] next unless code_object extend_object.class_mixins.push code_object # @todo add spec showing why this next line is necessary @@ -65,6 +67,7 @@ def rake_yard store next end + # @param obj [YARD::CodeObjects::RootObject] code_object_map[pin.path] ||= YARD::CodeObjects::MethodObject.new(code_object_at(pin.namespace, YARD::CodeObjects::NamespaceObject), pin.name, pin.scope) { |obj| next if pin.location.nil? || pin.location.filename.nil? obj.add_file pin.location.filename, pin.location.range.start.line diff --git a/lib/solargraph/api_map/store.rb b/lib/solargraph/api_map/store.rb index a99d5344d..bc829ba5a 100644 --- a/lib/solargraph/api_map/store.rb +++ b/lib/solargraph/api_map/store.rb @@ -17,7 +17,7 @@ def pins index.pins end - # @param pinsets [Array>] + # @param pinsets [Array>] # - pinsets[0] = core Ruby pins # - pinsets[1] = documentation/gem pins # - pinsets[2] = convention pins @@ -60,6 +60,7 @@ def inspect # @return [Enumerable] def get_constants fqns, visibility = [:public] namespace_children(fqns).select { |pin| + # @sg-ignore flow-sensitive typing not smart enough to handle this case !pin.name.empty? && (pin.is_a?(Pin::Namespace) || pin.is_a?(Pin::Constant)) && visibility.include?(pin.visibility) } end @@ -70,6 +71,7 @@ def get_constants fqns, visibility = [:public] # @return [Enumerable] def get_methods fqns, scope: :instance, visibility: [:public] all_pins = namespace_children(fqns).select do |pin| + # @sg-ignore https://github.com/castwide/solargraph/pull/1114 pin.is_a?(Pin::Method) && pin.scope == scope && visibility.include?(pin.visibility) end GemPins.combine_method_pins_by_path(all_pins) @@ -97,7 +99,7 @@ def qualify_superclass fq_sub_tag return unless ref res = constants.dereference(ref) return unless res - res + type.substring + res end # @param fqns [String] @@ -240,7 +242,8 @@ def get_ancestors(fqns) # Add includes, prepends, and extends [get_includes(current), get_prepends(current), get_extends(current)].each do |refs| next if refs.nil? - refs.map(&:parametrized_tag).map(&:to_s).each do |ref| + # @param ref [String] + refs.map(&:type).map(&:to_s).each do |ref| next if ref.nil? || ref.empty? || visited.include?(ref) ancestors << ref queue << ref @@ -253,7 +256,7 @@ def get_ancestors(fqns) # @param fqns [String] # - # @return [Array] + # @return [Array] def get_ancestor_references(fqns) (get_prepends(fqns) + get_includes(fqns) + [get_superclass(fqns)]).compact end @@ -270,7 +273,7 @@ def index @indexes.last end - # @param pinsets [Array>] + # @param pinsets [Array>] # # @return [void] def catalog pinsets @@ -291,6 +294,9 @@ def catalog pinsets # @return [Hash{::Array(String, String) => ::Array}] def fqns_pins_map + # @param h [Hash{::Array(String, String) => ::Array}] + # @param base [String] + # @param name [String] @fqns_pins_map ||= Hash.new do |h, (base, name)| value = namespace_children(base).select { |pin| pin.name == name && pin.is_a?(Pin::Namespace) } h[[base, name]] = value diff --git a/lib/solargraph/complex_type.rb b/lib/solargraph/complex_type.rb index 669a66900..1b9f96dfa 100644 --- a/lib/solargraph/complex_type.rb +++ b/lib/solargraph/complex_type.rb @@ -105,6 +105,21 @@ def can_assign?(api_map, atype) any? { |ut| ut.can_assign?(api_map, atype) } end + # @param new_name [String, nil] + # @param make_rooted [Boolean, nil] + # @param new_key_types [Array, nil] + # @param rooted [Boolean, nil] + # @param new_subtypes [Array, nil] + # @return [self] + def recreate(new_name: nil, make_rooted: nil, new_key_types: nil, new_subtypes: nil) + ComplexType.new(map do |ut| + ut.recreate(new_name: new_name, + make_rooted: make_rooted, + new_key_types: new_key_types, + new_subtypes: new_subtypes) + end) + end + # @return [Integer] def length @items.length @@ -324,6 +339,7 @@ def parse *strings, partial: false paren_stack = 0 base = String.new subtype_string = String.new + # @param char [String] type_string&.each_char do |char| if char == '=' #raise ComplexTypeError, "Invalid = in type #{type_string}" unless curly_stack > 0 diff --git a/lib/solargraph/complex_type/type_methods.rb b/lib/solargraph/complex_type/type_methods.rb index d8d4fc7d7..a0e99cdee 100644 --- a/lib/solargraph/complex_type/type_methods.rb +++ b/lib/solargraph/complex_type/type_methods.rb @@ -43,6 +43,10 @@ def rooted_tag @rooted_tag ||= rooted_name + rooted_substring end + def interface? + name.start_with?('_') + end + # @return [Boolean] def duck_type? @duck_type ||= name.start_with?('#') @@ -190,6 +194,7 @@ def scope # @param other [Object] def == other return false unless self.class == other.class + # @sg-ignore https://github.com/castwide/solargraph/pull/1114 tag == other.tag end diff --git a/lib/solargraph/complex_type/unique_type.rb b/lib/solargraph/complex_type/unique_type.rb index 05a585dcf..e490bff35 100644 --- a/lib/solargraph/complex_type/unique_type.rb +++ b/lib/solargraph/complex_type/unique_type.rb @@ -138,11 +138,17 @@ def determine_non_literal_name def eql?(other) self.class == other.class && + # @sg-ignore https://github.com/castwide/solargraph/pull/1114 @name == other.name && + # @sg-ignore https://github.com/castwide/solargraph/pull/1114 @key_types == other.key_types && + # @sg-ignore https://github.com/castwide/solargraph/pull/1114 @subtypes == other.subtypes && + # @sg-ignore https://github.com/castwide/solargraph/pull/1114 @rooted == other.rooted? && + # @sg-ignore https://github.com/castwide/solargraph/pull/1114 @all_params == other.all_params && + # @sg-ignore https://github.com/castwide/solargraph/pull/1114 @parameters_type == other.parameters_type end diff --git a/lib/solargraph/convention/active_support_concern.rb b/lib/solargraph/convention/active_support_concern.rb index 74c9ce765..ed1fba175 100644 --- a/lib/solargraph/convention/active_support_concern.rb +++ b/lib/solargraph/convention/active_support_concern.rb @@ -80,7 +80,7 @@ def process_include include_tag "ActiveSupportConcern#object(#{fqns}, #{scope}, #{visibility}, #{deep}) - " \ "Handling class include include_tag=#{include_tag}" end - module_extends = api_map.get_extends(rooted_include_tag).map(&:parametrized_tag).map(&:to_s) + module_extends = api_map.get_extends(rooted_include_tag).map(&:type).map(&:to_s) logger.debug do "ActiveSupportConcern#object(#{fqns}, #{scope}, #{visibility}, #{deep}) - " \ "found module extends of #{rooted_include_tag}: #{module_extends}" diff --git a/lib/solargraph/diagnostics/rubocop_helpers.rb b/lib/solargraph/diagnostics/rubocop_helpers.rb index f6f4c82c8..fc458956e 100644 --- a/lib/solargraph/diagnostics/rubocop_helpers.rb +++ b/lib/solargraph/diagnostics/rubocop_helpers.rb @@ -20,9 +20,11 @@ def require_rubocop(version = nil) gem_lib_path = File.join(gem_path, 'lib') $LOAD_PATH.unshift(gem_lib_path) unless $LOAD_PATH.include?(gem_lib_path) rescue Gem::MissingSpecVersionError => e + # @type [Array] + specs = e.specs raise InvalidRubocopVersionError, "could not find '#{e.name}' (#{e.requirement}) - "\ - "did find: [#{e.specs.map { |s| s.version.version }.join(', ')}]" + "did find: [#{specs.map { |s| s.version.version }.join(', ')}]" end require 'rubocop' end @@ -36,6 +38,7 @@ def generate_options filename, code args = ['-f', 'j', '--force-exclusion', filename] base_options = RuboCop::Options.new options, paths = base_options.parse(args) + # @sg-ignore options[:stdin] = code [options, paths] end diff --git a/lib/solargraph/equality.rb b/lib/solargraph/equality.rb index 0667efacd..f8c50ff31 100644 --- a/lib/solargraph/equality.rb +++ b/lib/solargraph/equality.rb @@ -12,6 +12,7 @@ module Equality # @return [Boolean] def eql?(other) self.class.eql?(other.class) && + # @sg-ignore https://github.com/castwide/solargraph/pull/1114 equality_fields.eql?(other.equality_fields) end diff --git a/lib/solargraph/language_server/host.rb b/lib/solargraph/language_server/host.rb index 53da20175..b228bdba6 100644 --- a/lib/solargraph/language_server/host.rb +++ b/lib/solargraph/language_server/host.rb @@ -504,6 +504,7 @@ def locate_pins params name: 'new', scope: :class, location: pin.location, + # @sg-ignore Unresolved call to parameters on Solargraph::Pin::Base parameters: pin.parameters, return_type: ComplexType.try_parse(params['data']['path']), comments: pin.comments, diff --git a/lib/solargraph/language_server/message/text_document/formatting.rb b/lib/solargraph/language_server/message/text_document/formatting.rb index 821de7ffc..d67a0b414 100644 --- a/lib/solargraph/language_server/message/text_document/formatting.rb +++ b/lib/solargraph/language_server/message/text_document/formatting.rb @@ -18,6 +18,7 @@ def process require_rubocop(config['version']) options, paths = ::RuboCop::Options.new.parse(args) + # @sg-ignore Unresolved call to []= options[:stdin] = original # Ensure only one instance of RuboCop::Runner is running at @@ -28,6 +29,7 @@ def process ::RuboCop::Runner.new(options, ::RuboCop::ConfigStore.new).run(paths) end end + # @sg-ignore Unresolved call to []= result = options[:stdin] log_corrections(corrections) diff --git a/lib/solargraph/language_server/progress.rb b/lib/solargraph/language_server/progress.rb index 10900a37e..98b155714 100644 --- a/lib/solargraph/language_server/progress.rb +++ b/lib/solargraph/language_server/progress.rb @@ -134,7 +134,7 @@ def keep_alive host end end - # @return [Mutex] + # @return [Thread::Mutex] def mutex @mutex ||= Mutex.new end diff --git a/lib/solargraph/library.rb b/lib/solargraph/library.rb index e788dfaa4..2c21e392f 100644 --- a/lib/solargraph/library.rb +++ b/lib/solargraph/library.rb @@ -526,7 +526,7 @@ def find_external_requires source_map @external_requires = nil end - # @return [Mutex] + # @return [Thread::Mutex] def mutex @mutex ||= Mutex.new end diff --git a/lib/solargraph/location.rb b/lib/solargraph/location.rb index 713b4fef1..df92668bf 100644 --- a/lib/solargraph/location.rb +++ b/lib/solargraph/location.rb @@ -71,6 +71,7 @@ def self.from_node(node) # @param other [BasicObject] def == other return false unless other.is_a?(Location) + # @sg-ignore https://github.com/castwide/solargraph/pull/1114 filename == other.filename and range == other.range end diff --git a/lib/solargraph/page.rb b/lib/solargraph/page.rb index 5d879bbe1..12782da90 100644 --- a/lib/solargraph/page.rb +++ b/lib/solargraph/page.rb @@ -27,7 +27,6 @@ def initialize locals, render_method end # @param text [String] - # @sg-ignore https://github.com/lsegal/yard/pull/1615 # @return [String] def htmlify text # @type [String] diff --git a/lib/solargraph/parser/node_methods.rb b/lib/solargraph/parser/node_methods.rb deleted file mode 100644 index f33a924c1..000000000 --- a/lib/solargraph/parser/node_methods.rb +++ /dev/null @@ -1,97 +0,0 @@ -module Solargraph - module Parser - module NodeMethods - module_function - - # @abstract - # @param node [Parser::AST::Node] - # @return [String] - def unpack_name node - raise NotImplementedError - end - - # @abstract - # @todo Temporarily here for testing. Move to Solargraph::Parser. - # @param node [Parser::AST::Node] - # @return [Array] - def call_nodes_from node - raise NotImplementedError - end - - # Find all the nodes within the provided node that potentially return a - # value. - # - # The node parameter typically represents a method's logic, e.g., the - # second child (after the :args node) of a :def node. A simple one-line - # method would typically return itself, while a node with conditions - # would return the resulting node from each conditional branch. Nodes - # that follow a :return node are assumed to be unreachable. Nil values - # are converted to nil node types. - # - # @abstract - # @param node [Parser::AST::Node] - # @return [Array] - def returns_from_method_body node - raise NotImplementedError - end - - # @abstract - # @param node [Parser::AST::Node] - # - # @return [Array] - def const_nodes_from node - raise NotImplementedError - end - - # @abstract - # @param cursor [Solargraph::Source::Cursor] - # @return [Parser::AST::Node, nil] - def find_recipient_node cursor - raise NotImplementedError - end - - # @abstract - # @param node [Parser::AST::Node] - # @return [Array] low-level value nodes in - # value position. Does not include explicit return - # statements - def value_position_nodes_only(node) - raise NotImplementedError - end - - # @abstract - # @param nodes [Enumerable] - def any_splatted_call?(nodes) - raise NotImplementedError - end - - # @abstract - # @param node [Parser::AST::Node] - # @return [void] - def process node - raise NotImplementedError - end - - # @abstract - # @param node [Parser::AST::Node] - # @return [Hash{Symbol => Source::Chain}] - def convert_hash node - raise NotImplementedError - end - - # @abstract - # @param node [Parser::AST::Node] - # @return [Position] - def get_node_start_position(node) - raise NotImplementedError - end - - # @abstract - # @param node [Parser::AST::Node] - # @return [Position] - def get_node_end_position(node) - raise NotImplementedError - end - end - end -end diff --git a/lib/solargraph/parser/parser_gem/node_methods.rb b/lib/solargraph/parser/parser_gem/node_methods.rb index 02f790c00..b77c4cd47 100644 --- a/lib/solargraph/parser/parser_gem/node_methods.rb +++ b/lib/solargraph/parser/parser_gem/node_methods.rb @@ -119,6 +119,7 @@ def convert_hash node result end + # @sg-ignore Wrong argument type for AST::Node.new: type expected AST::_ToSym, received :nil NIL_NODE = ::Parser::AST::Node.new(:nil) # @param node [Parser::AST::Node] diff --git a/lib/solargraph/parser/parser_gem/node_processors/and_node.rb b/lib/solargraph/parser/parser_gem/node_processors/and_node.rb index d3485af7c..a761ae38c 100644 --- a/lib/solargraph/parser/parser_gem/node_processors/and_node.rb +++ b/lib/solargraph/parser/parser_gem/node_processors/and_node.rb @@ -11,6 +11,7 @@ def process process_children position = get_node_start_position(node) + # @sg-ignore https://github.com/castwide/solargraph/pull/1114 enclosing_breakable_pin = pins.select{|pin| pin.is_a?(Pin::Breakable) && pin.location.range.contain?(position)}.last FlowSensitiveTyping.new(locals, enclosing_breakable_pin).process_and(node) end diff --git a/lib/solargraph/parser/parser_gem/node_processors/opasgn_node.rb b/lib/solargraph/parser/parser_gem/node_processors/opasgn_node.rb index 0e4d7b26a..a4359af9d 100644 --- a/lib/solargraph/parser/parser_gem/node_processors/opasgn_node.rb +++ b/lib/solargraph/parser/parser_gem/node_processors/opasgn_node.rb @@ -13,8 +13,10 @@ def process operator = node.children[1] argument = node.children[2] if target.type == :send + # @sg-ignore Need a downcast here process_send_target(target, operator, argument) elsif target.type.to_s.end_with?('vasgn') + # @sg-ignore Need a downcast here process_vasgn_target(target, operator, argument) else Solargraph.assert_or_log(:opasgn_unknown_target, diff --git a/lib/solargraph/parser/parser_gem/node_processors/send_node.rb b/lib/solargraph/parser/parser_gem/node_processors/send_node.rb index 645baf00f..861d6b157 100644 --- a/lib/solargraph/parser/parser_gem/node_processors/send_node.rb +++ b/lib/solargraph/parser/parser_gem/node_processors/send_node.rb @@ -36,15 +36,12 @@ def process process_autoload elsif method_name == :private_constant process_private_constant - # @sg-ignore elsif method_name == :alias_method && node.children[2] && node.children[2] && node.children[2].type == :sym && node.children[3] && node.children[3].type == :sym process_alias_method - # @sg-ignore elsif method_name == :private_class_method && node.children[2].is_a?(AST::Node) # Processing a private class can potentially handle children on its own return if process_private_class_method end - # @sg-ignore elsif method_name == :require && node.children[0].to_s == '(const nil :Bundler)' pins.push Pin::Reference::Require.new(Solargraph::Location.new(region.filename, Solargraph::Range.from_to(0, 0, 0, 0)), 'bundler/require', source: :parser) end @@ -231,6 +228,7 @@ def process_module_function closure: cm, name: ivar.name, comments: ivar.comments, + # @sg-ignore https://github.com/castwide/solargraph/pull/1114 assignment: ivar.assignment, source: :parser ) @@ -239,6 +237,7 @@ def process_module_function closure: mm, name: ivar.name, comments: ivar.comments, + # @sg-ignore https://github.com/castwide/solargraph/pull/1114 assignment: ivar.assignment, source: :parser ) diff --git a/lib/solargraph/pin/base.rb b/lib/solargraph/pin/base.rb index 511c7deb7..57d083453 100644 --- a/lib/solargraph/pin/base.rb +++ b/lib/solargraph/pin/base.rb @@ -259,6 +259,7 @@ def rbs_location? def assert_same_macros(other) return unless self.source == :yardoc && other.source == :yardoc assert_same_count(other, :macros) + # @param [YARD::Tags::MacroDirective] assert_same_array_content(other, :macros) { |macro| macro.tag.name } end @@ -466,6 +467,7 @@ def nearly? other # @param other [Object] def == other return false unless nearly? other + # @sg-ignore Should add more explicit type check on other comments == other.comments && location == other.location end diff --git a/lib/solargraph/pin/base_variable.rb b/lib/solargraph/pin/base_variable.rb index 764c1fb39..ab7bd3961 100644 --- a/lib/solargraph/pin/base_variable.rb +++ b/lib/solargraph/pin/base_variable.rb @@ -12,8 +12,9 @@ class BaseVariable < Base attr_accessor :mass_assignment # @param return_type [ComplexType, nil] + # @param mass_assignment [::Array(Parser::AST::Node, Integer), nil] # @param assignment [Parser::AST::Node, nil] - def initialize assignment: nil, return_type: nil, **splat + def initialize assignment: nil, return_type: nil, mass_assignment: nil, **splat super(**splat) @assignment = assignment # @type [nil, ::Array(Parser::AST::Node, Integer)] @@ -22,12 +23,12 @@ def initialize assignment: nil, return_type: nil, **splat end def combine_with(other, attrs={}) - attrs.merge({ + new_attrs = attrs.merge({ assignment: assert_same(other, :assignment), mass_assignment: assert_same(other, :mass_assignment), return_type: combine_return_type(other), }) - super(other, attrs) + super(other, new_attrs) end def completion_item_kind @@ -104,6 +105,7 @@ def probe api_map # @param other [Object] def == other return false unless super + # @sg-ignore Should add type check on other assignment == other.assignment end diff --git a/lib/solargraph/pin/block.rb b/lib/solargraph/pin/block.rb index 227bc0873..0c6ecd258 100644 --- a/lib/solargraph/pin/block.rb +++ b/lib/solargraph/pin/block.rb @@ -54,6 +54,7 @@ def typify_parameters(api_map) locals = clip.locals - [self] meths = chain.define(api_map, closure, locals) # @todo Convert logic to use signatures + # @param meth [Pin::Method] meths.each do |meth| next if meth.block.nil? diff --git a/lib/solargraph/pin/callable.rb b/lib/solargraph/pin/callable.rb index 626b75457..f1b41e55f 100644 --- a/lib/solargraph/pin/callable.rb +++ b/lib/solargraph/pin/callable.rb @@ -67,6 +67,8 @@ def generics # @return [Array] def choose_parameters(other) raise "Trying to combine two pins with different arities - \nself =#{inspect}, \nother=#{other.inspect}, \n\n self.arity=#{self.arity}, \nother.arity=#{other.arity}" if other.arity != arity + # @param param [Pin::Parameter] + # @param other_param [Pin::Parameter] parameters.zip(other.parameters).map do |param, other_param| if param.nil? && other_param.block? other_param diff --git a/lib/solargraph/pin/delegated_method.rb b/lib/solargraph/pin/delegated_method.rb index 9483fb058..bcf5b5912 100644 --- a/lib/solargraph/pin/delegated_method.rb +++ b/lib/solargraph/pin/delegated_method.rb @@ -51,7 +51,6 @@ def type_location %i[typify realize infer probe].each do |method| # @param api_map [ApiMap] define_method(method) do |api_map| - # @sg-ignore Unresolved call to resolve_method resolve_method(api_map) # @sg-ignore Need to set context correctly in define_method blocks @resolved_method ? @resolved_method.send(method, api_map) : super(api_map) diff --git a/lib/solargraph/pin/local_variable.rb b/lib/solargraph/pin/local_variable.rb index 9eae6cc6f..cb2dda140 100644 --- a/lib/solargraph/pin/local_variable.rb +++ b/lib/solargraph/pin/local_variable.rb @@ -26,9 +26,6 @@ def combine_with(other, attrs={}) assignment: assert_same(other, :assignment), presence_certain: assert_same(other, :presence_certain?), }.merge(attrs) - # @sg-ignore Wrong argument type for - # Solargraph::Pin::Base#assert_same: other expected - # Solargraph::Pin::Base, received self new_attrs[:presence] = assert_same(other, :presence) unless attrs.key?(:presence) super(other, new_attrs) diff --git a/lib/solargraph/pin/method.rb b/lib/solargraph/pin/method.rb index 011f096f6..86bf1cd09 100644 --- a/lib/solargraph/pin/method.rb +++ b/lib/solargraph/pin/method.rb @@ -34,14 +34,18 @@ def initialize visibility: :public, explicit: true, block: :undefined, node: nil @anon_splat = anon_splat end + # @param signature_pins [Array] # @return [Array] def combine_all_signature_pins(*signature_pins) + # @type [Hash{Array => Array}] by_arity = {} signature_pins.each do |signature_pin| by_arity[signature_pin.arity] ||= [] by_arity[signature_pin.arity] << signature_pin end by_arity.transform_values! do |same_arity_pins| + # @param memo [Pin::Signature, nil] + # @param signature [Pin::Signature] same_arity_pins.reduce(nil) do |memo, signature| next signature if memo.nil? memo.combine_with(signature) @@ -88,6 +92,7 @@ def combine_with(other, attrs = {}) end new_attrs = { visibility: combine_visibility(other), + # @sg-ignore https://github.com/castwide/solargraph/pull/1050 explicit: explicit? || other.explicit?, block: combine_blocks(other), node: choose_node(other, :node), @@ -376,11 +381,14 @@ def attribute? @attribute end - # @parm other [Method] + # @parm other [self] def nearly? other super && + # @sg-ignore https://github.com/castwide/solargraph/pull/1050 parameters == other.parameters && + # @sg-ignore https://github.com/castwide/solargraph/pull/1050 scope == other.scope && + # @sg-ignore https://github.com/castwide/solargraph/pull/1050 visibility == other.visibility end @@ -392,9 +400,12 @@ def probe api_map def overloads # Ignore overload tags with nil parameters. If it's not an array, the # tag's source is likely malformed. + + # @param tag [YARD::Tags::OverloadTag] @overloads ||= docstring.tags(:overload).select(&:parameters).map do |tag| Pin::Signature.new( generics: generics, + # @param src [Array(String, String)] parameters: tag.parameters.map do |src| name, decl = parse_overload_param(src.first) Pin::Parameter.new( @@ -507,6 +518,7 @@ def clean_param name # # @return [ComplexType] def param_type_from_name(tag, name) + # @param t [YARD::Tags::Tag] param = tag.tags(:param).select { |t| t.name == name }.first return ComplexType::UNDEFINED unless param ComplexType.try_parse(*param.types) @@ -522,8 +534,12 @@ def generate_complex_type # @param api_map [ApiMap] # @return [ComplexType, nil] def see_reference api_map + # This should actually be an intersection type + # @param ref [YARD::Tags::Tag, Solargraph::Yard::Tags::RefTag] docstring.ref_tags.each do |ref| + # @sg-ignore ref should actually be an intersection type next unless ref.tag_name == 'return' && ref.owner + # @sg-ignore ref should actually be an intersection type result = resolve_reference(ref.owner.to_s, api_map) return result unless result.nil? end diff --git a/lib/solargraph/pin/parameter.rb b/lib/solargraph/pin/parameter.rb index b5c6bdf4e..fed1e9cbd 100644 --- a/lib/solargraph/pin/parameter.rb +++ b/lib/solargraph/pin/parameter.rb @@ -237,8 +237,12 @@ def typify_method_param api_map # @param skip [::Array] # @return [::Array] def see_reference heredoc, api_map, skip = [] + # This should actually be an intersection type + # @param ref [YARD::Tags::Tag, Solargraph::Yard::Tags::RefTag] heredoc.ref_tags.each do |ref| + # @sg-ignore ref should actually be an intersection type next unless ref.tag_name == 'param' && ref.owner + # @sg-ignore ref should actually be an intersection type result = resolve_reference(ref.owner.to_s, api_map, skip) return result unless result.nil? end diff --git a/lib/solargraph/pin/proxy_type.rb b/lib/solargraph/pin/proxy_type.rb index 2323489a7..452536834 100644 --- a/lib/solargraph/pin/proxy_type.rb +++ b/lib/solargraph/pin/proxy_type.rb @@ -4,9 +4,12 @@ module Solargraph module Pin class ProxyType < Base # @param return_type [ComplexType] + # @param gates [Array, nil] Namespaces to try while resolving non-rooted types # @param binder [ComplexType, ComplexType::UniqueType, nil] - def initialize return_type: ComplexType::UNDEFINED, binder: nil, **splat + # @param gates [Array, nil] + def initialize return_type: ComplexType::UNDEFINED, binder: nil, gates: nil, **splat super(**splat) + @gates = gates @return_type = return_type @binder = binder if binder end diff --git a/lib/solargraph/pin/reference.rb b/lib/solargraph/pin/reference.rb index d678ab7b7..d456fbbf8 100644 --- a/lib/solargraph/pin/reference.rb +++ b/lib/solargraph/pin/reference.rb @@ -18,18 +18,9 @@ def initialize generic_values: [], **splat @generic_values = generic_values end - # @return [String] - def parameter_tag - @parameter_tag ||= if generic_values&.any? - "<#{generic_values.join(', ')}>" - else - '' - end - end - # @return [ComplexType] - def parametrized_tag - @parametrized_tag ||= ComplexType.try_parse( + def type + @type ||= ComplexType.try_parse( name + if generic_values&.length&.> 0 "<#{generic_values.join(', ')}>" diff --git a/lib/solargraph/pin/search.rb b/lib/solargraph/pin/search.rb index f92978a35..0f9883b65 100644 --- a/lib/solargraph/pin/search.rb +++ b/lib/solargraph/pin/search.rb @@ -42,6 +42,9 @@ def do_query Result.new(match, pin) if match > 0.7 end .compact + # @param a [self] + # @param b [self] + # @sg-ignore https://github.com/castwide/solargraph/pull/1050 .sort { |a, b| b.match <=> a.match } .map(&:pin) end diff --git a/lib/solargraph/position.rb b/lib/solargraph/position.rb index 2faa0a99b..a0d7bbc2e 100644 --- a/lib/solargraph/position.rb +++ b/lib/solargraph/position.rb @@ -58,8 +58,21 @@ def inspect # @return [Integer] def self.to_offset text, position return 0 if text.empty? - # @sg-ignore Unresolved call to + on Integer - text.lines[0...position.line].sum(&:length) + position.character + + newline_index = -1 + line = -1 + last_line_index = 0 + + while (newline_index = text.index("\n", newline_index + 1)) && line <= position.line + line += 1 + break if line == position.line + + line_length = newline_index - last_line_index + last_line_index = newline_index + end + + last_line_index += 1 if position.line > 0 + last_line_index + position.character end # Get a numeric offset for the specified text and a position identified @@ -75,22 +88,22 @@ def self.line_char_to_offset text, line, character # Get a position for the specified text and offset. # + # @raise [InvalidOffsetError] if the offset is outside the text range + # # @param text [String] # @param offset [Integer] # @return [Position] def self.from_offset text, offset + raise InvalidOffsetError if offset > text.length + cursor = 0 line = 0 - character = nil - text.lines.each do |l| - line_length = l.length - char_length = l.chomp.length - if cursor + char_length >= offset - character = offset - cursor - break - end - cursor += line_length + character = offset + newline_index = -1 + + while (newline_index = text.index("\n", newline_index + 1)) && newline_index < offset line += 1 + character = offset - newline_index - 1 end character = 0 if character.nil? and (cursor - offset).between?(0, 1) raise InvalidOffsetError if character.nil? @@ -112,6 +125,7 @@ def self.normalize object def == other return false unless other.is_a?(Position) + # @sg-ignore https://github.com/castwide/solargraph/pull/1114 line == other.line and character == other.character end end diff --git a/lib/solargraph/range.rb b/lib/solargraph/range.rb index 7a9bc0e30..86452d646 100644 --- a/lib/solargraph/range.rb +++ b/lib/solargraph/range.rb @@ -27,9 +27,12 @@ def initialize start, ending # @param other [BasicObject] def <=>(other) return nil unless other.is_a?(Range) + # @sg-ignore https://github.com/castwide/solargraph/pull/1114 if start == other.start + # @sg-ignore https://github.com/castwide/solargraph/pull/1114 ending <=> other.ending else + # @sg-ignore https://github.com/castwide/solargraph/pull/1114 start <=> other.start end end @@ -98,6 +101,7 @@ def self.from_expr expr def == other return false unless other.is_a?(Range) + # @sg-ignore https://github.com/castwide/solargraph/pull/1114 start == other.start && ending == other.ending end diff --git a/lib/solargraph/rbs_map/conversions.rb b/lib/solargraph/rbs_map/conversions.rb index 3e777f726..54bca0f73 100644 --- a/lib/solargraph/rbs_map/conversions.rb +++ b/lib/solargraph/rbs_map/conversions.rb @@ -65,6 +65,7 @@ def convert_decl_to_pin decl, closure # STDERR.puts "Skipping interface #{decl.name.relative!}" interface_decl_to_pin decl, closure when RBS::AST::Declarations::TypeAlias + # @sg-ignore https://github.com/castwide/solargraph/pull/1114 type_aliases[decl.name.to_s] = decl when RBS::AST::Declarations::Module module_decl_to_pin decl @@ -426,6 +427,7 @@ def method_def_to_pin decl, closure, context # @param pin [Pin::Method] # @return [void] def method_def_to_sigs decl, pin + # @param overload [RBS::AST::Members::MethodDefinition::Overload] decl.overloads.map do |overload| type_location = location_decl_to_pin_location(overload.method_type.location) generics = overload.method_type.type_params.map(&:name).map(&:to_s) @@ -466,12 +468,16 @@ def parts_of_function type, pin parameters = [] arg_num = -1 type.type.required_positionals.each do |param| + # @sg-ignore RBS generic type understanding issue name = param.name ? param.name.to_s : "arg_#{arg_num += 1}" + # @sg-ignore RBS generic type understanding issue parameters.push Solargraph::Pin::Parameter.new(decl: :arg, name: name, closure: pin, return_type: ComplexType.try_parse(other_type_to_tag(param.type)).force_rooted, source: :rbs, type_location: type_location) end type.type.optional_positionals.each do |param| + # @sg-ignore RBS generic type understanding issue name = param.name ? param.name.to_s : "arg_#{arg_num += 1}" parameters.push Solargraph::Pin::Parameter.new(decl: :optarg, name: name, closure: pin, + # @sg-ignore RBS generic type understanding issue return_type: ComplexType.try_parse(other_type_to_tag(param.type)).force_rooted, type_location: type_location, source: :rbs) @@ -489,18 +495,23 @@ def parts_of_function type, pin return_type: rest_positional_type,) end type.type.trailing_positionals.each do |param| + # @sg-ignore RBS generic type understanding issue name = param.name ? param.name.to_s : "arg_#{arg_num += 1}" parameters.push Solargraph::Pin::Parameter.new(decl: :arg, name: name, closure: pin, source: :rbs, type_location: type_location) end type.type.required_keywords.each do |orig, param| + # @sg-ignore RBS generic type understanding issue name = orig ? orig.to_s : "arg_#{arg_num += 1}" parameters.push Solargraph::Pin::Parameter.new(decl: :kwarg, name: name, closure: pin, + # @sg-ignore RBS generic type understanding issue return_type: ComplexType.try_parse(other_type_to_tag(param.type)).force_rooted, source: :rbs, type_location: type_location) end type.type.optional_keywords.each do |orig, param| + # @sg-ignore RBS generic type understanding issue name = orig ? orig.to_s : "arg_#{arg_num += 1}" parameters.push Solargraph::Pin::Parameter.new(decl: :kwoptarg, name: name, closure: pin, + # @sg-ignore RBS generic type understanding issue return_type: ComplexType.try_parse(other_type_to_tag(param.type)).force_rooted, type_location: type_location, source: :rbs) @@ -792,7 +803,9 @@ def other_type_to_tag type # @param namespace [Pin::Namespace] # @return [void] def add_mixins decl, namespace + # @param mixin [RBS::AST::Members::Include, RBS::AST::Members::Members::Extend, RBS::AST::Members::Members::Prepend] decl.each_mixin do |mixin| + # @todo are we handling prepend correctly? klass = mixin.is_a?(RBS::AST::Members::Include) ? Pin::Reference::Include : Pin::Reference::Extend type = build_type(mixin.name, mixin.args) generic_values = type.all_params.map(&:to_s) diff --git a/lib/solargraph/shell.rb b/lib/solargraph/shell.rb index 535aaaf27..e7472782e 100755 --- a/lib/solargraph/shell.rb +++ b/lib/solargraph/shell.rb @@ -80,6 +80,7 @@ def config(directory = '.') conf['extensions'].push m end end + # @param file [File] File.open(File.join(directory, '.solargraph.yml'), 'w') do |file| file.puts conf.to_yaml end @@ -206,6 +207,9 @@ def reporters # @return [void] def typecheck *files directory = File.realpath(options[:directory]) + workspace = Solargraph::Workspace.new(directory) + level = options[:level].to_sym + rules = workspace.rules(level) api_map = Solargraph::ApiMap.load_with_cache(directory, $stdout) probcount = 0 if files.empty? @@ -217,7 +221,7 @@ def typecheck *files time = Benchmark.measure { files.each do |file| - checker = TypeChecker.new(file, api_map: api_map, level: options[:level].to_sym) + checker = TypeChecker.new(file, api_map: api_map, level: options[:level].to_sym, workspace: workspace) problems = checker.problems next if problems.empty? problems.sort! { |a, b| a.location.range.start.line <=> b.location.range.start.line } @@ -274,6 +278,63 @@ def list puts "#{workspace.filenames.length} files total." end + desc 'pin [PATH]', 'Describe a pin', hide: true + option :rbs, type: :boolean, desc: 'Output the pin as RBS', default: false + option :typify, type: :boolean, desc: 'Output the calculated return type of the pin from annotations', default: false + option :references, type: :boolean, desc: 'Show references', default: false + option :probe, type: :boolean, desc: 'Output the calculated return type of the pin from annotations and inference', default: false + option :stack, type: :boolean, desc: 'Show entire stack of a method pin by including definitions in superclasses', default: false + # @param path [String] The path to the method pin, e.g. 'Class#method' or 'Class.method' + # @return [void] + def pin path + api_map = Solargraph::ApiMap.load_with_cache('.', $stderr) + is_method = path.include?('#') || path.include?('.') + if is_method && options[:stack] + scope, ns, meth = if path.include? '#' + [:instance, *path.split('#', 2)] + else + [:class, *path.split('.', 2)] + end + + # @sg-ignore Wrong argument type for + # Solargraph::ApiMap#get_method_stack: rooted_tag + # expected String, received Array + pins = api_map.get_method_stack(ns, meth, scope: scope) + else + pins = api_map.get_path_pins path + end + # @type [Hash{Symbol => Pin::Base}] + references = {} + pin = pins.first + case pin + when nil + $stderr.puts "Pin not found for path '#{path}'" + exit 1 + when Pin::Namespace + if options[:references] + superclass_tag = api_map.qualify_superclass(pin.return_type.tag) + superclass_pin = api_map.get_path_pins(superclass_tag).first if superclass_tag + references[:superclass] = superclass_pin if superclass_pin + end + end + + pins.each do |pin| + if options[:typify] || options[:probe] + type = ComplexType::UNDEFINED + type = pin.typify(api_map) if options[:typify] + type = pin.probe(api_map) if options[:probe] && type.undefined? + print_type(type) + next + end + + print_pin(pin) + end + references.each do |key, refpin| + puts "\n# #{key.to_s.capitalize}:\n\n" + print_pin(refpin) + end + end + private # @param pin [Solargraph::Pin::Base] @@ -291,5 +352,25 @@ def pin_description pin desc += " (#{pin.location.filename} #{pin.location.range.start.line})" if pin.location desc end + + # @param type [ComplexType] + # @return [void] + def print_type(type) + if options[:rbs] + puts type.to_rbs + else + puts type.rooted_tag + end + end + + # @param pin [Solargraph::Pin::Base] + # @return [void] + def print_pin(pin) + if options[:rbs] + puts pin.to_rbs + else + puts pin.inspect + end + end end end diff --git a/lib/solargraph/source.rb b/lib/solargraph/source.rb index ae5b08d3b..d8e4e2a3f 100644 --- a/lib/solargraph/source.rb +++ b/lib/solargraph/source.rb @@ -15,7 +15,7 @@ class Source include EncodingFixes - # @return [String] + # @return [String, nil] attr_reader :filename # @return [String] diff --git a/lib/solargraph/source/chain.rb b/lib/solargraph/source/chain.rb index c08d04878..f7a03b552 100644 --- a/lib/solargraph/source/chain.rb +++ b/lib/solargraph/source/chain.rb @@ -264,6 +264,8 @@ def infer_from_definitions pins, context, api_map, locals ComplexType::UNDEFINED elsif types.length > 1 # Move nil to the end by convention + + # @param a [ComplexType::UniqueType] sorted = types.flat_map(&:items).sort { |a, _| a.tag == 'nil' ? 1 : 0 } ComplexType.new(sorted.uniq) else diff --git a/lib/solargraph/source/chain/call.rb b/lib/solargraph/source/chain/call.rb index 24d10656d..89a28b0fa 100644 --- a/lib/solargraph/source/chain/call.rb +++ b/lib/solargraph/source/chain/call.rb @@ -98,7 +98,10 @@ def inferred_pins pins, api_map, name_pin, locals match = ol.parameters.any?(&:restarg?) break end - atype = atypes[idx] ||= arg.infer(api_map, Pin::ProxyType.anonymous(name_pin.context, source: :chain), locals) + arg_name_pin = Pin::ProxyType.anonymous(name_pin.context, + gates: name_pin.gates, + source: :chain) + atype = atypes[idx] ||= arg.infer(api_map, arg_name_pin, locals) unless param.compatible_arg?(atype, api_map) || param.restarg? match = false break @@ -266,6 +269,7 @@ def yield_pins api_map, name_pin method_pin = find_method_pin(name_pin) return [] unless method_pin + # @param signature_pin [Pin::Signature] method_pin.signatures.map(&:block).compact.map do |signature_pin| return_type = signature_pin.return_type.qualify(api_map, *name_pin.gates) signature_pin.proxy(return_type) diff --git a/lib/solargraph/source/chain/if.rb b/lib/solargraph/source/chain/if.rb index c14d00ddf..3a7fa0ca9 100644 --- a/lib/solargraph/source/chain/if.rb +++ b/lib/solargraph/source/chain/if.rb @@ -8,7 +8,7 @@ def word '' end - # @param links [::Array] + # @param links [::Array] def initialize links @links = links end diff --git a/lib/solargraph/source/chain/link.rb b/lib/solargraph/source/chain/link.rb index bcd9eb196..344f7affd 100644 --- a/lib/solargraph/source/chain/link.rb +++ b/lib/solargraph/source/chain/link.rb @@ -38,7 +38,7 @@ def constant? # @param api_map [ApiMap] # @param name_pin [Pin::Base] - # @param locals [::Enumerable] + # @param locals [::Array] # @return [::Array] def resolve api_map, name_pin, locals [] diff --git a/lib/solargraph/source/chain/or.rb b/lib/solargraph/source/chain/or.rb index 1e3a70f40..9264d4107 100644 --- a/lib/solargraph/source/chain/or.rb +++ b/lib/solargraph/source/chain/or.rb @@ -8,7 +8,7 @@ def word '' end - # @param links [::Array] + # @param links [::Array] def initialize links @links = links end diff --git a/lib/solargraph/source/encoding_fixes.rb b/lib/solargraph/source/encoding_fixes.rb index 8c5d081b0..2ed70037c 100644 --- a/lib/solargraph/source/encoding_fixes.rb +++ b/lib/solargraph/source/encoding_fixes.rb @@ -1,23 +1,23 @@ -# frozen_string_literal: true - -module Solargraph - class Source - module EncodingFixes - module_function - - # Convert strings to normalized UTF-8. - # - # @param string [String] - # @return [String] - def normalize string - begin - string.dup.force_encoding('UTF-8') - rescue ::Encoding::CompatibilityError, ::Encoding::UndefinedConversionError, ::Encoding::InvalidByteSequenceError => e - # @todo Improve error handling - Solargraph::Logging.logger.warn "Normalize error: #{e.message}" - string - end - end - end - end -end +# frozen_string_literal: true + +module Solargraph + class Source + module EncodingFixes + module_function + + # Convert strings to normalized UTF-8. + # + # @param string [String] + # @return [String] + def normalize string + begin + string.dup.force_encoding('UTF-8') + rescue ::Encoding::CompatibilityError, ::Encoding::UndefinedConversionError, ::Encoding::InvalidByteSequenceError => e + # @todo Improve error handling + Solargraph::Logging.logger.warn "Normalize error: #{e.message}" + string + end + end + end + end +end diff --git a/lib/solargraph/source_map.rb b/lib/solargraph/source_map.rb index d7b6fb4fc..15b747760 100644 --- a/lib/solargraph/source_map.rb +++ b/lib/solargraph/source_map.rb @@ -41,11 +41,13 @@ def initialize source # solargraph-rails is known to use this method to get the document symbols. It should probably be removed. @document_symbols = nil self.convention_pins = conventions_environ.pins + # @type [Hash{Class => Array}] @pin_select_cache = {} end # @generic T # @param klass [Class>] + # # @return [Array>] def pins_by_class klass @pin_select_cache[klass] ||= pin_class_hash.select { |key, _| key <= klass }.values.flatten @@ -171,10 +173,10 @@ def map source private - # @return [Hash{Class => Array}] # @return [Array] attr_writer :convention_pins + # @return [Hash{Class => Array}] def pin_class_hash @pin_class_hash ||= pins.to_set.classify(&:class).transform_values(&:to_a) end diff --git a/lib/solargraph/source_map/mapper.rb b/lib/solargraph/source_map/mapper.rb index 18fdf1f88..5fdcb9fe6 100644 --- a/lib/solargraph/source_map/mapper.rb +++ b/lib/solargraph/source_map/mapper.rb @@ -70,7 +70,6 @@ def closure_at(position) # @param comment [String] # @return [void] def process_comment source_position, comment_position, comment - # @sg-ignore Wrong argument type for String#=~: object expected String::_MatchAgainst, received Regexp return unless comment.encode('UTF-8', invalid: :replace, replace: '?') =~ DIRECTIVE_REGEXP cmnt = remove_inline_comment_hashes(comment) parse = Solargraph::Source.parse_docstring(cmnt) @@ -245,7 +244,6 @@ def remove_inline_comment_hashes comment # @return [void] def process_comment_directives - # @sg-ignore Wrong argument type for String#=~: object expected String::_MatchAgainst, received Regexp return unless @code.encode('UTF-8', invalid: :replace, replace: '?') =~ DIRECTIVE_REGEXP code_lines = @code.lines @source.associated_comments.each do |line, comments| diff --git a/lib/solargraph/type_checker.rb b/lib/solargraph/type_checker.rb index 4600767b5..c2bb6fc64 100644 --- a/lib/solargraph/type_checker.rb +++ b/lib/solargraph/type_checker.rb @@ -21,14 +21,23 @@ class TypeChecker # @return [ApiMap] attr_reader :api_map - # @param filename [String] + # @param filename [String, nil] # @param api_map [ApiMap, nil] - # @param level [Symbol] - def initialize filename, api_map: nil, level: :normal + # @param level [Symbol] Don't complain about anything above this level + # @param workspace [Workspace, nil] Workspace to use for loading + # type checker rules modified by user config + # @param type_checker_rules [Hash{Symbol => Symbol}] Overrides for + # type checker rules - e.g., :report_undefined => :strong + # @param rules [Rules] Type checker rules object + def initialize filename, + api_map: nil, + level: :normal, + workspace: filename ? Workspace.new(File.dirname(filename)) : nil, + rules: workspace ? workspace.rules(level) : Rules.new(level, {}) @filename = filename # @todo Smarter directory resolution @api_map = api_map || Solargraph::ApiMap.load(File.dirname(filename)) - @rules = Rules.new(level) + @rules = rules # @type [Array] @marked_ranges = [] end @@ -195,7 +204,7 @@ def variable_type_tag_problems if pin.return_type.defined? declared = pin.typify(api_map) next if declared.duck_type? - if declared.defined? + if declared.defined? && pin.assignment if rules.validate_tags? inferred = pin.probe(api_map) if inferred.undefined? @@ -216,7 +225,7 @@ def variable_type_tag_problems elsif !pin.is_a?(Pin::Parameter) && !resolved_constant?(pin) result.push Problem.new(pin.location, "Unresolved type #{pin.return_type} for variable #{pin.name}", pin: pin) end - else + elsif pin.assignment inferred = pin.probe(api_map) if inferred.undefined? && declared_externally?(pin) ignored_pins.push pin @@ -420,6 +429,7 @@ def signature_argument_problems_for location, locals, closure_pin, params, argum # @todo Some level (strong, I guess) should require the param here else argtype = argchain.infer(api_map, closure_pin, locals) + argtype = argtype.self_to_type(closure_pin.context) if argtype.defined? && ptype.defined? && !any_types_match?(api_map, ptype, argtype) errors.push Problem.new(location, "Wrong argument type for #{pin.path}: #{par.name} expected #{ptype}, received #{argtype}") return errors @@ -459,8 +469,11 @@ def kwarg_problems_for sig, argchain, api_map, closure_pin, locals, location, pi # @todo Some level (strong, I guess) should require the param here else ptype = data[:qualified] + ptype = ptype.self_to_type(pin.context) unless ptype.undefined? - argtype = argchain.infer(api_map, closure_pin, locals) + # @sg-ignore https://github.com/castwide/solargraph/pull/1127 + argtype = argchain.infer(api_map, closure_pin, locals).self_to_type(closure_pin.context) + # @sg-ignore Unresolved call to defined? if argtype.defined? && ptype && !any_types_match?(api_map, ptype, argtype) result.push Problem.new(location, "Wrong argument type for #{pin.path}: #{par.name} expected #{ptype}, received #{argtype}") end @@ -486,7 +499,9 @@ def kwrestarg_problems_for(api_map, closure_pin, locals, location, pin, params, kwargs.each_pair do |pname, argchain| next unless params.key?(pname.to_s) ptype = params[pname.to_s][:qualified] + ptype = ptype.self_to_type(pin.context) argtype = argchain.infer(api_map, closure_pin, locals) + argtype = argtype.self_to_type(closure_pin.context) if argtype.defined? && ptype && !any_types_match?(api_map, ptype, argtype) result.push Problem.new(location, "Wrong argument type for #{pin.path}: #{pname} expected #{ptype}, received #{argtype}") end @@ -604,7 +619,8 @@ def external? pin # @param pin [Pin::BaseVariable] def declared_externally? pin - return true if pin.assignment.nil? + raise "No assignment found" if pin.assignment.nil? + chain = Solargraph::Parser.chain(pin.assignment, filename) rng = Solargraph::Range.from_node(pin.assignment) closure_pin = source_map.locate_closure_pin(rng.start.line, rng.start.column) diff --git a/lib/solargraph/type_checker/rules.rb b/lib/solargraph/type_checker/rules.rb index a27fcbefa..81a2d4aa3 100644 --- a/lib/solargraph/type_checker/rules.rb +++ b/lib/solargraph/type_checker/rules.rb @@ -20,7 +20,8 @@ class Rules attr_reader :rank # @param level [Symbol] - def initialize level + # @param overrides [Hash{Symbol => Symbol}] + def initialize level, overrides @rank = if LEVELS.key?(level) LEVELS[level] else @@ -28,34 +29,39 @@ def initialize level 0 end @level = LEVELS[LEVELS.values.index(@rank)] + @overrides = overrides end def ignore_all_undefined? - rank < LEVELS[:strict] + !report_undefined? + end + + def report_undefined? + report?(:report_undefined, :strict) end def validate_consts? - rank >= LEVELS[:strict] + report?(:validate_consts, :strict) end def validate_calls? - rank >= LEVELS[:strict] + report?(:validate_calls, :strict) end def require_type_tags? - rank >= LEVELS[:strong] + report?(:validate_type_tags, :strong) end def must_tag_or_infer? - rank > LEVELS[:typed] + report?(:must_tag_or_infer, :strict) end def validate_tags? - rank > LEVELS[:normal] + report?(:validate_tags, :typed) end def require_all_return_types_match_inferred? - rank >= LEVELS[:alpha] + report?(:require_all_return_types_match_inferred, :alpha) end # We keep this at strong because if you added an @ sg-ignore to @@ -63,7 +69,15 @@ def require_all_return_types_match_inferred? # get a false positive - we don't run stronger level checks than # requested for performance reasons def validate_sg_ignores? - rank >= LEVELS[:strong] + report?(:validate_sg_ignores, :strong) + end + + private + + # @param type [Symbol] + # @param level [Symbol] + def report?(type, level) + rank >= LEVELS[@overrides.fetch(type, level)] end end end diff --git a/lib/solargraph/version.rb b/lib/solargraph/version.rb index 2c2219ecb..11dd7e1ff 100755 --- a/lib/solargraph/version.rb +++ b/lib/solargraph/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module Solargraph - VERSION = '0.57.0' + VERSION = '0.58.2' end diff --git a/lib/solargraph/workspace.rb b/lib/solargraph/workspace.rb index aa885e2f5..837d843b8 100644 --- a/lib/solargraph/workspace.rb +++ b/lib/solargraph/workspace.rb @@ -116,6 +116,12 @@ def resolve_require require gemspecs.resolve_require(require) end + # @param level [Symbol] + # @return [TypeChecker::Rules] + def rules(level) + @rules ||= TypeChecker::Rules.new(level, config.type_checker_rules) + end + # Merge the source. A merge will update the existing source for the file # or add it to the sources if the workspace is configured to include it. # The source is ignored if the configuration excludes it. diff --git a/lib/solargraph/workspace/config.rb b/lib/solargraph/workspace/config.rb index d1e6c27b5..ac9f36739 100644 --- a/lib/solargraph/workspace/config.rb +++ b/lib/solargraph/workspace/config.rb @@ -63,6 +63,7 @@ def calculated # namespace. It's typically used to identify available DSLs. # # @return [Array] + # @sg-ignore Need to validate config def domains raw_data['domains'] end @@ -70,6 +71,7 @@ def domains # An array of required paths to add to the workspace. # # @return [Array] + # @sg-ignore Need to validate config def required raw_data['require'] end @@ -83,6 +85,7 @@ def require_paths # An array of reporters to use for diagnostics. # + # @sg-ignore Need to validate config # @return [Array] def reporters raw_data['reporters'] @@ -90,6 +93,7 @@ def reporters # A hash of options supported by the formatter # + # @sg-ignore Need to validate config # @return [Hash] def formatter raw_data['formatter'] @@ -97,6 +101,7 @@ def formatter # An array of plugins to require. # + # @sg-ignore Need to validate config # @return [Array] def plugins raw_data['plugins'] @@ -104,11 +109,21 @@ def plugins # The maximum number of files to parse from the workspace. # + # @sg-ignore Need to validate config # @return [Integer] def max_files raw_data['max_files'] end + # @return [Hash{Symbol => Symbol}] + def type_checker_rules + # @type [Hash{String => String}] + raw_rules = raw_data.fetch('type_checker', {}).fetch('rules', {}) + raw_rules.to_h do |k, v| + [k.to_sym, v.to_sym] + end + end + private # @return [String] @@ -162,6 +177,9 @@ def default_config 'extra_args' =>[] } }, + 'type_checker' => { + 'rules' => { } + }, 'require_paths' => [], 'plugins' => [], 'max_files' => MAX_FILES diff --git a/lib/solargraph/workspace/require_paths.rb b/lib/solargraph/workspace/require_paths.rb index 67adae9e6..c8eea161b 100644 --- a/lib/solargraph/workspace/require_paths.rb +++ b/lib/solargraph/workspace/require_paths.rb @@ -76,7 +76,6 @@ def require_path_from_gemspec_file gemspec_file_path "spec = eval(File.read('#{gemspec_file_path}'), TOPLEVEL_BINDING, '#{gemspec_file_path}'); " \ 'return unless Gem::Specification === spec; ' \ 'puts({name: spec.name, paths: spec.require_paths}.to_json)'] - # @sg-ignore Unresolved call to capture3 on Module o, e, s = Open3.capture3(*cmd) if s.success? begin diff --git a/lib/solargraph/yard_map/mapper/to_method.rb b/lib/solargraph/yard_map/mapper/to_method.rb index d8e3b8b43..0838b9f4f 100644 --- a/lib/solargraph/yard_map/mapper/to_method.rb +++ b/lib/solargraph/yard_map/mapper/to_method.rb @@ -11,7 +11,7 @@ module ToMethod ["Rails::Engine", :class, "find_root_with_flag"] => :public } - # @param code_object [YARD::CodeObjects::Base] + # @param code_object [YARD::CodeObjects::MethodObject] # @param name [String, nil] # @param scope [Symbol, nil] # @param visibility [Symbol, nil] @@ -85,6 +85,7 @@ def get_parameters code_object, location, comments, pin # HACK: Skip `nil` and `self` parameters that are sometimes emitted # for methods defined in C # See https://github.com/castwide/solargraph/issues/345 + # @sg-ignore https://github.com/castwide/solargraph/pull/1114 code_object.parameters.select { |a| a[0] && a[0] != 'self' }.map do |a| Solargraph::Pin::Parameter.new( location: location, diff --git a/lib/solargraph/yard_map/to_method.rb b/lib/solargraph/yard_map/to_method.rb index 3ecb7ac26..010db89a5 100644 --- a/lib/solargraph/yard_map/to_method.rb +++ b/lib/solargraph/yard_map/to_method.rb @@ -15,6 +15,7 @@ def get_parameters code_object, location, comments # HACK: Skip `nil` and `self` parameters that are sometimes emitted # for methods defined in C # See https://github.com/castwide/solargraph/issues/345 + # @sg-ignore https://github.com/castwide/solargraph/pull/1114 code_object.parameters.select { |a| a[0] && a[0] != 'self' }.map do |a| Solargraph::Pin::Parameter.new( location: location, @@ -57,7 +58,7 @@ def arg_type a include Helpers - # @param code_object [YARD::CodeObjects::Base] + # @param code_object [YARD::CodeObjects::MethodObject] # @param name [String, nil] # @param scope [Symbol, nil] # @param visibility [Symbol, nil] diff --git a/lib/solargraph/yardoc.rb b/lib/solargraph/yardoc.rb index 50f212f13..43f707942 100644 --- a/lib/solargraph/yardoc.rb +++ b/lib/solargraph/yardoc.rb @@ -23,7 +23,11 @@ def build_docs gem_yardoc_path, yard_plugins, gemspec yard_plugins.each { |plugin| cmd << " --plugin #{plugin}" } Solargraph.logger.debug { "Running: #{cmd}" } # @todo set these up to run in parallel - unless File.exist?(gemspec.gem_dir) + unless Dir.exist? gemspec.gem_dir + # Can happen in at least some (old?) RubyGems versions when we + # have a gemspec describing a standard library like bundler. + # + # https://github.com/apiology/solargraph/actions/runs/17650140201/job/50158676842?pr=10 Solargraph.logger.info { "Bad info from gemspec - #{gemspec.gem_dir} does not exist" } return end diff --git a/sig/shims/ast/0/node.rbs b/rbs/shims/ast/0/node.rbs similarity index 100% rename from sig/shims/ast/0/node.rbs rename to rbs/shims/ast/0/node.rbs diff --git a/sig/shims/ast/2.4/.rbs_meta.yaml b/rbs/shims/ast/2.4/.rbs_meta.yaml similarity index 100% rename from sig/shims/ast/2.4/.rbs_meta.yaml rename to rbs/shims/ast/2.4/.rbs_meta.yaml diff --git a/sig/shims/ast/2.4/ast.rbs b/rbs/shims/ast/2.4/ast.rbs similarity index 100% rename from sig/shims/ast/2.4/ast.rbs rename to rbs/shims/ast/2.4/ast.rbs diff --git a/sig/shims/parser/3.2.0.1/builders/default.rbs b/rbs/shims/parser/3.2.0.1/builders/default.rbs similarity index 100% rename from sig/shims/parser/3.2.0.1/builders/default.rbs rename to rbs/shims/parser/3.2.0.1/builders/default.rbs diff --git a/sig/shims/parser/3.2.0.1/manifest.yaml b/rbs/shims/parser/3.2.0.1/manifest.yaml similarity index 100% rename from sig/shims/parser/3.2.0.1/manifest.yaml rename to rbs/shims/parser/3.2.0.1/manifest.yaml diff --git a/sig/shims/parser/3.2.0.1/parser.rbs b/rbs/shims/parser/3.2.0.1/parser.rbs similarity index 100% rename from sig/shims/parser/3.2.0.1/parser.rbs rename to rbs/shims/parser/3.2.0.1/parser.rbs diff --git a/sig/shims/parser/3.2.0.1/polyfill.rbs b/rbs/shims/parser/3.2.0.1/polyfill.rbs similarity index 100% rename from sig/shims/parser/3.2.0.1/polyfill.rbs rename to rbs/shims/parser/3.2.0.1/polyfill.rbs diff --git a/sig/shims/thor/1.2.0.1/.rbs_meta.yaml b/rbs/shims/thor/1.2.0.1/.rbs_meta.yaml similarity index 100% rename from sig/shims/thor/1.2.0.1/.rbs_meta.yaml rename to rbs/shims/thor/1.2.0.1/.rbs_meta.yaml diff --git a/sig/shims/thor/1.2.0.1/manifest.yaml b/rbs/shims/thor/1.2.0.1/manifest.yaml similarity index 100% rename from sig/shims/thor/1.2.0.1/manifest.yaml rename to rbs/shims/thor/1.2.0.1/manifest.yaml diff --git a/sig/shims/thor/1.2.0.1/thor.rbs b/rbs/shims/thor/1.2.0.1/thor.rbs similarity index 100% rename from sig/shims/thor/1.2.0.1/thor.rbs rename to rbs/shims/thor/1.2.0.1/thor.rbs diff --git a/rbs_collection.yaml b/rbs_collection.yaml index 898239cac..d94e1c896 100644 --- a/rbs_collection.yaml +++ b/rbs_collection.yaml @@ -2,7 +2,7 @@ sources: - type: local name: shims - path: sig/shims + path: rbs/shims - type: git name: ruby/gem_rbs_collection diff --git a/solargraph.gemspec b/solargraph.gemspec index 5bf452aeb..3e8acf27f 100755 --- a/solargraph.gemspec +++ b/solargraph.gemspec @@ -2,6 +2,7 @@ $LOAD_PATH.unshift File.dirname(__FILE__) + '/lib' require 'solargraph/version' require 'date' +# @param s [Gem::Specification] Gem::Specification.new do |s| s.name = 'solargraph' s.version = Solargraph::VERSION @@ -30,7 +31,7 @@ Gem::Specification.new do |s| s.add_runtime_dependency 'ast', '~> 2.4.3' s.add_runtime_dependency 'backport', '~> 1.2' s.add_runtime_dependency 'benchmark', '~> 0.4' - s.add_runtime_dependency 'bundler', '>= 2' + s.add_runtime_dependency 'bundler', '>= 2.0' s.add_runtime_dependency 'diff-lcs', '~> 1.4' s.add_runtime_dependency 'jaro_winkler', '~> 1.6', '>= 1.6.1' s.add_runtime_dependency 'kramdown', '~> 2.3' diff --git a/spec/api_map/constants_spec.rb b/spec/api_map/constants_spec.rb index c0460e79a..833a928cf 100644 --- a/spec/api_map/constants_spec.rb +++ b/spec/api_map/constants_spec.rb @@ -20,6 +20,31 @@ module Quuz expect(resolved).to eq('Foo::Bar') end + it 'resolves constants in includes' do + code = %( + module A + module Parser + module C + # @return [String] + def baz; "abc"; end + end + + B = C + end + + class Foo + include Parser::B + + # @return [String] + def bar + baz + end + end + end) + checker = Solargraph::TypeChecker.load_string(code, 'test.rb', :strong) + expect(checker.problems.map(&:message)).to be_empty + end + it 'resolves straightforward mixins' do source_map = Solargraph::SourceMap.load_string(%( module Bar diff --git a/spec/convention/activesupport_concern_spec.rb b/spec/convention/activesupport_concern_spec.rb index e75e8749c..b58cd6584 100644 --- a/spec/convention/activesupport_concern_spec.rb +++ b/spec/convention/activesupport_concern_spec.rb @@ -96,4 +96,100 @@ def self.my_method; end expect(pins.first.typify(api_map).map(&:tag)).to include('Numeric') end end + + context 'with RBS to digest' do + # create a temporary directory with the scope of the spec + around do |example| + require 'tmpdir' + Dir.mktmpdir("rspec-solargraph-") do |dir| + @temp_dir = dir + example.run + end + end + + let(:conversions) do + loader = RBS::EnvironmentLoader.new(core_root: nil, repository: RBS::Repository.new(no_stdlib: false)) + loader.add(path: Pathname(temp_dir)) + Solargraph::RbsMap::Conversions.new(loader: loader) + end + + let(:api_map) { Solargraph::ApiMap.new } + + before do + rbs_file = File.join(temp_dir, 'foo.rbs') + File.write(rbs_file, rbs) + api_map.index conversions.pins + end + + attr_reader :temp_dir + + context 'with Inheritance module in ActiveRecord' do + # See + # https://github.com/ruby/gem_rbs_collection/blob/main/gems/activerecord/6.0/activerecord-generated.rbs + # for full RBS + subject(:method_pins) { api_map.get_method_stack('MyActiveRecord::Base', 'abstract_class', scope: :class) } + + let(:rbs) do + <<~RBS + module MyActiveRecord + module Inheritance + extend ActiveSupport::Concern + + module ClassMethods + attr_accessor abstract_class: untyped + end + end + end + + module MyActiveRecord + class Base + include Inheritance + end + end + RBS + end + + it { should_not be_empty } + + it "has one item" do + expect(method_pins.size).to eq(1) + end + + it "is a Pin::Method" do + expect(method_pins.first).to be_a(Solargraph::Pin::Method) + end + end + + # https://github.com/castwide/solargraph/issues/1042 + context 'with Hash superclass with untyped value and alias' do + let(:rbs) do + <<~RBS + class Sub < Hash[Symbol, untyped] + alias meth_alias [] + end + RBS + end + + let(:sup_method_stack) { api_map.get_method_stack('Hash{Symbol => undefined}', '[]', scope: :instance) } + + let(:sub_alias_stack) { api_map.get_method_stack('Sub', 'meth_alias', scope: :instance) } + + it 'does not crash looking at superclass method' do + expect { sup_method_stack }.not_to raise_error + end + + it 'does not crash looking at alias' do + expect { sub_alias_stack }.not_to raise_error + end + + it 'finds superclass method pin return type' do + expect(sup_method_stack.map(&:return_type).map(&:rooted_tags).uniq).to eq(['undefined']) + end + + it 'finds superclass method pin parameter type' do + expect(sup_method_stack.flat_map(&:signatures).flat_map(&:parameters).map(&:return_type).map(&:rooted_tags) + .uniq).to eq(['Symbol']) + end + end + end end diff --git a/spec/gem_pins_spec.rb b/spec/gem_pins_spec.rb index 944afd331..ba48d429b 100644 --- a/spec/gem_pins_spec.rb +++ b/spec/gem_pins_spec.rb @@ -46,4 +46,9 @@ expect(pin.location.filename).to end_with('task.rb') end end + + it 'does not error out when handed incorrect gemspec' do + gemspec = instance_double(Gem::Specification, name: 'foo', version: '1.0', gem_dir: '/not-there') + expect { Solargraph::GemPins.build_yard_pins([], gemspec) }.not_to raise_error + end end diff --git a/spec/pin/parameter_spec.rb b/spec/pin/parameter_spec.rb index 082ec54c6..14c39f3fe 100644 --- a/spec/pin/parameter_spec.rb +++ b/spec/pin/parameter_spec.rb @@ -473,5 +473,33 @@ def self.foo bar: 'bar' type = pin.probe(api_map) expect(type.simple_tags).to eq('String') end + + it 'handles a relative type name case' do + source = Solargraph::Source.load_string(%( + module A + module B + class Method + end + end + end + + module A + module B + class C < B::Method + # @param alt [Method] + # @return [B::Method, nil] + def resolve_method alt + alt + end + end + end + end + ), 'test.rb') + api_map = Solargraph::ApiMap.new + api_map.map(source) + + clip = api_map.clip_at('test.rb', [14, 16]) + expect(clip.infer.rooted_tags).to eq('::A::B::Method') + end end end diff --git a/spec/position_spec.rb b/spec/position_spec.rb index fa30cf7d9..e8dab1960 100644 --- a/spec/position_spec.rb +++ b/spec/position_spec.rb @@ -12,9 +12,38 @@ expect(orig).to be(norm) end + it 'finds offset from position' do + text = "\n class Foo\n def bar baz, boo = 'boo'\n end\n end\n " + expect(Solargraph::Position.to_offset(text, Solargraph::Position.new(0, 0))).to eq(0) + expect(Solargraph::Position.to_offset(text, Solargraph::Position.new(0, 4))).to eq(4) + expect(Solargraph::Position.to_offset(text, Solargraph::Position.new(2, 12))).to eq(29) + expect(Solargraph::Position.to_offset(text, Solargraph::Position.new(2, 27))).to eq(44) + expect(Solargraph::Position.to_offset(text, Solargraph::Position.new(3, 8))).to eq(58) + end + + it 'constructs position from offset' do + text = "\n class Foo\n def bar baz, boo = 'boo'\n end\n end\n " + expect(Solargraph::Position.from_offset(text, 0)).to eq(Solargraph::Position.new(0, 0)) + expect(Solargraph::Position.from_offset(text, 4)).to eq(Solargraph::Position.new(1, 3)) + expect(Solargraph::Position.from_offset(text, 29)).to eq(Solargraph::Position.new(2, 12)) + expect(Solargraph::Position.from_offset(text, 44)).to eq(Solargraph::Position.new(2, 27)) + end + it "raises an error for objects that cannot be normalized" do expect { Solargraph::Position.normalize('0, 1') }.to raise_error(ArgumentError) end + + it 'avoids fencepost errors' do + text = " class Foo\n def bar baz, boo = 'boo'\n end\n end\n " + offset = Solargraph::Position.to_offset(text, Solargraph::Position.new(3, 6)) + expect(offset).to eq(67) + end + + it 'avoids fencepost errors with multiple blank lines' do + text = " class Foo\n def bar baz, boo = 'boo'\n\n end\n end\n " + offset = Solargraph::Position.to_offset(text, Solargraph::Position.new(4, 6)) + expect(offset).to eq(68) + end end diff --git a/spec/rbs_map/stdlib_map_spec.rb b/spec/rbs_map/stdlib_map_spec.rb index bc2a134c2..03f0b547f 100644 --- a/spec/rbs_map/stdlib_map_spec.rb +++ b/spec/rbs_map/stdlib_map_spec.rb @@ -5,15 +5,6 @@ expect(pin).to be end - it 'adds overrides' do - # @todo Unlike the YardMap stdlib, the RBS version reports the correct - # return type for Pathname#Join. Delete or modify this test depending - # on how StdLibFills will be handled going forward. - rbs_map = Solargraph::RbsMap::StdlibMap.load('pathname') - pin = rbs_map.path_pin('Pathname#join') - expect(pin.signatures.first.return_type.tag).to eq('Pathname') - end - it 'maps YAML' do rbs_map = Solargraph::RbsMap::StdlibMap.load('yaml') pin = rbs_map.path_pin('YAML') diff --git a/spec/shell_spec.rb b/spec/shell_spec.rb index f5eeb5734..aca90eb7e 100644 --- a/spec/shell_spec.rb +++ b/spec/shell_spec.rb @@ -5,6 +5,7 @@ describe Solargraph::Shell do let(:shell) { described_class.new } + let(:temp_dir) { Dir.mktmpdir } before do @@ -173,4 +174,144 @@ def bundle_exec(*cmd) end end end + + # @type cmd [Array] + # @return [String] + def bundle_exec(*cmd) + # run the command in the temporary directory with bundle exec + Bundler.with_unbundled_env do + output, status = Open3.capture2e("bundle exec #{cmd.join(' ')}") + expect(status.success?).to be(true), "Command failed: #{output}" + output + end + end + + describe 'pin on a class' do + let(:api_map) { instance_double(Solargraph::ApiMap) } + let(:string_pin) { instance_double(Solargraph::Pin::Namespace, name: 'String') } + + before do + allow(Solargraph::ApiMap).to receive(:load_with_cache).and_return(api_map) + allow(Solargraph::Pin::Namespace).to receive(:===).with(string_pin).and_return(true) + allow(string_pin).to receive(:return_type).and_return(Solargraph::ComplexType.parse('String')) + allow(api_map).to receive(:get_path_pins).with('String').and_return([string_pin]) + end + + context 'with --references option' do + let(:object_pin) { instance_double(Solargraph::Pin::Namespace, name: 'Object') } + + before do + allow(Solargraph::Pin::Namespace).to receive(:===).with(object_pin).and_return(true) + allow(api_map).to receive(:qualify_superclass).with('String').and_return('Object') + allow(api_map).to receive(:get_path_pins).with('Object').and_return([object_pin]) + end + + it 'prints a pin with info' do + out = capture_both do + shell.options = { references: true } + shell.pin('String') + end + expect(out).to include('# Superclass:') + end + end + end + + describe 'pin on a method' do + let(:api_map) { instance_double(Solargraph::ApiMap) } + let(:to_s_pin) { instance_double(Solargraph::Pin::Method, return_type: Solargraph::ComplexType.parse('String')) } + + before do + allow(Solargraph::Pin::Method).to receive(:===).with(to_s_pin).and_return(true) + allow(Solargraph::ApiMap).to receive(:load_with_cache).and_return(api_map) + allow(api_map).to receive(:get_path_pins).with('String#to_s').and_return([to_s_pin]) + end + + context 'with no options' do + it 'prints a pin' do + allow(to_s_pin).to receive(:inspect).and_return('pin inspect result') + + out = capture_both { shell.pin('String#to_s') } + + expect(out).to eq("pin inspect result\n") + end + end + + context 'with --rbs option' do + it 'prints a pin with RBS type' do + allow(to_s_pin).to receive(:to_rbs).and_return('pin RBS result') + + out = capture_both do + shell.options = { rbs: true } + shell.pin('String#to_s') + end + expect(out).to eq("pin RBS result\n") + end + end + + context 'with --stack option' do + it 'prints a pin using stack results' do + allow(to_s_pin).to receive(:to_rbs).and_return('pin RBS result') + + allow(api_map).to receive(:get_method_stack).and_return([to_s_pin]) + capture_both do + shell.options = { stack: true } + shell.pin('String#to_s') + end + expect(api_map).to have_received(:get_method_stack).with('String', 'to_s', scope: :instance) + end + + it 'prints a static pin using stack results' do + # allow(to_s_pin).to receive(:to_rbs).and_return('pin RBS result') + string_new_pin = instance_double(Solargraph::Pin::Method, return_type: Solargraph::ComplexType.parse('String')) + + allow(api_map).to receive(:get_method_stack).with('String', 'new', scope: :class).and_return([string_new_pin]) + allow(Solargraph::Pin::Method).to receive(:===).with(string_new_pin).and_return(true) + allow(api_map).to receive(:get_path_pins).with('String.new').and_return([string_new_pin]) + capture_both do + shell.options = { stack: true } + shell.pin('String.new') + end + expect(api_map).to have_received(:get_method_stack).with('String', 'new', scope: :class) + end + end + + context 'with --typify option' do + it 'prints a pin with typify type' do + allow(to_s_pin).to receive(:typify).and_return(Solargraph::ComplexType.parse('::String')) + + out = capture_both do + shell.options = { typify: true } + shell.pin('String#to_s') + end + expect(out).to eq("::String\n") + end + end + + context 'with --typify --rbs options' do + it 'prints a pin with typify type' do + allow(to_s_pin).to receive(:typify).and_return(Solargraph::ComplexType.parse('::String')) + + out = capture_both do + shell.options = { typify: true, rbs: true } + shell.pin('String#to_s') + end + expect(out).to eq("::String\n") + end + end + + context 'with no pin' do + it 'prints error' do + allow(api_map).to receive(:get_path_pins).with('Not#found').and_return([]) + allow(Solargraph::Pin::Method).to receive(:===).with(nil).and_return(false) + + out = capture_both do + shell.options = {} + shell.pin('Not#found') + rescue SystemExit + # Ignore the SystemExit raised by the shell when no pin is found + end + expect(out).to include("Pin not found for path 'Not#found'") + end + end + end end diff --git a/spec/source/chain/call_spec.rb b/spec/source/chain/call_spec.rb index 8b67a3c66..3725686a7 100644 --- a/spec/source/chain/call_spec.rb +++ b/spec/source/chain/call_spec.rb @@ -627,4 +627,41 @@ def bl clip = api_map.clip_at('test.rb', [3, 8]) expect(clip.infer.rooted_tags).to eq('::String') end + + it 'sends proper gates in ProxyType' do + source = Solargraph::Source.load_string(%( + module Foo + module Bar + class Symbol + end + end + end + + module Foo + module Baz + class Quux + # @return [void] + def foo + s = objects_by_class(Bar::Symbol) + s + end + + # @generic T + # @param klass [Class>] + # @return [Set>] + def objects_by_class klass + # @type [Set>] + s = Set.new + s + end + end + end + end + ), 'test.rb') + api_map = Solargraph::ApiMap.new + api_map.map source + + clip = api_map.clip_at('test.rb', [14, 14]) + expect(clip.infer.rooted_tags).to eq('::Set<::Foo::Bar::Symbol>') + end end diff --git a/spec/type_checker/levels/strong_spec.rb b/spec/type_checker/levels/strong_spec.rb index 970435dc3..7eeef1e96 100644 --- a/spec/type_checker/levels/strong_spec.rb +++ b/spec/type_checker/levels/strong_spec.rb @@ -4,6 +4,21 @@ def type_checker(code) Solargraph::TypeChecker.load_string(code, 'test.rb', :strong) end + it 'provides nil checking on calls from parameters without assignments' do + pending('https://github.com/castwide/solargraph/pull/1127') + + checker = type_checker(%( + # @param baz [String, nil] + # + # @return [String] + def quux(baz) + baz.upcase # ERROR: Unresolved call to upcase on String, nil + end + )) + expect(checker.problems.map(&:message)).to eq(['#quux return type could not be inferred', + 'Unresolved call to upcase on String, nil']) + end + it 'does not complain on array dereference' do checker = type_checker(%( # @param idx [Integer, nil] an index @@ -97,6 +112,29 @@ def bar expect(checker.problems.map(&:message)).to include('Call to #foo is missing keyword argument b') end + it 'understands complex use of other' do + checker = type_checker(%( + class A + # @param other [self] + # + # @return [void] + def foo other; end + + # @param other [self] + # + # @return [void] + def bar(other); end + end + + class B < A + def bar(other) + foo(other) + end + end + )) + expect(checker.problems.map(&:message)).to be_empty + end + it 'calls out type issues even when keyword issues are there' do pending('fixes to arg vs param checking algorithm') @@ -273,6 +311,43 @@ def meth arg expect(checker.problems).to be_empty end + context 'with class name available in more than one gate' do + let(:checker) do + type_checker(%( + module Foo + module Bar + class Symbol + end + end + end + + module Foo + module Baz + class Quux + # @return [void] + def foo + objects_by_class(Bar::Symbol) + end + + # @generic T + # @param klass [Class>] + # @return [Set>] + def objects_by_class klass + # @type [Set>] + s = Set.new + s + end + end + end + end + )) + end + + it 'resolves class name correctly in generic resolution' do + expect(checker.problems.map(&:message)).to be_empty + end + end + it 'resolves constants inside modules inside classes' do checker = type_checker(%( class Bar diff --git a/spec/type_checker/rules_spec.rb b/spec/type_checker/rules_spec.rb index e665e43a8..ded5302fa 100644 --- a/spec/type_checker/rules_spec.rb +++ b/spec/type_checker/rules_spec.rb @@ -1,6 +1,6 @@ describe Solargraph::TypeChecker::Rules do it 'sets normal rules' do - rules = Solargraph::TypeChecker::Rules.new(:normal) + rules = Solargraph::TypeChecker::Rules.new(:normal, {}) expect(rules.ignore_all_undefined?).to be(true) expect(rules.must_tag_or_infer?).to be(false) expect(rules.require_type_tags?).to be(false) @@ -9,7 +9,7 @@ end it 'sets typed rules' do - rules = Solargraph::TypeChecker::Rules.new(:typed) + rules = Solargraph::TypeChecker::Rules.new(:typed, {}) expect(rules.ignore_all_undefined?).to be(true) expect(rules.must_tag_or_infer?).to be(false) expect(rules.require_type_tags?).to be(false) @@ -18,7 +18,7 @@ end it 'sets strict rules' do - rules = Solargraph::TypeChecker::Rules.new(:strict) + rules = Solargraph::TypeChecker::Rules.new(:strict, {}) expect(rules.ignore_all_undefined?).to be(false) expect(rules.must_tag_or_infer?).to be(true) expect(rules.require_type_tags?).to be(false) @@ -27,7 +27,7 @@ end it 'sets strong rules' do - rules = Solargraph::TypeChecker::Rules.new(:strong) + rules = Solargraph::TypeChecker::Rules.new(:strong, {}) expect(rules.ignore_all_undefined?).to be(false) expect(rules.must_tag_or_infer?).to be(true) expect(rules.require_type_tags?).to be(true) diff --git a/spec/yardoc_spec.rb b/spec/yardoc_spec.rb index 6e7171afe..6cd575de0 100644 --- a/spec/yardoc_spec.rb +++ b/spec/yardoc_spec.rb @@ -104,7 +104,7 @@ described_class.build_docs(gem_yardoc_path, [], gemspec) - expect(called_with[0]['BUNDLE_GEMFILE']).to start_with('/') + expect(called_with[0]['BUNDLE_GEMFILE']).to eq(File.absolute_path('Gemfile')) end end end From 9e228a6f71544f403fbb43c96331ea837e8f0cd0 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Tue, 27 Jan 2026 11:36:27 -0500 Subject: [PATCH 376/400] Merge in master branch --- lib/solargraph/library.rb | 1 + lib/solargraph/page.rb | 2 ++ 2 files changed, 3 insertions(+) diff --git a/lib/solargraph/library.rb b/lib/solargraph/library.rb index 2c21e392f..daf63938c 100644 --- a/lib/solargraph/library.rb +++ b/lib/solargraph/library.rb @@ -517,6 +517,7 @@ def find_external_requires source_map # return if new_set == source_map_external_require_hash[source_map.filename] _filenames = nil filenames = ->{ _filenames ||= workspace.filenames.to_set } + # @sg-ignore Need to add a nil check here source_map_external_require_hash[source_map.filename] = new_set.reject do |path| workspace.require_paths.any? do |base| full = File.join(base, path) diff --git a/lib/solargraph/page.rb b/lib/solargraph/page.rb index 12782da90..e2e6a2d0f 100644 --- a/lib/solargraph/page.rb +++ b/lib/solargraph/page.rb @@ -35,7 +35,9 @@ def htmlify text # @param text [String] # @return [String] + # @sg-ignore Solargraph::Page::Binder#escape return type could not be inferred def escape text + # @sg-ignore Unresolved call to escapeHTML on Class CGI.escapeHTML(text) end From 317ca569d1bcd9c49f7f414c84fcede801b9c57c Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Tue, 27 Jan 2026 11:59:51 -0500 Subject: [PATCH 377/400] Fix merge --- spec/gem_pins_spec.rb | 5 ----- 1 file changed, 5 deletions(-) diff --git a/spec/gem_pins_spec.rb b/spec/gem_pins_spec.rb index ba48d429b..944afd331 100644 --- a/spec/gem_pins_spec.rb +++ b/spec/gem_pins_spec.rb @@ -46,9 +46,4 @@ expect(pin.location.filename).to end_with('task.rb') end end - - it 'does not error out when handed incorrect gemspec' do - gemspec = instance_double(Gem::Specification, name: 'foo', version: '1.0', gem_dir: '/not-there') - expect { Solargraph::GemPins.build_yard_pins([], gemspec) }.not_to raise_error - end end From d395c5fbdb30fec2b373759ed99e467dadcd14ae Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Tue, 27 Jan 2026 13:06:50 -0500 Subject: [PATCH 378/400] Fix merge --- lib/solargraph/doc_map.rb | 216 -------------------------------------- 1 file changed, 216 deletions(-) diff --git a/lib/solargraph/doc_map.rb b/lib/solargraph/doc_map.rb index 36d148841..cba40fc5c 100644 --- a/lib/solargraph/doc_map.rb +++ b/lib/solargraph/doc_map.rb @@ -173,170 +173,6 @@ def inspect self.class.inspect end - # @return [Hash{String => Gem::Specification}] - def preference_map - @preference_map ||= preferences.to_h { |gemspec| [gemspec.name, gemspec] } - end - - # @param gemspec [Gem::Specification] - # @return [Array, nil] - def deserialize_yard_pin_cache gemspec - if yard_pins_in_memory.key?([gemspec.name, gemspec.version]) - return yard_pins_in_memory[[gemspec.name, gemspec.version]] - end - - cached = PinCache.deserialize_yard_gem(gemspec) - if cached - logger.info { "Loaded #{cached.length} cached YARD pins from #{gemspec.name}:#{gemspec.version}" } - yard_pins_in_memory[[gemspec.name, gemspec.version]] = cached - cached - else - logger.debug "No YARD pin cache for #{gemspec.name}:#{gemspec.version}" - @uncached_yard_gemspecs.push gemspec - nil - end - end - - # @param gemspec [Gem::Specification] - # @return [void] - def deserialize_combined_pin_cache(gemspec) - unless combined_pins_in_memory[[gemspec.name, gemspec.version]].nil? - return combined_pins_in_memory[[gemspec.name, gemspec.version]] - end - - rbs_map = RbsMap.from_gemspec(gemspec, rbs_collection_path, rbs_collection_config_path) - rbs_version_cache_key = rbs_map.cache_key - - cached = PinCache.deserialize_combined_gem(gemspec, rbs_version_cache_key) - if cached - logger.info { "Loaded #{cached.length} cached YARD pins from #{gemspec.name}:#{gemspec.version}" } - combined_pins_in_memory[[gemspec.name, gemspec.version]] = cached - return combined_pins_in_memory[[gemspec.name, gemspec.version]] - end - - rbs_collection_pins = deserialize_rbs_collection_cache gemspec, rbs_version_cache_key - - yard_pins = deserialize_yard_pin_cache gemspec - - if !rbs_collection_pins.nil? && !yard_pins.nil? - logger.debug { "Combining pins for #{gemspec.name}:#{gemspec.version}" } - combined_pins = GemPins.combine(yard_pins, rbs_collection_pins) - PinCache.serialize_combined_gem(gemspec, rbs_version_cache_key, combined_pins) - combined_pins_in_memory[[gemspec.name, gemspec.version]] = combined_pins - logger.info { "Generated #{combined_pins_in_memory[[gemspec.name, gemspec.version]].length} combined pins for #{gemspec.name} #{gemspec.version}" } - return combined_pins - end - - if !yard_pins.nil? - logger.debug { "Using only YARD pins for #{gemspec.name}:#{gemspec.version}" } - combined_pins_in_memory[[gemspec.name, gemspec.version]] = yard_pins - return combined_pins_in_memory[[gemspec.name, gemspec.version]] - elsif !rbs_collection_pins.nil? - logger.debug { "Using only RBS collection pins for #{gemspec.name}:#{gemspec.version}" } - combined_pins_in_memory[[gemspec.name, gemspec.version]] = rbs_collection_pins - return combined_pins_in_memory[[gemspec.name, gemspec.version]] - else - logger.debug { "Pins not yet cached for #{gemspec.name}:#{gemspec.version}" } - return nil - end - end - - # @param path [String] require path that might be in the RBS stdlib collection - # @return [void] - def deserialize_stdlib_rbs_map path - map = RbsMap::StdlibMap.load(path) - if map.resolved? - logger.debug { "Loading stdlib pins for #{path}" } - @pins.concat map.pins - logger.debug { "Loaded #{map.pins.length} stdlib pins for #{path}" } - map.pins - else - # @todo Temporarily ignoring unresolved `require 'set'` - logger.debug { "Require path #{path} could not be resolved in RBS" } unless path == 'set' - nil - end - end - - # @param gemspec [Gem::Specification] - # @param rbs_version_cache_key [String] - # @return [Array, nil] - def deserialize_rbs_collection_cache gemspec, rbs_version_cache_key - return if rbs_collection_pins_in_memory.key?([gemspec, rbs_version_cache_key]) - cached = PinCache.deserialize_rbs_collection_gem(gemspec, rbs_version_cache_key) - if cached - logger.info { "Loaded #{cached.length} pins from RBS collection cache for #{gemspec.name}:#{gemspec.version}" } unless cached.empty? - rbs_collection_pins_in_memory[[gemspec, rbs_version_cache_key]] = cached - cached - else - logger.debug "No RBS collection pin cache for #{gemspec.name} #{gemspec.version}" - @uncached_rbs_collection_gemspecs.push gemspec - nil - end - end - - # @param path [String] - # @return [::Array, nil] - def resolve_path_to_gemspecs path - return nil if path.empty? - return gemspecs_required_from_bundler if path == 'bundler/require' - - # @type [Gem::Specification, nil] - gemspec = Gem::Specification.find_by_path(path) - if gemspec.nil? - gem_name_guess = path.split('/').first - begin - # this can happen when the gem is included via a local path in - # a Gemfile; Gem doesn't try to index the paths in that case. - # - # See if we can make a good guess: - potential_gemspec = Gem::Specification.find_by_name(gem_name_guess) - file = "lib/#{path}.rb" - gemspec = potential_gemspec if potential_gemspec.files.any? { |gemspec_file| file == gemspec_file } - rescue Gem::MissingSpecError - logger.debug { "Require path #{path} could not be resolved to a gem via find_by_path or guess of #{gem_name_guess}" } - [] - end - end - return nil if gemspec.nil? - [gemspec_or_preference(gemspec)] - end - - # @param gemspec [Gem::Specification] - # @return [Gem::Specification] - def gemspec_or_preference gemspec - # :nocov: dormant feature - return gemspec unless preference_map.key?(gemspec.name) - return gemspec if gemspec.version == preference_map[gemspec.name].version - - change_gemspec_version gemspec, preference_map[gemspec.name].version - # :nocov: - end - - # @param gemspec [Gem::Specification] - # @param version [Gem::Version] - # @return [Gem::Specification] - def change_gemspec_version gemspec, version - Gem::Specification.find_by_name(gemspec.name, "= #{version}") - rescue Gem::MissingSpecError - Solargraph.logger.info "Gem #{gemspec.name} version #{version} not found. Using #{gemspec.version} instead" - gemspec - end - - # @param gemspec [Gem::Specification] - # @return [Array] - def fetch_dependencies gemspec - # @param spec [Gem::Dependency] - only_runtime_dependencies(gemspec).each_with_object(Set.new) do |spec, deps| - Solargraph.logger.info "Adding #{spec.name} dependency for #{gemspec.name}" - dep = Gem.loaded_specs[spec.name] - # @todo is next line necessary? - dep ||= Gem::Specification.find_by_name(spec.name, spec.requirement) - deps.merge fetch_dependencies(dep) if deps.add?(dep) - rescue Gem::MissingSpecError - Solargraph.logger.warn "Gem dependency #{spec.name} #{spec.requirement} for #{gemspec.name} not found in RubyGems." - end.to_a - end - # @param gemspec [Gem::Specification] # @return [Array] def only_runtime_dependencies gemspec @@ -347,57 +183,5 @@ def only_runtime_dependencies gemspec def inspect self.class.inspect end - - # @return [Array, nil] - def gemspecs_required_from_bundler - # @todo Handle projects with custom Bundler/Gemfile setups - return unless workspace.gemfile? - - if workspace.gemfile? && Bundler.definition&.lockfile&.to_s&.start_with?(workspace.directory) - # Find only the gems bundler is now using - Bundler.definition.locked_gems.specs.flat_map do |lazy_spec| - logger.info "Handling #{lazy_spec.name}:#{lazy_spec.version}" - [Gem::Specification.find_by_name(lazy_spec.name, lazy_spec.version)] - rescue Gem::MissingSpecError => e - logger.info("Could not find #{lazy_spec.name}:#{lazy_spec.version} with find_by_name, falling back to guess") - # can happen in local filesystem references - specs = resolve_path_to_gemspecs lazy_spec.name - logger.warn "Gem #{lazy_spec.name} #{lazy_spec.version} from bundle not found: #{e}" if specs.nil? - next specs - end.compact - else - logger.info 'Fetching gemspecs required from Bundler (bundler/require)' - gemspecs_required_from_external_bundle - end - end - - # @return [Array, nil] - def gemspecs_required_from_external_bundle - logger.info 'Fetching gemspecs required from external bundle' - return [] unless workspace&.directory - - Solargraph.with_clean_env do - cmd = [ - 'ruby', '-e', - "require 'bundler'; require 'json'; Dir.chdir('#{workspace&.directory}') { puts Bundler.definition.locked_gems.specs.map { |spec| [spec.name, spec.version] }.to_h.to_json }" - ] - o, e, s = Open3.capture3(*cmd) - if s.success? - Solargraph.logger.debug "External bundle: #{o}" - hash = o && !o.empty? ? JSON.parse(o.split("\n").last) : {} - hash.flat_map do |name, version| - Gem::Specification.find_by_name(name, version) - rescue Gem::MissingSpecError => e - logger.info("Could not find #{name}:#{version} with find_by_name, falling back to guess") - # can happen in local filesystem references - specs = resolve_path_to_gemspecs name - logger.warn "Gem #{name} #{version} from bundle not found: #{e}" if specs.nil? - next specs - end.compact - else - Solargraph.logger.warn "Failed to load gems from bundle at #{workspace&.directory}: #{e}" - end - end - end end end From f9b6e1a781a20eecf9b8bc77bdad1025939e2b30 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Tue, 27 Jan 2026 13:12:26 -0500 Subject: [PATCH 379/400] Add annotatins --- lib/solargraph/gem_pins.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/solargraph/gem_pins.rb b/lib/solargraph/gem_pins.rb index 3b61b6a65..993f69dab 100644 --- a/lib/solargraph/gem_pins.rb +++ b/lib/solargraph/gem_pins.rb @@ -27,6 +27,7 @@ def self.combine_method_pins_by_path(pins) def self.combine_method_pins(*pins) # @type [Pin::Method, nil] combined_pin = nil + # @param memo [Pin::Method, nil] out = pins.reduce(combined_pin) do |memo, pin| next pin if memo.nil? if memo == pin && memo.source != :combined @@ -41,8 +42,8 @@ def self.combine_method_pins(*pins) out end - # @param yard_pins [Array] - # @param rbs_pins [Array] + # @param yard_pins [Array] + # @param rbs_pins [Array] # # @return [Array] def self.combine(yard_pins, rbs_pins) From 321193acb0ad497b03649c5ab89f16caff4580be Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Tue, 27 Jan 2026 13:24:15 -0500 Subject: [PATCH 380/400] Add @sg-ignores --- lib/solargraph/language_server/uri_helpers.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/solargraph/language_server/uri_helpers.rb b/lib/solargraph/language_server/uri_helpers.rb index c7e55afb8..1bfd3503b 100644 --- a/lib/solargraph/language_server/uri_helpers.rb +++ b/lib/solargraph/language_server/uri_helpers.rb @@ -29,7 +29,10 @@ def file_to_uri file # # @param text [String] # @return [String] + # @sg-ignore Solargraph::LanguageServer::UriHelpers.encode + # return type could not be inferred def encode text + # @sg-ignore Unresolved call to escape on Class CGI.escape(text) .gsub('%3A', ':') .gsub('%5C', '\\') @@ -41,7 +44,10 @@ def encode text # # @param text [String] # @return [String] + # @sg-ignore Solargraph::LanguageServer::UriHelpers.decode + # return type could not be inferred def decode text + # @sg-ignore Unresolved call to unescape on Class CGI.unescape(text) end end From 86cf428fc9a00631b89cf203c569e88374bf3af8 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Tue, 27 Jan 2026 13:27:33 -0500 Subject: [PATCH 381/400] Add @sg-ignores --- lib/solargraph/parser/parser_gem/class_methods.rb | 4 ++++ lib/solargraph/pin/conversions.rb | 1 + lib/solargraph/workspace/gemspecs.rb | 8 ++++++-- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/solargraph/parser/parser_gem/class_methods.rb b/lib/solargraph/parser/parser_gem/class_methods.rb index 8293d2ac5..9d1f61080 100644 --- a/lib/solargraph/parser/parser_gem/class_methods.rb +++ b/lib/solargraph/parser/parser_gem/class_methods.rb @@ -32,7 +32,11 @@ def parse code, filename = nil, line = 0 # @return [::Parser::Base] def parser @parser ||= Prism::Translation::Parser.new(FlawedBuilder.new).tap do |parser| + # @sg-ignore Unresolved call to diagnostics on + # Prism::Translation::Parser parser.diagnostics.all_errors_are_fatal = true + # @sg-ignore Unresolved call to diagnostics on + # Prism::Translation::Parser parser.diagnostics.ignore_warnings = true end end diff --git a/lib/solargraph/pin/conversions.rb b/lib/solargraph/pin/conversions.rb index e40cc8990..eccceb6db 100644 --- a/lib/solargraph/pin/conversions.rb +++ b/lib/solargraph/pin/conversions.rb @@ -109,6 +109,7 @@ def generate_link return nil if this_path == 'undefined' return nil if this_path.nil? || this_path == 'undefined' return this_path if path.nil? + # o@sg-ignore Unresolved call to escape on Class "[#{escape_brackets(this_path).gsub('_', '\\\\_')}](solargraph:/document?query=#{CGI.escape(this_path)})" end diff --git a/lib/solargraph/workspace/gemspecs.rb b/lib/solargraph/workspace/gemspecs.rb index bed157d2e..13bfbdd9a 100644 --- a/lib/solargraph/workspace/gemspecs.rb +++ b/lib/solargraph/workspace/gemspecs.rb @@ -118,6 +118,7 @@ def fetch_dependencies gemspec, out: $stderr Solargraph.logger.info "Adding #{runtime_dep.name} dependency for #{gemspec.name}" dep = gemspecs.find { |dep| dep.name == runtime_dep.name } + # @sg-ignore Unresolved call to requirement on Gem::Dependency dep ||= Gem::Specification.find_by_name(runtime_dep.name, runtime_dep.requirement) rescue Gem::MissingSpecError dep = resolve_gem_ignoring_local_bundle runtime_dep.name, out: out @@ -183,8 +184,11 @@ def to_gem_specification specish when Bundler::StubSpecification # turns a Bundler::StubSpecification into a # Gem::StubSpecification into a Gem::Specification + # @sg-ignore specish = specish.stub + # @sg-ignore if specish.respond_to?(:spec) + # @sg-ignore specish.spec else # turn the crank again @@ -193,8 +197,8 @@ def to_gem_specification specish else @@warned_on_gem_type ||= false unless @@warned_on_gem_type - logger.warn 'Unexpected type while resolving gem: ' \ - "#{specish.class}" + # @sg-ignore + logger.warn "Unexpected type while resolving gem: #{specish.class}" @@warned_on_gem_type = true end nil From b941021fdc59d0fd8a6659d23413d02b566fcdce Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Tue, 27 Jan 2026 13:40:15 -0500 Subject: [PATCH 382/400] Bring in plugin fixes from v0.59 --- .github/workflows/plugins.yml | 76 ++++++++++++++++++----------------- 1 file changed, 40 insertions(+), 36 deletions(-) diff --git a/.github/workflows/plugins.yml b/.github/workflows/plugins.yml index c7ad72cb4..4556215f1 100644 --- a/.github/workflows/plugins.yml +++ b/.github/workflows/plugins.yml @@ -9,7 +9,7 @@ on: push: branches: [master] pull_request: - branches: [master] + branches: ['*'] permissions: contents: read @@ -23,7 +23,7 @@ jobs: - name: Set up Ruby uses: ruby/setup-ruby@v1 with: - ruby-version: 3.4 + ruby-version: 3.4 # keep same as typecheck.yml bundler-cache: true - uses: awalsh128/cache-apt-pkgs-action@latest with: @@ -34,7 +34,7 @@ jobs: echo 'gem "solargraph-rails"' > .Gemfile echo 'gem "solargraph-rspec"' >> .Gemfile bundle install - bundle update rbs + bundle update --pre rbs - name: Configure to use plugins run: | bundle exec solargraph config @@ -43,7 +43,7 @@ jobs: - name: Install gem types run: bundle exec rbs collection update - name: Ensure typechecking still works - run: bundle exec solargraph typecheck --level typed + run: bundle exec solargraph typecheck --level strong - name: Ensure specs still run run: bundle exec rake spec rails: @@ -54,7 +54,9 @@ jobs: - name: Set up Ruby uses: ruby/setup-ruby@v1 with: - ruby-version: 3.4 + ruby-version: 3.4 # keep same as typecheck.yml + # See https://github.com/castwide/solargraph/actions/runs/19000135777/job/54265647107?pr=1119 + rubygems: latest bundler-cache: false - uses: awalsh128/cache-apt-pkgs-action@latest with: @@ -64,7 +66,7 @@ jobs: run: | echo 'gem "solargraph-rails"' > .Gemfile bundle install - bundle update rbs + bundle update --pre rbs - name: Configure to use plugins run: | bundle exec solargraph config @@ -72,7 +74,7 @@ jobs: - name: Install gem types run: bundle exec rbs collection update - name: Ensure typechecking still works - run: bundle exec solargraph typecheck --level typed + run: bundle exec solargraph typecheck --level strong - name: Ensure specs still run run: bundle exec rake spec rspec: @@ -83,7 +85,7 @@ jobs: - name: Set up Ruby uses: ruby/setup-ruby@v1 with: - ruby-version: 3.4 + ruby-version: 3.4 # keep same as typecheck.yml bundler-cache: false - uses: awalsh128/cache-apt-pkgs-action@latest with: @@ -93,7 +95,7 @@ jobs: run: | echo 'gem "solargraph-rspec"' >> .Gemfile bundle install - bundle update rbs + bundle update --pre rbs - name: Configure to use plugins run: | bundle exec solargraph config @@ -101,7 +103,7 @@ jobs: - name: Install gem types run: bundle exec rbs collection update - name: Ensure typechecking still works - run: bundle exec solargraph typecheck --level typed + run: bundle exec solargraph typecheck --level strong - name: Ensure specs still run run: bundle exec rake spec @@ -116,47 +118,47 @@ jobs: - name: clone https://github.com/lekemula/solargraph-rspec/ run: | cd .. - # git clone https://github.com/lekemula/solargraph-rspec.git + git clone https://github.com/lekemula/solargraph-rspec.git - # pending https://github.com/lekemula/solargraph-rspec/pull/30 - git clone https://github.com/apiology/solargraph-rspec.git cd solargraph-rspec - git checkout reset_closures - name: Set up Ruby uses: ruby/setup-ruby@v1 with: - ruby-version: '3.1' + ruby-version: 3.4 rubygems: latest bundler-cache: false - name: Install gems run: | - set -x + set -x - cd ../solargraph-rspec - echo "gem 'solargraph', path: '../solargraph'" >> Gemfile - bundle config path ${{ env.BUNDLE_PATH }} - bundle install --jobs 4 --retry 3 - bundle exec appraisal install - # @todo some kind of appraisal/bundle conflict? - # https://github.com/castwide/solargraph/actions/runs/19038710934/job/54369767122?pr=1116 - # /home/runner/work/solargraph/solargraph-rspec/vendor/bundle/ruby/3.1.0/gems/bundler-2.6.9/lib/bundler/runtime.rb:317:in - # `check_for_activated_spec!': You have already activated date - # 3.5.0, but your Gemfile requires date 3.4.1. Prepending - # `bundle exec` to your command may solve - # this. (Gem::LoadError) - bundle exec appraisal update date - # For some reason on ruby 3.1 it defaults to an old version: 1.3.2 - # https://github.com/lekemula/solargraph-rspec/actions/runs/17814581205/job/50645370316?pr=22 - # We update manually to the latest - bundle exec appraisal update rspec-rails + cd ../solargraph-rspec + echo "gem 'solargraph', path: '../solargraph'" >> Gemfile + bundle config path ${{ env.BUNDLE_PATH }} + bundle install --jobs 4 --retry 3 + bundle exec appraisal install + # @todo some kind of appraisal/bundle conflict? + # https://github.com/castwide/solargraph/actions/runs/19038710934/job/54369767122?pr=1116 + # /home/runner/work/solargraph/solargraph-rspec/vendor/bundle/ruby/3.1.0/gems/bundler-2.6.9/lib/bundler/runtime.rb:317:in + # `check_for_activated_spec!': You have already activated date + # 3.5.0, but your Gemfile requires date 3.4.1. Prepending + # `bundle exec` to your command may solve + # this. (Gem::LoadError) + bundle exec appraisal update date + # For some reason on ruby 3.1 it defaults to an old version: 1.3.2 + # https://github.com/lekemula/solargraph-rspec/actions/runs/17814581205/job/50645370316?pr=22 + # We update manually to the latest + bundle exec appraisal update rspec-rails - name: Configure .solargraph.yml run: | cd ../solargraph-rspec cp .solargraph.yml.example .solargraph.yml - - name: Solargraph generate RSpec gems YARD and RBS pins + - name: Solargraph generate RSpec gems YARD pins run: | cd ../solargraph-rspec - bundle exec appraisal rbs collection update + # solargraph-rspec's specs don't pass a workspace, so it + # doesn't know where to look for the RBS collection - let's + # not load one so that the solargraph gems command below works + rspec_gems=$(bundle exec appraisal ruby -r './lib/solargraph-rspec' -e 'puts Solargraph::Rspec::Gems.gem_names.join(" ")' 2>/dev/null | tail -n1) bundle exec appraisal solargraph gems $rspec_gems - name: Run specs @@ -180,6 +182,8 @@ jobs: # solargraph-rails supports Ruby 3.0+ ruby-version: '3.0' bundler-cache: false + # https://github.com/apiology/solargraph/actions/runs/19400815835/job/55508092473?pr=17 + rubygems: latest bundler: latest env: MATRIX_RAILS_VERSION: "7.0" @@ -191,7 +195,7 @@ jobs: cd ../solargraph-rails echo "gem 'solargraph', path: '${GITHUB_WORKSPACE:?}'" >> Gemfile bundle install - bundle update rbs + bundle update --pre rbs RAILS_DIR="$(pwd)/spec/rails7" export RAILS_DIR cd ${RAILS_DIR} From aa8a153c5a8c964482ea1252204d47b11c526b22 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Tue, 27 Jan 2026 13:55:58 -0500 Subject: [PATCH 383/400] Bring in typecheck fixes from v0.59 --- .github/workflows/typecheck.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/typecheck.yml b/.github/workflows/typecheck.yml index f40977acf..ddb3e6527 100644 --- a/.github/workflows/typecheck.yml +++ b/.github/workflows/typecheck.yml @@ -11,7 +11,7 @@ on: push: branches: [ master ] pull_request: - branches: [ master ] + branches: ['*'] permissions: contents: read @@ -32,7 +32,7 @@ jobs: - name: Install gems run: | bundle install - bundle update rbs # use latest available for this Ruby version + bundle update --pre rbs # use latest available for this Ruby version - name: Install gem types run: bundle exec rbs collection install - name: Typecheck self From 915603627494ea00b05b84d3911aa768c801557e Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Tue, 27 Jan 2026 13:58:24 -0500 Subject: [PATCH 384/400] Drop sg-ignores --- lib/solargraph/language_server/uri_helpers.rb | 6 ------ lib/solargraph/page.rb | 2 -- lib/solargraph/pin/conversions.rb | 1 - 3 files changed, 9 deletions(-) diff --git a/lib/solargraph/language_server/uri_helpers.rb b/lib/solargraph/language_server/uri_helpers.rb index 1bfd3503b..c7e55afb8 100644 --- a/lib/solargraph/language_server/uri_helpers.rb +++ b/lib/solargraph/language_server/uri_helpers.rb @@ -29,10 +29,7 @@ def file_to_uri file # # @param text [String] # @return [String] - # @sg-ignore Solargraph::LanguageServer::UriHelpers.encode - # return type could not be inferred def encode text - # @sg-ignore Unresolved call to escape on Class CGI.escape(text) .gsub('%3A', ':') .gsub('%5C', '\\') @@ -44,10 +41,7 @@ def encode text # # @param text [String] # @return [String] - # @sg-ignore Solargraph::LanguageServer::UriHelpers.decode - # return type could not be inferred def decode text - # @sg-ignore Unresolved call to unescape on Class CGI.unescape(text) end end diff --git a/lib/solargraph/page.rb b/lib/solargraph/page.rb index e2e6a2d0f..12782da90 100644 --- a/lib/solargraph/page.rb +++ b/lib/solargraph/page.rb @@ -35,9 +35,7 @@ def htmlify text # @param text [String] # @return [String] - # @sg-ignore Solargraph::Page::Binder#escape return type could not be inferred def escape text - # @sg-ignore Unresolved call to escapeHTML on Class CGI.escapeHTML(text) end diff --git a/lib/solargraph/pin/conversions.rb b/lib/solargraph/pin/conversions.rb index eccceb6db..e40cc8990 100644 --- a/lib/solargraph/pin/conversions.rb +++ b/lib/solargraph/pin/conversions.rb @@ -109,7 +109,6 @@ def generate_link return nil if this_path == 'undefined' return nil if this_path.nil? || this_path == 'undefined' return this_path if path.nil? - # o@sg-ignore Unresolved call to escape on Class "[#{escape_brackets(this_path).gsub('_', '\\\\_')}](solargraph:/document?query=#{CGI.escape(this_path)})" end From 12e17e5f15e8ac7d7b741c7427ccabb20c238a3d Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Tue, 27 Jan 2026 14:03:31 -0500 Subject: [PATCH 385/400] Bring in plugins from dev branch --- .github/workflows/plugins.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/plugins.yml b/.github/workflows/plugins.yml index 4556215f1..3de7288eb 100644 --- a/.github/workflows/plugins.yml +++ b/.github/workflows/plugins.yml @@ -118,9 +118,12 @@ jobs: - name: clone https://github.com/lekemula/solargraph-rspec/ run: | cd .. - git clone https://github.com/lekemula/solargraph-rspec.git + # git clone https://github.com/lekemula/solargraph-rspec.git + # pending https://github.com/lekemula/solargraph-rspec/pull/31 + git clone https://github.com/apiology/solargraph-rspec.git cd solargraph-rspec + git checkout test_solargraph_prereleases - name: Set up Ruby uses: ruby/setup-ruby@v1 with: From a4bf04e5334e283bc8abddbfaf00acc69d849e0b Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Tue, 27 Jan 2026 14:04:08 -0500 Subject: [PATCH 386/400] Drop sg-ignore --- lib/solargraph/language_server/host.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/solargraph/language_server/host.rb b/lib/solargraph/language_server/host.rb index b228bdba6..ca67487b6 100644 --- a/lib/solargraph/language_server/host.rb +++ b/lib/solargraph/language_server/host.rb @@ -765,7 +765,6 @@ def check_diff uri, change return change if source.code.length + 1 != change['text'].length diffs = Diff::LCS.diff(source.code, change['text']) return change if diffs.length.zero? || diffs.length > 1 || diffs.first.length > 1 - # @sg-ignore push this upstream # @type [Diff::LCS::Change] diff = diffs.first.first return change unless diff.adding? && ['.', ':', '(', ',', ' '].include?(diff.element) From 675a1c09572b16c1f8bfd56a4ba07bc6aefabd6d Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Tue, 27 Jan 2026 14:16:12 -0500 Subject: [PATCH 387/400] Fix annotation --- lib/solargraph/language_server/host.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/solargraph/language_server/host.rb b/lib/solargraph/language_server/host.rb index ca67487b6..b228bdba6 100644 --- a/lib/solargraph/language_server/host.rb +++ b/lib/solargraph/language_server/host.rb @@ -765,6 +765,7 @@ def check_diff uri, change return change if source.code.length + 1 != change['text'].length diffs = Diff::LCS.diff(source.code, change['text']) return change if diffs.length.zero? || diffs.length > 1 || diffs.first.length > 1 + # @sg-ignore push this upstream # @type [Diff::LCS::Change] diff = diffs.first.first return change unless diff.adding? && ['.', ':', '(', ',', ' '].include?(diff.element) From 880057b8bebc774c5d7ca2c7d508874b70d1661e Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Tue, 27 Jan 2026 19:01:01 -0500 Subject: [PATCH 388/400] Fix tag --- lib/solargraph/gem_pins.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/solargraph/gem_pins.rb b/lib/solargraph/gem_pins.rb index 5f07567ba..d1ae43998 100644 --- a/lib/solargraph/gem_pins.rb +++ b/lib/solargraph/gem_pins.rb @@ -45,7 +45,7 @@ def self.combine_method_pins(*pins) # @param yard_pins [Array] # @param rbs_pins [Array] # - # @return [Array, nil] + # @return [Array] def self.combine(yard_pins, rbs_pins) in_yard = Set.new rbs_store = Solargraph::ApiMap::Store.new(rbs_pins) From 16c56bea84edb12e0a1cd2207ac0b03147a7ce0a Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Tue, 27 Jan 2026 19:13:57 -0500 Subject: [PATCH 389/400] Cleanups --- lib/solargraph/api_map.rb | 4 ---- lib/solargraph/doc_map.rb | 12 ++++++------ lib/solargraph/parser/parser_gem/class_methods.rb | 4 ---- lib/solargraph/workspace.rb | 14 +------------- lib/solargraph/yardoc.rb | 5 ----- 5 files changed, 7 insertions(+), 32 deletions(-) diff --git a/lib/solargraph/api_map.rb b/lib/solargraph/api_map.rb index a3f910554..904edff8e 100755 --- a/lib/solargraph/api_map.rb +++ b/lib/solargraph/api_map.rb @@ -23,9 +23,6 @@ class ApiMap # @return [Array] attr_reader :missing_docs - # @return [Solargraph::Workspace::Gemspecs] - attr_reader :gemspecs - # @param pins [Array] # @param loose_unions [Boolean] if true, a potential type can be # inferred if ANY of the UniqueTypes in the base chain's @@ -123,7 +120,6 @@ def catalog bench if recreate_docmap @doc_map = DocMap.new(unresolved_requires, bench.workspace, out: nil) # @todo Implement gem preferences - @gemspecs = @doc_map.workspace.gemspecs @unresolved_requires = @doc_map.unresolved_requires end @cache.clear if store.update(@@core_map.pins, @doc_map.pins, conventions_environ.pins, iced_pins, live_pins) diff --git a/lib/solargraph/doc_map.rb b/lib/solargraph/doc_map.rb index e5e0fb342..50930d379 100644 --- a/lib/solargraph/doc_map.rb +++ b/lib/solargraph/doc_map.rb @@ -16,12 +16,6 @@ class DocMap # @return [Workspace] attr_reader :workspace - # @return [Array] - def requires - @requires ||= @provided_requires + (workspace.global_environ&.requires || []) - end - alias required requires - # @param requires [Array] # @param workspace [Workspace, nil] # @param out [IO, nil] output stream for logging @@ -31,6 +25,12 @@ def initialize requires, workspace, out: $stderr @out = out end + # @return [Array] + def requires + @requires ||= @provided_requires + (workspace.global_environ&.requires || []) + end + alias required requires + # @sg-ignore flow sensitive typing needs to understand reassignment # @return [Array] def uncached_gemspecs diff --git a/lib/solargraph/parser/parser_gem/class_methods.rb b/lib/solargraph/parser/parser_gem/class_methods.rb index 37fcaa1bd..634edf863 100644 --- a/lib/solargraph/parser/parser_gem/class_methods.rb +++ b/lib/solargraph/parser/parser_gem/class_methods.rb @@ -1,9 +1,5 @@ # frozen_string_literal: true -require 'prism' -require 'ast' -require 'parser' - module Solargraph module Parser module ParserGem diff --git a/lib/solargraph/workspace.rb b/lib/solargraph/workspace.rb index 0be0704d1..a893e6d4c 100644 --- a/lib/solargraph/workspace.rb +++ b/lib/solargraph/workspace.rb @@ -19,10 +19,6 @@ class Workspace # @return [String] attr_reader :directory - # @return [Array] - attr_reader :gemnames - alias source_gems gemnames - # @todo Remove '' and '*' special cases # @param directory [String] # @param config [Config, nil] @@ -243,14 +239,6 @@ def all_gemspecs_from_bundle gemspecs.all_gemspecs_from_bundle end - # @todo make this actually work against bundle instead of pulling - # all installed gemspecs - - # https://github.com/apiology/solargraph/pull/10 - # @return [Array] - def all_gemspecs_from_bundle - Gem::Specification.to_a - end - # @param out [StringIO, IO, nil] output stream for logging # @param rebuild [Boolean] whether to rebuild the pins even if they are cached # @return [void] @@ -258,7 +246,7 @@ def cache_all_for_workspace! out, rebuild: false PinCache.cache_core(out: out) unless PinCache.core? && !rebuild # @type [Array] - gem_specs = gemspecs.all_gemspecs_from_bundle + gem_specs = all_gemspecs_from_bundle # try any possible standard libraries, but be quiet about it stdlib_specs = pin_cache.possible_stdlibs.map { |stdlib| find_gem(stdlib, out: nil) }.compact specs = (gem_specs + stdlib_specs) diff --git a/lib/solargraph/yardoc.rb b/lib/solargraph/yardoc.rb index 7a9fd6e79..419d12cbd 100644 --- a/lib/solargraph/yardoc.rb +++ b/lib/solargraph/yardoc.rb @@ -18,10 +18,6 @@ module Yardoc def build_docs gem_yardoc_path, yard_plugins, gemspec return if docs_built?(gem_yardoc_path) - Solargraph.logger.info "Saving yardoc for #{gemspec.name} #{gemspec.version} into #{gem_yardoc_path}" - cmd = "yardoc --db #{gem_yardoc_path} --no-output --plugin solargraph" - yard_plugins.each { |plugin| cmd << " --plugin #{plugin}" } - Solargraph.logger.debug { "Running: #{cmd}" } # @todo set these up to run in parallel unless Dir.exist? gemspec.gem_dir # Can happen in at least some (old?) RubyGems versions when we @@ -39,7 +35,6 @@ def build_docs gem_yardoc_path, yard_plugins, gemspec # @todo set these up to run in parallel # @sg-ignore Our fill won't work properly due to an issue in # Callable#arity_matches? - see comment there - stdout_and_stderr_str, status = Open3.capture2e(current_bundle_env_tweaks, cmd, chdir: gemspec.gem_dir) return if status.success? Solargraph.logger.warn { "YARD failed running #{cmd.inspect} in #{gemspec.gem_dir}" } From 20a51956c3ef69e14a564191ca5a487cbaf2dbca Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Tue, 27 Jan 2026 19:19:45 -0500 Subject: [PATCH 390/400] Revert --- lib/solargraph/library.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/solargraph/library.rb b/lib/solargraph/library.rb index acf0e1c1f..7725ceaed 100644 --- a/lib/solargraph/library.rb +++ b/lib/solargraph/library.rb @@ -542,7 +542,7 @@ def source_map_external_require_hash # @param source_map [SourceMap] # @return [void] def find_external_requires source_map - # @type [Enumerable] + # @type [Set] new_set = source_map.requires.map(&:name).to_set # return if new_set == source_map_external_require_hash[source_map.filename] _filenames = nil From 065b18686b0bf0a2d764500e90c74fff09c37009 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Tue, 27 Jan 2026 19:31:21 -0500 Subject: [PATCH 391/400] Drop code based on spec --- lib/solargraph/workspace/gemspecs.rb | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/lib/solargraph/workspace/gemspecs.rb b/lib/solargraph/workspace/gemspecs.rb index 366eac793..75bb312e5 100644 --- a/lib/solargraph/workspace/gemspecs.rb +++ b/lib/solargraph/workspace/gemspecs.rb @@ -178,18 +178,8 @@ def to_gem_specification specish # print time including milliseconds self.class.gem_specification_cache[specish] ||= case specish when Gem::Specification - @@warned_on_rubygems ||= false - if specish.respond_to?(:identifier) - specish - else - # see https://github.com/castwide/solargraph/actions/runs/17588131738/job/49961580698?pr=1006 - happened on Ruby 3.0 - unless @@warned_on_rubygems - logger.warn "Incomplete Gem::Specification encountered - recommend upgrading rubygems" - @@warned_on_rubygems = true - end - nil - end # yay! + specish when Bundler::LazySpecification # materializing didn't work. Let's look in the local # rubygems without bundler's help From 4267b038f43d1790afca7ea6c5364188b505e22c Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Tue, 27 Jan 2026 19:47:03 -0500 Subject: [PATCH 392/400] Fix spec --- spec/workspace_spec.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spec/workspace_spec.rb b/spec/workspace_spec.rb index 866c06cf4..b4603a246 100644 --- a/spec/workspace_spec.rb +++ b/spec/workspace_spec.rb @@ -143,6 +143,7 @@ describe '#cache_all_for_workspace!' do let(:pin_cache) { instance_double(Solargraph::PinCache) } + let(:gemspecs) { instance_double(Solargraph::Workspace::Gemspecs) } before do allow(Solargraph::PinCache).to receive(:cache_core) @@ -150,6 +151,7 @@ allow(Solargraph::PinCache).to receive(:new).and_return(pin_cache) allow(pin_cache).to receive_messages(cache_gem: nil, possible_stdlibs: []) allow(Solargraph::PinCache).to receive(:cache_all_stdlibs) + allow(Solargraph::Workspace::Gemspecs).to receive(:new).and_return(gemspecs) end it 'caches core pins' do From 524c627fddbd0b9499e1e834ba45fd87908257c4 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Tue, 27 Jan 2026 19:50:40 -0500 Subject: [PATCH 393/400] Add prism require back --- lib/solargraph/parser/parser_gem/class_methods.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/solargraph/parser/parser_gem/class_methods.rb b/lib/solargraph/parser/parser_gem/class_methods.rb index 634edf863..3f70d14df 100644 --- a/lib/solargraph/parser/parser_gem/class_methods.rb +++ b/lib/solargraph/parser/parser_gem/class_methods.rb @@ -1,5 +1,7 @@ # frozen_string_literal: true +require 'prism' + module Solargraph module Parser module ParserGem From 3f60d96184cde6c28c61362a25de31a3e581019f Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Tue, 27 Jan 2026 19:52:08 -0500 Subject: [PATCH 394/400] Restore annotation --- lib/solargraph/gem_pins.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/solargraph/gem_pins.rb b/lib/solargraph/gem_pins.rb index d1ae43998..99ff62812 100644 --- a/lib/solargraph/gem_pins.rb +++ b/lib/solargraph/gem_pins.rb @@ -28,6 +28,7 @@ def self.combine_method_pins(*pins) # @type [Pin::Method, nil] combined_pin = nil # @param memo [Pin::Method, nil] + # @param pin [Pin::Method] out = pins.reduce(combined_pin) do |memo, pin| next pin if memo.nil? if memo == pin && memo.source != :combined From 6726e7354d5878e2d81728dacd5735ef6962b5fd Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Tue, 27 Jan 2026 19:52:52 -0500 Subject: [PATCH 395/400] Drop @type --- lib/solargraph/library.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/solargraph/library.rb b/lib/solargraph/library.rb index 7725ceaed..019d8d91c 100644 --- a/lib/solargraph/library.rb +++ b/lib/solargraph/library.rb @@ -619,7 +619,6 @@ def cache_errors def cache_next_gemspec return if @cache_progress - # @type [Gem::Specification] spec = cacheable_specs.first return end_cache_progress unless spec From 499f3825993b361cc54f582e06c1ad2852b155d8 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Tue, 27 Jan 2026 19:53:39 -0500 Subject: [PATCH 396/400] Drop annotation --- lib/solargraph/workspace.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/solargraph/workspace.rb b/lib/solargraph/workspace.rb index a893e6d4c..09f18dcc5 100644 --- a/lib/solargraph/workspace.rb +++ b/lib/solargraph/workspace.rb @@ -245,7 +245,6 @@ def all_gemspecs_from_bundle def cache_all_for_workspace! out, rebuild: false PinCache.cache_core(out: out) unless PinCache.core? && !rebuild - # @type [Array] gem_specs = all_gemspecs_from_bundle # try any possible standard libraries, but be quiet about it stdlib_specs = pin_cache.possible_stdlibs.map { |stdlib| find_gem(stdlib, out: nil) }.compact From d6bc633cbe0efb6eff6bef2bd0bfafd5e1ba410b Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Tue, 27 Jan 2026 19:54:25 -0500 Subject: [PATCH 397/400] Drop @todo --- lib/solargraph/yardoc.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/solargraph/yardoc.rb b/lib/solargraph/yardoc.rb index 419d12cbd..4accf9425 100644 --- a/lib/solargraph/yardoc.rb +++ b/lib/solargraph/yardoc.rb @@ -18,7 +18,6 @@ module Yardoc def build_docs gem_yardoc_path, yard_plugins, gemspec return if docs_built?(gem_yardoc_path) - # @todo set these up to run in parallel unless Dir.exist? gemspec.gem_dir # Can happen in at least some (old?) RubyGems versions when we # have a gemspec describing a standard library like bundler. From d567e0869b7567e864fc436b77a0a46f6d97d764 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Tue, 27 Jan 2026 20:05:12 -0500 Subject: [PATCH 398/400] Add @sg-ignore --- lib/solargraph/workspace/gemspecs.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/solargraph/workspace/gemspecs.rb b/lib/solargraph/workspace/gemspecs.rb index 75bb312e5..53b4b948e 100644 --- a/lib/solargraph/workspace/gemspecs.rb +++ b/lib/solargraph/workspace/gemspecs.rb @@ -202,6 +202,7 @@ def to_gem_specification specish end specish end + # @sg-ignore Unresolved constant Gem::StubSpecification when Gem::StubSpecification # @sg-ignore flow sensitive typing ought to be able to handle 'when ClassName' specish.to_spec From e20039a6a0a3aab7e568e832377c52e5049cf5fb Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Tue, 27 Jan 2026 20:16:58 -0500 Subject: [PATCH 399/400] Fix spec --- spec/workspace_spec.rb | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/spec/workspace_spec.rb b/spec/workspace_spec.rb index b4603a246..341ceeac4 100644 --- a/spec/workspace_spec.rb +++ b/spec/workspace_spec.rb @@ -152,6 +152,8 @@ allow(pin_cache).to receive_messages(cache_gem: nil, possible_stdlibs: []) allow(Solargraph::PinCache).to receive(:cache_all_stdlibs) allow(Solargraph::Workspace::Gemspecs).to receive(:new).and_return(gemspecs) + gemspec = instance_double(Gem::Specification, name: 'test_gem', version: '1.0.0') + allow(gemspecs).to receive(:all_gemspecs_from_bundle).and_return([gemspec]) end it 'caches core pins' do @@ -165,9 +167,7 @@ end it 'caches gems' do - gemspec = instance_double(Gem::Specification, name: 'test_gem', version: '1.0.0') - allow(gemspecs).to receive(:all_gemspecs_from_bundle).and_return([gemspec]) - allow(pin_cache).to receive(:cached?).with(gemspec).and_return(false) + allow(pin_cache).to receive(:cached?).and_return(false) allow(pin_cache).to receive(:cache_all_stdlibs).with(out: nil, rebuild: false) @@ -176,8 +176,7 @@ workspace.cache_all_for_workspace!(nil, rebuild: false) - expect(pin_cache).to have_received(:cache_gem).with(gemspec: gemspec, out: nil, - rebuild: false) + expect(pin_cache).to have_received(:cache_gem) end end end From 364c6b2b8e9aa3032bd00f820fe3f504b25fa262 Mon Sep 17 00:00:00 2001 From: Vince Broz Date: Sun, 1 Mar 2026 21:09:47 -0500 Subject: [PATCH 400/400] Add rspec-time-guard dep --- solargraph.gemspec | 1 + 1 file changed, 1 insertion(+) diff --git a/solargraph.gemspec b/solargraph.gemspec index 06edbf19f..56a6602c6 100755 --- a/solargraph.gemspec +++ b/solargraph.gemspec @@ -57,6 +57,7 @@ Gem::Specification.new do |s| s.add_development_dependency 'public_suffix', '~> 3.1' s.add_development_dependency 'rake', '~> 13.2' s.add_development_dependency 'rspec', '~> 3.5' + s.add_development_dependency 'rspec-time-guard', '~>0.2.0' # # very specific development-time RuboCop version patterns for CI # stability - feel free to update in an isolated PR