Skip to content

Commit

Permalink
Merge pull request #14488 from opf/chore/run-rubocop-autocorrect
Browse files Browse the repository at this point in the history
Run `rubocop --autocorrect` on all files
  • Loading branch information
cbliard authored Jan 5, 2024
2 parents 1504ab5 + 5055854 commit 5801120
Show file tree
Hide file tree
Showing 1,077 changed files with 3,944 additions and 4,115 deletions.
2 changes: 1 addition & 1 deletion app/components/members/user_filter_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def extra_user_status_options
def status_members_query(status)
params = {
project_id: project.id,
status:,
status:
}

self.class.filter(params)
Expand Down
1 change: 0 additions & 1 deletion app/components/oauth/applications/row_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
module OAuth
module Applications
class RowComponent < ::RowComponent

property :confidential

def application
Expand Down
4 changes: 1 addition & 3 deletions app/components/users/auto_login_tokens/row_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@ def token
model
end

def token_data
token.data
end
delegate :data, to: :token, prefix: true

def current?
token == current_token
Expand Down
2 changes: 1 addition & 1 deletion app/contracts/model_contract.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
# See COPYRIGHT and LICENSE files for more details.
#++

require_relative './base_contract'
require_relative 'base_contract'

##
# Model contract for AR records that
Expand Down
8 changes: 3 additions & 5 deletions app/controllers/account_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -203,12 +203,10 @@ def activate_self_registered(token)
else
flash[:error] = I18n.t(:notice_activation_failed)
end
elsif user.active?
flash[:notice] = I18n.t(:notice_account_already_activated)
else
if user.active?
flash[:notice] = I18n.t(:notice_account_already_activated)
else
flash[:error] = I18n.t(:notice_activation_failed)
end
flash[:error] = I18n.t(:notice_activation_failed)

end

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/admin_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def show_local_breadcrumb
private

def hidden_admin_menu_items
(OpenProject::Configuration.hidden_menu_items[:admin_menu.to_s] || [])
OpenProject::Configuration.hidden_menu_items[:admin_menu.to_s] || []
end

def plaintext_extraction_checks
Expand Down
6 changes: 3 additions & 3 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ def authorize_in_any_project(ctrl = params[:controller], action = params[:action
end

def authorize_in_model(ctrl = params[:controller], action = params[:action])
model = instance_variable_get("@#{model_object.to_s.underscore}")
model = instance_variable_get(:"@#{model_object.to_s.underscore}")

allowed = User.current.allowed_in_entity?({ controller: ctrl, action: }, model, model_object)

Expand Down Expand Up @@ -377,7 +377,7 @@ def find_model_object(object_id = :id)
model = self.class._model_object
if model
@object = model.find(params[object_id])
instance_variable_set("@#{controller_name.singularize}", @object) if @object
instance_variable_set(:"@#{controller_name.singularize}", @object) if @object
end
rescue ActiveRecord::RecordNotFound
render_404
Expand All @@ -388,7 +388,7 @@ def find_model_object_and_project(object_id = :id)
model_object = self.class._model_object
instance = model_object.find(params[object_id])
@project = instance.project
instance_variable_set("@#{model_object.to_s.underscore}", instance)
instance_variable_set(:"@#{model_object.to_s.underscore}", instance)
else
@project = Project.find(params[:project_id])
end
Expand Down
1 change: 1 addition & 0 deletions app/controllers/concerns/accounts/current_user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ def current_rss_key_user

def current_api_key_user
return unless Setting.rest_api_enabled? && api_request?

key = api_key_from_request

if key && accept_key_auth_actions.include?(params[:action])
Expand Down
6 changes: 2 additions & 4 deletions app/controllers/concerns/member_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,8 @@ def enterprise_allow_new_users?
!OpenProject::Enterprise.user_limit_reached? || !OpenProject::Enterprise.fail_fast?
end

def each_comma_separated(array, &block)
array.map do |e|
block.call(e)
end.flatten
def each_comma_separated(array, &)
array.map(&).flatten
end

def transform_array_of_comma_separated_ids(array)
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/concerns/op_turbo/component_stream.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def respond_to_with_turbo_streams(&format_block)
render turbo_stream: turbo_streams, status:
end

format_block.call(format) if block_given?
yield(format) if format_block
end
end
alias_method :respond_with_turbo_streams, :respond_to_with_turbo_streams
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/errors_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def not_found
end

def unacceptable
render file: "#{Rails.root}/public/422.html",
render file: "#{Rails.public_path.join('422.html')}",
status: :unacceptable,
layout: false
end
Expand Down
2 changes: 0 additions & 2 deletions app/controllers/members/menus_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ def nested_menu_items
]
end

private

def project_roles_entries
ProjectRole
.where(id: MemberRole.where(member_id: @project.members.select(:id)).select(:role_id))
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/messages_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def update
if call.success?
flash[:notice] = t(:notice_successful_update)
@message.reload
redirect_to topic_path(@message.root, r: (@message.parent_id && @message.id))
redirect_to topic_path(@message.root, r: @message.parent_id && @message.id)
else
render action: 'edit'
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/search_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def search_types
# don't search projects
types.delete('projects')
# only show what the user is allowed to view
types = types.select { |o| User.current.allowed_in_project?("view_#{o}".to_sym, projects_to_search) }
types = types.select { |o| User.current.allowed_in_project?(:"view_#{o}", projects_to_search) }
end

types
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/wiki_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ def current_menu_item_sym(page)
default_item = default_menu_item(page)
return unless default_item

"no-menu-item-#{default_item.menu_identifier}".to_sym
:"no-menu-item-#{default_item.menu_identifier}"
end

private
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/wiki_menu_items_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def self.default_menu_item(controller, page)
menu_item = controller.default_menu_item(page)
return unless menu_item

"no-menu-item-#{menu_item.menu_identifier}".to_sym
:"no-menu-item-#{menu_item.menu_identifier}"
end

before_action :find_project_by_project_id
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/admin_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def project_status_options_for_select(selected)

def linked_sha_reference(sha, url)
if sha && url
link_to sha, url, target: '_blank'
link_to sha, url, target: '_blank', rel: 'noopener'
else
sha
end
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/error_message_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ module ErrorMessageHelper
include ActionView::Helpers::OutputSafetyHelper

def error_messages_for(object)
object = instance_variable_get("@#{object}") unless object.respond_to?(:to_model)
object = instance_variable_get(:"@#{object}") unless object.respond_to?(:to_model)
object = convert_to_model(object)
return unless object

Expand Down
2 changes: 1 addition & 1 deletion app/helpers/individual_principal_hooks_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
module IndividualPrincipalHooksHelper
def call_individual_principals_memberships_hook(individual_principal, suffix, context = {})
call_context = { individual_principal_key(individual_principal) => individual_principal }.merge(context)
call_hook("view_#{individual_principal.class.name.underscore.pluralize}_memberships_table_#{suffix}".to_sym, call_context)
call_hook(:"view_#{individual_principal.class.name.underscore.pluralize}_memberships_table_#{suffix}", call_context)
end

def individual_principal_key(individual_principal)
Expand Down
8 changes: 4 additions & 4 deletions app/helpers/mail_layout_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ def action_button(&block)

def placeholder_cell(number, vertical:)
style = if vertical
"max-width:#{number}; min-width:#{number}; width:#{number}"
else
"line-height:#{number}; max-width:0; min-width:0; height:#{number}; width:0; font-size:#{number}"
end
"max-width:#{number}; min-width:#{number}; width:#{number}"
else
"line-height:#{number}; max-width:0; min-width:0; height:#{number}; width:0; font-size:#{number}"
end

content_tag('td', '&nbsp;'.html_safe, style:)
end
Expand Down
4 changes: 2 additions & 2 deletions app/helpers/reports_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ def aggregate(data, criteria)
end || 0
end

def aggregate_link(data, criteria, *args)
def aggregate_link(data, criteria, *)
a = aggregate data, criteria
a.positive? ? link_to(h(a), *args) : '-'
a.positive? ? link_to(h(a), *) : '-'
end
end
2 changes: 1 addition & 1 deletion app/helpers/repositories_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ def scm_vendor_tag(repository)
action: 'repository-settings#updateSelectedType',
'repository-settings-target': 'scmVendor'
},
disabled: (repository && !repository.new_record?))
disabled: repository && !repository.new_record?)
end

def git_path_encoding_options(repository)
Expand Down
10 changes: 5 additions & 5 deletions app/helpers/settings_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def setting_check_box(setting, options = {})
hidden +
styled_check_box_tag("settings[#{setting}]",
1,
Setting.send("#{setting}?"),
Setting.send(:"#{setting}?"),
disabled_setting_option(setting).merge(options))
end
end
Expand Down Expand Up @@ -199,11 +199,11 @@ def setting_block(setting, options = {}, &)

private

def wrap_field_outer(options, &block)
def wrap_field_outer(options, &)
if options[:label] == false
block.call
yield
else
content_tag(:span, class: 'form--field-container', &block)
content_tag(:span, class: 'form--field-container', &)
end
end

Expand All @@ -216,7 +216,7 @@ def build_settings_matrix_head(settings, options = {})
hidden_field_tag("settings[#{setting}][]", '') +
I18n.t("setting_#{setting}")
end
end.join.html_safe # rubocop:disable Rails/OutputSafety
end.join.html_safe
end
end

Expand Down
5 changes: 2 additions & 3 deletions app/helpers/sort_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ def to_a
.map { |c, o| [@available_criteria[c], o] }
.reject { |c, _| c.nil? }
.filter_map { |c, o| append_direction(Array(c), o) }

end

def to_query_hash
Expand All @@ -142,9 +141,9 @@ def add!(key, asc)
normalize!
end

def add(*args)
def add(*)
r = self.class.new.from_param(to_param)
r.add!(*args)
r.add!(*)
r
end

Expand Down
23 changes: 12 additions & 11 deletions app/mailers/sharing_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,18 @@ def derive_role_rights(role)
end

def derive_allowed_work_package_actions(role)
allowed_actions = case role.builtin
when Role::BUILTIN_WORK_PACKAGE_EDITOR
[I18n.t('work_package.sharing.permissions.view'),
I18n.t('work_package.sharing.permissions.comment'),
I18n.t('work_package.sharing.permissions.edit')]
when Role::BUILTIN_WORK_PACKAGE_COMMENTER
[I18n.t('work_package.sharing.permissions.view'),
I18n.t('work_package.sharing.permissions.comment')]
when Role::BUILTIN_WORK_PACKAGE_VIEWER
[I18n.t('work_package.sharing.permissions.view')]
end
allowed_actions =
case role.builtin
when Role::BUILTIN_WORK_PACKAGE_EDITOR
[I18n.t('work_package.sharing.permissions.view'),
I18n.t('work_package.sharing.permissions.comment'),
I18n.t('work_package.sharing.permissions.edit')]
when Role::BUILTIN_WORK_PACKAGE_COMMENTER
[I18n.t('work_package.sharing.permissions.view'),
I18n.t('work_package.sharing.permissions.comment')]
when Role::BUILTIN_WORK_PACKAGE_VIEWER
[I18n.t('work_package.sharing.permissions.view')]
end

allowed_actions.map(&:downcase)
end
Expand Down
2 changes: 1 addition & 1 deletion app/models/activities/base_activity_provider.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def self.activity_provider_for(options = {})
self.activity_provider_options = {
type: name.underscore.pluralize,
activities: [:activity],
permission: "view_#{name.underscore.pluralize}".to_sym
permission: :"view_#{name.underscore.pluralize}"
}.merge(options)
end

Expand Down
2 changes: 1 addition & 1 deletion app/models/changeset.rb
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def scan_comment_for_work_package_ids
refs = match[3]
next unless action.present? || ref_keywords_any

refs.scan(/#(\d+)(\s+@#{TIMELOG_RE})?/).each do |m|
refs.scan(/#(\d+)(\s+@#{TIMELOG_RE})?/o).each do |m|
work_package = find_referenced_work_package_by_id(m[0].to_i)
hours = m[2]
if work_package
Expand Down
2 changes: 1 addition & 1 deletion app/models/concerns/virtual_attribute.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def _define_virtual_attributes_hook(attribute)
end

def _define_virtual_attribute_setter(attribute)
define_method "#{attribute}=" do |value|
define_method :"#{attribute}=" do |value|
set_virtual_attribute(attribute, value) if send(attribute) != value
instance_variable_set(:"@#{attribute}_set", true)
instance_variable_set(:"@#{attribute}", value)
Expand Down
6 changes: 3 additions & 3 deletions app/models/custom_actions/conditions/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,17 +110,17 @@ def self.habtm_table
private_class_method :habtm_table

def self.key_id
@key_id ||= "#{key}_id".to_sym
@key_id ||= :"#{key}_id"
end
private_class_method :key_id

def self.association_key
"#{key}_conditions".to_sym
:"#{key}_conditions"
end
private_class_method :association_key

def self.association_ids
"#{key}_condition_ids".to_sym
:"#{key}_condition_ids"
end
private_class_method :association_ids
end
4 changes: 2 additions & 2 deletions app/models/custom_style.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ def digest
end

%i(favicon touch_icon export_logo export_cover logo).each do |name|
define_method "#{name}_path" do
define_method :"#{name}_path" do
image = send(name)

if image.readable?
image.local_file.path
end
end

define_method "remove_#{name}" do
define_method :"remove_#{name}" do
image = send(name)
image&.remove!

Expand Down
4 changes: 2 additions & 2 deletions app/models/exports/exporter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ def formatter_for(attribute, export_format)
::Exports::Register.formatter_for(model, attribute, export_format)
end

def format_attribute(object, attribute, export_format, **options)
def format_attribute(object, attribute, export_format, **)
formatter = formatter_for(attribute, export_format)
formatter.format(object, **options)
formatter.format(object, **)
end
end
end
Loading

0 comments on commit 5801120

Please sign in to comment.