Skip to content

Commit

Permalink
Revert "Fixes with upstream rubocop 1.50.2"
Browse files Browse the repository at this point in the history
This reverts commit a5ce332.
  • Loading branch information
lentschi committed Jan 12, 2024
1 parent a5ce332 commit 88b7528
Show file tree
Hide file tree
Showing 23 changed files with 49 additions and 41 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ group :development do
end

group :development, :test do
gem 'rubocop', '1.50.2', require: false
gem 'rubocop', require: false
gem 'rubocop-rails', require: false
gem 'rubocop-rspec', require: false
gem 'ruby-prof', require: false
Expand Down
30 changes: 14 additions & 16 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -316,10 +316,9 @@ GEM
nokogiri (1.13.1)
mini_portile2 (~> 2.7.0)
racc (~> 1.4)
parallel (1.24.0)
parser (3.3.0.2)
parallel (1.21.0)
parser (3.1.0.0)
ast (~> 2.4.1)
racc
pdf-core (0.9.0)
polyglot (0.3.5)
prawn (2.4.0)
Expand Down Expand Up @@ -401,7 +400,7 @@ GEM
redis-namespace (1.8.1)
redis (>= 3.0.4)
ref (2.0.0)
regexp_parser (2.9.0)
regexp_parser (2.2.1)
responders (3.0.1)
actionpack (>= 5.0)
railties (>= 5.0)
Expand All @@ -411,7 +410,7 @@ GEM
redis-namespace (~> 1.6)
sinatra (>= 0.9.2)
vegas (~> 0.1.2)
rexml (3.2.6)
rexml (3.2.5)
roo (2.8.3)
nokogiri (~> 1)
rubyzip (>= 1.3.0, < 3.0.0)
Expand Down Expand Up @@ -442,18 +441,17 @@ GEM
rspec-rerun (1.1.0)
rspec (~> 3.0)
rspec-support (3.11.0)
rubocop (1.50.2)
json (~> 2.3)
rubocop (1.25.1)
parallel (~> 1.10)
parser (>= 3.2.0.0)
parser (>= 3.1.0.0)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.28.0, < 2.0)
rexml
rubocop-ast (>= 1.15.1, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.30.0)
parser (>= 3.2.1.0)
unicode-display_width (>= 1.4.0, < 3.0)
rubocop-ast (1.15.2)
parser (>= 3.0.1.1)
rubocop-rails (2.13.2)
activesupport (>= 4.2.0)
rack (>= 1.1)
Expand All @@ -463,7 +461,7 @@ GEM
ruby-filemagic (0.7.3)
ruby-ole (1.2.12.2)
ruby-prof (1.4.3)
ruby-progressbar (1.13.0)
ruby-progressbar (1.11.0)
ruby-units (2.3.2)
ruby2_keywords (0.0.5)
ruby_parser (3.18.1)
Expand Down Expand Up @@ -542,7 +540,7 @@ GEM
unf (0.1.4)
unf_ext
unf_ext (0.0.8)
unicode-display_width (2.5.0)
unicode-display_width (2.1.0)
uniform_notifier (1.14.2)
vegas (0.1.11)
rack (>= 1.0.0)
Expand Down Expand Up @@ -634,7 +632,7 @@ DEPENDENCIES
rspec-core
rspec-rails
rspec-rerun
rubocop (= 1.50.2)
rubocop
rubocop-rails
rubocop-rspec
ruby-filemagic
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/concerns/locale.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def session_language
end

def browser_language
request.env['HTTP_ACCEPT_LANGUAGE']&.scan(/^[a-z]{2}/)&.first
request.env['HTTP_ACCEPT_LANGUAGE'] ? request.env['HTTP_ACCEPT_LANGUAGE'].scan(/^[a-z]{2}/).first : nil
end

def default_language
Expand Down
4 changes: 3 additions & 1 deletion app/controllers/sessions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ class SessionsController < ApplicationController
layout 'login'

def new
respond_to(&:html)
respond_to do |format|
format.html
end
end

def create
Expand Down
2 changes: 1 addition & 1 deletion app/models/article.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def in_open_order
@in_open_order ||= begin
order_articles = OrderArticle.where(order_id: Order.open.collect(&:id))
order_article = order_articles.detect { |oa| oa.article_version.article_id == id }
order_article&.order
order_article ? order_article.order : nil
end
end

Expand Down
2 changes: 1 addition & 1 deletion app/models/article_version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def duplicate_including_article_unit_ratios
# @return [Hash<Symbol, Object>] Changed attributes with new values
def self.compare_attributes(attributes)
unequal_attributes = attributes.select { |_name, values| values[0] != values[1] && !(values[0].blank? && values[1].blank?) }
unequal_attributes.to_a.to_h { |a| [a[0], a[1].last] }
unequal_attributes.to_a.map { |a| [a[0], a[1].last] }.to_h

