Skip to content

Commit

Permalink
Auto correct rubocop style issues
Browse files Browse the repository at this point in the history
  • Loading branch information
paroga committed Feb 20, 2022
1 parent f260e60 commit 7e8c1d0
Show file tree
Hide file tree
Showing 39 changed files with 115 additions and 199 deletions.
149 changes: 0 additions & 149 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,6 @@ Lint/AmbiguousBlockAssociation:
- 'spec/api/v1/user/group_order_articles_spec.rb'
- 'spec/models/article_spec.rb'

# Offense count: 4
# Cop supports --auto-correct.
Lint/AmbiguousOperator:
Exclude:
- 'app/mailers/mailer.rb'
- 'spec/models/order_article_spec.rb'

# Offense count: 4
# Cop supports --auto-correct.
Lint/AmbiguousOperatorPrecedence:
Expand Down Expand Up @@ -134,12 +127,6 @@ Lint/IneffectiveAccessModifier:
- 'lib/foodsoft_mail_receiver.rb'
- 'lib/token_verifier.rb'

# Offense count: 1
# Cop supports --auto-correct-all.
Lint/InterpolationCheck:
Exclude:
- 'db/migrate/007_create_article_prices.rb'

# Offense count: 1
# Cop supports --auto-correct-all.
Lint/Loop:
Expand All @@ -158,32 +145,11 @@ Lint/NonDeterministicRequireOrder:
Exclude:
- 'spec/spec_helper.rb'

# Offense count: 5
# Cop supports --auto-correct.
Lint/ParenthesesAsGroupedExpression:
Exclude:
- 'spec/integration/articles_spec.rb'
- 'spec/lib/token_verifier_spec.rb'
- 'spec/models/order_article_spec.rb'

# Offense count: 1
Lint/ReturnInVoidContext:
Exclude:
- 'lib/foodsoft_config.rb'

# Offense count: 8
# Cop supports --auto-correct.
Lint/ScriptPermission:
Exclude:
- 'Rakefile'
- 'plugins/discourse/Rakefile'
- 'plugins/documents/Rakefile'
- 'plugins/links/Rakefile'
- 'plugins/messages/Rakefile'
- 'plugins/polls/Rakefile'
- 'plugins/printer/Rakefile'
- 'plugins/wiki/Rakefile'

# Offense count: 7
# Cop supports --auto-correct.
Lint/SendWithMixinArgument:
Expand Down Expand Up @@ -479,71 +445,11 @@ RSpec/DescribedClass:
- 'spec/models/ordergroup_spec.rb'
- 'spec/models/user_spec.rb'

# Offense count: 9
# Cop supports --auto-correct.
# Configuration parameters: AllowConsecutiveOneLiners.
RSpec/EmptyLineAfterExample:
Exclude:
- 'spec/integration/session_spec.rb'
- 'spec/models/user_spec.rb'

# Offense count: 6
# Cop supports --auto-correct.
RSpec/EmptyLineAfterExampleGroup:
Exclude:
- 'spec/models/order_article_spec.rb'

# Offense count: 30
# Cop supports --auto-correct.
RSpec/EmptyLineAfterFinalLet:
Exclude:
- 'spec/api/v1/order_articles_spec.rb'
- 'spec/api/v1/swagger_spec.rb'
- 'spec/api/v1/user/financial_transactions_spec.rb'
- 'spec/api/v1/user/group_order_articles_spec.rb'
- 'spec/integration/articles_spec.rb'
- 'spec/integration/balancing_spec.rb'
- 'spec/integration/login_spec.rb'
- 'spec/integration/supplier_spec.rb'
- 'spec/models/order_article_spec.rb'
- 'spec/models/order_spec.rb'
- 'spec/models/user_spec.rb'
- 'spec/support/api_helper.rb'

