Bundle update rubocop and auto correct style issues

This commit is contained in:
Patrick Gansterer 2022-05-27 21:57:06 +02:00
parent 22fd814193
commit 9c9ebdf557
13 changed files with 42 additions and 37 deletions

View file

@ -892,6 +892,11 @@ Rails/SquishedSQLHeredocs:
Rails/TimeZone:
Enabled: false
# Offense count: 1
Rails/TransactionExitStatement:
Exclude:
- 'app/models/bank_transaction.rb'
# Offense count: 3
# Configuration parameters: Include.
# Include: app/models/**/*.rb

View file

@ -309,8 +309,8 @@ GEM
nokogiri (1.13.4)
mini_portile2 (~> 2.8.0)
racc (~> 1.4)
parallel (1.21.0)
parser (3.1.0.0)
parallel (1.22.1)
parser (3.1.2.0)
ast (~> 2.4.1)
pdf-core (0.9.0)
polyglot (0.3.5)
@ -393,7 +393,7 @@ GEM
redis-namespace (1.8.1)
redis (>= 3.0.4)
ref (2.0.0)
regexp_parser (2.2.1)
regexp_parser (2.4.0)
responders (3.0.1)
actionpack (>= 5.0)
railties (>= 5.0)
@ -434,22 +434,22 @@ GEM
rspec-rerun (1.1.0)
rspec (~> 3.0)
rspec-support (3.11.0)
rubocop (1.25.1)
rubocop (1.30.0)
parallel (~> 1.10)
parser (>= 3.1.0.0)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml
rubocop-ast (>= 1.15.1, < 2.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.18.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 3.0)
rubocop-ast (1.15.2)
parser (>= 3.0.1.1)
rubocop-rails (2.13.2)
rubocop-ast (1.18.0)
parser (>= 3.1.1.0)
rubocop-rails (2.14.2)
activesupport (>= 4.2.0)
rack (>= 1.1)
rubocop (>= 1.7.0, < 2.0)
rubocop-rspec (2.8.0)
rubocop-rspec (2.11.1)
rubocop (~> 1.19)
ruby-filemagic (0.7.3)
ruby-ole (1.2.12.2)

View file

@ -3,6 +3,6 @@
require ::File.expand_path('../config/environment', __FILE__)
# https://gist.github.com/ebeigarts/5450422
map ENV['RAILS_RELATIVE_URL_ROOT'] || '/' do
map ENV.fetch('RAILS_RELATIVE_URL_ROOT', '/') do
run Foodsoft::Application
end

View file

@ -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['SECRET_KEY_BASE']).present?
if (token = ENV.fetch('SECRET_KEY_BASE', nil)).present?
token
elsif Rails.env.production? || Rails.env.staging?
raise "You must set SECRET_KEY_BASE"

View file

@ -47,7 +47,7 @@ class FoodsoftConfig
# Configuration file location.
# Taken from environment variable +FOODSOFT_APP_CONFIG+,
# or else +config/app_config.yml+.
APP_CONFIG_FILE = ENV['FOODSOFT_APP_CONFIG'] || 'config/app_config.yml'
APP_CONFIG_FILE = ENV.fetch('FOODSOFT_APP_CONFIG', 'config/app_config.yml')
# Loaded configuration
APP_CONFIG = ActiveSupport::HashWithIndifferentAccess.new

View file

@ -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['RECIPIENT'], STDIN.read
FoodsoftMailReceiver.received ENV.fetch('RECIPIENT', nil), 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['SMTP_SERVER_HOST']
host = ENV.fetch('SMTP_SERVER_HOST', nil)
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

View file

@ -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['TASK']
task_to_run = ENV.fetch('TASK', nil)
last_error = nil
FoodsoftConfig.each_coop do |coop|
begin
@ -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['TASK']
FoodsoftConfig.select_foodcoop ENV['FOODCOOP']
rake_say "Run '#{task_to_run}' for #{ENV['FOODCOOP']}"
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)}"
Rake::Task[task_to_run].execute
end
end

View file

@ -6,7 +6,7 @@ require 'pathname'
namespace :db do
namespace :seed do
Dir.glob(Rails.root.join('db/seeds/*.seeds.rb')).each do |seedfile|
Dir.glob(Rails.root.join('db/seeds/*.seeds.rb')).sort.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

View file

@ -180,6 +180,6 @@ feature 'settling an order', js: true do
end
expect(page).to_not have_selector('form#new_order_article')
expect(page).to have_content(new_article.name)
expect(order.order_articles.where(article_id: new_article.id)).to_not be nil
expect(order.order_articles.where(article_id: new_article.id)).to_not be_nil
end
end

