Maintenance: Updated rubocop(-* gems) to latest version (1.4.1).

This commit is contained in:
Thorsten Eckel 2020-11-24 17:20:57 +01:00
parent cca33e4b5e
commit 85573432c0
24 changed files with 42 additions and 37 deletions

View file

@ -23,10 +23,10 @@ AllCops:
- 'node_modules/**/*' - 'node_modules/**/*'
- 'public/assets/**/*' - 'public/assets/**/*'
- 'public/packs/**/*' - 'public/packs/**/*'
RSpec: RSpec:
Patterns: Include:
- '_spec.rb$' - "**/*_spec.rb"
- '_examples.rb$' - "**/*_examples.rb"
Rails: Rails:
Enabled: true Enabled: true

View file

@ -185,7 +185,7 @@ group :development, :test do
gem 'rubocop' gem 'rubocop'
gem 'rubocop-performance' gem 'rubocop-performance'
gem 'rubocop-rails' gem 'rubocop-rails'
gem 'rubocop-rspec', '2.0.0.pre' # see: https://github.com/rubocop-hq/rubocop-rspec/issues/1051 gem 'rubocop-rspec'
# changelog generation # changelog generation
gem 'github_changelog_generator' gem 'github_changelog_generator'

View file

@ -357,7 +357,7 @@ GEM
omniauth (~> 1.5) omniauth (~> 1.5)
omniauth-oauth2 (>= 1.4.0) omniauth-oauth2 (>= 1.4.0)
openssl (2.1.2) openssl (2.1.2)
parallel (1.20.0) parallel (1.20.1)
parser (2.7.2.0) parser (2.7.2.0)
ast (~> 2.4.1) ast (~> 2.4.1)
pg (0.21.0) pg (0.21.0)
@ -452,7 +452,7 @@ GEM
rspec-support (~> 3.9.0) rspec-support (~> 3.9.0)
rspec-support (3.9.3) rspec-support (3.9.3)
rszr (0.5.2) rszr (0.5.2)
rubocop (1.3.0) rubocop (1.4.1)
parallel (~> 1.10) parallel (~> 1.10)
parser (>= 2.7.1.5) parser (>= 2.7.1.5)
rainbow (>= 2.2.2, < 4.0) rainbow (>= 2.2.2, < 4.0)
@ -463,15 +463,16 @@ GEM
unicode-display_width (>= 1.4.0, < 2.0) unicode-display_width (>= 1.4.0, < 2.0)
rubocop-ast (1.1.1) rubocop-ast (1.1.1)
parser (>= 2.7.1.5) parser (>= 2.7.1.5)
rubocop-performance (1.8.1) rubocop-performance (1.9.0)
rubocop (>= 0.87.0) rubocop (>= 0.90.0, < 2.0)
rubocop-ast (>= 0.4.0) rubocop-ast (>= 0.4.0)
rubocop-rails (2.8.1) rubocop-rails (2.8.1)
activesupport (>= 4.2.0) activesupport (>= 4.2.0)
rack (>= 1.1) rack (>= 1.1)
rubocop (>= 0.87.0) rubocop (>= 0.87.0)
rubocop-rspec (2.0.0.pre) rubocop-rspec (2.0.0)
rubocop (~> 1.0) rubocop (~> 1.0)
rubocop-ast (>= 1.1.0)
ruby-progressbar (1.10.1) ruby-progressbar (1.10.1)
ruby-saml (1.10.2) ruby-saml (1.10.2)
nokogiri (>= 1.5.10) nokogiri (>= 1.5.10)
@ -655,7 +656,7 @@ DEPENDENCIES
rubocop rubocop
rubocop-performance rubocop-performance
rubocop-rails rubocop-rails
rubocop-rspec (= 2.0.0.pre) rubocop-rspec
rubyntlm! rubyntlm!
sassc-rails sassc-rails
selenium-webdriver selenium-webdriver

View file

@ -7,7 +7,7 @@ class Issue2715FixBrokenTwitterUrlsJob < ApplicationJob
.where(ticket_article_types: { name: ['twitter status', 'twitter direct-message'] }) .where(ticket_article_types: { name: ['twitter status', 'twitter direct-message'] })
.order(created_at: :desc) .order(created_at: :desc)
.limit(10_000) .limit(10_000)
.find_each(&method(:fix_broken_links)) .find_each { |article| fix_broken_links(article) }
end end
private private

View file

@ -116,7 +116,7 @@ cleanup old token
def with_context(user:, &block) def with_context(user:, &block)
@effective_user = user @effective_user = user
instance_eval(&block) if block_given? instance_eval(&block) if block
ensure ensure
@effective_user = nil @effective_user = nil
end end

