Skip to content

Supporting aliased constants #3

@iBotPeaches

Description

@iBotPeaches

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions