Run rubocop --autocorrect on all files

Only the safe cops have run. rubocop version is 1.59.0.
This commit is contained in:
Christophe Bliard
2024-01-04 17:01:17 +01:00
parent 1504ab5e17
commit 8fa8584538
1076 changed files with 3915 additions and 4092 deletions
@@ -64,7 +64,7 @@ module Members
def status_members_query(status)
params = {
project_id: project.id,
status:,
status:
}
self.class.filter(params)
@@ -31,7 +31,6 @@
module OAuth
module Applications
class RowComponent < ::RowComponent
property :confidential
def application
@@ -37,9 +37,7 @@ module Users
model
end
def token_data
token.data
end
delegate :data, to: :token, prefix: true
def current?
token == current_token
+1 -1
View File
@@ -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
+3 -5
View File
@@ -203,12 +203,10 @@ class AccountController < ApplicationController
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
+1 -1
View File
@@ -105,7 +105,7 @@ class AdminController < ApplicationController
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
+3 -3
View File
@@ -263,7 +263,7 @@ class ApplicationController < ActionController::Base
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)
@@ -377,7 +377,7 @@ class ApplicationController < ActionController::Base
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
@@ -388,7 +388,7 @@ class ApplicationController < ActionController::Base
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
@@ -113,6 +113,7 @@ module Accounts::CurrentUser
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])
+2 -4
View File
@@ -79,10 +79,8 @@ module MemberHelper
!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)
@@ -36,7 +36,7 @@ module OpTurbo
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
+1 -1
View File
@@ -8,7 +8,7 @@ class ErrorsController < ActionController::Base
end
def unacceptable
render file: "#{Rails.root}/public/422.html",
render file: "#{Rails.public_path.join('422.html')}",
status: :unacceptable,
layout: false
end
@@ -65,8 +65,6 @@ module Members
]
end
private
def project_roles_entries
ProjectRole
.where(id: MemberRole.where(member_id: @project.members.select(:id)).select(:role_id))
+1 -1
View File
@@ -114,7 +114,7 @@ class MessagesController < ApplicationController
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
+1 -1
View File
@@ -151,7 +151,7 @@ class SearchController < ApplicationController
# 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
+1 -1
View File
@@ -336,7 +336,7 @@ class WikiController < ApplicationController
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
@@ -52,7 +52,7 @@ class WikiMenuItemsController < ApplicationController
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
+1 -1
View File
@@ -34,7 +34,7 @@ module AdminHelper
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
+1 -1
View File
@@ -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
@@ -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)
+4 -4
View File
@@ -61,10 +61,10 @@ module MailLayoutHelper
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
+2 -2
View File
@@ -41,8 +41,8 @@ module ReportsHelper
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
+1 -1
View File
@@ -252,7 +252,7 @@ module RepositoriesHelper
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)
+5 -5
View File
@@ -169,7 +169,7 @@ module SettingsHelper
hidden +
styled_check_box_tag("settings[#{setting}]",
1,
Setting.send("#{setting}?"),
Setting.send(:"#{setting}?"),
disabled_setting_option(setting).merge(options))
end
end
@@ -199,11 +199,11 @@ module SettingsHelper
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
@@ -216,7 +216,7 @@ module SettingsHelper
hidden_field_tag("settings[#{setting}][]", '') +
I18n.t("setting_#{setting}")
end
end.join.html_safe # rubocop:disable Rails/OutputSafety
end.join.html_safe
end
end
+2 -3
View File
@@ -124,7 +124,6 @@ module SortHelper
.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
@@ -142,9 +141,9 @@ module SortHelper
normalize!
end
def add(*args)
def add(*)
r = self.class.new.from_param(to_param)
r.add!(*args)
r.add!(*)
r
end
+12 -11
View File
@@ -50,17 +50,18 @@ class SharingMailer < ApplicationMailer
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
@@ -68,7 +68,7 @@ class Activities::BaseActivityProvider
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
+1 -1
View File
@@ -146,7 +146,7 @@ class Changeset < ApplicationRecord
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
+1 -1
View File
@@ -56,7 +56,7 @@ module VirtualAttribute
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)
+3 -3
View File
@@ -110,17 +110,17 @@ class CustomActions::Conditions::Base
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
+2 -2
View File
@@ -23,7 +23,7 @@ class CustomStyle < ApplicationRecord
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?
@@ -31,7 +31,7 @@ class CustomStyle < ApplicationRecord
end
end
define_method "remove_#{name}" do
define_method :"remove_#{name}" do
image = send(name)
image&.remove!
+2 -2
View File
@@ -67,9 +67,9 @@ module Exports
::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
@@ -235,6 +235,7 @@ class Journable::WithHistoricAttributes < SimpleDelegator
historic_journable = at_timestamp(Timestamp.parse(timestamp))
return unless historic_journable
changes = ::Acts::Journalized::JournableDiffer.changes(__getobj__, historic_journable)
# In the other occurrences of JournableDiffer.association_changes calls, we are using the plural
+2 -2
View File
@@ -297,8 +297,8 @@ class MailHandler < ActionMailer::Base
# Adds To and Cc as watchers of the given object if the sender has the
# appropriate permission
def add_watchers(obj)
if user.allowed_in_project?("add_#{obj.class.name.underscore}_watchers".to_sym, obj.project) ||
user.allowed_in_project?("add_#{obj.class.lookup_ancestors.last.name.underscore}_watchers".to_sym, obj.project)
if user.allowed_in_project?(:"add_#{obj.class.name.underscore}_watchers", obj.project) ||
user.allowed_in_project?(:"add_#{obj.class.lookup_ancestors.last.name.underscore}_watchers", obj.project)
addresses = [email.to, email.cc].flatten.compact.uniq.map { |a| a.strip.downcase }
unless addresses.empty?
User
+2 -2
View File
@@ -44,7 +44,7 @@ class MenuItems::WikiMenuItem < MenuItem
end
def menu_identifier
"wiki-#{slug}".to_sym
:"wiki-#{slug}"
end
def index_page
@@ -68,6 +68,6 @@ class MenuItems::WikiMenuItem < MenuItem
end
def self.add_entry_item_prefix(identifier)
"entry-item-#{identifier}".to_sym
:"entry-item-#{identifier}"
end
end
+1 -1
View File
@@ -61,7 +61,7 @@ class News < ApplicationRecord
end
def description=(val)
super val.presence || ''
super(val.presence || '')
end
# returns latest news for projects visible by user
+1 -1
View File
@@ -41,7 +41,7 @@ module Principals::Scopes
not_builtin.where(status: val)
end
define_singleton_method("not_#{key}") do
define_singleton_method(:"not_#{key}") do
not_builtin.where.not(status: val)
end
end
+1 -1
View File
@@ -54,7 +54,7 @@ class Queries::Columns::Base
association
null_handling
default_order).each do |attribute|
send("#{attribute}=", options[attribute])
send(:"#{attribute}=", options[attribute])
end
end
+1 -1
View File
@@ -49,7 +49,7 @@ class Queries::Filters::Base
self.context = options[:context]
self.class.filter_params.each do |param_field|
send("#{param_field}=", options[param_field])
send(:"#{param_field}=", options[param_field])
end
end
@@ -56,7 +56,7 @@ module Queries
def to_hash
{
(name || :non_existent_filter) => {
name || :non_existent_filter => {
operator:,
values:
}
@@ -60,19 +60,19 @@ module Queries::Filters::Shared::CustomFieldFilter
##
# Create a filter instance for the given custom field accessor
def create!(name:, **options)
def create!(name:, **)
custom_field = find_by_accessor(name)
raise ::Queries::Filters::InvalidError if custom_field.nil?
from_custom_field!(custom_field:, **options)
from_custom_field!(custom_field:, **)
end
##
# Create a filter instance for the given custom field
def from_custom_field!(custom_field:, **options)
def from_custom_field!(custom_field:, **)
constant_name = subfilter_module(custom_field)
clazz = "::Queries::Filters::Shared::CustomFields::#{constant_name}".constantize
clazz.create!(custom_field:, custom_field_context:, **options)
clazz.create!(custom_field:, custom_field_context:, **)
rescue NameError => e
Rails.logger.error "Failed to constantize custom field filter for #{name}. #{e}"
raise ::Queries::Filters::InvalidError
@@ -42,8 +42,8 @@ module Queries::Filters::Shared
super(name, options)
end
def self.create!(custom_field:, custom_field_context:, **options)
new(custom_field:, custom_field_context:, **options)
def self.create!(custom_field:, custom_field_context:, **)
new(custom_field:, custom_field_context:, **)
end
def project
@@ -30,10 +30,10 @@ class Queries::WorkPackages::Columns::ManualSortingColumn < Queries::WorkPackage
include ::Queries::WorkPackages::Common::ManualSorting
def initialize
super :manual_sorting,
super(:manual_sorting,
default_order: 'asc',
displayable: false,
sortable: "#{OrderedWorkPackage.table_name}.position NULLS LAST, #{WorkPackage.table_name}.id"
sortable: "#{OrderedWorkPackage.table_name}.position NULLS LAST, #{WorkPackage.table_name}.id")
end
def sortable_join_statement(query)
@@ -34,7 +34,7 @@ class Queries::WorkPackages::Columns::RelationOfTypeColumn < Queries::WorkPackag
end
def name
"relations_of_type_#{type[:sym]}".to_sym
:"relations_of_type_#{type[:sym]}"
end
def sym
@@ -35,7 +35,7 @@ class Queries::WorkPackages::Columns::RelationToTypeColumn < Queries::WorkPackag
end
def set_name!(type)
self.name = "relations_to_type_#{type.id}".to_sym
self.name = :"relations_to_type_#{type.id}"
end
def caption
@@ -49,7 +49,6 @@ class Queries::WorkPackages::Filter::CategoryFilter <
values
.filter_map { |category_id| available_categories[category_id.to_i] }
end
def ar_object_filter?
@@ -56,7 +56,6 @@ class Queries::WorkPackages::Filter::GroupFilter < Queries::WorkPackages::Filter
values
.filter_map { |group_id| available_groups[group_id.to_i] }
end
def where
@@ -53,7 +53,6 @@ class Queries::WorkPackages::Filter::PriorityFilter <
values
.filter_map { |priority_id| available_priorities[priority_id.to_i] }
end
private
@@ -54,7 +54,6 @@ class Queries::WorkPackages::Filter::StatusFilter < Queries::WorkPackages::Filte
def value_objects
values
.filter_map { |status_id| all_statuses[status_id.to_i] }
end
def allowed_objects
@@ -63,7 +63,6 @@ class Queries::WorkPackages::Filter::SubprojectFilter <
values
.filter_map { |subproject_id| available_subprojects[subproject_id.to_i] }
end
def where
@@ -53,7 +53,6 @@ class Queries::WorkPackages::Filter::TypeFilter <
values
.filter_map { |type_id| available_types[type_id.to_i] }
end
private
@@ -54,7 +54,6 @@ class Queries::WorkPackages::Filter::VersionFilter <
values
.filter_map { |version_id| available_versions[version_id.to_i] }
end
private
-1
View File
@@ -136,7 +136,6 @@ class ::Query::Results
query
.sort_criteria_columns
.filter_map { |column, _direction| column.sortable_join_statement(query) }
end
def sort_criteria_array
-1
View File
@@ -45,7 +45,6 @@ class ::Query::SortCriteria < SortHelper::SortCriteria
.reject { |column, criterion, _| column.nil? || criterion.nil? }
.map { |column, criterion, order| [column, execute_criterion(criterion), order] }
.filter_map { |column, criterion, order| append_order(column, Array(criterion), order) }
end
private
+1 -1
View File
@@ -154,7 +154,7 @@ class Relation < ApplicationRecord
end
TYPES.each_key do |type|
define_method "#{type}?" do
define_method :"#{type}?" do
canonical_type == self.class.canonical_type(type)
end
end
+2 -2
View File
@@ -116,11 +116,11 @@ class Setting < ApplicationRecord
class_eval src, __FILE__, __LINE__
end
def method_missing(method, *args, &)
def method_missing(method, *, &)
if exists?(accessor_base_name(method))
create_setting_accessors(accessor_base_name(method))
send(method, *args)
send(method, *)
else
super
end
+1 -1
View File
@@ -38,7 +38,7 @@ class Timestamp
DATE_KEYWORD_REGEX =
%r{
^(?:#{ALLOWED_DATE_KEYWORDS.join("|")}) # match the relative date keyword
^(?:#{ALLOWED_DATE_KEYWORDS.join('|')}) # match the relative date keyword
@(?:([0-1]?[0-9]|2[0-3]):[0-5]?[0-9]) # match the hour part
[+-](?:([0-1]?[0-9]|2[0-3]):[0-5]?[0-9])$ # match the timezone offset
}x
-1
View File
@@ -229,7 +229,6 @@ module Type::AttributeGroups
ids = (old_groups.map(&:last).flatten - new_groups.map(&:last).flatten)
.filter_map { |k| ::Type::QueryGroup.query_attribute_id(k) }
Query.where(id: ids).destroy_all
end
+2 -2
View File
@@ -30,11 +30,11 @@ class Type::QueryGroup < Type::FormGroup
MEMBER_PREFIX = 'query_'.freeze
def self.query_attribute?(name)
name.to_s.match?(/#{Type::QueryGroup::MEMBER_PREFIX}(\d+)/)
name.to_s.match?(/#{Type::QueryGroup::MEMBER_PREFIX}(\d+)/o)
end
def self.query_attribute_id(name)
match = name.to_s.match(/#{Type::QueryGroup::MEMBER_PREFIX}(\d+)/)
match = name.to_s.match(/#{Type::QueryGroup::MEMBER_PREFIX}(\d+)/o)
match ? match[1] : nil
end
+2 -2
View File
@@ -366,8 +366,8 @@ class User < Principal
block_threshold = Setting.brute_force_block_after_failed_logins.to_i
return false if block_threshold == 0 # disabled
(last_failed_login_within_block_time? and
failed_login_count >= block_threshold)
last_failed_login_within_block_time? and
failed_login_count >= block_threshold
end
def log_failed_login
+2 -2
View File
@@ -38,11 +38,11 @@ module Users::PermissionChecks
entity_name_underscored = entity_model_name.underscore
entity_class = entity_model_name.constantize
define_method "allowed_in_#{entity_name_underscored}?" do |permission, entity|
define_method :"allowed_in_#{entity_name_underscored}?" do |permission, entity|
allowed_in_entity?(permission, entity, entity_class)
end
define_method "allowed_in_any_#{entity_name_underscored}?" do |permission, in_project: nil|
define_method :"allowed_in_any_#{entity_name_underscored}?" do |permission, in_project: nil|
allowed_in_any_entity?(permission, entity_class, in_project:)
end
end
@@ -45,9 +45,9 @@ module WorkPackage::AskBeforeDestruction
def cleanup_associated_before_destructing_if_required(work_packages, user, to_do = { action: 'destroy' })
cleanup_required = cleanup_action_required_before_destructing?(work_packages)
(!cleanup_required ||
!cleanup_required ||
(cleanup_required &&
cleanup_each_associated_class(work_packages, user, to_do)))
cleanup_each_associated_class(work_packages, user, to_do))
end
def associated_classes_to_address_before_destruction_of(work_packages)
@@ -37,7 +37,8 @@ module WorkPackage::Exports
values = cost_helper.summarized_cost_entries.map do |kvp|
cost_type = kvp[0]
volume = kvp[1]
type_unit = volume.to_d == 1.0.to_d ? cost_type.unit : cost_type.unit_plural
BigDecimal('1.0')
type_unit = volume.to_d == BigDecimal('1.0') ? cost_type.unit : cost_type.unit_plural
"#{volume} #{type_unit}"
end
return nil if values.empty?
+2 -2
View File
@@ -141,7 +141,7 @@ module WorkPackage::PDFExport::Common
def draw_text_multiline_left(text:, text_style:, max_left:, top:, max_lines:)
lines = wrap_to_lines(text, max_left - pdf.bounds.left, text_style, max_lines)
starting_position = top
lines.reverse.each do |line|
lines.reverse_each do |line|
starting_position += draw_text_multiline_part(line, text_style, pdf.bounds.left, starting_position)
end
end
@@ -149,7 +149,7 @@ module WorkPackage::PDFExport::Common
def draw_text_multiline_right(text:, text_style:, max_left:, top:, max_lines:)
lines = wrap_to_lines(text, pdf.bounds.right - max_left, text_style, max_lines)
starting_position = top
lines.reverse.each do |line|
lines.reverse_each do |line|
line_width = measure_text_width(line, text_style)
line_x = pdf.bounds.right - line_width
starting_position += draw_text_multiline_part(line, text_style, line_x, starting_position)
+3 -3
View File
@@ -147,7 +147,7 @@ module WorkPackage::PDFExport::Style
def toc_item(level)
resolve_font(@styles.dig(:toc, :item)).merge(
resolve_font(@styles.dig(:toc, "item_level_#{level}".to_sym))
resolve_font(@styles.dig(:toc, :"item_level_#{level}"))
)
end
@@ -157,7 +157,7 @@ module WorkPackage::PDFExport::Style
def toc_item_margins(level)
resolve_margin(@styles.dig(:toc, :item)).merge(
resolve_margin(@styles.dig(:toc, "item_level_#{level}".to_sym))
resolve_margin(@styles.dig(:toc, :"item_level_#{level}"))
)
end
@@ -167,7 +167,7 @@ module WorkPackage::PDFExport::Style
def wp_subject(level)
resolve_font(@styles.dig(:work_package, :subject)).merge(
resolve_font(@styles.dig(:work_package, "subject_level_#{level}".to_sym))
resolve_font(@styles.dig(:work_package, :"subject_level_#{level}"))
)
end
@@ -27,7 +27,7 @@
#++
module WorkPackage::PDFExport::SumsTable
def write_work_packages_sums!(work_packages)
def write_work_packages_sums!(_work_packages)
return unless has_summable_column?
write_optional_page_break
+1 -1
View File
@@ -73,7 +73,7 @@ module DemoData
end
end
def query_id_references(overview, widget_options)
def query_id_references(_overview, widget_options)
if widget_options && widget_options['queryId']
widget_options['queryId'] = with_references(widget_options['queryId'])
end
+1 -1
View File
@@ -56,7 +56,7 @@ module DemoData
DemoData::WorkPackageSeeder,
DemoData::WorkPackageBoardSeeder,
::Meetings::DemoData::MeetingSeeder,
::Meetings::DemoData::MeetingAgendaItemsSeeder,
::Meetings::DemoData::MeetingAgendaItemsSeeder
]
end
@@ -31,7 +31,7 @@ module Attachments
def set_attributes(params)
# Don't set the content type manually,
# we always want to infer it
super params.except :content_type
super(params.except :content_type)
end
def set_default_attributes(_params)
@@ -252,7 +252,7 @@ module Authentication
mail: info[:email],
firstname: info[:first_name] || info[:name],
lastname: info[:last_name],
identity_url: identity_url_from_omniauth,
identity_url: identity_url_from_omniauth
}
# Map the admin attribute if provided in an attribute mapping
@@ -284,7 +284,7 @@ module Authentication
##
# Try to provide some context of the auth_hash in case of errors
def auth_uid
hash = (auth_hash || {})
hash = auth_hash || {}
hash.dig(:info, :uid) || hash.dig(:uid) || 'unknown'
end
end
@@ -42,7 +42,7 @@ class Authorization::QueryTransformation
self.block = block
end
def apply(*args)
block.call(*args)
def apply(*)
block.call(*)
end
end
+1 -1
View File
@@ -29,7 +29,7 @@
module Backups
class CreateService < ::BaseServices::Create
def initialize(user:, backup_token:, include_attachments: true, contract_class: ::Backups::CreateContract)
super user:, contract_class:, contract_options: { backup_token: }
super(user:, contract_class:, contract_options: { backup_token: })
@include_attachments = include_attachments
end
+1 -1
View File
@@ -28,7 +28,7 @@
class CreateTypeService < BaseTypeService
def initialize(user)
super Type.new, user
super(Type.new, user)
end
private
+1 -1
View File
@@ -83,7 +83,7 @@ module Design
end
def custom_style
@custom_style ||= (CustomStyle.current || CustomStyle.create!)
@custom_style ||= CustomStyle.current || CustomStyle.create!
end
end
end
+1 -1
View File
@@ -46,7 +46,7 @@ module Grids
end
def initialize(user:, source:, contract_class: ::EmptyContract)
super user:, source:, contract_class:
super(user:, source:, contract_class:)
end
protected
+2 -2
View File
@@ -33,8 +33,8 @@ module Groups
def initialize(group, current_user:, contract_class: AdminOnlyContract)
self.model = group
super user: current_user,
contract_class:
super(user: current_user,
contract_class:)
end
private
@@ -40,8 +40,8 @@ module Groups
def initialize(group, current_user:, contract_class: AdminOnlyContract)
self.model = group
super user: current_user,
contract_class:
super(user: current_user,
contract_class:)
end
private
@@ -36,8 +36,8 @@ module Groups
def initialize(group, current_user:, contract_class: AdminOnlyContract)
self.model = group
super user: current_user,
contract_class:
super(user: current_user,
contract_class:)
end
private
+2 -2
View File
@@ -35,8 +35,8 @@ module Groups
def initialize(group, current_user:, contract_class: AdminOnlyContract)
self.model = group
super user: current_user,
contract_class:
super(user: current_user,
contract_class:)
end
private
+2 -2
View File
@@ -254,9 +254,9 @@ module Journals
def association_modifications_sql(association, predecessor)
<<~SQL
cleanup_predecessor_#{association} AS (
#{send("cleanup_predecessor_#{association}", predecessor)}
#{send(:"cleanup_predecessor_#{association}", predecessor)}
), insert_#{association} AS (
#{send("insert_#{association}_sql")}
#{send(:"insert_#{association}_sql")}
)
SQL
end
@@ -345,7 +345,7 @@ class Notifications::CreateFromModelService
end
def strategy
@strategy ||= if self.class.const_defined?("#{resource.class}Strategy")
@strategy ||= if self.class.const_defined?(:"#{resource.class}Strategy")
"#{self.class}::#{resource.class}Strategy".constantize
end
end
+1 -1
View File
@@ -52,7 +52,7 @@ module Notifications
end
def strategy
@strategy ||= if self.class.const_defined?("#{strategy_model}Strategy")
@strategy ||= if self.class.const_defined?(:"#{strategy_model}Strategy")
"#{self.class}::#{strategy_model}Strategy".constantize
end
end
@@ -86,8 +86,7 @@ module Principals
Budget,
MeetingAgenda,
MeetingMinutes,
MeetingAgendaItem
].each do |klass|
MeetingAgendaItem].each do |klass|
rewrite(klass, :author_id, from, to)
end
end
+2 -2
View File
@@ -28,8 +28,8 @@
class Settings::UpdateService < BaseServices::BaseContracted
def initialize(user:)
super user:,
contract_class: Settings::UpdateContract
super(user:,
contract_class: Settings::UpdateContract)
end
def persist(call)
@@ -111,13 +111,13 @@ class WorkPackages::UpdateAncestors::Loader
.send(relation_type)
.where.not(id: queried_work_package.id)
if send("#{relation_type}_joins")
scope = scope.joins(send("#{relation_type}_joins"))
if send(:"#{relation_type}_joins")
scope = scope.joins(send(:"#{relation_type}_joins"))
end
scope
.pluck(*send("selected_#{relation_type}_attributes"))
.map { |p| LoaderStruct.new(send("selected_#{relation_type}_attributes").zip(p).to_h) }
.pluck(*send(:"selected_#{relation_type}_attributes"))
.map { |p| LoaderStruct.new(send(:"selected_#{relation_type}_attributes").zip(p).to_h) }
end
# Returns the current ancestors sorted by distance (called generations in the table)
+2 -2
View File
@@ -59,9 +59,9 @@ class ApplicationJob < ActiveJob::Base
def self.queue_with_priority(value = :default)
if value.is_a?(Symbol)
super priority_number(value)
super(priority_number(value))
else
super value
super(value)
end
end
+2 -2
View File
@@ -35,8 +35,8 @@ module StateMachineJob
extend ActiveSupport::Concern
included do
def perform(state, *args)
results = instance_exec(*args, &states[state][:block])
def perform(state, *)
results = instance_exec(*, &states[state][:block])
to = states[state][:to]
+1 -1
View File
@@ -34,7 +34,7 @@ module Cron
self.cron_expression = '15 1 * * *'
def perform
super 'db:sessions:expire', 7
super('db:sessions:expire', 7)
end
end
end
+1 -1
View File
@@ -34,7 +34,7 @@ module Cron
self.cron_expression = '45 2 * * 7'
def perform
super 'tmp:cache:clear'
super('tmp:cache:clear')
end
end
end
+1 -1
View File
@@ -34,7 +34,7 @@ module Cron
self.cron_expression = '0 23 * * 5'
def perform
super 'attachments:clear'
super('attachments:clear')
end
end
end
+1 -1
View File
@@ -36,7 +36,7 @@ module OAuth
queue_with_priority :low
def perform
super 'doorkeeper:db:cleanup'
super('doorkeeper:db:cleanup')
end
end
end
@@ -49,7 +49,7 @@ class SCM::CreateLocalRepositoryJob < ApplicationJob
self.class.ensure_not_existing!(repository)
# Create the repository locally.
mode = (config[:mode] || default_mode)
mode = config[:mode] || default_mode
# Ensure that chmod receives an octal number
unless mode.is_a? Integer
+1 -1
View File
@@ -28,7 +28,7 @@
# This file is used by Rack-based servers to start the application.
require ::File.expand_path('config/environment', __dir__)
require File.expand_path('config/environment', __dir__)
subdir = OpenProject::Configuration.rails_relative_url_root.presence
+1 -1
View File
@@ -141,7 +141,7 @@ module OpenProject
# config.time_zone = 'Central Time (US & Canada)'
# Add locales from crowdin translations to i18n
config.i18n.load_path += Dir[Rails.root.join('config', 'locales', 'crowdin', '*.{rb,yml}').to_s]
config.i18n.load_path += Dir[Rails.root.join("config/locales/crowdin/*.{rb,yml}").to_s]
config.i18n.default_locale = :en
# Fall back to default locale
+1 -1
View File
@@ -36,7 +36,7 @@ end
require 'bundler/setup' # Set up gems listed in the Gemfile.
env = ENV['RAILS_ENV']
env = ENV.fetch('RAILS_ENV', nil)
# Disable deprecation warnings early on (before loading gems), which behaves as RUBYOPT="-w0"
# to disable the Ruby warnings in production.
# Set OPENPROJECT_PROD_DEPRECATIONS=true if you want to see them for debugging purposes
+1 -1
View File
@@ -41,7 +41,7 @@ module OpenProject
@providers ||= Hash.new { |h, k| h[k] = Set.new }
end
def map(&_block)
def map(&)
yield self
end
@@ -60,7 +60,7 @@ module OpenProject
end
def database_config
YAML.load_file(File.join(Rails.root, "config", "database.yml"))[Rails.env]
YAML.load_file(Rails.root.join("config/database.yml").to_s)[Rails.env]
end
end
end
+3 -3
View File
@@ -206,13 +206,13 @@ module Settings
description: 'The memcache server host and IP',
format: :string,
default: nil,
writable: false,
writable: false
},
cache_redis_url: {
description: 'URL to the redis cache server',
format: :string,
default: nil,
writable: false,
writable: false
},
cache_namespace: {
format: :string,
@@ -896,7 +896,7 @@ module Settings
},
show_product_version: {
description: 'Show product version information in the administration section',
default: true,
default: true
},
show_pending_migrations_warning: {
description: 'Enable or disable warning bar in case of pending migrations',
+1 -1
View File
@@ -33,7 +33,7 @@ module Constants
contract_strategy: nil)
@registered ||= {}
@registered[canonical_type(type)] = { contract_strategy: contract_strategy }
@registered[canonical_type(type)] = { contract_strategy: }
end
def registered_types
+1 -1
View File
@@ -87,4 +87,4 @@ OpenProject::Application.configure do
end
end
ActiveRecord::Base.logger = ActiveSupport::Logger.new($stdout) unless String(ENV["SILENCE_SQL_LOGS"]).to_bool
ActiveRecord::Base.logger = ActiveSupport::Logger.new($stdout) unless String(ENV.fetch("SILENCE_SQL_LOGS", nil)).to_bool
+2 -2
View File
@@ -41,8 +41,8 @@ if OpenProject::Appsignal.enabled?
)
# Extend the core log delegator
handler = ::OpenProject::Appsignal.method(:exception_handler)
::OpenProject::Logging::LogDelegator.register(:appsignal, handler)
handler = OpenProject::Appsignal.method(:exception_handler)
OpenProject::Logging::LogDelegator.register(:appsignal, handler)
Appsignal.start
end

Some files were not shown because too many files have changed in this diff Show More