Run rubocop --fix-layout and remove encoding comments

This commit is contained in:
Patrick Gansterer 2021-03-01 15:27:26 +01:00
parent fa63e6e81d
commit ea2862fdef
283 changed files with 1164 additions and 1969 deletions

View File

@ -29,491 +29,6 @@ Gemspec/RequiredRubyVersion:
- 'plugins/uservoice/foodsoft_uservoice.gemspec'
- 'plugins/wiki/foodsoft_wiki.gemspec'
# Offense count: 5
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, IndentationWidth.
# SupportedStyles: outdent, indent
Layout/AccessModifierIndentation:
Exclude:
- 'app/controllers/finance/financial_links_controller.rb'
- 'app/models/invite.rb'
- 'db/migrate/20130622095040_move_weekly_tasks.rb'
# Offense count: 13
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, IndentationWidth.
# SupportedStyles: with_first_argument, with_fixed_indentation
Layout/ArgumentAlignment:
Exclude:
- 'app/controllers/finance/balancing_controller.rb'
- 'app/controllers/foodcoop/workgroups_controller.rb'
- 'app/helpers/deliveries_helper.rb'
- 'app/helpers/stockit_helper.rb'
- 'db/migrate/20140102170431_add_result_computed_to_group_order_articles.rb'
- 'plugins/discourse/app/controllers/discourse_login_controller.rb'
- 'plugins/discourse/app/controllers/discourse_sso_controller.rb'
- 'plugins/messages/lib/foodsoft_messages/user_link.rb'
- 'plugins/polls/app/controllers/polls_controller.rb'
- 'spec/models/user_spec.rb'
# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, IndentationWidth.
# SupportedStyles: with_first_element, with_fixed_indentation
Layout/ArrayAlignment:
Exclude:
- 'lib/render_pdf.rb'
# Offense count: 3
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyleAlignWith.
# SupportedStylesAlignWith: either, start_of_block, start_of_line
Layout/BlockAlignment:
Exclude:
- 'db/migrate/008_create_orders.rb'
- 'db/migrate/20090120184410_road_to_version_three.rb'
- 'spec/api/v1/user/group_order_articles_spec.rb'
# Offense count: 86
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, IndentOneStep, IndentationWidth.
# SupportedStyles: case, end
Layout/CaseIndentation:
Enabled: false
# Offense count: 5
# Cop supports --auto-correct.
Layout/ClosingParenthesisIndentation:
Exclude:
- 'app/helpers/stockit_helper.rb'
- 'app/models/group_order_article.rb'
- 'app/models/shared_article.rb'
- 'db/seeds/minimal.seeds.rb'
# Offense count: 4
# Cop supports --auto-correct.
Layout/CommentIndentation:
Exclude:
- 'app/controllers/concerns/auth_api.rb'
- 'app/controllers/finance/financial_transactions_controller.rb'
- 'app/documents/order_fax.rb'
- 'db/migrate/20090120184410_road_to_version_three.rb'
# Offense count: 51
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: leading, trailing
Layout/DotPosition:
Exclude:
- 'app/controllers/api/v1/user/group_order_articles_controller.rb'
- 'app/controllers/stockit_controller.rb'
- 'app/documents/order_fax.rb'
- 'app/models/order.rb'
- 'app/models/stock_article.rb'
- 'app/models/task.rb'
- 'lib/order_pdf.rb'
- 'plugins/current_orders/app/controllers/current_orders/group_orders_controller.rb'
- 'plugins/current_orders/app/controllers/current_orders/ordergroups_controller.rb'
- 'plugins/current_orders/app/documents/multiple_orders_by_articles.rb'
- 'plugins/current_orders/app/documents/multiple_orders_by_groups.rb'
# Offense count: 3
# Cop supports --auto-correct.
Layout/ElseAlignment:
Exclude:
- 'app/helpers/group_orders_helper.rb'
# Offense count: 70
# Cop supports --auto-correct.
Layout/EmptyLineAfterGuardClause:
Enabled: false
# Offense count: 38
# Cop supports --auto-correct.
Layout/EmptyLineAfterMagicComment:
Enabled: false
# Offense count: 15
# Cop supports --auto-correct.
# Configuration parameters: EmptyLineBetweenMethodDefs, EmptyLineBetweenClassDefs, EmptyLineBetweenModuleDefs, AllowAdjacentOneLineDefs, NumberOfEmptyLines.
Layout/EmptyLineBetweenDefs:
Exclude:
- 'app/helpers/finance/invoices_helper.rb'
- 'app/helpers/orders_helper.rb'
- 'app/models/group_order.rb'
- 'app/models/ordergroup.rb'
- 'app/models/task.rb'
- 'db/migrate/20181201000400_create_supplier_categories.rb'
- 'db/migrate/20181204000000_clear_invalid_invoices_from_orders.rb'
- 'db/migrate/20181204070000_create_stock_events.rb'
- 'lib/api/errors.rb'
- 'lib/foodsoft/expansion_variables.rb'
- 'lib/token_verifier.rb'
- 'plugins/wiki/app/helpers/pages_helper.rb'
- 'spec/support/shared_database.rb'
# Offense count: 55
# Cop supports --auto-correct.
Layout/EmptyLines:
Enabled: false
# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: around, only_before
Layout/EmptyLinesAroundAccessModifier:
Exclude:
- 'db/migrate/20130622095040_move_weekly_tasks.rb'
# Offense count: 85
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: empty_lines, no_empty_lines
Layout/EmptyLinesAroundBlockBody:
Enabled: false
# Offense count: 147
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines, beginning_only, ending_only
Layout/EmptyLinesAroundClassBody:
Enabled: false
# Offense count: 3
# Cop supports --auto-correct.
Layout/EmptyLinesAroundExceptionHandlingKeywords:
Exclude:
- 'app/controllers/articles_controller.rb'
- 'app/controllers/finance/balancing_controller.rb'
- 'plugins/wiki/app/controllers/pages_controller.rb'
# Offense count: 2
# Cop supports --auto-correct.
Layout/EmptyLinesAroundMethodBody:
Exclude:
- 'app/helpers/application_helper.rb'
- 'db/migrate/002_create_groups.rb'
# Offense count: 37
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines
Layout/EmptyLinesAroundModuleBody:
Enabled: false
# Offense count: 9
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyleAlignWith, Severity.
# SupportedStylesAlignWith: keyword, variable, start_of_line
Layout/EndAlignment:
Exclude:
- 'app/controllers/articles_controller.rb'
- 'app/controllers/concerns/auth.rb'
- 'app/controllers/concerns/send_order_pdf.rb'
- 'app/controllers/finance/financial_transactions_controller.rb'
- 'app/controllers/home_controller.rb'
- 'app/controllers/orders_controller.rb'
- 'app/helpers/group_orders_helper.rb'
- 'plugins/wiki/app/controllers/pages_controller.rb'
# Offense count: 57
# Cop supports --auto-correct.
# Configuration parameters: AllowForAlignment, AllowBeforeTrailingComments, ForceEqualSignAlignment.
Layout/ExtraSpacing:
Enabled: false
# Offense count: 6
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, IndentationWidth.
# SupportedStyles: consistent, consistent_relative_to_receiver, special_for_inner_method_call, special_for_inner_method_call_in_parentheses
Layout/FirstArgumentIndentation:
Exclude:
- 'app/models/group_order_article.rb'
- 'app/models/shared_article.rb'
- 'db/seeds/minimal.seeds.rb'
- 'plugins/current_orders/app/controllers/current_orders/articles_controller.rb'
- 'plugins/current_orders/app/controllers/current_orders/ordergroups_controller.rb'
# Offense count: 8
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, IndentationWidth.
# SupportedStyles: special_inside_parentheses, consistent, align_brackets
Layout/FirstArrayElementIndentation:
Exclude:
- 'db/seeds/small.en.seeds.rb'
- 'db/seeds/small.nl.seeds.rb'
- 'lib/financial_transactions_csv.rb'
- 'lib/order_csv.rb'
# Offense count: 9
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, IndentationWidth.
# SupportedStyles: special_inside_parentheses, consistent, align_braces
Layout/FirstHashElementIndentation:
Exclude:
- 'app/controllers/finance/financial_transactions_controller.rb'
- 'app/helpers/application_helper.rb'
- 'app/models/group_order.rb'
- 'db/migrate/20130718183101_migrate_user_settings.rb'
- 'lib/bank_account_information_importer.rb'
# Offense count: 83
# Cop supports --auto-correct.
# Configuration parameters: AllowMultipleStyles, EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle.
# SupportedHashRocketStyles: key, separator, table
# SupportedColonStyles: key, separator, table
# SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit
Layout/HashAlignment:
Enabled: false
# Offense count: 9
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: normal, indented_internal_methods
Layout/IndentationConsistency:
Exclude:
- 'db/migrate/003_create_suppliers.rb'
- 'db/migrate/007_create_article_prices.rb'
- 'db/migrate/008_create_orders.rb'
- 'db/migrate/010_user_password_reset.rb'
- 'db/migrate/20090120184410_road_to_version_three.rb'
# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: IndentationWidth, EnforcedStyle.
# SupportedStyles: spaces, tabs
Layout/IndentationStyle:
Exclude:
- 'db/migrate/010_user_password_reset.rb'
# Offense count: 12
# Cop supports --auto-correct.
# Configuration parameters: Width, IgnoredPatterns.
Layout/IndentationWidth:
Exclude:
- 'app/helpers/admin/configs_helper.rb'
- 'app/helpers/group_orders_helper.rb'
- 'app/models/user.rb'
- 'db/migrate/003_create_suppliers.rb'
- 'db/migrate/007_create_article_prices.rb'
- 'db/migrate/008_create_orders.rb'
- 'db/migrate/20090120184410_road_to_version_three.rb'
- 'lib/tasks/multicoops.rake'
- 'spec/api/v1/user/group_order_articles_spec.rb'
- 'spec/spec_helper.rb'
# Offense count: 39
# Cop supports --auto-correct.
# Configuration parameters: AllowDoxygenCommentStyle, AllowGemfileRubyComment.
Layout/LeadingCommentSpace:
Enabled: false
# Offense count: 5
# Cop supports --auto-correct.
Layout/LeadingEmptyLines:
Exclude:
- 'db/migrate/20090120184410_road_to_version_three.rb'
- 'db/seeds/seed_helper.rb'
- 'lib/order_txt.rb'
- 'spec/support/integration.rb'
- 'spec/support/session_helper.rb'
# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: symmetrical, new_line, same_line
Layout/MultilineMethodCallBraceLayout:
Exclude:
- 'app/helpers/stockit_helper.rb'
# Offense count: 42
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, IndentationWidth.
# SupportedStyles: aligned, indented, indented_relative_to_receiver
Layout/MultilineMethodCallIndentation:
Exclude:
- 'app/controllers/stockit_controller.rb'
- 'app/models/order.rb'
- 'app/models/ordergroup.rb'
- 'app/models/stock_article.rb'
- 'app/models/task.rb'
- 'lib/foodsoft/expansion_variables.rb'
- 'lib/order_pdf.rb'
- 'plugins/current_orders/app/controllers/current_orders/group_orders_controller.rb'
- 'plugins/current_orders/app/controllers/current_orders/ordergroups_controller.rb'
- 'plugins/current_orders/app/documents/multiple_orders_by_groups.rb'
- 'spec/api/v1/user/group_order_articles_spec.rb'
# Offense count: 9
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, IndentationWidth.
# SupportedStyles: aligned, indented
Layout/MultilineOperationIndentation:
Exclude:
- 'app/helpers/orders_helper.rb'
- 'app/inputs/date_picker_time_input.rb'
- 'app/models/ordergroup.rb'
- 'app/models/task.rb'
- 'lib/apple_bar.rb'
# Offense count: 1
# Cop supports --auto-correct.
Layout/RescueEnsureAlignment:
Exclude:
- 'app/controllers/suppliers_controller.rb'
# Offense count: 9
# Cop supports --auto-correct.
Layout/SpaceAfterColon:
Exclude:
- 'app/controllers/styles_controller.rb'
- 'spec/integration/articles_spec.rb'
- 'spec/integration/balancing_spec.rb'
- 'spec/integration/order_spec.rb'
- 'spec/integration/receive_spec.rb'
- 'spec/integration/supplier_spec.rb'
- 'spec/models/order_article_spec.rb'
- 'spec/models/ordergroup_spec.rb'
# Offense count: 110
# Cop supports --auto-correct.
Layout/SpaceAfterComma:
Enabled: false
# Offense count: 8
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyleInsidePipes.
# SupportedStylesInsidePipes: space, no_space
Layout/SpaceAroundBlockParameters:
Exclude:
- 'app/models/group_order_article.rb'
- 'db/migrate/008_create_orders.rb'
# Offense count: 50
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: space, no_space
Layout/SpaceAroundEqualsInParameterDefault:
Enabled: false
# Offense count: 109
# Cop supports --auto-correct.
# Configuration parameters: AllowForAlignment, EnforcedStyleForExponentOperator.
# SupportedStylesForExponentOperator: space, no_space
Layout/SpaceAroundOperators:
Enabled: false
# Offense count: 73
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces.
# SupportedStyles: space, no_space
# SupportedStylesForEmptyBraces: space, no_space
Layout/SpaceBeforeBlockBraces:
Enabled: false
# Offense count: 2
# Cop supports --auto-correct.
Layout/SpaceBeforeComma:
Exclude:
- 'db/migrate/016_add_shared_lists_connection.rb'
- 'lib/render_pdf.rb'
# Offense count: 1
# Cop supports --auto-correct.
Layout/SpaceBeforeComment:
Exclude:
- 'plugins/wiki/lib/foodsoft_wiki/wiki_parser.rb'
# Offense count: 1
# Cop supports --auto-correct.
# Configuration parameters: AllowForAlignment.
Layout/SpaceBeforeFirstArg:
Exclude:
- 'app/controllers/application_controller.rb'
# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: require_no_space, require_space
Layout/SpaceInLambdaLiteral:
Exclude:
- 'plugins/messages/app/models/message.rb'
# Offense count: 7
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBrackets.
# SupportedStyles: space, no_space, compact
# SupportedStylesForEmptyBrackets: space, no_space
Layout/SpaceInsideArrayLiteralBrackets:
Exclude:
- 'app/helpers/orders_helper.rb'
- 'config/application.rb'
- 'config/environments/production.rb'
- 'db/migrate/20130718183100_create_settings.rb'
# Offense count: 148
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters.
# SupportedStyles: space, no_space
# SupportedStylesForEmptyBraces: space, no_space
Layout/SpaceInsideBlockBraces:
Enabled: false
# Offense count: 374
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces.
# SupportedStyles: space, no_space, compact
# SupportedStylesForEmptyBraces: space, no_space
Layout/SpaceInsideHashLiteralBraces:
Enabled: false
# Offense count: 6
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: space, no_space
Layout/SpaceInsideParens:
Exclude:
- 'app/helpers/group_orders_helper.rb'
- 'db/migrate/006_create_articles.rb'
- 'spec/api/v1/user/group_order_articles_spec.rb'
# Offense count: 14
# Cop supports --auto-correct.
Layout/SpaceInsidePercentLiteralDelimiters:
Exclude:
- 'lib/tasks/foodsoft_setup.rake'
# Offense count: 7
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBrackets.
# SupportedStyles: space, no_space
# SupportedStylesForEmptyBrackets: space, no_space
Layout/SpaceInsideReferenceBrackets:
Exclude:
- 'lib/bank_account_information_importer.rb'
- 'lib/foodsoft_config.rb'
- 'spec/api/v1/user/ordergroup_spec.rb'
# Offense count: 7
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: final_newline, final_blank_line
Layout/TrailingEmptyLines:
Exclude:
- 'app/models/ordergroup.rb'
- 'config/initializers/bullet.rb'
- 'config/initializers/new_rails_defaults.rb'
- 'db/migrate/20130718183101_migrate_user_settings.rb'
- 'lib/apple_bar.rb'
- 'lib/tasks/foodsoft_setup.rake'
- 'spec/support/faker.rb'
# Offense count: 111
# Cop supports --auto-correct.
# Configuration parameters: AllowInHeredoc.
Layout/TrailingWhitespace:
Enabled: false
# Offense count: 8
Lint/AmbiguousBlockAssociation:
Exclude:
@ -529,13 +44,12 @@ Lint/AmbiguousOperator:
- 'app/mailers/mailer.rb'
- 'spec/models/order_article_spec.rb'
# Offense count: 3
# Offense count: 2
# Cop supports --auto-correct.
Lint/AmbiguousRegexpLiteral:
Exclude:
- 'app/models/article_category.rb'
- 'lib/foodsoft/expansion_variables.rb'
- 'lib/foodsoft_config.rb'
# Offense count: 40
# Configuration parameters: AllowSafeAssignment.
@ -626,7 +140,7 @@ Lint/ParenthesesAsGroupedExpression:
- 'spec/lib/token_verifier_spec.rb'
- 'spec/models/order_article_spec.rb'
# Offense count: 2
# Offense count: 1
Lint/ReturnInVoidContext:
Exclude:
- 'lib/foodsoft_config.rb'
@ -721,12 +235,11 @@ Lint/UnusedMethodArgument:
- 'lib/render_pdf.rb'
- 'plugins/wiki/lib/foodsoft_wiki/mailer.rb'
# Offense count: 3
# Offense count: 2
# Cop supports --auto-correct.
# Configuration parameters: ContextCreatingMethods, MethodCreatingMethods.
Lint/UselessAccessModifier:
Exclude:
- 'lib/foodsoft_config.rb'
- 'lib/token_verifier.rb'
- 'plugins/messages/app/models/messagegroup.rb'
@ -746,6 +259,12 @@ Lint/UselessAssignment:
- 'plugins/current_orders/app/documents/multiple_orders_by_groups.rb'
- 'spec/lib/foodsoft_config_spec.rb'
# Offense count: 1
# Configuration parameters: CheckForMethodsWithNoSideEffects.
Lint/Void:
Exclude:
- 'lib/foodsoft_config.rb'
# Offense count: 158
# Configuration parameters: IgnoredMethods, CountRepeatedAttributes.
Metrics/AbcSize:
@ -1082,7 +601,7 @@ RSpec/MultipleMemoizedHelpers:
RSpec/NestedGroups:
Max: 6
# Offense count: 32
# Offense count: 31
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: not_to, to_not
@ -1092,7 +611,6 @@ RSpec/NotToNot:
- 'spec/api/v1/user/group_order_articles_spec.rb'
- 'spec/integration/balancing_spec.rb'
- 'spec/integration/login_spec.rb'
- 'spec/integration/order_spec.rb'
- 'spec/integration/receive_spec.rb'
- 'spec/integration/session_spec.rb'
- 'spec/lib/token_verifier_spec.rb'
@ -1520,14 +1038,13 @@ Security/YAMLLoad:
- 'lib/foodsoft_config.rb'
- 'spec/api/v1/swagger_spec.rb'
# Offense count: 4
# Offense count: 3
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle.
# SupportedStyles: prefer_alias, prefer_alias_method
Style/Alias:
Exclude:
- 'config/initializers/session_store.rb'
- 'lib/foodsoft_config.rb'
- 'plugins/discourse/lib/foodsoft_discourse/redirect_to_login.rb'
- 'plugins/printer/lib/foodsoft_printer/order_printer_jobs.rb'
@ -1685,7 +1202,7 @@ Style/DefWithParentheses:
Exclude:
- 'app/models/user.rb'
# Offense count: 306
# Offense count: 307
Style/Documentation:
Enabled: false
@ -1735,11 +1252,6 @@ Style/EmptyMethod:
- 'db/migrate/20140318173000_delete_empty_group_order_articles.rb'
- 'lib/bank_account_connector.rb'
# Offense count: 40
# Cop supports --auto-correct.
Style/Encoding:
Enabled: false
# Offense count: 21
# Cop supports --auto-correct.
Style/ExpandPathArguments:
@ -1809,7 +1321,7 @@ Style/GlobalStdStream:
- 'lib/tasks/foodsoft.rake'
- 'lib/tasks/foodsoft_setup.rake'
# Offense count: 63
# Offense count: 62
# Configuration parameters: MinBodyLength.
Style/GuardClause:
Enabled: false
@ -1822,7 +1334,7 @@ Style/HashAsLastArrayItem:
Exclude:
- 'app/models/order.rb'
# Offense count: 7
# Offense count: 6
# Cop supports --auto-correct.
# Configuration parameters: AllowSplatArgument.
Style/HashConversion:
@ -1831,7 +1343,6 @@ Style/HashConversion:
- 'app/models/article.rb'
- 'app/models/order.rb'
- 'lib/bank_account_information_importer.rb'
- 'lib/foodsoft_config.rb'
- 'plugins/wiki/app/controllers/pages_controller.rb'
- 'spec/api/v1/user/ordergroup_spec.rb'
@ -2201,7 +1712,7 @@ Style/RedundantRegexpEscape:
- 'plugins/documents/app/controllers/documents_controller.rb'
- 'plugins/wiki/app/models/page.rb'
# Offense count: 18
# Offense count: 15
# Cop supports --auto-correct.
# Configuration parameters: AllowMultipleReturnValues.
Style/RedundantReturn:
@ -2216,7 +1727,6 @@ Style/RedundantReturn:
- 'app/models/periodic_task_group.rb'
- 'app/models/supplier.rb'
- 'lib/bank_transaction_reference.rb'
- 'lib/foodsoft_config.rb'
# Offense count: 85
# Cop supports --auto-correct.
@ -2435,9 +1945,9 @@ Style/ZeroLengthPredicate:
- 'plugins/current_orders/app/documents/multiple_orders_by_articles.rb'
- 'plugins/current_orders/app/documents/multiple_orders_by_groups.rb'
# Offense count: 436
# Offense count: 447
# Cop supports --auto-correct.
# Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
# URISchemes: http, https
Layout/LineLength:
Max: 414
Max: 420

