Skip to content

Commit f603abd

Browse files
committed
Make --lint work with Lint/UnneededDisable
By letting --lint be an alias for --only Lint, we take advantage of the logic that's already in place for handling of --only in Lint/UnneededDisable.
1 parent a0ae989 commit f603abd

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* [#2232](https://github.com/bbatsov/rubocop/issues/2232): Fix false positive in `Lint/FormatParameterMismatch` for argument with splat operator. ([@dreyks][])
88
* [#2237](https://github.com/bbatsov/rubocop/pull/2237): Allow `Lint/FormatParameterMismatch` to be called using `Kernel.format` and `Kernel.sprintf`. ([@rrosenblum][])
99
* [#2234](https://github.com/bbatsov/rubocop/issues/2234): Do not register an offense for `Lint/FormatParameterMismatch` when the format string is a variable. ([@rrosenblum][])
10+
* [#2240](https://github.com/bbatsov/rubocop/pull/2240): `Lint/UnneededDisable` should not report non-`Lint` `rubocop:disable` comments when running `rubocop --lint`. ([@jonas054][])
1011

1112
## 0.34.1 (09/09/2015)
1213

lib/rubocop/options.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,10 @@ def add_boolean_flags(opts)
137137
option(opts, '-D', '--display-cop-names')
138138
option(opts, '-S', '--display-style-guide')
139139
option(opts, '-R', '--rails')
140-
option(opts, '-l', '--lint')
140+
option(opts, '-l', '--lint') do
141+
@options[:only] ||= []
142+
@options[:only] << 'Lint'
143+
end
141144
option(opts, '-a', '--auto-correct')
142145

143146
@options[:color] = true

lib/rubocop/runner.rb

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,7 @@ def mobilized_cop_classes(config)
180180
[:only, :except].each { |opt| Options.validate_cop_list(@options[opt]) }
181181

182182
if @options[:only]
183-
cop_classes.select! do |c|
184-
c.match?(@options[:only]) || @options[:lint] && c.lint?
185-
end
183+
cop_classes.select! { |c| c.match?(@options[:only]) }
186184
else
187185
filter_cop_classes(cop_classes, config)
188186
end
@@ -201,9 +199,6 @@ def filter_cop_classes(cop_classes, config)
201199

202200
# filter out Rails cops unless requested
203201
cop_classes.reject!(&:rails?) unless run_rails_cops?(config)
204-
205-
# select only lint cops when --lint is passed
206-
cop_classes.select!(&:lint?) if @options[:lint]
207202
end
208203

209204
def run_rails_cops?(config)

spec/rubocop/cli_spec.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1533,6 +1533,7 @@ def abs(path)
15331533
it 'runs only lint cops' do
15341534
create_file('example.rb', ['if 0 ',
15351535
"\ty",
1536+
"\tz # rubocop:disable Style/Tab",
15361537
'end'])
15371538
# IfUnlessModifier depends on the configuration of LineLength.
15381539

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy