rubocop-require_tools icon indicating copy to clipboard operation
rubocop-require_tools copied to clipboard

Supporting aliased constants

Open iBotPeaches opened this issue 1 month ago • 0 comments

So I was looking at a new fastlane PR

It had a ton of rubocop violation ignored that looked like.

    def is_messages?
      # rubocop:disable Require/MissingRequireStatement
      return DisplayType::ALL_IMESSAGE.include?(self.display_type)
      # rubocop:enable Require/MissingRequireStatement
    end

It however didn't complain about that alias used in new constants.

    DEVICE_RESOLUTIONS_MESSAGES = {
      DisplayType::IMESSAGE_APP_IPHONE_40 => DEVICE_RESOLUTIONS[DisplayType::APP_IPHONE_40],

I thought that was odd, since ~60 lines above was this

    # Shorthand for DisplayType constants
    DisplayType = Spaceship::ConnectAPI::AppScreenshotSet::DisplayType

Which of course inside that has the constant.

module Spaceship
  class ConnectAPI
    class AppScreenshotSet
      include Spaceship::ConnectAPI::Model

      module DisplayType
        ALL_IMESSAGE = []

So surely the constant exists and just has a shorter alias. So I started wondering why that was. The code landed at this gem, which does appear to be slightly old hitting 7 years with no work.

So I figured I'd report this bug, maybe assign Copilot to it. Best I can tell during process_const_assign the code assumes it'll be a scalar and doesn't track down / resolve a reference for like an aliased constant.

iBotPeaches avatar Nov 20 '25 11:11 iBotPeaches