View File

@ -9,7 +9,6 @@ gem 'uglifier', '>= 1.0.3'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
gem 'therubyracer', platforms: :ruby
gem 'jquery-rails'
gem 'select2-rails'
gem 'rails_tokeninput'
@ -67,10 +66,9 @@ gem 'foodsoft_links', path: 'plugins/links'
gem 'foodsoft_polls', path: 'plugins/polls'
# plugins not enabled by default
#gem 'foodsoft_current_orders', path: 'plugins/current_orders'
#gem 'foodsoft_printer', path: 'plugins/printer'
#gem 'foodsoft_uservoice', path: 'plugins/uservoice'
# gem 'foodsoft_current_orders', path: 'plugins/current_orders'
# gem 'foodsoft_printer', path: 'plugins/printer'
# gem 'foodsoft_uservoice', path: 'plugins/uservoice'
group :development do
gem 'sqlite3', '~> 1.3.6'

View File

@ -6,5 +6,4 @@ class Admin::BaseController < ApplicationController
@groups = Group.where(deleted_at: nil).order('created_on DESC').limit(10)
@users = User.order('created_on DESC').limit(10)
end
end

View File

@ -1,5 +1,4 @@
class Admin::ConfigsController < Admin::BaseController
before_action :get_tabs, only: [:show, :list]
def show
@ -11,7 +10,7 @@ class Admin::ConfigsController < Admin::BaseController
@current_tab = 'list'
@cfg = FoodsoftConfig
@dfl = FoodsoftConfig.config
@keys = FoodsoftConfig.keys.select {|k| FoodsoftConfig.allowed_key?(k)}.sort
@keys = FoodsoftConfig.keys.select { |k| FoodsoftConfig.allowed_key?(k) }.sort
end
def update
@ -56,10 +55,9 @@ class Admin::ConfigsController < Admin::BaseController
def convert_config_value(value)
if value.is_a? ActionController::Parameters
value.transform_values{ |v| convert_config_value(v) }.to_hash
value.transform_values { |v| convert_config_value(v) }.to_hash
else
value
end
end
end

View File

@ -15,5 +15,4 @@ class Admin::FinancesController < Admin::BaseController
@financial_transaction_classes = FinancialTransactionClass.includes(:financial_transaction_types).order('name ASC')
render :layout => false
end
end

View File

@ -1,4 +1,3 @@
# encoding: utf-8
class Admin::OrdergroupsController < Admin::BaseController
inherit_resources

View File

@ -1,4 +1,3 @@
# encoding: utf-8
class Admin::WorkgroupsController < Admin::BaseController
inherit_resources

View File

@ -22,5 +22,4 @@ class Api::V1::ArticleCategoriesController < Api::V1::BaseController
def scope
ArticleCategory.all
end
end

View File

@ -51,26 +51,26 @@ class Api::V1::BaseController < ApplicationController
def not_found_handler(e)
# remove where-clauses from error message (not suitable for end-users)
msg = e.message.try {|m| m.sub(/\s*\[.*?\]\s*$/, '')} || 'Not found'
render status: 404, json: {error: 'not_found', error_description: msg}
msg = e.message.try { |m| m.sub(/\s*\[.*?\]\s*$/, '') } || 'Not found'
render status: 404, json: { error: 'not_found', error_description: msg }
end
def not_acceptable_handler(e)
msg = e.message || 'Data not acceptable'
render status: 422, json: {error: 'not_acceptable', error_description: msg}
render status: 422, json: { error: 'not_acceptable', error_description: msg }
end
def doorkeeper_unauthorized_render_options(error:)
{json: {error: error.name, error_description: error.description}}
{ json: { error: error.name, error_description: error.description } }
end
def doorkeeper_forbidden_render_options(error:)
{json: {error: error.name, error_description: error.description}}
{ json: { error: error.name, error_description: error.description } }
end
def permission_required_handler(e)
msg = e.message || 'Forbidden, user has no access'
render status: 403, json: {error: 'forbidden', error_description: msg}
render status: 403, json: { error: 'forbidden', error_description: msg }
end
# @todo something with ApplicationHelper#show_user

View File

@ -1,9 +1,7 @@
class Api::V1::ConfigsController < Api::V1::BaseController
before_action ->{ doorkeeper_authorize! 'config:user', 'config:read', 'config:write' }
before_action -> { doorkeeper_authorize! 'config:user', 'config:read', 'config:write' }
def show
render json: FoodsoftConfig, serializer: ConfigSerializer, root: 'config'
end
end

View File

@ -22,5 +22,4 @@ class Api::V1::FinancialTransactionClassesController < Api::V1::BaseController
def scope
FinancialTransactionClass.all
end
end

View File

@ -22,5 +22,4 @@ class Api::V1::FinancialTransactionTypesController < Api::V1::BaseController
def scope
FinancialTransactionType.includes(:bank_account, :financial_transaction_class)
end
end

View File

@ -1,7 +1,7 @@
class Api::V1::FinancialTransactionsController < Api::V1::BaseController
include Concerns::CollectionScope
before_action ->{ doorkeeper_authorize! 'finance:read', 'finance:write' }
before_action -> { doorkeeper_authorize! 'finance:read', 'finance:write' }
def index
render_collection search_scope
@ -20,5 +20,4 @@ class Api::V1::FinancialTransactionsController < Api::V1::BaseController
def ransack_auth_object
:finance
end
end

View File

@ -1,5 +1,4 @@
class Api::V1::NavigationsController < Api::V1::BaseController
def show
# we don't use active_model_serializers here, because source is a Hash
render json: { navigation: transform(navigation) }
@ -20,5 +19,4 @@ class Api::V1::NavigationsController < Api::V1::BaseController
r
end
end
end

View File

@ -1,7 +1,7 @@
class Api::V1::OrderArticlesController < Api::V1::BaseController
include Concerns::CollectionScope
before_action ->{ doorkeeper_authorize! 'orders:read', 'orders:write' }
before_action -> { doorkeeper_authorize! 'orders:read', 'orders:write' }
def index
render_collection search_scope

View File

@ -1,7 +1,7 @@
class Api::V1::OrdersController < Api::V1::BaseController
include Concerns::CollectionScope
before_action ->{ doorkeeper_authorize! 'orders:read', 'orders:write' }
before_action -> { doorkeeper_authorize! 'orders:read', 'orders:write' }
def index
render_collection search_scope

View File

@ -1,7 +1,7 @@
class Api::V1::User::FinancialTransactionsController < Api::V1::BaseController
include Concerns::CollectionScope
before_action ->{ doorkeeper_authorize! 'finance:user' }
before_action -> { doorkeeper_authorize! 'finance:user' }
before_action :require_ordergroup
before_action :require_minimum_balance, only: [:create]
before_action -> { require_config_enabled :use_self_service }, only: [:create]
@ -29,5 +29,4 @@ class Api::V1::User::FinancialTransactionsController < Api::V1::BaseController
def create_params
params.require(:financial_transaction).permit(:amount, :financial_transaction_type_id, :note)
end
end

View File

@ -1,7 +1,7 @@
class Api::V1::User::GroupOrderArticlesController < Api::V1::BaseController
include Concerns::CollectionScope
before_action ->{ doorkeeper_authorize! 'group_orders:user' }
before_action -> { doorkeeper_authorize! 'group_orders:user' }
before_action :require_ordergroup
before_action :require_minimum_balance, only: [:create, :update] # destroy is ok
@ -62,10 +62,10 @@ class Api::V1::User::GroupOrderArticlesController < Api::V1::BaseController
end
def scope
GroupOrderArticle.
joins(:group_order).
includes(order_article: :article, group_order: :order).
where(group_orders: { ordergroup_id: current_ordergroup.id })
GroupOrderArticle
.joins(:group_order)
.includes(order_article: :article, group_order: :order)
.where(group_orders: { ordergroup_id: current_ordergroup.id })
end
def scope_for_update

View File

@ -1,6 +1,5 @@
class Api::V1::User::OrdergroupController < Api::V1::BaseController
before_action ->{ doorkeeper_authorize! 'finance:user' }, only: [:financial_overview]
before_action -> { doorkeeper_authorize! 'finance:user' }, only: [:financial_overview]
def financial_overview
ordergroup = Ordergroup.include_transaction_class_sum.find(current_ordergroup.id)
@ -19,5 +18,4 @@ class Api::V1::User::OrdergroupController < Api::V1::BaseController
}
}
end
end

View File

@ -1,9 +1,7 @@
class Api::V1::User::UsersController < Api::V1::BaseController
before_action ->{ doorkeeper_authorize! 'user:read', 'user:write' }
before_action -> { doorkeeper_authorize! 'user:read', 'user:write' }
def show
render json: current_user
end
end

View File

@ -1,4 +1,3 @@
# encoding: utf-8
class ApplicationController < ActionController::Base
include Concerns::FoodcoopScope
include Concerns::Auth
@ -8,11 +7,10 @@ class ApplicationController < ActionController::Base
helper_method :available_locales
protect_from_forgery
before_action :authenticate, :set_user_last_activity, :store_controller, :items_per_page
before_action :authenticate, :set_user_last_activity, :store_controller, :items_per_page
after_action :remove_controller
around_action :set_time_zone, :set_currency
# Returns the controller handling the current request.
def self.current
Thread.current[:application_controller]
@ -90,10 +88,9 @@ class ApplicationController < ActionController::Base
old_currency = ::I18n.t('number.currency.format.unit')
new_currency = FoodsoftConfig[:currency_unit] || ''
new_currency += "\u202f" if FoodsoftConfig[:currency_space]
::I18n.backend.store_translations(::I18n.locale, number: {currency: {format: {unit: new_currency}}})
::I18n.backend.store_translations(::I18n.locale, number: { currency: { format: { unit: new_currency } } })
yield
ensure
::I18n.backend.store_translations(::I18n.locale, number: {currency: {format: {unit: old_currency}}})
::I18n.backend.store_translations(::I18n.locale, number: { currency: { format: { unit: old_currency } } })
end
end

View File

@ -1,5 +1,4 @@
class ArticleCategoriesController < ApplicationController
inherit_resources # Build default REST Actions via plugin
before_action :authenticate_article_meta
@ -23,5 +22,4 @@ class ArticleCategoriesController < ApplicationController
def collection
@article_categories = ArticleCategory.order('name')
end
end

View File

@ -1,21 +1,20 @@
# encoding: utf-8
class ArticlesController < ApplicationController
before_action :authenticate_article_meta, :find_supplier
def index
if params['sort']
sort = case params['sort']
when "name" then "articles.name"
when "unit" then "articles.unit"
when "article_category" then "article_categories.name"
when "note" then "articles.note"
when "availability" then "articles.availability"
when "name_reverse" then "articles.name DESC"
when "unit_reverse" then "articles.unit DESC"
when "article_category_reverse" then "article_categories.name DESC"
when "note_reverse" then "articles.note DESC"
when "availability_reverse" then "articles.availability DESC"
end
when "name" then "articles.name"
when "unit" then "articles.unit"
when "article_category" then "article_categories.name"
when "note" then "articles.note"
when "availability" then "articles.availability"
when "name_reverse" then "articles.name DESC"
when "unit_reverse" then "articles.unit DESC"
when "article_category_reverse" then "article_categories.name DESC"
when "note_reverse" then "articles.note DESC"
when "availability_reverse" then "articles.availability DESC"
end
else
sort = "article_categories.name, articles.name"
end
@ -99,7 +98,7 @@ class ArticlesController < ApplicationController
end
end
raise ActiveRecord::Rollback if invalid_articles # Rollback all changes
raise ActiveRecord::Rollback if invalid_articles # Rollback all changes
end
end
end
@ -117,25 +116,25 @@ class ArticlesController < ApplicationController
# makes different actions on selected articles
def update_selected
raise I18n.t('articles.controller.error_nosel') if params[:selected_articles].nil?
articles = Article.find(params[:selected_articles])
Article.transaction do
case params[:selected_action]
when 'destroy'
articles.each(&:mark_as_deleted)
flash[:notice] = I18n.t('articles.controller.update_sel.notice_destroy')
when 'setNotAvailable'
articles.each {|a| a.update_attribute(:availability, false) }
flash[:notice] = I18n.t('articles.controller.update_sel.notice_unavail')
when 'setAvailable'
articles.each {|a| a.update_attribute(:availability, true) }
flash[:notice] = I18n.t('articles.controller.update_sel.notice_avail')
else
flash[:alert] = I18n.t('articles.controller.update_sel.notice_noaction')
when 'destroy'
articles.each(&:mark_as_deleted)
flash[:notice] = I18n.t('articles.controller.update_sel.notice_destroy')
when 'setNotAvailable'
articles.each { |a| a.update_attribute(:availability, false) }
flash[:notice] = I18n.t('articles.controller.update_sel.notice_unavail')
when 'setAvailable'
articles.each { |a| a.update_attribute(:availability, true) }
flash[:notice] = I18n.t('articles.controller.update_sel.notice_avail')
else
flash[:alert] = I18n.t('articles.controller.update_sel.notice_noaction')
end
end
# action succeded
redirect_to supplier_articles_url(@supplier, :per_page => params[:per_page])
rescue => error
redirect_to supplier_articles_url(@supplier, :per_page => params[:per_page]),
:alert => I18n.t('errors.general_msg', :msg => error)
@ -149,7 +148,7 @@ class ArticlesController < ApplicationController
# Update articles from a spreadsheet
def parse_upload
uploaded_file = params[:articles]['file'] or raise I18n.t('articles.controller.parse_upload.no_file')
options = {filename: uploaded_file.original_filename}
options = { filename: uploaded_file.original_filename }
options[:outlist_absent] = (params[:articles]['outlist_absent'] == '1')
options[:convert_units] = (params[:articles]['convert_units'] == '1')
@updated_article_pairs, @outlisted_articles, @new_articles = @supplier.sync_from_file uploaded_file.tempfile, options
@ -177,10 +176,10 @@ class ArticlesController < ApplicationController
# Updates, deletes articles when upload or sync form is submitted
def update_synchronized
@outlisted_articles = Article.find(params[:outlisted_articles].try(:keys)||[])
@updated_articles = Article.find(params[:articles].try(:keys)||[])
@updated_articles.map{|a| a.assign_attributes(params[:articles][a.id.to_s]) }
@new_articles = (params[:new_articles]||[]).map{|a| @supplier.articles.build(a) }
@outlisted_articles = Article.find(params[:outlisted_articles].try(:keys) || [])
@updated_articles = Article.find(params[:articles].try(:keys) || [])
@updated_articles.map { |a| a.assign_attributes(params[:articles][a.id.to_s]) }
@new_articles = (params[:new_articles] || []).map { |a| @supplier.articles.build(a) }
has_error = false
Article.transaction do
@ -192,9 +191,9 @@ class ArticlesController < ApplicationController
has_error = true
end
# Update articles
@updated_articles.each {|a| a.save or has_error=true }
@updated_articles.each { |a| a.save or has_error = true }
# Add new articles
@new_articles.each {|a| a.save or has_error=true }
@new_articles.each { |a| a.save or has_error = true }
raise ActiveRecord::Rollback if has_error
end

View File

@ -24,7 +24,7 @@ module Concerns::Auth
def login(user)
session[:user_id] = user.id
session[:scope] = FoodsoftConfig.scope # Save scope in session to not allow switching between foodcoops with one account
session[:scope] = FoodsoftConfig.scope # Save scope in session to not allow switching between foodcoops with one account
session[:locale] = user.locale
end
@ -56,18 +56,18 @@ module Concerns::Auth
# We have an authenticated user, now check role...
# Roles gets the user through his memberships.
hasRole = case role
when 'admin' then current_user.role_admin?
when 'finance' then current_user.role_finance?
when 'article_meta' then current_user.role_article_meta?
when 'pickups' then current_user.role_pickups?
when 'suppliers' then current_user.role_suppliers?
when 'orders' then current_user.role_orders?
when 'finance_or_invoices' then (current_user.role_finance? || current_user.role_invoices?)
when 'finance_or_orders' then (current_user.role_finance? || current_user.role_orders?)
when 'pickups_or_orders' then (current_user.role_pickups? || current_user.role_orders?)
when 'any' then true # no role required
else false # any unknown role will always fail
end
when 'admin' then current_user.role_admin?
when 'finance' then current_user.role_finance?
when 'article_meta' then current_user.role_article_meta?
when 'pickups' then current_user.role_pickups?
when 'suppliers' then current_user.role_suppliers?
when 'orders' then current_user.role_orders?
when 'finance_or_invoices' then (current_user.role_finance? || current_user.role_invoices?)
when 'finance_or_orders' then (current_user.role_finance? || current_user.role_orders?)
when 'pickups_or_orders' then (current_user.role_pickups? || current_user.role_orders?)
when 'any' then true # no role required
else false # any unknown role will always fail
end
if hasRole
current_user
else
@ -137,6 +137,7 @@ module Concerns::Auth
# @see https://github.com/doorkeeper-gem/doorkeeper/issues/71#issuecomment-5471317
def expire_access_tokens
return unless @current_user
Doorkeeper::AccessToken.transaction do
token_scope = Doorkeeper::AccessToken.where(revoked_at: nil, resource_owner_id: @current_user.id)
token_scope.each do |token|
@ -146,8 +147,7 @@ module Concerns::Auth
end
# Redirect to the login page, used in authenticate, plugins can override this.
def redirect_to_login(options={})
def redirect_to_login(options = {})
redirect_to login_url, options
end
end

View File

@ -36,7 +36,7 @@ module Concerns::AuthApi
# Make sure that at least one the given OAuth scopes is valid for the current user's permissions.
# @raise Api::Errors::PermissionsRequired
def doorkeeper_authorize_roles!(*scopes)
unless scopes.any? {|scope| doorkeeper_scope_permitted?(scope) }
unless scopes.any? { |scope| doorkeeper_scope_permitted?(scope) }
raise Api::Errors::PermissionRequired.new('Forbidden, no permission')
end
end
@ -60,7 +60,7 @@ module Concerns::AuthApi
when 'suppliers' then return current_user.role_suppliers?
when 'group_orders' then return current_user.role_orders?
when 'finance' then return current_user.role_finance?
# please note that offline_access does not belong here, since it is not used for permission checking
# please note that offline_access does not belong here, since it is not used for permission checking
end
case scope

View File

@ -54,5 +54,4 @@ module Concerns::CollectionScope
def ransack_auth_object
nil
end
end

View File

@ -30,7 +30,6 @@ module Concerns::FoodcoopScope
# Always stay in foodcoop url scope
def default_url_options(options = {})
super().merge({foodcoop: FoodsoftConfig.scope})
super().merge({ foodcoop: FoodsoftConfig.scope })
end
end

View File

@ -47,5 +47,4 @@ module Concerns::Locale
locale = session[:locale] = ::I18n.locale
logger.info("Set locale to #{locale}")
end
end

View File

@ -9,9 +9,8 @@ module Concerns::SendOrderPdf
when 'articles' then OrderByArticles
when 'fax' then OrderFax
when 'matrix' then OrderMatrix
end
end
pdf = klass.new order
send_data pdf.to_pdf, filename: pdf.filename, type: 'application/pdf'
end
end

View File

@ -1,6 +1,4 @@
# encoding: utf-8
class DeliveriesController < ApplicationController
before_action :find_supplier, :exclude => :fill_new_stock_article_form
def index
@ -14,7 +12,7 @@ class DeliveriesController < ApplicationController
def new
@delivery = @supplier.deliveries.build
@delivery.date = Date.today #TODO: move to model/database
@delivery.date = Date.today # TODO: move to model/database
end
def create
@ -37,7 +35,7 @@ class DeliveriesController < ApplicationController
if @delivery.update_attributes(params[:delivery])
flash[:notice] = I18n.t('deliveries.update.notice')
redirect_to [@supplier,@delivery]
redirect_to [@supplier, @delivery]
else
render :action => "edit"
end
@ -68,5 +66,4 @@ class DeliveriesController < ApplicationController
render :layout => false
end
end

View File

@ -1,5 +1,4 @@
class FeedbackController < ApplicationController
def new
end
@ -11,5 +10,4 @@ class FeedbackController < ApplicationController
render :action => 'new'
end
end
end

View File

@ -1,6 +1,4 @@
# encoding: utf-8
class Finance::BalancingController < Finance::BaseController
def index
@orders = Order.finished.page(params[:page]).per(@per_page).order('ends DESC')
end
@ -11,20 +9,20 @@ class Finance::BalancingController < Finance::BaseController
@comments = @order.comments
@articles = @order.order_articles.ordered_or_member.includes(:article, :article_price,
group_order_articles: {group_order: :ordergroup})
group_order_articles: { group_order: :ordergroup })
sort_param = params['sort'] || 'name'
@articles = case sort_param
when 'name' then
@articles.order('articles.name ASC')
when 'name_reverse' then
@articles.order('articles.name DESC')
when 'order_number' then
@articles.order('articles.order_number ASC')
when 'order_number_reverse' then
@articles.order('articles.order_number DESC')
else
@articles
when 'name' then
@articles.order('articles.name ASC')
when 'name_reverse' then
@articles.order('articles.name DESC')
when 'order_number' then
@articles.order('articles.order_number ASC')
when 'order_number_reverse' then
@articles.order('articles.order_number DESC')
else
@articles
end
render layout: false if request.xhr?
@ -84,7 +82,6 @@ class Finance::BalancingController < Finance::BaseController
@type = FinancialTransactionType.find_by_id(params.permit(:type)[:type])
@order.close!(@current_user, @type)
redirect_to finance_order_index_url, notice: t('finance.balancing.close.notice')
rescue => error
redirect_to new_finance_order_url(order_id: @order.id), alert: t('finance.balancing.close.alert', message: error.message)
end
@ -110,5 +107,4 @@ class Finance::BalancingController < Finance::BaseController
rescue => error
redirect_to finance_order_index_url, alert: t('errors.general_msg', msg: error.message)
end
end

View File

@ -1,5 +1,4 @@
class Finance::BankAccountsController < Finance::BaseController
def index
@bank_accounts = BankAccount.order('name')
redirect_to finance_bank_account_transactions_url(@bank_accounts.first) if @bank_accounts.count == 1