Land #13822, update to the latest rubocop version

This commit is contained in:
adfoster-r7 2020-07-22 10:18:31 +01:00 committed by GitHub
commit a7e12bfa50
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 20 additions and 17 deletions

View File

@ -40,7 +40,7 @@ group :development, :test do
# environment is development
gem 'rspec-rails'
gem 'rspec-rerun'
gem 'rubocop', "0.86.0"
gem 'rubocop'
gem 'swagger-blocks'
end

View File

@ -375,13 +375,13 @@ GEM
rspec-rerun (1.1.0)
rspec (~> 3.0)
rspec-support (3.9.3)
rubocop (0.86.0)
rubocop (0.87.0)
parallel (~> 1.10)
parser (>= 2.7.0.1)
parser (>= 2.7.1.1)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.7)
rexml
rubocop-ast (>= 0.0.3, < 1.0)
rubocop-ast (>= 0.1.0, < 1.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 2.0)
rubocop-ast (0.1.0)
@ -450,7 +450,7 @@ DEPENDENCIES
redcarpet
rspec-rails
rspec-rerun
rubocop (= 0.86.0)
rubocop
ruby-prof
simplecov (= 0.18.2)
sqlite3 (~> 1.3.0)

View File

@ -1,7 +1,8 @@
module RuboCop
module Cop
module Layout
class ModuleDescriptionIndentation < Cop
class ModuleDescriptionIndentation < Base
extend AutoCorrector
include Alignment
MSG = "Module descriptions should be properly aligned to the 'Description' key, and within %q{ ... }"
@ -22,13 +23,15 @@ module RuboCop
hash.each_pair do |key, value|
if key.value == "Description"
if requires_correction?(key, value)
add_offense(value, location: :end)
add_offense(value.location.end, &autocorrector(value))
end
end
end
end
def autocorrect(description_value)
private
def autocorrector(description_value)
lambda do |corrector|
description_key = description_value.parent.key
new_content = indent_description_value_correctly(description_key, description_value)
@ -37,8 +40,6 @@ module RuboCop
end
end
private
def requires_correction?(description_key, description_value)
return false if description_value.single_line?

View File

@ -1,7 +1,8 @@
module RuboCop
module Cop
module Layout
class ModuleHashOnNewLine < Cop
class ModuleHashOnNewLine < Base
extend AutoCorrector
include Alignment
MSG = "%<name>s should start on its own line"
@ -20,22 +21,24 @@ module RuboCop
return if update_info_node.nil?
unless begins_its_line?(update_info_node.source_range)
add_offense(update_info_node, location: :begin)
add_offense(update_info_node.loc.begin, message: message(update_info_node), &autocorrector(update_info_node))
end
# Ensure every argument to update_info is on its own line, i.e. info and the hash arguments
update_info_node.arguments.each do |argument|
unless begins_its_line?(argument.source_range)
add_offense(argument)
add_offense(argument.source_range, message: message(argument), &autocorrector(argument))
end
end
if missing_new_line_after_parenthesis?(update_info_node)
add_offense(update_info_node, location: :end, message: MISSING_NEW_LINE_MSG)
add_offense(update_info_node.loc.end, message: MISSING_NEW_LINE_MSG, &autocorrector(update_info_node))
end
end
def autocorrect(node)
private
def autocorrector(node)
lambda do |corrector|
if merge_function?(node) && missing_new_line_after_parenthesis?(node)
# Ensure there's always a new line after `update_info(...)` to avoid `))` at the end of the `super(update_info` call
@ -47,8 +50,6 @@ module RuboCop
end
end
private
def message(node)
if update_info?(node)
format(MSG, name: :update_info)

View File

@ -11,6 +11,7 @@ require File.expand_path('../../config/rails_bigdecimal_fix', __FILE__)
#
# Must be explicit as activerecord is optional dependency
require 'active_record/railtie'
require 'rubocop'
require 'rubocop/rspec/support'
require 'metasploit/framework/database'
# check if database.yml is present