rubocop 0.26.1 → 0.27.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of rubocop might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/.rubocop.yml +5 -0
- data/.rubocop_todo.yml +10 -6
- data/.travis.yml +2 -0
- data/CHANGELOG.md +30 -0
- data/README.md +9 -2
- data/assets/logo.png +0 -0
- data/assets/output.html.erb +68 -65
- data/config/default.yml +42 -7
- data/config/disabled.yml +5 -0
- data/config/enabled.yml +32 -7
- data/lib/rubocop.rb +10 -2
- data/lib/rubocop/comment_config.rb +11 -17
- data/lib/rubocop/config.rb +20 -16
- data/lib/rubocop/config_loader.rb +8 -12
- data/lib/rubocop/cop/cop.rb +13 -12
- data/lib/rubocop/cop/lint/block_alignment.rb +4 -6
- data/lib/rubocop/cop/lint/def_end_alignment.rb +2 -2
- data/lib/rubocop/cop/lint/require_parentheses.rb +1 -1
- data/lib/rubocop/cop/lint/useless_access_modifier.rb +2 -3
- data/lib/rubocop/cop/lint/useless_setter_call.rb +2 -2
- data/lib/rubocop/cop/metrics/abc_size.rb +27 -0
- data/lib/rubocop/cop/metrics/block_nesting.rb +2 -4
- data/lib/rubocop/cop/metrics/class_length.rb +1 -1
- data/lib/rubocop/cop/metrics/line_length.rb +2 -5
- data/lib/rubocop/cop/metrics/method_length.rb +2 -2
- data/lib/rubocop/cop/mixin/autocorrect_alignment.rb +24 -15
- data/lib/rubocop/cop/mixin/autocorrect_unless_changing_ast.rb +15 -2
- data/lib/rubocop/cop/mixin/empty_lines_around_body.rb +63 -0
- data/lib/rubocop/cop/mixin/end_keyword_alignment.rb +1 -1
- data/lib/rubocop/cop/mixin/if_node.rb +3 -1
- data/lib/rubocop/cop/mixin/method_complexity.rb +3 -3
- data/lib/rubocop/cop/mixin/{on_method.rb → on_method_def.rb} +3 -3
- data/lib/rubocop/cop/mixin/space_after_punctuation.rb +2 -2
- data/lib/rubocop/cop/mixin/space_before_punctuation.rb +1 -1
- data/lib/rubocop/cop/mixin/statement_modifier.rb +2 -2
- data/lib/rubocop/cop/mixin/string_literals_help.rb +28 -0
- data/lib/rubocop/cop/rails/delegate.rb +2 -2
- data/lib/rubocop/cop/style/access_modifier_indentation.rb +2 -2
- data/lib/rubocop/cop/style/accessor_method_name.rb +2 -2
- data/lib/rubocop/cop/style/align_hash.rb +16 -12
- data/lib/rubocop/cop/style/align_parameters.rb +1 -1
- data/lib/rubocop/cop/style/and_or.rb +14 -6
- data/lib/rubocop/cop/style/array_join.rb +1 -1
- data/lib/rubocop/cop/style/block_comments.rb +16 -8
- data/lib/rubocop/cop/style/braces_around_hash_parameters.rb +6 -30
- data/lib/rubocop/cop/style/case_indentation.rb +20 -12
- data/lib/rubocop/cop/style/collection_methods.rb +4 -4
- data/lib/rubocop/cop/style/colon_method_call.rb +9 -0
- data/lib/rubocop/cop/style/comment_annotation.rb +1 -1
- data/lib/rubocop/cop/style/comment_indentation.rb +22 -22
- data/lib/rubocop/cop/style/def_with_parentheses.rb +2 -2
- data/lib/rubocop/cop/style/deprecated_hash_methods.rb +1 -1
- data/lib/rubocop/cop/style/double_negation.rb +6 -1
- data/lib/rubocop/cop/style/else_alignment.rb +93 -0
- data/lib/rubocop/cop/style/empty_line_between_defs.rb +1 -1
- data/lib/rubocop/cop/style/empty_lines.rb +1 -1
- data/lib/rubocop/cop/style/empty_lines_around_class_body.rb +34 -0
- data/lib/rubocop/cop/style/empty_lines_around_method_body.rb +37 -0
- data/lib/rubocop/cop/style/empty_lines_around_module_body.rb +30 -0
- data/lib/rubocop/cop/style/encoding.rb +1 -1
- data/lib/rubocop/cop/style/format_string.rb +4 -4
- data/lib/rubocop/cop/style/indent_array.rb +2 -2
- data/lib/rubocop/cop/style/indent_hash.rb +17 -12
- data/lib/rubocop/cop/style/indentation_width.rb +27 -19
- data/lib/rubocop/cop/style/method_call_parentheses.rb +3 -3
- data/lib/rubocop/cop/style/method_called_on_do_end_block.rb +1 -1
- data/lib/rubocop/cop/style/method_def_parentheses.rb +17 -11
- data/lib/rubocop/cop/style/method_name.rb +1 -1
- data/lib/rubocop/cop/style/multiline_operation_indentation.rb +174 -0
- data/lib/rubocop/cop/style/non_nil_check.rb +12 -15
- data/lib/rubocop/cop/style/not.rb +1 -1
- data/lib/rubocop/cop/style/percent_literal_delimiters.rb +12 -17
- data/lib/rubocop/cop/style/percent_q_literals.rb +1 -1
- data/lib/rubocop/cop/style/predicate_name.rb +2 -2
- data/lib/rubocop/cop/style/redundant_begin.rb +2 -2
- data/lib/rubocop/cop/style/redundant_return.rb +3 -3
- data/lib/rubocop/cop/style/redundant_self.rb +3 -3
- data/lib/rubocop/cop/style/regexp_literal.rb +17 -13
- data/lib/rubocop/cop/style/rescue_modifier.rb +2 -2
- data/lib/rubocop/cop/style/single_line_methods.rb +7 -4
- data/lib/rubocop/cop/style/space_after_method_name.rb +2 -2
- data/lib/rubocop/cop/style/space_around_equals_in_parameter_default.rb +17 -11
- data/lib/rubocop/cop/style/space_before_block_braces.rb +1 -1
- data/lib/rubocop/cop/style/space_inside_block_braces.rb +17 -14
- data/lib/rubocop/cop/style/space_inside_hash_literal_braces.rb +10 -6
- data/lib/rubocop/cop/style/string_literals.rb +13 -16
- data/lib/rubocop/cop/style/string_literals_in_interpolation.rb +41 -0
- data/lib/rubocop/cop/style/trailing_comma.rb +1 -3
- data/lib/rubocop/cop/style/trivial_accessors.rb +3 -3
- data/lib/rubocop/cop/style/unneeded_capital_w.rb +1 -1
- data/lib/rubocop/cop/style/unneeded_percent_q.rb +2 -2
- data/lib/rubocop/cop/style/word_array.rb +23 -19
- data/lib/rubocop/cop/team.rb +13 -26
- data/lib/rubocop/cop/util.rb +5 -0
- data/lib/rubocop/cop/variable_force/locatable.rb +7 -13
- data/lib/rubocop/formatter/disabled_config_formatter.rb +1 -1
- data/lib/rubocop/formatter/formatter_set.rb +9 -1
- data/lib/rubocop/formatter/html_formatter.rb +83 -55
- data/lib/rubocop/formatter/simple_text_formatter.rb +2 -2
- data/lib/rubocop/formatter/text_util.rb +25 -0
- data/lib/rubocop/options.rb +14 -7
- data/lib/rubocop/path_util.rb +11 -7
- data/lib/rubocop/runner.rb +7 -2
- data/lib/rubocop/version.rb +1 -1
- data/relnotes/v0.27.0.md +77 -0
- data/rubocop.gemspec +1 -1
- data/spec/fixtures/html_formatter/expected.html +495 -0
- data/spec/fixtures/html_formatter/project/app/controllers/application_controller.rb +5 -0
- data/spec/fixtures/html_formatter/project/app/controllers/books_controller.rb +74 -0
- data/spec/fixtures/html_formatter/project/app/models/book.rb +5 -0
- data/spec/rubocop/cli_spec.rb +56 -13
- data/spec/rubocop/cop/lint/invalid_character_literal_spec.rb +1 -1
- data/spec/rubocop/cop/metrics/abc_size_spec.rb +99 -0
- data/spec/rubocop/cop/rails/action_filter_spec.rb +1 -0
- data/spec/rubocop/cop/style/access_modifier_indentation_spec.rb +23 -1
- data/spec/rubocop/cop/style/align_hash_spec.rb +13 -0
- data/spec/rubocop/cop/style/align_parameters_spec.rb +44 -33
- data/spec/rubocop/cop/style/blocks_spec.rb +8 -0
- data/spec/rubocop/cop/style/braces_around_hash_parameters_spec.rb +9 -9
- data/spec/rubocop/cop/style/case_indentation_spec.rb +3 -2
- data/spec/rubocop/cop/style/colon_method_call_spec.rb +5 -0
- data/spec/rubocop/cop/style/comment_indentation_spec.rb +6 -1
- data/spec/rubocop/cop/style/else_alignment_spec.rb +437 -0
- data/spec/rubocop/cop/style/empty_lines_around_class_body_spec.rb +75 -0
- data/spec/rubocop/cop/style/{empty_lines_around_body_spec.rb → empty_lines_around_method_body_spec.rb} +9 -50
- data/spec/rubocop/cop/style/empty_lines_around_module_body_spec.rb +79 -0
- data/spec/rubocop/cop/style/file_name_spec.rb +1 -1
- data/spec/rubocop/cop/style/format_string_spec.rb +12 -0
- data/spec/rubocop/cop/style/indent_array_spec.rb +6 -1
- data/spec/rubocop/cop/style/indent_hash_spec.rb +2 -1
- data/spec/rubocop/cop/style/indentation_width_spec.rb +765 -722
- data/spec/rubocop/cop/style/multiline_operation_indentation_spec.rb +414 -0
- data/spec/rubocop/cop/style/non_nil_check_spec.rb +86 -55
- data/spec/rubocop/cop/style/single_line_methods_spec.rb +5 -1
- data/spec/rubocop/cop/style/space_before_block_braces_spec.rb +2 -1
- data/spec/rubocop/cop/style/space_inside_block_braces_spec.rb +2 -1
- data/spec/rubocop/cop/style/string_literals_in_interpolation_spec.rb +63 -0
- data/spec/rubocop/cop/style/string_literals_spec.rb +2 -2
- data/spec/rubocop/cop/style/word_array_spec.rb +15 -1
- data/spec/rubocop/formatter/base_formatter_spec.rb +1 -1
- data/spec/rubocop/formatter/disabled_lines_formatter_spec.rb +0 -1
- data/spec/rubocop/formatter/formatter_set_spec.rb +9 -0
- data/spec/rubocop/formatter/html_formatter_spec.rb +25 -122
- data/spec/rubocop/formatter/offense_count_formatter_spec.rb +0 -1
- data/spec/rubocop/runner_spec.rb +1 -1
- data/spec/spec_helper.rb +12 -130
- data/spec/support/cop_helper.rb +72 -0
- data/spec/support/coverage.rb +15 -0
- data/spec/support/{offenses_matcher.rb → custom_matchers.rb} +28 -0
- data/spec/support/jruby_workaround.rb +15 -0
- data/spec/support/{isolated_environment.rb → shared_contexts.rb} +19 -0
- metadata +49 -14
- data/lib/rubocop/cop/style/empty_lines_around_body.rb +0 -75
- data/spec/support/shared_context.rb +0 -20
@@ -0,0 +1,72 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'tempfile'
|
4
|
+
|
5
|
+
module CopHelper
|
6
|
+
def inspect_source_file(cop, source)
|
7
|
+
Tempfile.open('tmp') { |f| inspect_source(cop, source, f) }
|
8
|
+
end
|
9
|
+
|
10
|
+
def inspect_source(cop, source, file = nil)
|
11
|
+
RuboCop::Formatter::DisabledConfigFormatter.config_to_allow_offenses = {}
|
12
|
+
processed_source = parse_source(source, file)
|
13
|
+
fail 'Error parsing example code' unless processed_source.valid_syntax?
|
14
|
+
_investigate(cop, processed_source)
|
15
|
+
end
|
16
|
+
|
17
|
+
def parse_source(source, file = nil)
|
18
|
+
source = source.join($RS) if source.is_a?(Array)
|
19
|
+
|
20
|
+
if file && file.respond_to?(:write)
|
21
|
+
file.write(source)
|
22
|
+
file.rewind
|
23
|
+
file = file.path
|
24
|
+
end
|
25
|
+
|
26
|
+
RuboCop::ProcessedSource.new(source, file)
|
27
|
+
end
|
28
|
+
|
29
|
+
def autocorrect_source_file(cop, source)
|
30
|
+
Tempfile.open('tmp') { |f| autocorrect_source(cop, source, f) }
|
31
|
+
end
|
32
|
+
|
33
|
+
def autocorrect_source(cop, source, file = nil)
|
34
|
+
cop.instance_variable_get(:@options)[:auto_correct] = true
|
35
|
+
processed_source = parse_source(source, file)
|
36
|
+
_investigate(cop, processed_source)
|
37
|
+
|
38
|
+
corrector =
|
39
|
+
RuboCop::Cop::Corrector.new(processed_source.buffer, cop.corrections)
|
40
|
+
corrector.rewrite
|
41
|
+
end
|
42
|
+
|
43
|
+
def _investigate(cop, processed_source)
|
44
|
+
forces = RuboCop::Cop::Force.all.each_with_object([]) do |klass, instances|
|
45
|
+
next unless cop.join_force?(klass)
|
46
|
+
instances << klass.new([cop])
|
47
|
+
end
|
48
|
+
|
49
|
+
commissioner =
|
50
|
+
RuboCop::Cop::Commissioner.new([cop], forces, raise_error: true)
|
51
|
+
commissioner.investigate(processed_source)
|
52
|
+
commissioner
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
module RuboCop
|
57
|
+
module Cop
|
58
|
+
class Cop
|
59
|
+
def messages
|
60
|
+
offenses.sort.map(&:message)
|
61
|
+
end
|
62
|
+
|
63
|
+
def highlights
|
64
|
+
offenses.sort.map { |o| o.location.source }
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
RSpec.configure do |config|
|
71
|
+
config.include CopHelper
|
72
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
if ENV['TRAVIS'] || ENV['COVERAGE']
|
4
|
+
require 'simplecov'
|
5
|
+
|
6
|
+
if ENV['TRAVIS']
|
7
|
+
require 'coveralls'
|
8
|
+
SimpleCov.formatter = Coveralls::SimpleCov::Formatter
|
9
|
+
end
|
10
|
+
|
11
|
+
SimpleCov.start do
|
12
|
+
add_filter '/spec/'
|
13
|
+
add_filter '/vendor/bundle/'
|
14
|
+
end
|
15
|
+
end
|
@@ -1,5 +1,33 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
+
RSpec::Matchers.define :exit_with_code do |code|
|
4
|
+
supports_block_expectations
|
5
|
+
|
6
|
+
actual = nil
|
7
|
+
|
8
|
+
match do |block|
|
9
|
+
begin
|
10
|
+
block.call
|
11
|
+
rescue SystemExit => e
|
12
|
+
actual = e.status
|
13
|
+
end
|
14
|
+
actual && actual == code
|
15
|
+
end
|
16
|
+
|
17
|
+
failure_message do
|
18
|
+
"expected block to call exit(#{code}) but exit" +
|
19
|
+
(actual.nil? ? ' not called' : "(#{actual}) was called")
|
20
|
+
end
|
21
|
+
|
22
|
+
failure_message_when_negated do
|
23
|
+
"expected block not to call exit(#{code})"
|
24
|
+
end
|
25
|
+
|
26
|
+
description do
|
27
|
+
"expect block to call exit(#{code})"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
3
31
|
RSpec::Matchers.define :find_offenses_in do |code|
|
4
32
|
match do |cop|
|
5
33
|
inspect_source(cop, [code])
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
# Force JRuby not to select the current working directory
|
4
|
+
# as a temporary directory on Travis CI.
|
5
|
+
# https://github.com/jruby/jruby/issues/405
|
6
|
+
if ENV['TRAVIS'] && RUBY_ENGINE == 'jruby'
|
7
|
+
require 'fileutils'
|
8
|
+
|
9
|
+
tmp_dir = ENV['TMPDIR'] || ENV['TMP'] || ENV['TEMP'] ||
|
10
|
+
Etc.systmpdir || '/tmp'
|
11
|
+
|
12
|
+
non_world_writable_tmp_dir = File.join(tmp_dir, 'rubocop')
|
13
|
+
FileUtils.makedirs(non_world_writable_tmp_dir, mode: 0700)
|
14
|
+
ENV['TMPDIR'] = non_world_writable_tmp_dir
|
15
|
+
end
|
@@ -32,3 +32,22 @@ shared_context 'isolated environment', :isolated_environment do
|
|
32
32
|
end
|
33
33
|
end
|
34
34
|
end
|
35
|
+
|
36
|
+
# `cop_config` must be declared with #let.
|
37
|
+
shared_context 'config', :config do
|
38
|
+
let(:config) do
|
39
|
+
# Module#<
|
40
|
+
unless described_class < RuboCop::Cop::Cop
|
41
|
+
fail '`config` must be used in `describe SomeCopClass do .. end`'
|
42
|
+
end
|
43
|
+
|
44
|
+
fail '`cop_config` must be declared with #let' unless cop_config.is_a?(Hash)
|
45
|
+
|
46
|
+
cop_name = described_class.cop_name
|
47
|
+
hash = {
|
48
|
+
cop_name =>
|
49
|
+
RuboCop::ConfigLoader.default_configuration[cop_name].merge(cop_config)
|
50
|
+
}
|
51
|
+
RuboCop::Config.new(hash, "#{Dir.pwd}/.rubocop.yml")
|
52
|
+
end
|
53
|
+
end
|
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: 0.
|
4
|
+
version: 0.27.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bozhidar Batsov
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2014-
|
13
|
+
date: 2014-10-30 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rainbow
|
@@ -38,7 +38,7 @@ dependencies:
|
|
38
38
|
requirements:
|
39
39
|
- - ">="
|
40
40
|
- !ruby/object:Gem::Version
|
41
|
-
version: 2.2.0.pre.
|
41
|
+
version: 2.2.0.pre.6
|
42
42
|
- - "<"
|
43
43
|
- !ruby/object:Gem::Version
|
44
44
|
version: '3.0'
|
@@ -48,7 +48,7 @@ dependencies:
|
|
48
48
|
requirements:
|
49
49
|
- - ">="
|
50
50
|
- !ruby/object:Gem::Version
|
51
|
-
version: 2.2.0.pre.
|
51
|
+
version: 2.2.0.pre.6
|
52
52
|
- - "<"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '3.0'
|
@@ -187,6 +187,7 @@ files:
|
|
187
187
|
- LICENSE.txt
|
188
188
|
- README.md
|
189
189
|
- Rakefile
|
190
|
+
- assets/logo.png
|
190
191
|
- assets/output.html.erb
|
191
192
|
- bin/rubocop
|
192
193
|
- config/default.yml
|
@@ -240,6 +241,7 @@ files:
|
|
240
241
|
- lib/rubocop/cop/lint/useless_else_without_rescue.rb
|
241
242
|
- lib/rubocop/cop/lint/useless_setter_call.rb
|
242
243
|
- lib/rubocop/cop/lint/void.rb
|
244
|
+
- lib/rubocop/cop/metrics/abc_size.rb
|
243
245
|
- lib/rubocop/cop/metrics/block_nesting.rb
|
244
246
|
- lib/rubocop/cop/metrics/class_length.rb
|
245
247
|
- lib/rubocop/cop/metrics/cyclomatic_complexity.rb
|
@@ -257,11 +259,12 @@ files:
|
|
257
259
|
- lib/rubocop/cop/mixin/configurable_enforced_style.rb
|
258
260
|
- lib/rubocop/cop/mixin/configurable_max.rb
|
259
261
|
- lib/rubocop/cop/mixin/configurable_naming.rb
|
262
|
+
- lib/rubocop/cop/mixin/empty_lines_around_body.rb
|
260
263
|
- lib/rubocop/cop/mixin/end_keyword_alignment.rb
|
261
264
|
- lib/rubocop/cop/mixin/if_node.rb
|
262
265
|
- lib/rubocop/cop/mixin/method_complexity.rb
|
263
266
|
- lib/rubocop/cop/mixin/negative_conditional.rb
|
264
|
-
- lib/rubocop/cop/mixin/
|
267
|
+
- lib/rubocop/cop/mixin/on_method_def.rb
|
265
268
|
- lib/rubocop/cop/mixin/on_normal_if_unless.rb
|
266
269
|
- lib/rubocop/cop/mixin/parser_diagnostic.rb
|
267
270
|
- lib/rubocop/cop/mixin/percent_literal.rb
|
@@ -271,6 +274,7 @@ files:
|
|
271
274
|
- lib/rubocop/cop/mixin/space_inside.rb
|
272
275
|
- lib/rubocop/cop/mixin/statement_modifier.rb
|
273
276
|
- lib/rubocop/cop/mixin/string_help.rb
|
277
|
+
- lib/rubocop/cop/mixin/string_literals_help.rb
|
274
278
|
- lib/rubocop/cop/mixin/surrounding_space.rb
|
275
279
|
- lib/rubocop/cop/mixin/unused_argument.rb
|
276
280
|
- lib/rubocop/cop/offense.rb
|
@@ -319,10 +323,13 @@ files:
|
|
319
323
|
- lib/rubocop/cop/style/dot_position.rb
|
320
324
|
- lib/rubocop/cop/style/double_negation.rb
|
321
325
|
- lib/rubocop/cop/style/each_with_object.rb
|
326
|
+
- lib/rubocop/cop/style/else_alignment.rb
|
322
327
|
- lib/rubocop/cop/style/empty_line_between_defs.rb
|
323
328
|
- lib/rubocop/cop/style/empty_lines.rb
|
324
329
|
- lib/rubocop/cop/style/empty_lines_around_access_modifier.rb
|
325
|
-
- lib/rubocop/cop/style/
|
330
|
+
- lib/rubocop/cop/style/empty_lines_around_class_body.rb
|
331
|
+
- lib/rubocop/cop/style/empty_lines_around_method_body.rb
|
332
|
+
- lib/rubocop/cop/style/empty_lines_around_module_body.rb
|
326
333
|
- lib/rubocop/cop/style/empty_literal.rb
|
327
334
|
- lib/rubocop/cop/style/encoding.rb
|
328
335
|
- lib/rubocop/cop/style/end_block.rb
|
@@ -355,6 +362,7 @@ files:
|
|
355
362
|
- lib/rubocop/cop/style/multiline_block_chain.rb
|
356
363
|
- lib/rubocop/cop/style/multiline_block_layout.rb
|
357
364
|
- lib/rubocop/cop/style/multiline_if_then.rb
|
365
|
+
- lib/rubocop/cop/style/multiline_operation_indentation.rb
|
358
366
|
- lib/rubocop/cop/style/multiline_ternary_operator.rb
|
359
367
|
- lib/rubocop/cop/style/negated_if.rb
|
360
368
|
- lib/rubocop/cop/style/negated_while.rb
|
@@ -405,6 +413,7 @@ files:
|
|
405
413
|
- lib/rubocop/cop/style/space_inside_range_literal.rb
|
406
414
|
- lib/rubocop/cop/style/special_global_vars.rb
|
407
415
|
- lib/rubocop/cop/style/string_literals.rb
|
416
|
+
- lib/rubocop/cop/style/string_literals_in_interpolation.rb
|
408
417
|
- lib/rubocop/cop/style/symbol_array.rb
|
409
418
|
- lib/rubocop/cop/style/symbol_proc.rb
|
410
419
|
- lib/rubocop/cop/style/tab.rb
|
@@ -445,6 +454,7 @@ files:
|
|
445
454
|
- lib/rubocop/formatter/offense_count_formatter.rb
|
446
455
|
- lib/rubocop/formatter/progress_formatter.rb
|
447
456
|
- lib/rubocop/formatter/simple_text_formatter.rb
|
457
|
+
- lib/rubocop/formatter/text_util.rb
|
448
458
|
- lib/rubocop/options.rb
|
449
459
|
- lib/rubocop/path_util.rb
|
450
460
|
- lib/rubocop/processed_source.rb
|
@@ -470,8 +480,13 @@ files:
|
|
470
480
|
- relnotes/v0.25.0.md
|
471
481
|
- relnotes/v0.26.0.md
|
472
482
|
- relnotes/v0.26.1.md
|
483
|
+
- relnotes/v0.27.0.md
|
473
484
|
- rubocop.gemspec
|
474
485
|
- spec/.rubocop.yml
|
486
|
+
- spec/fixtures/html_formatter/expected.html
|
487
|
+
- spec/fixtures/html_formatter/project/app/controllers/application_controller.rb
|
488
|
+
- spec/fixtures/html_formatter/project/app/controllers/books_controller.rb
|
489
|
+
- spec/fixtures/html_formatter/project/app/models/book.rb
|
475
490
|
- spec/isolated_environment_spec.rb
|
476
491
|
- spec/project_spec.rb
|
477
492
|
- spec/rubocop/cli_spec.rb
|
@@ -520,6 +535,7 @@ files:
|
|
520
535
|
- spec/rubocop/cop/lint/useless_else_without_rescue_spec.rb
|
521
536
|
- spec/rubocop/cop/lint/useless_setter_call_spec.rb
|
522
537
|
- spec/rubocop/cop/lint/void_spec.rb
|
538
|
+
- spec/rubocop/cop/metrics/abc_size_spec.rb
|
523
539
|
- spec/rubocop/cop/metrics/block_nesting_spec.rb
|
524
540
|
- spec/rubocop/cop/metrics/class_length_spec.rb
|
525
541
|
- spec/rubocop/cop/metrics/cyclomatic_complexity_spec.rb
|
@@ -575,9 +591,12 @@ files:
|
|
575
591
|
- spec/rubocop/cop/style/dot_position_spec.rb
|
576
592
|
- spec/rubocop/cop/style/double_negation_spec.rb
|
577
593
|
- spec/rubocop/cop/style/each_with_object_spec.rb
|
594
|
+
- spec/rubocop/cop/style/else_alignment_spec.rb
|
578
595
|
- spec/rubocop/cop/style/empty_line_between_defs_spec.rb
|
579
596
|
- spec/rubocop/cop/style/empty_lines_around_access_modifier_spec.rb
|
580
|
-
- spec/rubocop/cop/style/
|
597
|
+
- spec/rubocop/cop/style/empty_lines_around_class_body_spec.rb
|
598
|
+
- spec/rubocop/cop/style/empty_lines_around_method_body_spec.rb
|
599
|
+
- spec/rubocop/cop/style/empty_lines_around_module_body_spec.rb
|
581
600
|
- spec/rubocop/cop/style/empty_lines_spec.rb
|
582
601
|
- spec/rubocop/cop/style/empty_literal_spec.rb
|
583
602
|
- spec/rubocop/cop/style/encoding_spec.rb
|
@@ -610,6 +629,7 @@ files:
|
|
610
629
|
- spec/rubocop/cop/style/multiline_block_chain_spec.rb
|
611
630
|
- spec/rubocop/cop/style/multiline_block_layout_spec.rb
|
612
631
|
- spec/rubocop/cop/style/multiline_if_then_spec.rb
|
632
|
+
- spec/rubocop/cop/style/multiline_operation_indentation_spec.rb
|
613
633
|
- spec/rubocop/cop/style/multiline_ternary_operator_spec.rb
|
614
634
|
- spec/rubocop/cop/style/negated_if_spec.rb
|
615
635
|
- spec/rubocop/cop/style/negated_while_spec.rb
|
@@ -659,6 +679,7 @@ files:
|
|
659
679
|
- spec/rubocop/cop/style/space_inside_parens_spec.rb
|
660
680
|
- spec/rubocop/cop/style/space_inside_range_literal_spec.rb
|
661
681
|
- spec/rubocop/cop/style/special_global_vars_spec.rb
|
682
|
+
- spec/rubocop/cop/style/string_literals_in_interpolation_spec.rb
|
662
683
|
- spec/rubocop/cop/style/string_literals_spec.rb
|
663
684
|
- spec/rubocop/cop/style/symbol_array_spec.rb
|
664
685
|
- spec/rubocop/cop/style/symbol_proc_spec.rb
|
@@ -706,11 +727,13 @@ files:
|
|
706
727
|
- spec/rubocop/target_finder_spec.rb
|
707
728
|
- spec/rubocop/token_spec.rb
|
708
729
|
- spec/spec_helper.rb
|
730
|
+
- spec/support/cop_helper.rb
|
731
|
+
- spec/support/coverage.rb
|
732
|
+
- spec/support/custom_matchers.rb
|
709
733
|
- spec/support/file_helper.rb
|
710
|
-
- spec/support/
|
734
|
+
- spec/support/jruby_workaround.rb
|
711
735
|
- spec/support/mri_syntax_checker.rb
|
712
|
-
- spec/support/
|
713
|
-
- spec/support/shared_context.rb
|
736
|
+
- spec/support/shared_contexts.rb
|
714
737
|
- spec/support/shared_examples.rb
|
715
738
|
- spec/support/statement_modifier_helper.rb
|
716
739
|
homepage: http://github.com/bbatsov/rubocop
|
@@ -739,6 +762,10 @@ specification_version: 4
|
|
739
762
|
summary: Automatic Ruby code style checking tool.
|
740
763
|
test_files:
|
741
764
|
- spec/.rubocop.yml
|
765
|
+
- spec/fixtures/html_formatter/expected.html
|
766
|
+
- spec/fixtures/html_formatter/project/app/controllers/application_controller.rb
|
767
|
+
- spec/fixtures/html_formatter/project/app/controllers/books_controller.rb
|
768
|
+
- spec/fixtures/html_formatter/project/app/models/book.rb
|
742
769
|
- spec/isolated_environment_spec.rb
|
743
770
|
- spec/project_spec.rb
|
744
771
|
- spec/rubocop/cli_spec.rb
|
@@ -787,6 +814,7 @@ test_files:
|
|
787
814
|
- spec/rubocop/cop/lint/useless_else_without_rescue_spec.rb
|
788
815
|
- spec/rubocop/cop/lint/useless_setter_call_spec.rb
|
789
816
|
- spec/rubocop/cop/lint/void_spec.rb
|
817
|
+
- spec/rubocop/cop/metrics/abc_size_spec.rb
|
790
818
|
- spec/rubocop/cop/metrics/block_nesting_spec.rb
|
791
819
|
- spec/rubocop/cop/metrics/class_length_spec.rb
|
792
820
|
- spec/rubocop/cop/metrics/cyclomatic_complexity_spec.rb
|
@@ -842,9 +870,12 @@ test_files:
|
|
842
870
|
- spec/rubocop/cop/style/dot_position_spec.rb
|
843
871
|
- spec/rubocop/cop/style/double_negation_spec.rb
|
844
872
|
- spec/rubocop/cop/style/each_with_object_spec.rb
|
873
|
+
- spec/rubocop/cop/style/else_alignment_spec.rb
|
845
874
|
- spec/rubocop/cop/style/empty_line_between_defs_spec.rb
|
846
875
|
- spec/rubocop/cop/style/empty_lines_around_access_modifier_spec.rb
|
847
|
-
- spec/rubocop/cop/style/
|
876
|
+
- spec/rubocop/cop/style/empty_lines_around_class_body_spec.rb
|
877
|
+
- spec/rubocop/cop/style/empty_lines_around_method_body_spec.rb
|
878
|
+
- spec/rubocop/cop/style/empty_lines_around_module_body_spec.rb
|
848
879
|
- spec/rubocop/cop/style/empty_lines_spec.rb
|
849
880
|
- spec/rubocop/cop/style/empty_literal_spec.rb
|
850
881
|
- spec/rubocop/cop/style/encoding_spec.rb
|
@@ -877,6 +908,7 @@ test_files:
|
|
877
908
|
- spec/rubocop/cop/style/multiline_block_chain_spec.rb
|
878
909
|
- spec/rubocop/cop/style/multiline_block_layout_spec.rb
|
879
910
|
- spec/rubocop/cop/style/multiline_if_then_spec.rb
|
911
|
+
- spec/rubocop/cop/style/multiline_operation_indentation_spec.rb
|
880
912
|
- spec/rubocop/cop/style/multiline_ternary_operator_spec.rb
|
881
913
|
- spec/rubocop/cop/style/negated_if_spec.rb
|
882
914
|
- spec/rubocop/cop/style/negated_while_spec.rb
|
@@ -926,6 +958,7 @@ test_files:
|
|
926
958
|
- spec/rubocop/cop/style/space_inside_parens_spec.rb
|
927
959
|
- spec/rubocop/cop/style/space_inside_range_literal_spec.rb
|
928
960
|
- spec/rubocop/cop/style/special_global_vars_spec.rb
|
961
|
+
- spec/rubocop/cop/style/string_literals_in_interpolation_spec.rb
|
929
962
|
- spec/rubocop/cop/style/string_literals_spec.rb
|
930
963
|
- spec/rubocop/cop/style/symbol_array_spec.rb
|
931
964
|
- spec/rubocop/cop/style/symbol_proc_spec.rb
|
@@ -973,11 +1006,13 @@ test_files:
|
|
973
1006
|
- spec/rubocop/target_finder_spec.rb
|
974
1007
|
- spec/rubocop/token_spec.rb
|
975
1008
|
- spec/spec_helper.rb
|
1009
|
+
- spec/support/cop_helper.rb
|
1010
|
+
- spec/support/coverage.rb
|
1011
|
+
- spec/support/custom_matchers.rb
|
976
1012
|
- spec/support/file_helper.rb
|
977
|
-
- spec/support/
|
1013
|
+
- spec/support/jruby_workaround.rb
|
978
1014
|
- spec/support/mri_syntax_checker.rb
|
979
|
-
- spec/support/
|
980
|
-
- spec/support/shared_context.rb
|
1015
|
+
- spec/support/shared_contexts.rb
|
981
1016
|
- spec/support/shared_examples.rb
|
982
1017
|
- spec/support/statement_modifier_helper.rb
|
983
1018
|
has_rdoc:
|
@@ -1,75 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
module RuboCop
|
4
|
-
module Cop
|
5
|
-
module Style
|
6
|
-
# This cops checks redundant empty lines around the bodies of classes,
|
7
|
-
# modules & methods.
|
8
|
-
#
|
9
|
-
# @example
|
10
|
-
#
|
11
|
-
# class Test
|
12
|
-
#
|
13
|
-
# def something
|
14
|
-
# ...
|
15
|
-
# end
|
16
|
-
#
|
17
|
-
# end
|
18
|
-
#
|
19
|
-
# def something(arg)
|
20
|
-
#
|
21
|
-
# ...
|
22
|
-
# end
|
23
|
-
#
|
24
|
-
class EmptyLinesAroundBody < Cop
|
25
|
-
include OnMethod
|
26
|
-
|
27
|
-
MSG_BEG = 'Extra empty line detected at body beginning.'
|
28
|
-
MSG_END = 'Extra empty line detected at body end.'
|
29
|
-
|
30
|
-
def on_class(node)
|
31
|
-
check(node)
|
32
|
-
end
|
33
|
-
|
34
|
-
def on_module(node)
|
35
|
-
check(node)
|
36
|
-
end
|
37
|
-
|
38
|
-
def on_sclass(node)
|
39
|
-
check(node)
|
40
|
-
end
|
41
|
-
|
42
|
-
def autocorrect(range)
|
43
|
-
@corrections << ->(corrector) { corrector.remove(range) }
|
44
|
-
end
|
45
|
-
|
46
|
-
private
|
47
|
-
|
48
|
-
def on_method(node, _method_name, _args, _body)
|
49
|
-
check(node)
|
50
|
-
end
|
51
|
-
|
52
|
-
def check(node)
|
53
|
-
start_line = node.loc.keyword.line
|
54
|
-
end_line = node.loc.end.line
|
55
|
-
|
56
|
-
return if start_line == end_line
|
57
|
-
|
58
|
-
check_source(start_line, end_line)
|
59
|
-
end
|
60
|
-
|
61
|
-
def check_source(start_line, end_line)
|
62
|
-
check_line(start_line, MSG_BEG)
|
63
|
-
check_line(end_line - 2, MSG_END) unless end_line - 2 == start_line
|
64
|
-
end
|
65
|
-
|
66
|
-
def check_line(line, msg)
|
67
|
-
return unless processed_source.lines[line].empty?
|
68
|
-
|
69
|
-
range = source_range(processed_source.buffer, line + 1, 0)
|
70
|
-
add_offense(range, range, msg)
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|