# Offense count: 17
# Cop supports --auto-correct.
RSpec/EmptyLineAfterHook:
Exclude:
- 'spec/api/v1/swagger_spec.rb'
- 'spec/api/v1/user/financial_transactions_spec.rb'
- 'spec/api/v1/user/group_order_articles_spec.rb'
- 'spec/integration/balancing_spec.rb'
- 'spec/integration/login_spec.rb'
- 'spec/models/order_article_spec.rb'
- 'spec/support/api_oauth.rb'

# Offense count: 59
# Configuration parameters: CountAsOne.
RSpec/ExampleLength:
Max: 81

# Offense count: 7
# Cop supports --auto-correct.
# Configuration parameters: CustomTransform, IgnoredWords.
RSpec/ExampleWording:
Exclude:
- 'spec/models/order_spec.rb'

# Offense count: 5
# Cop supports --auto-correct.
# Configuration parameters: Include.
# Include: spec/factories.rb, spec/factories/**/*.rb, features/support/factories/**/*.rb
RSpec/FactoryBot/FactoryClassName:
Exclude:
- 'spec/factories/article.rb'
- 'spec/factories/doorkeeper.rb'
- 'spec/factories/supplier.rb'

# Offense count: 2
# Cop supports --auto-correct.
RSpec/FactoryBot/SyntaxMethods:
Expand Down Expand Up @@ -599,12 +505,6 @@ RSpec/IteratedExpectation:
- 'spec/models/order_spec.rb'
- 'spec/models/supplier_spec.rb'

# Offense count: 3
# Cop supports --auto-correct.
RSpec/LetBeforeExamples:
Exclude:
- 'spec/api/v1/swagger_spec.rb'

# Offense count: 13
RSpec/LetSetup:
Exclude:
Expand Down Expand Up @@ -674,14 +574,6 @@ RSpec/RepeatedExample:
- 'spec/lib/bank_transaction_reference_spec.rb'
- 'spec/lib/foodsoft_mail_receiver_spec.rb'

# Offense count: 9
# Cop supports --auto-correct.
RSpec/ScatteredLet:
Exclude:
- 'spec/api/v1/swagger_spec.rb'
- 'spec/api/v1/user/group_order_articles_spec.rb'
- 'spec/api/v1/user/ordergroup_spec.rb'

# Offense count: 7
RSpec/ScatteredSetup:
Exclude:
Expand Down Expand Up @@ -710,14 +602,6 @@ Rails/ActiveRecordCallbacksOrder:
- 'app/models/order.rb'
- 'app/models/stock_change.rb'

# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: Include.
# Include: db/migrate/*.rb
Rails/AddColumnIndex:
Exclude:
- 'db/migrate/20171002000000_create_financial_links.rb'

# Offense count: 1
# Cop supports --auto-correct.
Rails/ApplicationMailer:
Expand Down Expand Up @@ -751,12 +635,6 @@ Rails/Blank:
Exclude:
- 'app/controllers/api/v1/base_controller.rb'

# Offense count: 1
# Cop supports --auto-correct.
Rails/ContentTag:
Exclude:
- 'plugins/wiki/app/helpers/pages_helper.rb'

# Offense count: 33
# Configuration parameters: Include.
# Include: db/migrate/*.rb
Expand All @@ -783,12 +661,6 @@ Rails/Date:
Rails/DynamicFindBy:
Enabled: false

# Offense count: 1
# Cop supports --auto-correct.
Rails/EagerEvaluationLogMessage:
Exclude:
- 'db/migrate/20130718183101_migrate_user_settings.rb'

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: Include.
Expand Down Expand Up @@ -1297,15 +1169,6 @@ Style/ExplicitBlockArgument:
- 'plugins/current_orders/app/documents/multiple_orders_by_articles.rb'
- 'plugins/current_orders/app/documents/multiple_orders_by_groups.rb'

# Offense count: 4
# Cop supports --auto-correct.
Style/FileWrite:
Exclude:
- 'config/initializers/secret_token.rb'
- 'lib/order_txt.rb'
- 'lib/render_csv.rb'
- 'lib/render_pdf.rb'

# Offense count: 1
# Cop supports --auto-correct-all.
# Configuration parameters: EnforcedStyle.
Expand Down Expand Up @@ -1462,12 +1325,6 @@ Style/LineEndConcatenation:
- 'db/migrate/20130702113610_update_group_order_totals.rb'
- 'plugins/current_orders/app/documents/multiple_orders_by_articles.rb'

# Offense count: 1
# Cop supports --auto-correct-all.
Style/MapToHash:
Exclude:
- 'lib/foodsoft_config.rb'

# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: IgnoredMethods.
Expand Down Expand Up @@ -1780,12 +1637,6 @@ Style/RedundantReturn:
Style/RedundantSelf:
Enabled: false

# Offense count: 1
# Cop supports --auto-correct.
Style/RedundantSelfAssignmentBranch:
Exclude:
- 'db/migrate/20130718183101_migrate_user_settings.rb'

# Offense count: 1
# Cop supports --auto-correct-all.
Style/RedundantSort:
Expand Down
Empty file modified Rakefile
100644 → 100755
Empty file.
4 changes: 2 additions & 2 deletions app/mailers/mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,13 @@ def mail(args)

def self.deliver_now_with_user_locale(user, &block)
I18n.with_locale(user.settings['profile']['language']) do
self.deliver_now &block
self.deliver_now(&block)
end
end

def self.deliver_now_with_default_locale(&block)
I18n.with_locale(FoodsoftConfig[:default_locale]) do
self.deliver_now &block
self.deliver_now(&block)
end
end

Expand Down
2 changes: 1 addition & 1 deletion config/initializers/secret_token.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
else
puts "=> Generating initial SECRET_KEY_BASE in #{sf}"
token = SecureRandom.hex(30)
File.open(sf, 'w') { |f| f.write(token) }
File.write(sf, token)
token
end
end
Expand Down
2 changes: 1 addition & 1 deletion db/migrate/007_create_article_prices.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def self.up
puts 'add prices to the sample articles'
CreateArticles::SAMPLE_ARTICLE_NAMES.each do |a|
puts 'Create Price for article ' + a
raise 'article #{a} not found!' unless article = Article.find_by_name(a)
raise "article #{a} not found!" unless article = Article.find_by_name(a)

