Skip to content

Commit 4a7a543

Browse files
committed
Always include all Cops by default
I made a change a couple of weeks back to only include Rails cops in the event we detect railties in the project's Gemfile.lock. I'm convinced this was the wrong course of action since our default rubocop configuration file (https://github.com/codeclimate/codeclimate/blob/master/config/rubocop/.rubocop.yml#L1119) has these mostly disabled out of the box. It makes much more sense to rely on either a user's existing .rubocop.yml or our default rather than mucking with this within the engine itself.
1 parent 386725e commit 4a7a543

File tree

6 files changed

+1
-262
lines changed

6 files changed

+1
-262
lines changed

lib/cc/engine/lockfile_specs.rb

Lines changed: 0 additions & 15 deletions
This file was deleted.

lib/cc/engine/rubocop.rb

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
require "rubocop/cop/method_complexity_patch"
55
require "cc/engine/category_parser"
66
require "cc/engine/file_list_resolver"
7-
require "cc/engine/lockfile_specs"
87
require "cc/engine/violation_decorator"
98
require "active_support"
109
require "active_support/core_ext"
@@ -69,7 +68,7 @@ def rubocop_config_store
6968

7069
def rubocop_team_for_path(path)
7170
rubocop_config = rubocop_config_store.for(path)
72-
RuboCop::Cop::Team.new(cops, rubocop_config)
71+
RuboCop::Cop::Team.new(RuboCop::Cop::Cop.all, rubocop_config)
7372
end
7473

7574
def violation_positions(location)
@@ -120,16 +119,6 @@ def content_body(cop_name)
120119
)
121120
File.exist?(path) ? File.read(path) : nil
122121
end
123-
124-
def cops
125-
specs = LockfileSpecs.new("Gemfile.lock")
126-
127-
if specs.include?("railties")
128-
RuboCop::Cop::Cop.all
129-
else
130-
RuboCop::Cop::Cop.non_rails
131-
end
132-
end
133122
end
134123
end
135124
end

spec/cc/engine/lockfile_specs_spec.rb

Lines changed: 0 additions & 37 deletions
This file was deleted.

spec/cc/engine/rubocop_spec.rb

Lines changed: 0 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -110,79 +110,6 @@ def method
110110
assert !includes_check?(output, "Lint/UselessAssignment")
111111
end
112112

113-
it "excludes Rails cops when there is no Gemfile.lock file present" do
114-
create_source_file("object.rb", <<-EORUBY)
115-
class Object
116-
def method
117-
target.method
118-
end
119-
end
120-
EORUBY
121-
122-
assert !includes_check?(run_engine, "Rubocop/Rails/Delegate")
123-
end
124-
125-
it "excludes Rails cops when railties isn't in the Gemfile.lock file" do
126-
create_source_file("object.rb", <<-EORUBY)
127-
class Object
128-
def method
129-
target.method
130-
end
131-
end
132-
EORUBY
133-
134-
create_source_file("Gemfile.lock", <<-EORUBY.strip_heredoc)
135-
GEM
136-
remote: https://rubygems.org/
137-
specs:
138-
rake (10.4.2)
139-
EORUBY
140-
141-
assert !includes_check?(run_engine, "Rubocop/Rails/Delegate")
142-
end
143-
144-
it "excludes Rails cops when there is no valid Gemfile.lock file" do
145-
create_source_file("object.rb", <<-EORUBY)
146-
class Object
147-
def method
148-
target.method
149-
end
150-
end
151-
EORUBY
152-
153-
# This will create a parse error as Bundler::LockfileParser looks
154-
# specifically for merge conflict artifacts and bails.
155-
create_source_file("Gemfile.lock", <<-EORUBY.strip_heredoc)
156-
<<<<<<< HEAD
157-
=======
158-
GEM
159-
remote: https://rubygems.org/
160-
specs:
161-
rake (10.4.2)
162-
EORUBY
163-
164-
assert !includes_check?(run_engine, "Rubocop/Rails/Delegate")
165-
end
166-
167-
it "includes Rails cops when railties is in the Gemfile.lock file" do
168-
create_source_file("object.rb", <<-EORUBY)
169-
class Object
170-
def method
171-
target.method
172-
end
173-
end
174-
EORUBY
175-
176-
create_source_file("Gemfile.lock", <<-EORUBY.strip_heredoc)
177-
GEM
178-
remote: https://rubygems.org/
179-
specs:
180-
railties (4.2.4)
181-
EORUBY
182-
183-
assert includes_check?(run_engine, "Rubocop/Rails/Delegate")
184-
end
185-
186113
it "layers config exclusions on top of the YAML config" do
187114
create_source_file("foo.rb", <<-EORUBY)
188115
def method

spec/fixtures/Gemfile.lock

Lines changed: 0 additions & 61 deletions
This file was deleted.

spec/fixtures/Gemfile.lock.with_merge_conflicts

Lines changed: 0 additions & 64 deletions
This file was deleted.

0 commit comments

Comments
 (0)