Skip to content
代码片段 群组 项目
未验证 提交 3a697314 编辑于 作者: Peter Leitzen's avatar Peter Leitzen
浏览文件

Remove deprecated and unused .rubocop_todo.yml

We've moved RuboCop TODO's to `.rubocop_todo/**/*.yml` over an year ago
and it's not been used ever since then.
上级 91410120
No related branches found
No related tags found
无相关合并请求
...@@ -11,7 +11,6 @@ inherit_from: ...@@ -11,7 +11,6 @@ inherit_from:
<% Dir.glob('.rubocop_todo/**/*.yml').each do |rubocop_todo_yaml| %> <% Dir.glob('.rubocop_todo/**/*.yml').each do |rubocop_todo_yaml| %>
- '<%= rubocop_todo_yaml %>' - '<%= rubocop_todo_yaml %>'
<% end %> <% end %>
- '.rubocop_todo.yml'
<% end %> <% end %>
- ./rubocop/rubocop-migrations.yml - ./rubocop/rubocop-migrations.yml
- ./rubocop/rubocop-usage-data.yml - ./rubocop/rubocop-usage-data.yml
......
# This configuration is no longer used.
#
# The RuboCop TODO lists are located in `.rubocop_todo/**/*.yml`.
#
# Please use `rake rubocop:todo:generate` to generate TODOs.
#
# See https://docs.gitlab.com/ee/development/rake_tasks.html#generate-initial-rubocop-todo-list
...@@ -178,7 +178,7 @@ and run `bundle exec gitlab-housekeeper -k Keeps::GenerateRubocopTodos`. ...@@ -178,7 +178,7 @@ and run `bundle exec gitlab-housekeeper -k Keeps::GenerateRubocopTodos`.
## Reveal existing RuboCop exceptions ## Reveal existing RuboCop exceptions
To reveal existing RuboCop exceptions in the code that have been excluded via `.rubocop_todo.yml` and To reveal existing RuboCop exceptions in the code that have been excluded via
`.rubocop_todo/**/*.yml`, set the environment variable `REVEAL_RUBOCOP_TODO` to `1`. `.rubocop_todo/**/*.yml`, set the environment variable `REVEAL_RUBOCOP_TODO` to `1`.
This allows you to reveal existing RuboCop exceptions during your daily work cycle and fix them along the way. This allows you to reveal existing RuboCop exceptions during your daily work cycle and fix them along the way.
......
...@@ -35,8 +35,6 @@ def initialize(output, _options = {}) ...@@ -35,8 +35,6 @@ def initialize(output, _options = {})
@todos = Hash.new { |hash, cop_name| hash[cop_name] = CopTodo.new(cop_name) } @todos = Hash.new { |hash, cop_name| hash[cop_name] = CopTodo.new(cop_name) }
@todo_dir = TodoDir.new(directory) @todo_dir = TodoDir.new(directory)
@config_inspect_todo_dir = load_config_inspect_todo_dir @config_inspect_todo_dir = load_config_inspect_todo_dir
@config_old_todo_yml = load_config_old_todo_yml
check_multiple_configurations!
create_todos_retaining_exclusions(@config_inspect_todo_dir) create_todos_retaining_exclusions(@config_inspect_todo_dir)
super super
...@@ -79,14 +77,6 @@ def relative_path(path) ...@@ -79,14 +77,6 @@ def relative_path(path)
path.delete_prefix("#{parent}/") path.delete_prefix("#{parent}/")
end end
def check_multiple_configurations!
cop_names = @config_inspect_todo_dir.keys & @config_old_todo_yml.keys
return if cop_names.empty?
list = cop_names.sort.map { |cop_name| "- #{cop_name}" }.join("\n")
raise "Multiple configurations found for cops:\n#{list}\n"
end
def create_todos_retaining_exclusions(inspected_cop_config) def create_todos_retaining_exclusions(inspected_cop_config)
inspected_cop_config.each do |cop_name, config| inspected_cop_config.each do |cop_name, config|
todo = @todos[cop_name] todo = @todos[cop_name]
...@@ -98,7 +88,7 @@ def create_todos_retaining_exclusions(inspected_cop_config) ...@@ -98,7 +88,7 @@ def create_todos_retaining_exclusions(inspected_cop_config)
def config_for(todo) def config_for(todo)
cop_name = todo.cop_name cop_name = todo.cop_name
@config_old_todo_yml[cop_name] || @config_inspect_todo_dir[cop_name] || {} @config_inspect_todo_dir[cop_name] || {}
end end
def previously_disabled?(todo) def previously_disabled?(todo)
...@@ -131,15 +121,6 @@ def load_config_inspect_todo_dir ...@@ -131,15 +121,6 @@ def load_config_inspect_todo_dir
combined.update(config) if Hash === config combined.update(config) if Hash === config
end end
end end
# Load YAML configuration from `.rubocop_todo.yml`.
# We consider this file already old, obsolete, and to be removed soon.
def load_config_old_todo_yml
path = File.expand_path(File.join(directory, '../.rubocop_todo.yml'))
config = YAML.load_file(path) if File.exist?(path)
config || {}
end
end end
end end
end end
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
require_relative '../../../rubocop/formatter/graceful_formatter' require_relative '../../../rubocop/formatter/graceful_formatter'
require_relative '../../../rubocop/todo_dir' require_relative '../../../rubocop/todo_dir'
RSpec.describe RuboCop::Formatter::GracefulFormatter, :isolated_environment do RSpec.describe RuboCop::Formatter::GracefulFormatter, :isolated_environment, feature_category: :tooling do
# Set by :isolated_environment # Set by :isolated_environment
let(:todo_dir) { RuboCop::TodoDir.new("#{Dir.pwd}/.rubocop_todo") } let(:todo_dir) { RuboCop::TodoDir.new("#{Dir.pwd}/.rubocop_todo") }
let(:stdout) { StringIO.new } let(:stdout) { StringIO.new }
...@@ -43,14 +43,11 @@ ...@@ -43,14 +43,11 @@
let(:offense2) { fake_offense('Cop2') } let(:offense2) { fake_offense('Cop2') }
before do before do
FileUtils.touch('.rubocop_todo.yml')
File.write('.rubocop.yml', <<~YAML) File.write('.rubocop.yml', <<~YAML)
inherit_from: inherit_from:
<% Dir.glob('.rubocop_todo/**/*.yml').each do |rubocop_todo_yaml| %> <% Dir.glob('.rubocop_todo/**/*.yml').each do |rubocop_todo_yaml| %>
- '<%= rubocop_todo_yaml %>' - '<%= rubocop_todo_yaml %>'
<% end %> <% end %>
- '.rubocop_todo.yml'
AllCops: AllCops:
NewCops: enable # Avoiding RuboCop warnings NewCops: enable # Avoiding RuboCop warnings
...@@ -80,7 +77,7 @@ ...@@ -80,7 +77,7 @@
Details: grace period Details: grace period
YAML YAML
File.write('.rubocop_todo.yml', <<~YAML) todo_dir.write('Cop2', <<~YAML)
--- ---
Cop2: Cop2:
Details: grace period Details: grace period
......
...@@ -200,35 +200,6 @@ def run_formatter ...@@ -200,35 +200,6 @@ def run_formatter
end end
end end
context 'when cop previously explicitly disabled in rubocop_todo.yml' do
before do
File.write('.rubocop_todo.yml', <<~YAML)
---
B/TooManyOffenses:
Enabled: false
Exclude:
- 'x.rb'
YAML
todo_dir.inspect_all
end
it 'keeps cop disabled' do
run_formatter
expect(todo_yml('B/TooManyOffenses')).to eq(<<~YAML)
---
B/TooManyOffenses:
# Offense count: 3
# Temporarily disabled due to too many offenses
Enabled: false
Exclude:
- 'a.rb'
- 'c.rb'
YAML
end
end
context 'with grace period' do context 'with grace period' do
let(:yaml) do let(:yaml) do
<<~YAML <<~YAML
...@@ -240,6 +211,11 @@ def run_formatter ...@@ -240,6 +211,11 @@ def run_formatter
YAML YAML
end end
before do
todo_dir.write('B/TooManyOffenses', yaml)
todo_dir.inspect_all
end
shared_examples 'keeps grace period' do shared_examples 'keeps grace period' do
it 'keeps Details: grace period' do it 'keeps Details: grace period' do
run_formatter run_formatter
...@@ -255,22 +231,7 @@ def run_formatter ...@@ -255,22 +231,7 @@ def run_formatter
end end
end end
context 'in rubocop_todo/' do it_behaves_like 'keeps grace period'
before do
todo_dir.write('B/TooManyOffenses', yaml)
todo_dir.inspect_all
end
it_behaves_like 'keeps grace period'
end
context 'in rubocop_todo.yml' do
before do
File.write('.rubocop_todo.yml', yaml)
end
it_behaves_like 'keeps grace period'
end
context 'with invalid details value' do context 'with invalid details value' do
let(:yaml) do let(:yaml) do
...@@ -284,8 +245,6 @@ def run_formatter ...@@ -284,8 +245,6 @@ def run_formatter
end end
it 'ignores the details and warns' do it 'ignores the details and warns' do
File.write('.rubocop_todo.yml', yaml)
expect { run_formatter } expect { run_formatter }
.to output(%r{B/TooManyOffenses: Unhandled value "something unknown" for `Details` key.}) .to output(%r{B/TooManyOffenses: Unhandled value "something unknown" for `Details` key.})
.to_stderr .to_stderr
...@@ -313,51 +272,11 @@ def run_formatter ...@@ -313,51 +272,11 @@ def run_formatter
end end
it 'raises an exception' do it 'raises an exception' do
File.write('.rubocop_todo.yml', yaml)
expect { run_formatter } expect { run_formatter }
.to raise_error(RuntimeError, 'B/TooManyOffenses: Cop must be enabled to use `Details: grace period`.') .to raise_error(RuntimeError, 'B/TooManyOffenses: Cop must be enabled to use `Details: grace period`.')
end end
end end
end end
context 'with cop configuration in both .rubocop_todo/ and .rubocop_todo.yml' do
before do
todo_dir.write('B/TooManyOffenses', <<~YAML)
---
B/TooManyOffenses:
Exclude:
- 'a.rb'
YAML
todo_dir.write('A/Offense', <<~YAML)
---
A/Offense:
Exclude:
- 'a.rb'
YAML
todo_dir.inspect_all
File.write('.rubocop_todo.yml', <<~YAML)
---
B/TooManyOffenses:
Exclude:
- 'x.rb'
A/Offense:
Exclude:
- 'y.rb'
YAML
end
it 'raises an error' do
expect { run_formatter }.to raise_error(RuntimeError, <<~TXT)
Multiple configurations found for cops:
- A/Offense
- B/TooManyOffenses
TXT
end
end
end end
context 'without offenses detected' do context 'without offenses detected' do
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
require_relative '../../rubocop/todo_dir' require_relative '../../rubocop/todo_dir'
require_relative '../../rubocop/check_graceful_task' require_relative '../../rubocop/check_graceful_task'
RSpec.describe 'rubocop rake tasks', :silence_stdout do RSpec.describe 'rubocop rake tasks', :silence_stdout, feature_category: :tooling do
include NextInstanceOf include NextInstanceOf
before do before do
...@@ -81,14 +81,13 @@ ...@@ -81,14 +81,13 @@
RUBY RUBY
# Mimicking GitLab's .rubocop_todo.yml avoids relying on RuboCop's # Mimicking GitLab's .rubocop_todo/**/*.yml avoids relying on RuboCop's
# default.yml configuration. # default.yml configuration.
File.write('.rubocop.yml', <<~YAML) File.write('.rubocop.yml', <<~YAML)
<% unless ENV['REVEAL_RUBOCOP_TODO'] == '1' %> <% unless ENV['REVEAL_RUBOCOP_TODO'] == '1' %>
<% Dir.glob('.rubocop_todo/**/*.yml').each do |rubocop_todo_yaml| %> <% Dir.glob('.rubocop_todo/**/*.yml').each do |rubocop_todo_yaml| %>
- '<%= rubocop_todo_yaml %>' - '<%= rubocop_todo_yaml %>'
<% end %> <% end %>
- '.rubocop_todo.yml'
<% end %> <% end %>
AllCops: AllCops:
...@@ -107,16 +106,6 @@ ...@@ -107,16 +106,6 @@
Enabled: true Enabled: true
YAML YAML
# Required to verify that we are revealing all TODOs via
# ENV['REVEAL_RUBOCOP_TODO'] = '1'.
# This file can be removed from specs after we've moved all offenses from
# .rubocop_todo.yml to .rubocop_todo/**/*.yml.
File.write('.rubocop_todo.yml', <<~YAML)
# Too many offenses
Layout/SpaceAroundOperators:
Enabled: false
YAML
# Previous offense now fixed. # Previous offense now fixed.
todo_dir.write('Lint/Syntax', '') todo_dir.write('Lint/Syntax', '')
end end
......
...@@ -90,7 +90,6 @@ ...@@ -90,7 +90,6 @@
'lib/foo' | [:backend] 'lib/foo' | [:backend]
'rubocop/foo' | [:backend] 'rubocop/foo' | [:backend]
'.rubocop.yml' | [:backend] '.rubocop.yml' | [:backend]
'.rubocop_todo.yml' | [:backend]
'.rubocop_todo/cop/name.yml' | [:backend] '.rubocop_todo/cop/name.yml' | [:backend]
'gems/foo/.rubocop.yml' | [:backend] 'gems/foo/.rubocop.yml' | [:backend]
'spec/foo' | [:backend] 'spec/foo' | [:backend]
......
...@@ -144,7 +144,7 @@ module ProjectHelper ...@@ -144,7 +144,7 @@ module ProjectHelper
%r{\A((ee|jh)/)?vendor/} => :backend, %r{\A((ee|jh)/)?vendor/} => :backend,
%r{\A(Gemfile.*|Rakefile)\z} => :backend, %r{\A(Gemfile.*|Rakefile)\z} => :backend,
%r{\A[A-Z_]+_VERSION\z} => :backend, %r{\A[A-Z_]+_VERSION\z} => :backend,
%r{\A\.rubocop(_todo)?\.yml\z} => :backend, %r{\A\.rubocop\.yml\z} => :backend,
%r{\Agems/.*/\.rubocop\.yml\z} => :backend, %r{\Agems/.*/\.rubocop\.yml\z} => :backend,
%r{\A\.rubocop_todo/.*\.yml\z} => :backend, %r{\A\.rubocop_todo/.*\.yml\z} => :backend,
%r{\Afile_hooks/} => :backend, %r{\Afile_hooks/} => :backend,
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册