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/ExtraSpacing does not detects all the offenses #11641

Closed
x-yuri opened this issue Mar 1, 2023 · 0 comments · Fixed by #11708
Closed

Layout/ExtraSpacing does not detects all the offenses #11641

x-yuri opened this issue Mar 1, 2023 · 0 comments · Fixed by #11708

Comments

@x-yuri
Copy link

x-yuri commented Mar 1, 2023

I created a class to use paths relative to the app's root when requiring files, and in some other cases. It uses one-letter parameter names, which might be bad in some cases, but not in this one. Or so I think. So I decided to disable Naming/MethodParameterName with end-of-line comments and used 2 spaces:

app_root.rb:

class AppRoot
  def require(p)  # rubocop:disable Naming/MethodParameterName
  end

  def load(p)  # rubocop:disable Naming/MethodParameterName
  end

  def join(*ps)  # rubocop:disable Naming/MethodParameterName
  end

  def exist?(*ps)  # rubocop:disable Naming/MethodParameterName
  end
end

I'm okay with using one space here, but rubocop flagged only the load and join lines.

Expected behavior

I would expect rubocop to flag all the lines.

Actual behavior

Only the load and join lines were flagged.

$ bundle exec rubocop --debug --except Style/Documentation,Style/FrozenStringLiteralComment app_root.rb
For /app: Default configuration from /usr/lib/ruby/gems/3.1.0/gems/rubocop-1.46.0/config/default.yml
Use parallel by default.
Skipping parallel inspection: only a single file needs inspection
Inspecting 1 file
Scanning /app/app_root.rb
Loading cache from /root/.cache/rubocop_cache/b0b2d280e1442f43fb9ce326f03ed071dc511cb9/eb58adbf39a487e9f4638f9bbbf2b1db65580191/6663cda0f9a6c744cc92d830188b72aab50bfa61
C

Offenses:

app_root.rb:5:14: C: [Correctable] Layout/ExtraSpacing: Unnecessary spacing detected.
  def load(p)  # rubocop:disable Naming/MethodParameterName
             ^
app_root.rb:8:16: C: [Correctable] Layout/ExtraSpacing: Unnecessary spacing detected.
  def join(*ps)  # rubocop:disable Naming/MethodParameterName
               ^

1 file inspected, 2 offenses detected, 2 offenses autocorrectable
Finished in 0.13135084799978358 seconds

Apparently this happens because the first and last lines are for some reason excluded. But I couldn't quickly figure out the reason.

Steps to reproduce the problem

Gemfile:

source 'https://rubygems.org'
gem 'rubocop', '1.46.0'
$ bundle exec rubocop --debug --except Style/Documentation,Style/FrozenStringLiteralComment app_root.rb

RuboCop version

$ bundle exec rubocop -V
1.46.0 (using Parser 3.2.1.0, rubocop-ast 1.27.0, running on ruby 3.1.3) [x86_64-linux-musl]
nobuyo added a commit to nobuyo/rubocop that referenced this issue Mar 18, 2023
…en there are many comments with extra spaces
bbatsov pushed a commit that referenced this issue Mar 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant