Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Sord strips important information from included constants #87

Open
connorshea opened this issue Jul 11, 2019 · 4 comments
Open

Sord strips important information from included constants #87

connorshea opened this issue Jul 11, 2019 · 4 comments
Labels
bug Something isn't working

Comments

@connorshea
Copy link
Contributor

Describe the bug

In YARD, this file can be found at lib/yard/server/commands/list_command.rb:

# frozen_string_literal: true
module YARD
  module Server
    module Commands
      class ListCommand < LibraryCommand
        include Templates::Helpers::BaseHelper

        def run
          # code
        end
      end
    end
  end
end

To Reproduce
Run Sord on YARD and search for include BaseHelper in class ListCommand.

Expected behavior

class ListCommand < LibraryCommand
  include Templates::Helpers::BaseHelper

  # methods
end

Actual behavior
Just BaseHelper is generated, which causes an error:

class ListCommand < LibraryCommand
  include BaseHelper

  # methods
end
@connorshea connorshea added the bug Something isn't working label Jul 11, 2019
@connorshea
Copy link
Contributor Author

connorshea commented Jul 11, 2019

You can also see something similar happen in bundler.rbi where class RGProxy < ::Gem::SilentUI becomes class RGProxy < SilentUI, causing an Sorbet error.

@AaronC81
Copy link
Owner

Changing name to path in https://github.com/AaronC81/sord/blob/master/lib/sord/rbi_generator.rb#L68-L73 produces this result instead:

class ListCommand < LibraryCommand
  include YARD::Templates::Helpers::BaseHelper
  # ...
end

This is probably better than the current behaviour, but still not identical to the original include.

@connorshea
Copy link
Contributor Author

With that change (after #90), it goes from 209 errors to 175 in sord_examples.

@connorshea
Copy link
Contributor Author

Here's a related test:

it 'returns fully qualified classes' do
  YARD.parse_string(<<-RUBY)
    class Alphabet
    end

    class Letters < Alphabet
    end

    class A < Alphabet::Letters
      # @return [void]
      def x; end
    end
  RUBY

  expect(subject.generate.strip).to eq fix_heredoc(<<-RUBY)
    # typed: strong
    class Alphabet
    end
    
    class Letters < Alphabet
    end
    
    class A < Alphabet::Letters
      sig { void }
      def x; end
    end
  RUBY
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants