rubocop 0.60.0 → 0.61.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +4 -4
  3. data/config/default.yml +573 -560
  4. data/lib/rubocop.rb +5 -0
  5. data/lib/rubocop/ast/node.rb +1 -1
  6. data/lib/rubocop/ast/sexp.rb +1 -1
  7. data/lib/rubocop/cli.rb +9 -14
  8. data/lib/rubocop/config.rb +4 -3
  9. data/lib/rubocop/config_loader.rb +25 -22
  10. data/lib/rubocop/config_loader_resolver.rb +3 -2
  11. data/lib/rubocop/cop/correctors/each_to_for_corrector.rb +53 -0
  12. data/lib/rubocop/cop/correctors/for_to_each_corrector.rb +73 -0
  13. data/lib/rubocop/cop/correctors/lambda_literal_to_method_corrector.rb +138 -0
  14. data/lib/rubocop/cop/correctors/multiline_literal_brace_corrector.rb +52 -46
  15. data/lib/rubocop/cop/generator.rb +13 -17
  16. data/lib/rubocop/cop/generator/configuration_injector.rb +60 -0
  17. data/lib/rubocop/cop/layout/align_hash.rb +3 -0
  18. data/lib/rubocop/cop/layout/comment_indentation.rb +32 -2
  19. data/lib/rubocop/cop/layout/indent_heredoc.rb +11 -5
  20. data/lib/rubocop/cop/layout/indentation_width.rb +7 -1
  21. data/lib/rubocop/cop/layout/multiline_array_brace_layout.rb +11 -11
  22. data/lib/rubocop/cop/layout/multiline_hash_brace_layout.rb +1 -1
  23. data/lib/rubocop/cop/layout/multiline_method_call_brace_layout.rb +1 -1
  24. data/lib/rubocop/cop/layout/multiline_method_definition_brace_layout.rb +1 -1
  25. data/lib/rubocop/cop/layout/rescue_ensure_alignment.rb +16 -3
  26. data/lib/rubocop/cop/layout/space_around_block_parameters.rb +30 -17
  27. data/lib/rubocop/cop/lint/format_parameter_mismatch.rb +11 -0
  28. data/lib/rubocop/cop/lint/shadowed_exception.rb +2 -5
  29. data/lib/rubocop/cop/lint/useless_access_modifier.rb +1 -1
  30. data/lib/rubocop/cop/metrics/line_length.rb +2 -2
  31. data/lib/rubocop/cop/mixin/trailing_comma.rb +11 -15
  32. data/lib/rubocop/cop/offense.rb +1 -1
  33. data/lib/rubocop/cop/performance/open_struct.rb +46 -0
  34. data/lib/rubocop/cop/performance/redundant_merge.rb +18 -4
  35. data/lib/rubocop/cop/rails/bulk_change_table.rb +2 -2
  36. data/lib/rubocop/cop/rails/dynamic_find_by.rb +15 -8
  37. data/lib/rubocop/cop/rails/http_positional_arguments.rb +17 -14
  38. data/lib/rubocop/cop/rails/http_status.rb +4 -4
  39. data/lib/rubocop/cop/rails/inverse_of.rb +2 -2
  40. data/lib/rubocop/cop/rails/reversible_migration.rb +1 -1
  41. data/lib/rubocop/cop/rails/skips_model_validations.rb +1 -1
  42. data/lib/rubocop/cop/rails/validation.rb +4 -4
  43. data/lib/rubocop/cop/security/open.rb +31 -11
  44. data/lib/rubocop/cop/style/begin_block.rb +6 -0
  45. data/lib/rubocop/cop/style/braces_around_hash_parameters.rb +1 -1
  46. data/lib/rubocop/cop/style/empty_case_condition.rb +13 -7
  47. data/lib/rubocop/cop/style/for.rb +9 -78
  48. data/lib/rubocop/cop/style/frozen_string_literal_comment.rb +6 -4
  49. data/lib/rubocop/cop/style/global_vars.rb +1 -1
  50. data/lib/rubocop/cop/style/infinite_loop.rb +42 -6
  51. data/lib/rubocop/cop/style/lambda.rb +4 -87
  52. data/lib/rubocop/cop/style/method_call_with_args_parentheses.rb +221 -16
  53. data/lib/rubocop/cop/style/raise_args.rb +1 -1
  54. data/lib/rubocop/cop/style/regexp_literal.rb +62 -10
  55. data/lib/rubocop/cop/style/unneeded_condition.rb +2 -2
  56. data/lib/rubocop/cop/variable_force.rb +4 -2
  57. data/lib/rubocop/cop/variable_force/variable.rb +2 -0
  58. data/lib/rubocop/magic_comment.rb +1 -1
  59. data/lib/rubocop/remote_config.rb +13 -4
  60. data/lib/rubocop/rspec/expect_offense.rb +1 -1
  61. data/lib/rubocop/runner.rb +15 -4
  62. data/lib/rubocop/version.rb +1 -1
  63. metadata +7 -2
@@ -42,16 +42,25 @@ module RuboCop
42
42
  raise ArgumentError, 'HTTP redirect too deep' if limit.zero?
43
43
 
44
44
  http = Net::HTTP.new(uri.hostname, uri.port)
45
- http.use_ssl = true if uri.instance_of? URI::HTTPS
45
+ http.use_ssl = uri.instance_of?(URI::HTTPS)
46
46
 
47
+ generate_request(uri) do |request|
48
+ begin
49
+ handle_response(http.request(request), limit, &block)
50
+ rescue SocketError => err
51
+ handle_response(err, limit, &block)
52
+ end
53
+ end
54
+ end
55
+
56
+ def generate_request(uri)
47
57
  request = Net::HTTP::Get.new(uri.request_uri)
58
+
48
59
  if cache_path_exists?
49
60
  request['If-Modified-Since'] = File.stat(cache_path).mtime.rfc2822
50
61
  end
51
62
 
52
- handle_response(http.request(request), limit, &block)
53
- rescue SocketError => err
54
- handle_response(err, limit, &block)
63
+ yield request
55
64
  end
56
65
 
57
66
  def handle_response(response, limit, &block)
@@ -41,7 +41,7 @@ module RuboCop
41
41
  # If you do not want to specify an offense then use the
42
42
  # companion method `expect_no_offenses`. This method is a much
43
43
  # simpler assertion since it just inspects the source and checks
44
- # that there were no offenses. The `expect_offenses` method has
44
+ # that there were no offenses. The `expect_offense` method has
45
45
  # to do more work by parsing out lines that contain carets.
46
46
  module ExpectOffense
47
47
  def expect_offense(source, file = nil)
@@ -19,8 +19,8 @@ module RuboCop
19
19
 
20
20
  MAX_ITERATIONS = 200
21
21
 
22
- attr_reader :errors, :warnings, :aborting
23
- alias aborting? aborting
22
+ attr_reader :errors, :warnings
23
+ attr_writer :aborting
24
24
 
25
25
  def initialize(options, config_store)
26
26
  @options = options
@@ -30,6 +30,15 @@ module RuboCop
30
30
  @aborting = false
31
31
  end
32
32
 
33
+ def trap_interrupt
34
+ Signal.trap('INT') do
35
+ exit!(1) if aborting?
36
+ self.aborting = true
37
+ warn ''
38
+ warn 'Exiting... Interrupt again to exit immediately.'
39
+ end
40
+ end
41
+
33
42
  def run(paths)
34
43
  target_files = find_target_files(paths)
35
44
  if @options[:list_target_files]
@@ -40,8 +49,8 @@ module RuboCop
40
49
  end
41
50
  end
42
51
 
43
- def abort
44
- @aborting = true
52
+ def aborting?
53
+ @aborting
45
54
  end
46
55
 
47
56
  private
@@ -72,6 +81,8 @@ module RuboCop
72
81
  end
73
82
 
74
83
  def each_inspected_file(files)
84
+ trap_interrupt
85
+
75
86
  files.reduce(true) do |all_passed, file|
76
87
  break false if aborting?
77
88
 
@@ -3,7 +3,7 @@
3
3
  module RuboCop
4
4
  # This module holds the RuboCop version information.
5
5
  module Version
6
- STRING = '0.60.0'.freeze
6
+ STRING = '0.61.0'.freeze
7
7
 
8
8
  MSG = '%<version>s (using Parser %<parser_version>s, running on ' \
9
9
  '%<ruby_engine>s %<ruby_version>s %<ruby_platform>s)'.freeze
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.60.0
4
+ version: 0.61.0
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: 2018-10-26 00:00:00.000000000 Z
13
+ date: 2018-12-05 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: jaro_winkler
@@ -226,7 +226,10 @@ files:
226
226
  - lib/rubocop/cop/corrector.rb
227
227
  - lib/rubocop/cop/correctors/alignment_corrector.rb
228
228
  - lib/rubocop/cop/correctors/condition_corrector.rb
229
+ - lib/rubocop/cop/correctors/each_to_for_corrector.rb
229
230
  - lib/rubocop/cop/correctors/empty_line_corrector.rb
231
+ - lib/rubocop/cop/correctors/for_to_each_corrector.rb
232
+ - lib/rubocop/cop/correctors/lambda_literal_to_method_corrector.rb
230
233
  - lib/rubocop/cop/correctors/line_break_corrector.rb
231
234
  - lib/rubocop/cop/correctors/multiline_literal_brace_corrector.rb
232
235
  - lib/rubocop/cop/correctors/ordered_gem_corrector.rb
@@ -241,6 +244,7 @@ files:
241
244
  - lib/rubocop/cop/gemspec/ordered_dependencies.rb
242
245
  - lib/rubocop/cop/gemspec/required_ruby_version.rb
243
246
  - lib/rubocop/cop/generator.rb
247
+ - lib/rubocop/cop/generator/configuration_injector.rb
244
248
  - lib/rubocop/cop/generator/require_file_injector.rb
245
249
  - lib/rubocop/cop/ignored_node.rb
246
250
  - lib/rubocop/cop/internal_affairs.rb
@@ -507,6 +511,7 @@ files:
507
511
  - lib/rubocop/cop/performance/flat_map.rb
508
512
  - lib/rubocop/cop/performance/inefficient_hash_search.rb
509
513
  - lib/rubocop/cop/performance/lstrip_rstrip.rb
514
+ - lib/rubocop/cop/performance/open_struct.rb
510
515
  - lib/rubocop/cop/performance/range_include.rb
511
516
  - lib/rubocop/cop/performance/redundant_block_call.rb
512
517
  - lib/rubocop/cop/performance/redundant_match.rb