new_price = ArticlePrice.new(:clear_price => rand(4) + 1,
:tax => 7.0,
Expand Down
4 changes: 2 additions & 2 deletions db/migrate/20130718183101_migrate_user_settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def up
begin
user = type.constantize.find(id)
rescue ActiveRecord::RecordNotFound
Rails.logger.debug "Can't find configurable object with type: #{type.inspect}, id: #{id.inspect}"
Rails.logger.debug { "Can't find configurable object with type: #{type.inspect}, id: #{id.inspect}" }
next
end

Expand All @@ -27,7 +27,7 @@ def up

# prepare value
value = YAML.load(old_setting.value)
value = value.nil? ? false : value
value = false if value.nil?

# set the settings_attributes (thanks to settings.merge! we can set them one by one)
user.settings_attributes = {
Expand Down
7 changes: 5 additions & 2 deletions db/migrate/20171002000000_create_financial_links.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ def change
t.text :note
end

add_column :financial_transactions, :financial_link_id, :integer, index: true
add_column :invoices, :financial_link_id, :integer, index: true
add_column :financial_transactions, :financial_link_id, :integer
add_column :invoices, :financial_link_id, :integer

add_index :financial_transactions, :financial_link_id
add_index :invoices, :financial_link_id
end
end
4 changes: 2 additions & 2 deletions lib/foodsoft_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def keys
# @return [Array<String>] Valid names of foodcoops.
def foodcoops
if config[:multi_coop_install]
APP_CONFIG.keys.reject { |coop| coop =~ /^(default|development|test|production)$/ }
APP_CONFIG.keys.grep_v(/^(default|development|test|production)$/)
else
[config[:default_scope]]
end
Expand Down Expand Up @@ -189,7 +189,7 @@ def allowed_key?(key)

# @return [Hash] Full configuration.
def to_hash
keys.map { |k| [k, self[k]] }.to_h
keys.to_h { |k| [k, self[k]] }
end

# for using active_model_serializer in the api/v1/configs controller
Expand Down
2 changes: 1 addition & 1 deletion lib/order_txt.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ def to_txt

# Helper method to test pdf via rails console: OrderTxt.new(order).save_tmp
def save_tmp
File.open("#{Rails.root}/tmp/#{self.class.to_s.underscore}.txt", 'w') { |f| f.write(to_csv.force_encoding("UTF-8")) }
File.write("#{Rails.root}/tmp/#{self.class.to_s.underscore}.txt", to_csv.force_encoding("UTF-8"))
end
end
2 changes: 1 addition & 1 deletion lib/render_csv.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def data
# Helper method to test pdf via rails console: OrderCsv.new(order).save_tmp
def save_tmp
encoding = @options[:encoding] || 'UTF-8'
File.open("#{Rails.root}/tmp/#{self.class.to_s.underscore}.csv", 'w') { |f| f.write(to_csv.force_encoding(encoding)) }
File.write("#{Rails.root}/tmp/#{self.class.to_s.underscore}.csv", to_csv.force_encoding(encoding))
end

# XXX disable unit to avoid encoding problems, both in unit and whitespace. Also allows computations in spreadsheet.
Expand Down
2 changes: 1 addition & 1 deletion lib/render_pdf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def to_pdf

# Helper method to test pdf via rails console: OrderByGroups.new(order).save_tmp
def save_tmp
File.open("#{Rails.root}/tmp/#{self.class.to_s.underscore}.pdf", 'w') { |f| f.write(to_pdf.force_encoding("UTF-8")) }
File.write("#{Rails.root}/tmp/#{self.class.to_s.underscore}.pdf", to_pdf.force_encoding("UTF-8"))
end

# @todo avoid underscore instead of unicode whitespace in pdf :/
Expand Down
Empty file modified plugins/discourse/Rakefile
100644 → 100755
Empty file.
Empty file modified plugins/documents/Rakefile
100644 → 100755
Empty file.
Empty file modified plugins/links/Rakefile
100644 → 100755
Empty file.
Empty file modified plugins/messages/Rakefile
100644 → 100755
Empty file.
Empty file modified plugins/polls/Rakefile
100644 → 100755
Empty file.
Empty file modified plugins/printer/Rakefile
100644 → 100755
Empty file.
Empty file modified plugins/wiki/Rakefile
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion plugins/wiki/app/helpers/pages_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module PagesHelper
include WikiCloth

def rss_meta_tag
tag('link', :rel => "alternate", :type => "application/rss+xml", :title => "RSS", :href => all_pages_rss_url).html_safe
tag.link(rel: "alternate", type: "application/rss+xml", title: "RSS", href: all_pages_rss_url).html_safe
end

def wikified_body(body, title = nil)
Expand Down
2 changes: 2 additions & 0 deletions spec/api/v1/order_articles_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
context "with param q[ordered]" do
let(:order) { create(:order, article_count: 4) }
let(:order_articles) { order.order_articles }

before do
order_articles[0].update_attributes! quantity: 0, tolerance: 0, units_to_order: 0
order_articles[1].update_attributes! quantity: 1, tolerance: 0, units_to_order: 0
Expand Down Expand Up @@ -42,6 +43,7 @@
context "when ordered by user" do
let(:user) { create(:user, :ordergroup) }
let(:go) { create(:group_order, order: order, ordergroup: user.ordergroup) }

before do
create(:group_order_article, group_order: go, order_article: order_articles[1], quantity: 1)
create(:group_order_article, group_order: go, order_article: order_articles[2], tolerance: 0)
Expand Down
Loading

0 comments on commit 7e8c1d0

Please sign in to comment.