View file

@ -19,6 +19,7 @@ module ActiveRecord
end end
end end
end end
module ActiveRecord module ActiveRecord
module ConnectionAdapters module ConnectionAdapters
module PostgreSQL module PostgreSQL

View file

@ -95,7 +95,7 @@ class String
end end
c c
end end
.join('') .join
end end
=begin =begin

View file

@ -1,6 +1,7 @@
module Exceptions module Exceptions
class NotAuthorized < StandardError; end class NotAuthorized < StandardError; end
class UnprocessableEntity < StandardError; end class UnprocessableEntity < StandardError; end
end end

View file

@ -103,7 +103,7 @@ satinize html string based on whiltelist
# clean class / only use allowed classes # clean class / only use allowed classes
if node['class'] if node['class']
classes = node['class'].gsub(/\t|\n|\r/, '').split(' ') classes = node['class'].gsub(/\t|\n|\r/, '').split
class_new = '' class_new = ''
classes.each do |local_class| classes.each do |local_class|
next if classes_whitelist.exclude?(local_class.to_s.strip) next if classes_whitelist.exclude?(local_class.to_s.strip)

View file

@ -33,7 +33,7 @@ module Import
def children(*parents) def children(*parents)
return [] if parents.empty? return [] if parents.empty?
direct_descendants = parents.map(&method(:request_children)) direct_descendants = parents.map { |parent| request_children(parent) }
.flatten.uniq.compact .flatten.uniq.compact
direct_descendants | children(*direct_descendants) direct_descendants | children(*direct_descendants)

View file

@ -20,7 +20,7 @@ module Import
# Import::Helper::AttributesExamples.new do |extractor| # Import::Helper::AttributesExamples.new do |extractor|
# extractor.extract(attributes) # extractor.extract(attributes)
# end # end
return if !block_given? return if !block
if block.arity.zero? if block.arity.zero?
instance_eval(&block) instance_eval(&block)

View file

@ -31,9 +31,7 @@ class KnowledgeBase
return if params.blank? return if params.blank?
params params
.map { |location_params| update_location_using_params! knowledge_base, location_params } .map { |location_params| update_location_using_params! knowledge_base, location_params }.sum(&:reload)
.map(&:reload)
.sum
end end
# Mass-update KB menu items in a given location # Mass-update KB menu items in a given location

View file

@ -92,7 +92,7 @@ class Ldap
# re-order according to oracle format index and join # re-order according to oracle format index and join
oracle_format_indices = [3, 2, 1, 0, 5, 4, 7, 6, 8, 9, 10, 11, 12, 13, 14, 15] oracle_format_indices = [3, 2, 1, 0, 5, 4, 7, 6, 8, 9, 10, 11, 12, 13, 14, 15]
result = oracle_format_indices.map { |index| parts[index] }.join('') result = oracle_format_indices.map { |index| parts[index] }.join
# add dashes if requested # add dashes if requested
return result if !dashify return result if !dashify

View file

@ -44,7 +44,7 @@ returns
.map { |filename| data.merge(filename: filename) } .map { |filename| data.merge(filename: filename) }
.map { |data_hash| TEMPLATE_PATH_STRING % data_hash } .map { |data_hash| TEMPLATE_PATH_STRING % data_hash }
found = candidates.find(&File.method(:exist?)) found = candidates.find { |candidate| File.exist?(candidate) }
raise FileNotFoundError, "Missing template files #{candidates}!" if !found raise FileNotFoundError, "Missing template files #{candidates}!" if !found

View file

@ -36,7 +36,7 @@ class Pseudonymisation
return '*' if source.length == 1 return '*' if source.length == 1
return "#{source.first}*#{source.last}" if source.exclude?(' ') return "#{source.first}*#{source.last}" if source.exclude?(' ')
source.split(' ').map do |sub_string| source.split.map do |sub_string|
of_string(sub_string) of_string(sub_string)
end.join(' ') end.join(' ')
end end

View file

@ -44,17 +44,17 @@ class Sequencer
# Because it doesn't include associations # Because it doesn't include associations
# stored on OTHER TABLES (has-one, has-many, HABTM) # stored on OTHER TABLES (has-one, has-many, HABTM)
def changes def changes
@changes ||= unfiltered_changes.reject(&method(:no_diff?)) @changes ||= unfiltered_changes.reject { |_attribute, values| no_diff?(values) }
end end
def unfiltered_changes def unfiltered_changes
attrs = associations.keys attrs = associations.keys
before = attrs.map(&instance.method(:send)) before = attrs.map { |attribute| instance.send(attribute) }
after = associations.values after = associations.values
attrs.zip(before.zip(after)).to_h.with_indifferent_access attrs.zip(before.zip(after)).to_h.with_indifferent_access
end end
def no_diff?(_, values) def no_diff?(values)
values.map!(&:sort) if values.all? { |val| val.respond_to?(:sort) } values.map!(&:sort) if values.all? { |val| val.respond_to?(:sort) }
values.map!(&:presence) # [nil, []] -> [nil, nil] values.map!(&:presence) # [nil, []] -> [nil, nil]
values.uniq.length == 1 values.uniq.length == 1

View file

@ -18,7 +18,7 @@ class Sequencer
end end
def not_synced(entries) def not_synced(entries)
entries.find(&method(:not_synced?)) entries.find { |entry| not_synced?(entry) }
end end
def not_synced?(entry) def not_synced?(entry)

View file

@ -31,10 +31,10 @@ FactoryBot.define do
create(:knowledge_base_category, parent: obj) create(:knowledge_base_category, parent: obj)
level2 = create(:knowledge_base_category, parent: obj) level2 = create(:knowledge_base_category, parent: obj)
2.times { create(:knowledge_base_category, parent: level2) } create_list(:knowledge_base_category, 2, parent: level2)
level3 = level2.children.reload.first level3 = level2.children.reload.first
2.times { create(:knowledge_base_category, parent: level3) } create_list(:knowledge_base_category, 2, parent: level3)
obj.reload obj.reload
end end

View file

@ -1,5 +1,5 @@
FactoryBot.define do FactoryBot.define do
factory :notification_factory_renderer, class: NotificationFactory::Renderer do factory :notification_factory_renderer, class: 'NotificationFactory::Renderer' do
objects { nil } objects { nil }
locale { 'en-en' } locale { 'en-en' }
template { '' } template { '' }

View file

@ -1,5 +1,5 @@
FactoryBot.define do FactoryBot.define do
factory :object_manager_attribute, class: ObjectManager::Attribute do factory :object_manager_attribute, class: 'ObjectManager::Attribute' do
transient do transient do
object_name { 'Ticket' } object_name { 'Ticket' }
additional_data_options { nil } additional_data_options { nil }

View file

@ -3,7 +3,7 @@ FactoryBot.define do
# add custom attributes via: # add custom attributes via:
# mocked_entry = build(:ldap_entry) # mocked_entry = build(:ldap_entry)
# mocked_entry['attr'] = [value, another_value] # mocked_entry['attr'] = [value, another_value]
factory :ldap_entry, class: Net::LDAP::Entry do factory :ldap_entry, class: 'Net::LDAP::Entry' do
initialize_with { new('dc=com') } initialize_with { new('dc=com') }
end end
end end

View file

@ -75,7 +75,7 @@ RSpec.describe SearchIndexBackend, searchindex: true do
QUERIES QUERIES
it 'appends a * to the original query' do it 'appends a * to the original query' do
expect(queries.map(&described_class.method(:append_wildcard_to_simple_query))) expect(queries.map { |query| described_class.append_wildcard_to_simple_query(query) })
.to eq(queries.map { |q| "#{q}*" }) .to eq(queries.map { |q| "#{q}*" })
end end
end end
@ -117,7 +117,7 @@ RSpec.describe SearchIndexBackend, searchindex: true do
QUERIES QUERIES
it 'returns the original query verbatim' do it 'returns the original query verbatim' do
expect(queries.map(&described_class.method(:append_wildcard_to_simple_query))) expect(queries.map { |query| described_class.append_wildcard_to_simple_query(query) })
.to eq(queries) .to eq(queries)
end end
end end

View file

@ -115,7 +115,7 @@ module DbMigrationHelper
# remove_foreign_key(:online_notifications, :users) # remove_foreign_key(:online_notifications, :users)
# #
# @return [nil] # @return [nil]
def respond_to_missing?(*) # rubocop:disable Lint/MissingSuper def respond_to_missing?(*)
true true
end end

View file

@ -92,6 +92,10 @@ RSpec.configure do |config|
end end
end end
config.around(:each, use_vcr: true, &RSpec::Support::VCRHelper.method(:inject_advisory)) config.around(:each, use_vcr: true) do |example|
config.around(:each, use_vcr: true, &RSpec::Expectations::VCRHelper.method(:inject_advisory)) RSpec::Support::VCRHelper.inject_advisory(example)
end
config.around(:each, use_vcr: true) do |example|
RSpec::Expectations::VCRHelper.inject_advisory(example)
end
end end