Check failure on line 141 in app/models/article_version.rb

View workflow job for this annotation

GitHub Actions / test

Style/MapToHash: Pass a block to `to_h` instead of calling `map.to_h`.
end

protected
Expand Down
4 changes: 2 additions & 2 deletions app/models/group_order_article.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,14 @@ def update_quantities(quantity, tolerance)
logger.debug("Need to decrease quantities for GroupOrderArticleQuantity[#{quantities[i].id}]")
if (quantity < self.quantity && quantities[i].quantity > 0)
delta = self.quantity - quantity
delta = [delta, quantities[i].quantity].min
delta = (delta > quantities[i].quantity ? quantities[i].quantity : delta)
logger.debug("Decreasing quantity by #{delta}")
quantities[i].quantity -= delta
self.quantity -= delta
end
if (tolerance < self.tolerance && quantities[i].tolerance > 0)
delta = self.tolerance - tolerance
delta = [delta, quantities[i].tolerance].min
delta = (delta > quantities[i].tolerance ? quantities[i].tolerance : delta)
logger.debug("Decreasing tolerance by #{delta}")
quantities[i].tolerance -= delta
self.tolerance -= delta
Expand Down
2 changes: 1 addition & 1 deletion config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
end

# Use default logging formatter so that PID and timestamp are not suppressed.
config.log_formatter = Logger::Formatter.new
config.log_formatter = ::Logger::Formatter.new

# Use a different logger for distributed setups.
# require 'syslog/logger'
Expand Down
6 changes: 3 additions & 3 deletions config/initializers/currency_display.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# remove all currency translations, so that we can set the default language and
# have it shown in all other languages too
I18n.available_locales.each do |locale|
unless locale == I18n.default_locale
I18n.backend.store_translations(locale, number: { currency: { format: { unit: nil } } })
::I18n.available_locales.each do |locale|
unless locale == ::I18n.default_locale
::I18n.backend.store_translations(locale, number: { currency: { format: { unit: nil } } })
end
end
2 changes: 1 addition & 1 deletion config/initializers/secret_token.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# Make sure the secret is at least 30 characters and all random,
# no regular words or you'll be exposed to dictionary attacks.
Foodsoft::Application.config.secret_key_base = begin
if (token = ENV.fetch('SECRET_KEY_BASE', nil)).present?
if (token = ENV['SECRET_KEY_BASE']).present?
token
elsif Rails.env.production? || Rails.env.staging?
raise "You must set SECRET_KEY_BASE"
Expand Down
2 changes: 1 addition & 1 deletion lib/apple_bar.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def group_bar_state

# Use apples as percentage, but show at least 10 percent
def group_bar_width
[@ordergroup.apples, 2].max
@ordergroup.apples < 2 ? 2 : @ordergroup.apples
end

def mean_order_amount_per_job
Expand Down
8 changes: 4 additions & 4 deletions lib/tasks/db_shared.rake
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@ task spec: ['shared:db:test:prepare']
namespace :shared do
namespace :db do |ns|
[:drop, :create, :setup, :migrate, :rollback, :seed, :version].each do |task_name|
task task_name => :environment do
task task_name do
Rake::Task["db:#{task_name}"].invoke
end
end

namespace :schema do
[:load, :dump].each do |task_name|
task task_name => :environment do
task task_name do
Rake::Task["db:schema:#{task_name}"].invoke
end
end
end

namespace :test do
task prepare: :environment do
task :prepare do
Rake::Task['db:test:prepare'].invoke
end
end
Expand All @@ -33,7 +33,7 @@ namespace :shared do
task set_custom_config: :environment do
# save current vars
@original_config = {
env_schema: ENV.fetch('SCHEMA', nil),
env_schema: ENV['SCHEMA'],
config: Rails.application.config.dup
}

Expand Down
4 changes: 2 additions & 2 deletions lib/tasks/foodsoft.rake
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ namespace :foodsoft do

desc "Parse incoming email on stdin (options: RECIPIENT=foodcoop.handling)"
task :parse_reply_email => :environment do
FoodsoftMailReceiver.received ENV.fetch('RECIPIENT', nil), STDIN.read
FoodsoftMailReceiver.received ENV['RECIPIENT'], STDIN.read
end

desc "Start STMP server for incoming email (options: SMTP_SERVER_PORT=2525, SMTP_SERVER_HOST=0.0.0.0)"
task :reply_email_smtp_server => :environment do
port = ENV['SMTP_SERVER_PORT'].present? ? ENV['SMTP_SERVER_PORT'].to_i : 2525
host = ENV.fetch('SMTP_SERVER_HOST', nil)
host = ENV['SMTP_SERVER_HOST']
rake_say "Started SMTP server for incoming email on port #{port}."
server = FoodsoftMailReceiver.new(ports: port, hosts: host, max_processings: 1, logger: Rails.logger)
server.start
Expand Down
8 changes: 4 additions & 4 deletions lib/tasks/multicoops.rake
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace :multicoops do
desc 'Runs a specific rake task for each registered foodcoop, use rake multicoops:run TASK=db:migrate'
task :run => :environment do
task_to_run = ENV.fetch('TASK', nil)
task_to_run = ENV['TASK']
last_error = nil
FoodsoftConfig.each_coop do |coop|
begin
Expand All @@ -21,9 +21,9 @@ namespace :multicoops do

