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

Layout/SpaceeAroundKeyword should allow super::ConstName #7517

Closed
ozydingo opened this issue Nov 20, 2019 · 0 comments
Closed

Layout/SpaceeAroundKeyword should allow super::ConstName #7517

ozydingo opened this issue Nov 20, 2019 · 0 comments
Labels

Comments

@ozydingo
Copy link

Be clear, concise and precise in your description of the problem.
Open an issue with a descriptive title and a summary in grammatically correct,
complete sentences.

Use the template below when reporting bugs. Please, make sure that
you're running the latest stable RuboCop and that the problem you're reporting
hasn't been reported (and potentially fixed) already.

Before filing the ticket you should replace all text above the horizontal
rule with your own words.


Expected behavior

The Layout/SpaceAroundKeyword cop should allow code such as super::MyModule and super::MY_CONST.

A common example of this construct could be in Rails to dynamically refer to modules such as SomeActiveRecordClass::GeneratedAssociationMethods

My specific use case is simply a plain-ruby method that returns a module being overridden by subclasses to return a dynamically-generated child module:

def storage_class
  secure? ? super::Secure : super
end

Actual behavior

Layout/SpaceAroundKeyword: Space after keyword super is missing.

Steps to reproduce the problem

Run rubocop over a file with the following contents:

# this part is just for fun; option to skip if these are already defined :-)
module RuboCop
  module Cop
    module Layout
    end
  end
end

class C
  def mod
    return RuboCop::Cop
  end
end

class D < C
  def mod
    super::Layout
  end
end

RuboCop version

0.76.0 (using Parser 2.6.5.0, running on ruby 2.6.1 x86_64-darwin18)
@koic koic added the bug label Nov 21, 2019
@koic koic closed this as completed in 0a0c442 Nov 22, 2019
koic added a commit that referenced this issue Nov 22, 2019
…mespace

[Fix #7517] Layout/WhitespaceAroundKeyword: allow `super::const`
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