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

Bug: deconstruction + array of symbols #1547

Open
stackmystack opened this issue Jun 27, 2024 · 0 comments
Open

Bug: deconstruction + array of symbols #1547

stackmystack opened this issue Jun 27, 2024 · 0 comments
Labels

Comments

@stackmystack
Copy link

Description

YARD is losing control with deconstruction and array of symbols.

Steps to reproduce

This is the minimal reproduction for the issue.

Gemfile:

source 'https://rubygems.org'
ruby '>= 3.0'
gem 'yard'

.yardopts:

yardoc
--output-dir rdoc
--markup=markdown
src/**/*.rb

src/main.rb:

module Mod
  class A
    # Some fn
    # @param arg [Object]
    def fn(arg)
      case arg
      in SomeClass['array', v]
        '42'
      else
        super
      end
    end

    # A nice little const.
    CONST = %i[a b c]
  end
end

Actual Output

image

Expected Output

image

And that was something I can achieve by:

  1. Putting the const before the fn
module Mod
  class A
    # A nice little const.
    CONST = %i[a b c]

    # Some fn
    # @param arg [Object]
    def fn(arg)
      case arg
      in SomeClass['array', v]
        '42'
      else
        super
      end
    end
  end
end
  1. Avoiding %i notation:
module Mod
  class A
    # Some fn
    # @param arg [Object]
    def fn(arg)
      case arg
      in SomeClass['array', v]
        '42'
      else
        super
      end
    end

    # A nice little const.
    CONST = [:a, :b, :c]
  end
end

None of those solutions are actually acceptable in my case:

  1. I cannot change the order of these particular things, because the deconstruction happens in a class different than that of the const, and I cannot extract the class to a separate file (I can —physically— of course, it's just that it doesn't make sense in my project).
  2. I cannot avoid %i notation because the actual const is humongous (again, I physically can, but I would be violating the codebase coding style to please YARD).

Environment details:

  • OS: mac (M1) or Linux (ubuntu) … I don't think it matters
  • Ruby version (ruby -v): 3.3.1
  • YARD version (yard -v): 0.9.36
  • Relevant software dependency/versions:
    • none
@lsegal lsegal added the Bug label Jul 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants