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

Lint/ConstantResolution: Fully qualify a module name? #8518

Closed
FilBot3 opened this issue Aug 10, 2020 · 1 comment · Fixed by #8542
Closed

Lint/ConstantResolution: Fully qualify a module name? #8518

FilBot3 opened this issue Aug 10, 2020 · 1 comment · Fixed by #8542

Comments

@FilBot3
Copy link

FilBot3 commented Aug 10, 2020

Lint/ConstantResolution: Fully qualify this constant to avoid possibly ambiguous resolution.

Expected behavior

Tell me how to fix this linting issue.

Actual behavior

Same linting issue as when calling other libraries needing ::Dir[..]

Steps to reproduce the problem

given the code below:

# frozen_string_literal: true

require('logger')
require('rest-client')

# Rest-Client Examples
module RestClientExample
  # The main method
  def main
    logger = ::Logger.new($stdout)
    logger.level = ::Logger::INFO

    url = ''

    cyberark_headers = {
      'Content-Type': 'application/json'
    }

    payload_json = {}

    cyberark_response = ::RestClient.post(
      url,
      payload_json,
      cyberark_headers
    )

    logger.info(cyberark_response)
  end
end

Get this linter warning:

Lint/ConstantResolution: Fully qualify this constant to avoid possibly ambiguous resolution.

on line#7. I'm not sure how to fix this, or why it's being flagged.

RuboCop version

Include the output of rubocop -V or bundle exec rubocop -V if using Bundler. Here's an example:

$ rubocop -V
0.89.1 (using Parser 2.7.1.4, rubocop-ast 0.3.0, running on ruby 2.7.1 x86_64-linux)

image

@nguyenquangminh0711
Copy link
Contributor

nguyenquangminh0711 commented Aug 15, 2020

Tested with same configuration, but I could not reproduce the bug. Tested using master branch, the result is the same, only Metrics/MethodLength offense.

0.89.1 (using Parser 2.7.1.4, rubocop-ast 0.3.0, running on ruby 2.7.1 x86_64-linux)

Screenshot from 2020-08-15 16-30-59

@FilBot3 Could you please run Rubocop outside of your editor, directly in the command line?

tejasbubane added a commit to tejasbubane/rubocop that referenced this issue Aug 18, 2020
…e for `module` and `class` definitions

Closes rubocop#8518
koic added a commit that referenced this issue Aug 19, 2020
[Fix #8518] Fix `Lint/ConstantResolution` cop reporting offense for `module` and `class` definitions
Drenmi pushed a commit to Drenmi/rubocop that referenced this issue Aug 20, 2020
[Fix rubocop#8518] Fix `Lint/ConstantResolution` cop reporting offense for `module` and `class` definitions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants