rubocop 1.28.2 → 1.29.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +3 -3
- data/config/default.yml +36 -21
- data/lib/rubocop/cop/badge.rb +1 -1
- data/lib/rubocop/cop/bundler/duplicated_gem.rb +1 -1
- data/lib/rubocop/cop/bundler/gem_comment.rb +1 -1
- data/lib/rubocop/cop/gemspec/dependency_version.rb +156 -0
- data/lib/rubocop/cop/gemspec/duplicated_assignment.rb +3 -6
- data/lib/rubocop/cop/gemspec/ruby_version_globals_usage.rb +1 -1
- data/lib/rubocop/cop/internal_affairs/method_name_end_with.rb +80 -0
- data/lib/rubocop/cop/internal_affairs.rb +1 -0
- data/lib/rubocop/cop/layout/comment_indentation.rb +1 -1
- data/lib/rubocop/cop/layout/line_end_string_concatenation_indentation.rb +1 -1
- data/lib/rubocop/cop/layout/space_around_block_parameters.rb +1 -1
- data/lib/rubocop/cop/layout/space_inside_reference_brackets.rb +1 -1
- data/lib/rubocop/cop/layout/trailing_empty_lines.rb +1 -1
- data/lib/rubocop/cop/lint/ambiguous_range.rb +2 -2
- data/lib/rubocop/cop/lint/erb_new_arguments.rb +1 -1
- data/lib/rubocop/cop/lint/loop.rb +1 -1
- data/lib/rubocop/cop/lint/non_deterministic_require_order.rb +5 -5
- data/lib/rubocop/cop/lint/or_assignment_to_constant.rb +1 -1
- data/lib/rubocop/cop/lint/parentheses_as_grouped_expression.rb +1 -1
- data/lib/rubocop/cop/lint/raise_exception.rb +1 -1
- data/lib/rubocop/cop/lint/return_in_void_context.rb +5 -17
- data/lib/rubocop/cop/lint/useless_times.rb +1 -1
- data/lib/rubocop/cop/mixin/duplication.rb +1 -1
- data/lib/rubocop/cop/mixin/preferred_delimiters.rb +2 -2
- data/lib/rubocop/cop/mixin/statement_modifier.rb +1 -1
- data/lib/rubocop/cop/mixin/trailing_comma.rb +1 -1
- data/lib/rubocop/cop/naming/block_forwarding.rb +1 -1
- data/lib/rubocop/cop/naming/file_name.rb +1 -1
- data/lib/rubocop/cop/naming/inclusive_language.rb +3 -2
- data/lib/rubocop/cop/naming/predicate_name.rb +2 -2
- data/lib/rubocop/cop/naming/variable_name.rb +9 -0
- data/lib/rubocop/cop/naming/variable_number.rb +10 -0
- data/lib/rubocop/cop/security/yaml_load.rb +1 -1
- data/lib/rubocop/cop/style/alias.rb +3 -3
- data/lib/rubocop/cop/style/and_or.rb +1 -1
- data/lib/rubocop/cop/style/bisected_attr_accessor/macro.rb +1 -1
- data/lib/rubocop/cop/style/case_like_if.rb +1 -1
- data/lib/rubocop/cop/style/character_literal.rb +1 -1
- data/lib/rubocop/cop/style/collection_compact.rb +3 -3
- data/lib/rubocop/cop/style/date_time.rb +1 -1
- data/lib/rubocop/cop/style/double_negation.rb +28 -2
- data/lib/rubocop/cop/style/empty_case_condition.rb +1 -1
- data/lib/rubocop/cop/style/empty_literal.rb +1 -1
- data/lib/rubocop/cop/style/env_home.rb +56 -0
- data/lib/rubocop/cop/style/fetch_env_var.rb +240 -11
- data/lib/rubocop/cop/style/identical_conditional_branches.rb +2 -2
- data/lib/rubocop/cop/style/mixin_grouping.rb +1 -1
- data/lib/rubocop/cop/style/multiline_ternary_operator.rb +5 -1
- data/lib/rubocop/cop/style/next.rb +1 -1
- data/lib/rubocop/cop/style/optional_arguments.rb +1 -1
- data/lib/rubocop/cop/style/optional_boolean_parameter.rb +1 -1
- data/lib/rubocop/cop/style/quoted_symbols.rb +1 -1
- data/lib/rubocop/cop/style/raise_args.rb +4 -1
- data/lib/rubocop/cop/style/redundant_condition.rb +108 -11
- data/lib/rubocop/cop/style/redundant_regexp_character_class.rb +1 -1
- data/lib/rubocop/cop/style/redundant_regexp_escape.rb +1 -1
- data/lib/rubocop/cop/style/redundant_self_assignment.rb +1 -2
- data/lib/rubocop/cop/style/safe_navigation.rb +1 -1
- data/lib/rubocop/cop/style/string_chars.rb +1 -1
- data/lib/rubocop/cop/style/trivial_accessors.rb +7 -8
- data/lib/rubocop/cops_documentation_generator.rb +1 -1
- data/lib/rubocop/formatter/formatter_set.rb +1 -0
- data/lib/rubocop/formatter/html_formatter.rb +2 -9
- data/lib/rubocop/formatter/markdown_formatter.rb +76 -0
- data/lib/rubocop/magic_comment.rb +4 -3
- data/lib/rubocop/options.rb +4 -3
- data/lib/rubocop/result_cache.rb +1 -1
- data/lib/rubocop/rspec/cop_helper.rb +1 -1
- data/lib/rubocop/rspec/parallel_formatter.rb +1 -1
- data/lib/rubocop/rspec/shared_contexts.rb +1 -1
- data/lib/rubocop/runner.rb +1 -1
- data/lib/rubocop/string_interpreter.rb +4 -4
- data/lib/rubocop/target_ruby.rb +7 -1
- data/lib/rubocop/version.rb +1 -1
- data/lib/rubocop.rb +3 -1
- metadata +16 -7
- data/lib/rubocop/cop/lint/useless_else_without_rescue.rb +0 -45
@@ -246,7 +246,7 @@ class CopsDocumentationGenerator # rubocop:disable Metrics/ClassLength
|
|
246
246
|
end
|
247
247
|
|
248
248
|
def table_of_content_for_department(department)
|
249
|
-
type_title = department[0].upcase + department[1
|
249
|
+
type_title = department[0].upcase + department[1..]
|
250
250
|
filename = "#{department_to_basename(department)}.adoc"
|
251
251
|
content = +"=== Department xref:#{filename}[#{type_title}]\n\n"
|
252
252
|
cops_of_department(department).each do |cop|
|
@@ -53,14 +53,7 @@ module RuboCop
|
|
53
53
|
context = ERBContext.new(files, summary)
|
54
54
|
|
55
55
|
template = File.read(TEMPLATE_PATH, encoding: Encoding::UTF_8)
|
56
|
-
|
57
|
-
# The following condition is workaround for until Ruby 2.6 is released.
|
58
|
-
# https://github.com/ruby/ruby/commit/cc777d09f44fa909a336ba14f3aa802ffe16e010
|
59
|
-
erb = if RUBY_VERSION >= '2.6'
|
60
|
-
ERB.new(template, trim_mode: '-')
|
61
|
-
else
|
62
|
-
ERB.new(template, nil, '-')
|
63
|
-
end
|
56
|
+
erb = ERB.new(template, trim_mode: '-')
|
64
57
|
html = erb.result(context.binding)
|
65
58
|
|
66
59
|
output.write html
|
@@ -119,7 +112,7 @@ module RuboCop
|
|
119
112
|
|
120
113
|
def source_after_highlight(offense)
|
121
114
|
source_line = offense.location.source_line
|
122
|
-
escape(source_line[offense.highlighted_area.end_pos
|
115
|
+
escape(source_line[offense.highlighted_area.end_pos..])
|
123
116
|
end
|
124
117
|
|
125
118
|
def possible_ellipses(location)
|
@@ -0,0 +1,76 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module Formatter
|
5
|
+
# This formatter displays the report data in markdown
|
6
|
+
class MarkdownFormatter < BaseFormatter
|
7
|
+
include TextUtil
|
8
|
+
include PathUtil
|
9
|
+
attr_reader :files, :summary
|
10
|
+
|
11
|
+
def initialize(output, options = {})
|
12
|
+
super
|
13
|
+
@files = []
|
14
|
+
@summary = Struct.new(:offense_count, :inspected_files, :target_files).new(0)
|
15
|
+
end
|
16
|
+
|
17
|
+
def started(target_files)
|
18
|
+
summary.target_files = target_files
|
19
|
+
end
|
20
|
+
|
21
|
+
def file_finished(file, offenses)
|
22
|
+
files << Struct.new(:path, :offenses).new(file, offenses)
|
23
|
+
summary.offense_count += offenses.count
|
24
|
+
end
|
25
|
+
|
26
|
+
def finished(inspected_files)
|
27
|
+
summary.inspected_files = inspected_files
|
28
|
+
render_markdown
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def render_markdown
|
34
|
+
n_files = pluralize(summary.inspected_files.count, 'file')
|
35
|
+
n_offenses = pluralize(summary.offense_count, 'offense', no_for_zero: true)
|
36
|
+
|
37
|
+
output.write "# RuboCop Inspection Report\n\n"
|
38
|
+
output.write "#{n_files} inspected, #{n_offenses} detected:\n\n"
|
39
|
+
write_file_messages
|
40
|
+
end
|
41
|
+
|
42
|
+
def write_file_messages
|
43
|
+
files.each do |file|
|
44
|
+
write_heading(file)
|
45
|
+
file.offenses.each do |offense|
|
46
|
+
write_context(offense)
|
47
|
+
write_code(offense)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def write_heading(file)
|
53
|
+
filename = relative_path(file.path)
|
54
|
+
n_offenses = pluralize(file.offenses.count, 'offense')
|
55
|
+
|
56
|
+
output.write "### #{filename} - (#{n_offenses})\n"
|
57
|
+
end
|
58
|
+
|
59
|
+
def write_context(offense)
|
60
|
+
output.write(
|
61
|
+
" * **Line # #{offense.location.line} - #{offense.severity}:** #{offense.message}\n\n"
|
62
|
+
)
|
63
|
+
end
|
64
|
+
|
65
|
+
def write_code(offense)
|
66
|
+
code = offense.location.source_line + possible_ellipses(offense.location)
|
67
|
+
|
68
|
+
output.write " ```rb\n #{code}\n ```\n\n" unless code.blank?
|
69
|
+
end
|
70
|
+
|
71
|
+
def possible_ellipses(location)
|
72
|
+
location.first_line == location.last_line ? '' : ' ...'
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -5,7 +5,8 @@ module RuboCop
|
|
5
5
|
#
|
6
6
|
# @abstract parent of three different magic comment handlers
|
7
7
|
class MagicComment
|
8
|
-
#
|
8
|
+
# IRB's pattern for matching magic comment tokens.
|
9
|
+
# @see https://github.com/ruby/ruby/blob/b4a55c1/lib/irb/magic-file.rb#L5
|
9
10
|
TOKEN = /[[:alnum:]\-_]+/.freeze
|
10
11
|
KEYWORDS = {
|
11
12
|
encoding: '(?:en)?coding',
|
@@ -170,7 +171,7 @@ module RuboCop
|
|
170
171
|
# comment.encoding # => 'ascii-8bit'
|
171
172
|
#
|
172
173
|
# @see https://www.gnu.org/software/emacs/manual/html_node/emacs/Specify-Coding.html
|
173
|
-
# @see https://
|
174
|
+
# @see https://github.com/ruby/ruby/blob/3f306dc/parse.y#L6873-L6892 Emacs handling in parse.y
|
174
175
|
class EmacsComment < EditorComment
|
175
176
|
REGEXP = /-\*-(.+)-\*-/.freeze
|
176
177
|
FORMAT = '# -*- %s -*-'
|
@@ -259,7 +260,7 @@ module RuboCop
|
|
259
260
|
# is the only text in the comment.
|
260
261
|
#
|
261
262
|
# Case-insensitive and dashes/underscores are acceptable.
|
262
|
-
# @see https://
|
263
|
+
# @see https://github.com/ruby/ruby/blob/78b95b4/parse.y#L7134-L7138
|
263
264
|
def extract_frozen_string_literal
|
264
265
|
extract(/\A\s*#\s*#{KEYWORDS[:frozen_string_literal]}:\s*(#{TOKEN})\s*\z/io)
|
265
266
|
end
|
data/lib/rubocop/options.rb
CHANGED
@@ -239,7 +239,7 @@ module RuboCop
|
|
239
239
|
# e.g. [..., '--auto-correct', ...] to :auto_correct.
|
240
240
|
def long_opt_symbol(args)
|
241
241
|
long_opt = args.find { |arg| arg.start_with?('--') }
|
242
|
-
long_opt[2
|
242
|
+
long_opt[2..].sub('[no-]', '').sub(/ .*/, '').tr('-', '_').gsub(/[\[\]]/, '').to_sym
|
243
243
|
end
|
244
244
|
|
245
245
|
def require_feature(file)
|
@@ -309,7 +309,7 @@ module RuboCop
|
|
309
309
|
end
|
310
310
|
|
311
311
|
if display_only_fail_level_offenses_with_autocorrect?
|
312
|
-
raise OptionArgumentError, '--
|
312
|
+
raise OptionArgumentError, '--auto-correct cannot be used with ' \
|
313
313
|
'--display-only-fail-level-offenses'
|
314
314
|
end
|
315
315
|
|
@@ -402,7 +402,8 @@ module RuboCop
|
|
402
402
|
end
|
403
403
|
|
404
404
|
def display_only_fail_level_offenses_with_autocorrect?
|
405
|
-
@options[:display_only_fail_level_offenses] &&
|
405
|
+
@options[:display_only_fail_level_offenses] &&
|
406
|
+
(@options.key?(:auto_correct) || @options.key?(:safe_auto_correct))
|
406
407
|
end
|
407
408
|
|
408
409
|
def except_syntax?
|
data/lib/rubocop/result_cache.rb
CHANGED
@@ -81,7 +81,7 @@ module RuboCop
|
|
81
81
|
#
|
82
82
|
# To avoid raising warn log messages on FreeBSD, we retrieve
|
83
83
|
# the real path of the home folder.
|
84
|
-
File.join(File.realpath(
|
84
|
+
File.join(File.realpath(Dir.home), '.cache')
|
85
85
|
end
|
86
86
|
File.join(root, 'rubocop_cache')
|
87
87
|
end
|
@@ -65,7 +65,7 @@ module RuboCop
|
|
65
65
|
# removed!
|
66
66
|
def output_rerun_commands(summary)
|
67
67
|
output.puts '# RERUN BEGIN'
|
68
|
-
output.puts summary.colorized_rerun_commands.lines[3
|
68
|
+
output.puts summary.colorized_rerun_commands.lines[3..].join
|
69
69
|
output.puts '# RERUN END'
|
70
70
|
end
|
71
71
|
|
@@ -5,7 +5,7 @@ require 'tmpdir'
|
|
5
5
|
RSpec.shared_context 'isolated environment', :isolated_environment do
|
6
6
|
around do |example|
|
7
7
|
Dir.mktmpdir do |tmpdir|
|
8
|
-
original_home =
|
8
|
+
original_home = Dir.home
|
9
9
|
original_xdg_config_home = ENV.fetch('XDG_CONFIG_HOME', nil)
|
10
10
|
|
11
11
|
# Make sure to expand all symlinks in the path first. Otherwise we may
|
data/lib/rubocop/runner.rb
CHANGED
@@ -13,7 +13,7 @@ module RuboCop
|
|
13
13
|
|
14
14
|
def initialize(path, offenses_by_iteration, loop_start: -1)
|
15
15
|
@offenses = offenses_by_iteration.flatten.uniq
|
16
|
-
root_cause = offenses_by_iteration[loop_start
|
16
|
+
root_cause = offenses_by_iteration[loop_start..]
|
17
17
|
.map { |x| x.map(&:cop_name).uniq.join(', ') }
|
18
18
|
.join(' -> ')
|
19
19
|
|
@@ -42,18 +42,18 @@ module RuboCop
|
|
42
42
|
|
43
43
|
def interpret_unicode(escape)
|
44
44
|
if escape[2] == '{'
|
45
|
-
escape[3
|
45
|
+
escape[3..].split(/\s+/).map(&:hex).pack('U*')
|
46
46
|
else
|
47
|
-
[escape[2
|
47
|
+
[escape[2..].hex].pack('U')
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
51
51
|
def interpret_hex(escape)
|
52
|
-
[escape[2
|
52
|
+
[escape[2..].hex].pack('C')
|
53
53
|
end
|
54
54
|
|
55
55
|
def interpret_octal(escape)
|
56
|
-
[escape[1
|
56
|
+
[escape[1..].to_i(8)].pack('C')
|
57
57
|
end
|
58
58
|
end
|
59
59
|
end
|
data/lib/rubocop/target_ruby.rb
CHANGED
@@ -8,7 +8,13 @@ module RuboCop
|
|
8
8
|
DEFAULT_VERSION = KNOWN_RUBIES.first
|
9
9
|
|
10
10
|
OBSOLETE_RUBIES = {
|
11
|
-
1.9 => '0.41',
|
11
|
+
1.9 => '0.41',
|
12
|
+
2.0 => '0.50',
|
13
|
+
2.1 => '0.57',
|
14
|
+
2.2 => '0.68',
|
15
|
+
2.3 => '0.81',
|
16
|
+
2.4 => '1.12',
|
17
|
+
2.5 => '1.28'
|
12
18
|
}.freeze
|
13
19
|
private_constant :KNOWN_RUBIES, :OBSOLETE_RUBIES
|
14
20
|
|
data/lib/rubocop/version.rb
CHANGED
data/lib/rubocop.rb
CHANGED
@@ -161,6 +161,7 @@ require_relative 'rubocop/cop/bundler/insecure_protocol_source'
|
|
161
161
|
require_relative 'rubocop/cop/bundler/ordered_gems'
|
162
162
|
|
163
163
|
require_relative 'rubocop/cop/gemspec/date_assignment'
|
164
|
+
require_relative 'rubocop/cop/gemspec/dependency_version'
|
164
165
|
require_relative 'rubocop/cop/gemspec/duplicated_assignment'
|
165
166
|
require_relative 'rubocop/cop/gemspec/ordered_dependencies'
|
166
167
|
require_relative 'rubocop/cop/gemspec/require_mfa'
|
@@ -385,7 +386,6 @@ require_relative 'rubocop/cop/lint/uri_escape_unescape'
|
|
385
386
|
require_relative 'rubocop/cop/lint/uri_regexp'
|
386
387
|
require_relative 'rubocop/cop/lint/useless_access_modifier'
|
387
388
|
require_relative 'rubocop/cop/lint/useless_assignment'
|
388
|
-
require_relative 'rubocop/cop/lint/useless_else_without_rescue'
|
389
389
|
require_relative 'rubocop/cop/lint/useless_method_definition'
|
390
390
|
require_relative 'rubocop/cop/lint/useless_ruby2_keywords'
|
391
391
|
require_relative 'rubocop/cop/lint/useless_setter_call'
|
@@ -480,6 +480,7 @@ require_relative 'rubocop/cop/style/empty_method'
|
|
480
480
|
require_relative 'rubocop/cop/style/endless_method'
|
481
481
|
require_relative 'rubocop/cop/style/encoding'
|
482
482
|
require_relative 'rubocop/cop/style/end_block'
|
483
|
+
require_relative 'rubocop/cop/style/env_home'
|
483
484
|
require_relative 'rubocop/cop/style/eval_with_location'
|
484
485
|
require_relative 'rubocop/cop/style/even_odd'
|
485
486
|
require_relative 'rubocop/cop/style/expand_path_arguments'
|
@@ -675,6 +676,7 @@ require_relative 'rubocop/formatter/git_hub_actions_formatter'
|
|
675
676
|
require_relative 'rubocop/formatter/html_formatter'
|
676
677
|
require_relative 'rubocop/formatter/json_formatter'
|
677
678
|
require_relative 'rubocop/formatter/junit_formatter'
|
679
|
+
require_relative 'rubocop/formatter/markdown_formatter'
|
678
680
|
require_relative 'rubocop/formatter/offense_count_formatter'
|
679
681
|
require_relative 'rubocop/formatter/progress_formatter'
|
680
682
|
require_relative 'rubocop/formatter/quiet_formatter'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubocop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.29.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bozhidar Batsov
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date: 2022-
|
13
|
+
date: 2022-05-12 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: parallel
|
@@ -86,14 +86,20 @@ dependencies:
|
|
86
86
|
requirements:
|
87
87
|
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
89
|
+
version: 3.2.5
|
90
|
+
- - "<"
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: '4.0'
|
90
93
|
type: :runtime
|
91
94
|
prerelease: false
|
92
95
|
version_requirements: !ruby/object:Gem::Requirement
|
93
96
|
requirements:
|
94
97
|
- - ">="
|
95
98
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
99
|
+
version: 3.2.5
|
100
|
+
- - "<"
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '4.0'
|
97
103
|
- !ruby/object:Gem::Dependency
|
98
104
|
name: rubocop-ast
|
99
105
|
requirement: !ruby/object:Gem::Requirement
|
@@ -250,6 +256,7 @@ files:
|
|
250
256
|
- lib/rubocop/cop/exclude_limit.rb
|
251
257
|
- lib/rubocop/cop/force.rb
|
252
258
|
- lib/rubocop/cop/gemspec/date_assignment.rb
|
259
|
+
- lib/rubocop/cop/gemspec/dependency_version.rb
|
253
260
|
- lib/rubocop/cop/gemspec/duplicated_assignment.rb
|
254
261
|
- lib/rubocop/cop/gemspec/ordered_dependencies.rb
|
255
262
|
- lib/rubocop/cop/gemspec/require_mfa.rb
|
@@ -264,6 +271,7 @@ files:
|
|
264
271
|
- lib/rubocop/cop/internal_affairs/example_description.rb
|
265
272
|
- lib/rubocop/cop/internal_affairs/inherit_deprecated_cop_class.rb
|
266
273
|
- lib/rubocop/cop/internal_affairs/location_line_equality_comparison.rb
|
274
|
+
- lib/rubocop/cop/internal_affairs/method_name_end_with.rb
|
267
275
|
- lib/rubocop/cop/internal_affairs/method_name_equal.rb
|
268
276
|
- lib/rubocop/cop/internal_affairs/node_destructuring.rb
|
269
277
|
- lib/rubocop/cop/internal_affairs/node_matcher_directive.rb
|
@@ -497,7 +505,6 @@ files:
|
|
497
505
|
- lib/rubocop/cop/lint/uri_regexp.rb
|
498
506
|
- lib/rubocop/cop/lint/useless_access_modifier.rb
|
499
507
|
- lib/rubocop/cop/lint/useless_assignment.rb
|
500
|
-
- lib/rubocop/cop/lint/useless_else_without_rescue.rb
|
501
508
|
- lib/rubocop/cop/lint/useless_method_definition.rb
|
502
509
|
- lib/rubocop/cop/lint/useless_ruby2_keywords.rb
|
503
510
|
- lib/rubocop/cop/lint/useless_setter_call.rb
|
@@ -674,6 +681,7 @@ files:
|
|
674
681
|
- lib/rubocop/cop/style/encoding.rb
|
675
682
|
- lib/rubocop/cop/style/end_block.rb
|
676
683
|
- lib/rubocop/cop/style/endless_method.rb
|
684
|
+
- lib/rubocop/cop/style/env_home.rb
|
677
685
|
- lib/rubocop/cop/style/eval_with_location.rb
|
678
686
|
- lib/rubocop/cop/style/even_odd.rb
|
679
687
|
- lib/rubocop/cop/style/expand_path_arguments.rb
|
@@ -880,6 +888,7 @@ files:
|
|
880
888
|
- lib/rubocop/formatter/html_formatter.rb
|
881
889
|
- lib/rubocop/formatter/json_formatter.rb
|
882
890
|
- lib/rubocop/formatter/junit_formatter.rb
|
891
|
+
- lib/rubocop/formatter/markdown_formatter.rb
|
883
892
|
- lib/rubocop/formatter/offense_count_formatter.rb
|
884
893
|
- lib/rubocop/formatter/pacman_formatter.rb
|
885
894
|
- lib/rubocop/formatter/progress_formatter.rb
|
@@ -918,7 +927,7 @@ metadata:
|
|
918
927
|
homepage_uri: https://rubocop.org/
|
919
928
|
changelog_uri: https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md
|
920
929
|
source_code_uri: https://github.com/rubocop/rubocop/
|
921
|
-
documentation_uri: https://docs.rubocop.org/rubocop/1.
|
930
|
+
documentation_uri: https://docs.rubocop.org/rubocop/1.29/
|
922
931
|
bug_tracker_uri: https://github.com/rubocop/rubocop/issues
|
923
932
|
rubygems_mfa_required: 'true'
|
924
933
|
post_install_message:
|
@@ -929,7 +938,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
929
938
|
requirements:
|
930
939
|
- - ">="
|
931
940
|
- !ruby/object:Gem::Version
|
932
|
-
version: 2.
|
941
|
+
version: 2.6.0
|
933
942
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
934
943
|
requirements:
|
935
944
|
- - ">="
|
@@ -1,45 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module RuboCop
|
4
|
-
module Cop
|
5
|
-
module Lint
|
6
|
-
# This cop checks for useless `else` in `begin..end` without `rescue`.
|
7
|
-
#
|
8
|
-
# NOTE: This syntax is no longer valid on Ruby 2.6 or higher and
|
9
|
-
# this cop is going to be removed at some point the future.
|
10
|
-
#
|
11
|
-
# @example
|
12
|
-
#
|
13
|
-
# # bad
|
14
|
-
#
|
15
|
-
# begin
|
16
|
-
# do_something
|
17
|
-
# else
|
18
|
-
# do_something_else # This will never be run.
|
19
|
-
# end
|
20
|
-
#
|
21
|
-
# @example
|
22
|
-
#
|
23
|
-
# # good
|
24
|
-
#
|
25
|
-
# begin
|
26
|
-
# do_something
|
27
|
-
# rescue
|
28
|
-
# handle_errors
|
29
|
-
# else
|
30
|
-
# do_something_else
|
31
|
-
# end
|
32
|
-
class UselessElseWithoutRescue < Base
|
33
|
-
MSG = '`else` without `rescue` is useless.'
|
34
|
-
|
35
|
-
def on_new_investigation
|
36
|
-
processed_source.diagnostics.each do |diagnostic|
|
37
|
-
next unless diagnostic.reason == :useless_else
|
38
|
-
|
39
|
-
add_offense(diagnostic.location, severity: diagnostic.level)
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|