View file

@ -8,7 +8,7 @@ describe BankTransaction do
JSON
importer = BankAccountInformationImporter.new(bank_account)
expect(importer.import!(content)).to be(nil)
expect(importer.import!(content)).to be_nil
end
it 'invalid JSON' do
@ -241,7 +241,7 @@ describe BankTransaction do
expect(bt.amount).to eq(-238.68)
expect(bt.date).to eq('2019-02-13'.to_date)
expect(bt.text).to eq('Hammersmith Inc.')
expect(bt.iban).to be(nil)
expect(bt.iban).to be_nil
expect(bt.reference).to eq("Corvette Ersatzteile\nMartin Schöneicher, Inv# 123453423, Thx")
expect(bt.receipt).to eq('Auslands-Überweisung')
end
@ -277,7 +277,7 @@ describe BankTransaction do
expect(bt.amount).to eq(-12.3)
expect(bt.date).to eq('2019-02-14'.to_date)
expect(bt.text).to eq('superbank AG')
expect(bt.iban).to be(nil)
expect(bt.iban).to be_nil
expect(bt.reference).to eq("Überweisung US, Wechselspesen u Provision")
expect(bt.receipt).to eq('Spesen/Gebühren')
end
@ -399,14 +399,14 @@ describe BankTransaction do
expect(bt2.text).to eq('CN2')
expect(bt2.iban).to eq('CH9300762011623852957')
expect(bt2.reference).to eq('RI2')
expect(bt2.receipt).to be(nil)
expect(bt2.receipt).to be_nil
bt3 = bank_account.bank_transactions.find_by_external_id("T3")
expect(bt3.amount).to eq(33)
expect(bt3.date).to eq('2000-03-01'.to_date)
expect(bt3.text).to eq('DN3')
expect(bt3.iban).to be(nil)
expect(bt3.iban).to be_nil
expect(bt3.reference).to eq('')
expect(bt3.receipt).to be(nil)
expect(bt3.receipt).to be_nil
end
end

View file

@ -2,35 +2,35 @@ require_relative '../spec_helper'
describe BankTransactionReference do
it 'returns nil for empty input' do
expect(BankTransactionReference.parse('')).to be nil
expect(BankTransactionReference.parse('')).to be_nil
end
it 'returns nil for invalid string' do
expect(BankTransactionReference.parse('invalid')).to be nil
expect(BankTransactionReference.parse('invalid')).to be_nil
end
it 'returns nil for FS1A' do
expect(BankTransactionReference.parse('FS1A')).to be nil
expect(BankTransactionReference.parse('FS1A')).to be_nil
end
it 'returns nil for FS1.1A' do
expect(BankTransactionReference.parse('FS1.1A')).to be nil
expect(BankTransactionReference.parse('FS1.1A')).to be_nil
end
it 'returns nil for xFS1A1' do
expect(BankTransactionReference.parse('xFS1A1')).to be nil
expect(BankTransactionReference.parse('xFS1A1')).to be_nil
end
it 'returns nil for .FS1A1' do
expect(BankTransactionReference.parse('.FS1A1')).to be nil
expect(BankTransactionReference.parse('.FS1A1')).to be_nil
end
it 'returns nil for FS1A1x' do
expect(BankTransactionReference.parse('FS1A1x')).to be nil
expect(BankTransactionReference.parse('FS1A1x')).to be_nil
end
it 'returns nil for FS1A1.' do
expect(BankTransactionReference.parse('FS1A1.')).to be nil
expect(BankTransactionReference.parse('FS1A1.')).to be_nil
end
it 'returns correct value for FS1A1' do

View file

@ -9,7 +9,7 @@ describe FoodsoftConfig do
end
it 'returns an empty default value' do
expect(FoodsoftConfig[:protected][:LIUhniuyGNKUQTWfbiOQIWYexngo78hqexul]).to be nil
expect(FoodsoftConfig[:protected][:LIUhniuyGNKUQTWfbiOQIWYexngo78hqexul]).to be_nil
end
it 'returns a configuration value' do

View file

@ -59,7 +59,7 @@ describe BankTransaction do
let!(:bank_transaction8) { create :bank_transaction, bank_account: bank_account, reference: "FS#{ordergroup.id}X10", amount: 10 }
it 'ignores transaction with invalid reference' do
expect(bank_transaction1.assign_to_ordergroup).to be nil
expect(bank_transaction1.assign_to_ordergroup).to be_nil
end
it 'ignores transaction with invalid ordergroup' do