desc 'Runs a specific rake task for a single coop, use rake mutlicoops:run_single TASK=db:migrate FOODCOOP=demo'
task :run_single => :environment do
task_to_run = ENV.fetch('TASK', nil)
FoodsoftConfig.select_foodcoop ENV.fetch('FOODCOOP', nil)
rake_say "Run '#{task_to_run}' for #{ENV.fetch('FOODCOOP', nil)}"
task_to_run = ENV['TASK']
FoodsoftConfig.select_foodcoop ENV['FOODCOOP']
rake_say "Run '#{task_to_run}' for #{ENV['FOODCOOP']}"
Rake::Task[task_to_run].execute
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/tasks/seeds.rake
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require 'pathname'

namespace :db do
namespace :seed do
Dir.glob(Rails.root.join('db/seeds/*.seeds.rb')).sort.each do |seedfile|
Dir.glob(Rails.root.join('db/seeds/*.seeds.rb')).each do |seedfile|
desc "Load the seed data from #{Pathname.new(seedfile).relative_path_from(Rails.root)}"
task File.basename(seedfile, '.seeds.rb') => :environment do
require_relative seedfile
Expand Down
1 change: 1 addition & 0 deletions plugins/discourse/foodsoft_discourse.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Gem::Specification.new do |s|
s.description = "Allow SSO login via Discourse"

s.files = Dir["{app,config,db,lib}/**/*"] + ["Rakefile", "README.md"]
s.test_files = Dir["test/**/*"]

s.add_dependency "rails"
s.add_dependency "deface", "~> 1.0"
Expand Down
1 change: 1 addition & 0 deletions plugins/documents/foodsoft_documents.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Gem::Specification.new do |s|
s.description = "Adds simple document management to foodsoft."

s.files = Dir["{app,config,db,lib}/**/*"] + ["Rakefile", "README.md"]
s.test_files = Dir["test/**/*"]

s.add_dependency "rails"
s.add_dependency "deface", "~> 1.0"
Expand Down
1 change: 1 addition & 0 deletions plugins/links/foodsoft_links.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Gem::Specification.new do |s|
s.description = "Adds simple link management to foodsoft."

s.files = Dir["{app,config,db,lib}/**/*"] + ["Rakefile", "README.md"]
s.test_files = Dir["test/**/*"]

s.add_dependency "rails"
s.add_dependency "deface", "~> 1.0"
Expand Down
1 change: 1 addition & 0 deletions plugins/messages/foodsoft_messages.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Gem::Specification.new do |s|
s.description = "Adds the ability to exchange messages to foodsoft."

s.files = Dir["{app,config,db,lib}/**/*"] + ["Rakefile", "README.md"]
s.test_files = Dir["test/**/*"]

s.add_dependency "rails"
s.add_dependency "base32"
Expand Down
1 change: 1 addition & 0 deletions plugins/polls/foodsoft_polls.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Gem::Specification.new do |s|
s.description = "Adds possibility to do polls with foodsoft."

s.files = Dir["{app,config,db,lib}/**/*"] + ["Rakefile", "README.md"]
s.test_files = Dir["test/**/*"]

s.add_dependency "rails"
s.add_dependency "deface", "~> 1.0"
Expand Down
1 change: 1 addition & 0 deletions plugins/printer/foodsoft_printer.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Gem::Specification.new do |s|
s.description = "Add a printer queue to foodsoft."

s.files = Dir["{app,config,db,lib}/**/*"] + ["Rakefile", "README.md"]
s.test_files = Dir["test/**/*"]

s.add_dependency "rails"
s.add_dependency "deface", "~> 1.0"
Expand Down
1 change: 1 addition & 0 deletions plugins/wiki/foodsoft_wiki.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Gem::Specification.new do |s|
s.description = "Adds a wiki to foodsoft."

s.files = Dir["{app,config,db,lib}/**/*"] + ["Rakefile", "README.md"]
s.test_files = Dir["test/**/*"]

s.add_dependency "rails"
s.add_dependency 'wikicloth'
Expand Down
3 changes: 2 additions & 1 deletion spec/lib/bank_account_information_importer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
let(:bank_account) { create :bank_account }

it 'empty content' do
content = ''
content = <<-JSON
JSON

importer = BankAccountInformationImporter.new(bank_account)
expect(importer.import!(content)).to be(nil)
Expand Down

0 comments on commit 88b7528

Please sign in to comment.