Skip to content

Commit

Permalink
Switch to double quotes for files modified on this branch
Browse files Browse the repository at this point in the history
  • Loading branch information
cbliard committed Mar 21, 2024
1 parent d085f3e commit 03d9ff7
Show file tree
Hide file tree
Showing 16 changed files with 1,879 additions and 1,879 deletions.
8 changes: 4 additions & 4 deletions app/contracts/work_packages/base_contract.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,15 @@ class BaseContract < ::ModelContract
next unless model.project

validate_people_visible :assigned_to,
'assigned_to_id',
"assigned_to_id",
assignable_assignees
end

attribute :responsible_id do
next unless model.project

validate_people_visible :responsible,
'responsible_id',
"responsible_id",
assignable_responsibles
end

Expand Down Expand Up @@ -223,7 +223,7 @@ def validate_estimated_hours

def validate_after_soonest_start(date_attribute)
if !model.schedule_manually? && before_soonest_start?(date_attribute)
message = I18n.t('activerecord.errors.models.work_package.attributes.start_date.violates_relationships',
message = I18n.t("activerecord.errors.models.work_package.attributes.start_date.violates_relationships",
soonest_start: model.soonest_start)

errors.add date_attribute, message, error_symbol: :violates_relationships
Expand Down Expand Up @@ -353,7 +353,7 @@ def validate_people_visible(attribute, id_attribute, list)

unless principal_visible?(id, list)
errors.add attribute,
I18n.t('api_v3.errors.validation.invalid_user_assigned_to_work_package',
I18n.t("api_v3.errors.validation.invalid_user_assigned_to_work_package",
property: I18n.t("attributes.#{attribute}"))
end
end
Expand Down
64 changes: 32 additions & 32 deletions app/models/mail_handler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def initialize
# Code copied from base class and extended with optional options parameter
# as well as force_encoding support.
def self.receive(raw_mail, options = {})
raw_mail.force_encoding('ASCII-8BIT') if raw_mail.respond_to?(:force_encoding)
raw_mail.force_encoding("ASCII-8BIT") if raw_mail.respond_to?(:force_encoding)

ActiveSupport::Notifications.instrument("receive.action_mailer") do |payload|
mail = Mail.new(raw_mail)
Expand All @@ -66,8 +66,8 @@ def self.with_options(options)

cattr_accessor :ignored_emails_headers
@@ignored_emails_headers = {
'X-Auto-Response-Suppress' => 'oof',
'Auto-Submitted' => /\Aauto-/
"X-Auto-Response-Suppress" => "oof",
"Auto-Submitted" => /\Aauto-/
}

# Processes incoming emails
Expand Down Expand Up @@ -102,9 +102,9 @@ def receive(email)
if @user.nil?
# Email was submitted by an unknown user
case options[:unknown_user]
when 'accept'
when "accept"
@user = User.anonymous
when 'create'
when "create"
@user, password = MailHandler::UserCreator.create_user_from_email(email)
if @user
log "[#{@user.login}] account created"
Expand Down Expand Up @@ -140,7 +140,7 @@ def options=(value)
options[:allow_override] << :type unless options[:issue].has_key?(:type)
# Priority overridable by default
options[:allow_override] << :priority unless options[:issue].has_key?(:priority)
options[:no_permission_check] = options[:no_permission_check].to_s == '1'
options[:no_permission_check] = options[:no_permission_check].to_s == "1"
end

private
Expand Down Expand Up @@ -255,7 +255,7 @@ def receive_message_reply(message_id)
if message.locked?
log "ignoring reply from [#{sender_email}] to a locked topic"
else
reply = Message.new(subject: email.subject.gsub(%r{^.*msg\d+\]}, '').strip,
reply = Message.new(subject: email.subject.gsub(%r{^.*msg\d+\]}, "").strip,
content: cleaned_up_text_body)
reply.author = user
reply.forum = message.forum
Expand Down Expand Up @@ -303,7 +303,7 @@ def add_watchers(obj)
unless addresses.empty?
User
.active
.where(['LOWER(mail) IN (?)', addresses])
.where(["LOWER(mail) IN (?)", addresses])
.find_each do |user|
Services::CreateWatcher
.new(obj, user)
Expand Down Expand Up @@ -348,7 +348,7 @@ def extract_keyword!(text, attr, format)
text.gsub!(/^(#{keys.join('|')})[ \t]*:[ \t]*(?<value>#{format || '.+'})\s*$/i) do |_|
value = Regexp.last_match[:value]&.strip

''
""
end

value
Expand All @@ -369,25 +369,25 @@ def target_project
# * parse the email To field
# * specific project (eg. Setting.mail_handler_target_project)
target = Project.find_by(identifier: get_keyword(:project))
raise MissingInformation.new('Unable to determine target project') if target.nil?
raise MissingInformation.new("Unable to determine target project") if target.nil?

target
end

# Returns a Hash of issue attributes extracted from keywords in the email body
def wp_attributes_from_keywords(work_package)
{
'type_id' => wp_type_from_keywords(work_package),
'status_id' => wp_status_from_keywords,
'parent_id' => wp_parent_from_keywords,
'priority_id' => wp_priority_from_keywords,
'category_id' => wp_category_from_keywords(work_package),
'assigned_to_id' => wp_assignee_from_keywords(work_package),
'version_id' => wp_version_from_keywords(work_package),
'start_date' => wp_start_date_from_keywords,
'due_date' => wp_due_date_from_keywords,
'estimated_hours' => wp_estimated_hours_from_keywords,
'remaining_hours' => wp_remaining_hours_from_keywords
"type_id" => wp_type_from_keywords(work_package),
"status_id" => wp_status_from_keywords,
"parent_id" => wp_parent_from_keywords,
"priority_id" => wp_priority_from_keywords,
"category_id" => wp_category_from_keywords(work_package),
"assigned_to_id" => wp_assignee_from_keywords(work_package),
"version_id" => wp_version_from_keywords(work_package),
"start_date" => wp_start_date_from_keywords,
"due_date" => wp_due_date_from_keywords,
"estimated_hours" => wp_estimated_hours_from_keywords,
"remaining_hours" => wp_remaining_hours_from_keywords
}.compact_blank!
end

Expand All @@ -401,7 +401,7 @@ def custom_field_values_from_keywords(customized)
end
end

def lookup_case_insensitive_key(scope, attribute, column_name = Arel.sql('name'))
def lookup_case_insensitive_key(scope, attribute, column_name = Arel.sql("name"))
if k = get_keyword(attribute)
scope.find_by("lower(#{column_name}) = ?", k.downcase).try(:id)
end
Expand All @@ -420,7 +420,7 @@ def plain_text_body
@plain_text_body = strip_tags(@plain_text_body.strip)
@plain_text_body = CGI.unescapeHTML(@plain_text_body)

@plain_text_body.sub! %r{^<!DOCTYPE .*$}, ''
@plain_text_body.sub! %r{^<!DOCTYPE .*$}, ""
@plain_text_body
end

Expand All @@ -434,7 +434,7 @@ def self.full_sanitizer

def allow_override_option(options)
if options[:allow_override].is_a?(String)
options[:allow_override].split(',').map(&:strip)
options[:allow_override].split(",").map(&:strip)
else
options[:allow_override] || []
end
Expand All @@ -445,13 +445,13 @@ def cleanup_body(body)
delimiters = Setting.mail_handler_body_delimiters.to_s.split(/[\r\n]+/).compact_blank.map { |s| Regexp.escape(s) }
unless delimiters.empty?
regex = Regexp.new("^[> ]*(#{delimiters.join('|')})\s*[\r\n].*", Regexp::MULTILINE)
body = body.gsub(regex, '')
body = body.gsub(regex, "")
end

regex_delimiter = Setting.mail_handler_body_delimiter_regex
if regex_delimiter.present?
regex = Regexp.new(regex_delimiter, Regexp::MULTILINE)
body = body.gsub(regex, '')
body = body.gsub(regex, "")
end

body.strip
Expand Down Expand Up @@ -491,9 +491,9 @@ def create_work_package(project)
def collect_wp_attributes_from_email_on_create(work_package)
attributes = wp_attributes_from_keywords(work_package)
attributes
.merge('custom_field_values' => custom_field_values_from_keywords(work_package),
'subject' => email.subject.to_s.chomp[0, 255] || '(no subject)',
'description' => cleaned_up_text_body)
.merge("custom_field_values" => custom_field_values_from_keywords(work_package),
"subject" => email.subject.to_s.chomp[0, 255] || "(no subject)",
"description" => cleaned_up_text_body)
end

def update_work_package(work_package)
Expand All @@ -516,8 +516,8 @@ def update_work_package(work_package)
def collect_wp_attributes_from_email_on_update(work_package)
attributes = wp_attributes_from_keywords(work_package)
attributes
.merge('custom_field_values' => custom_field_values_from_keywords(work_package),
'journal_notes' => cleaned_up_text_body)
.merge("custom_field_values" => custom_field_values_from_keywords(work_package),
"journal_notes" => cleaned_up_text_body)
end

def wp_type_from_keywords(work_package)
Expand Down Expand Up @@ -586,7 +586,7 @@ def mail_as_hash(email)
{
message_id: email.message_id,
subject: email.subject,
from: email.from&.first || '(unknown from address)',
from: email.from&.first || "(unknown from address)",
quote: incoming_email_quote(email),
text: plain_text_body || incoming_email_text(email)
}
Expand Down
2 changes: 1 addition & 1 deletion app/services/work_packages/set_attributes_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ def default_description?
end

def normalize_whitespace(string)
string.gsub(/\s/, ' ').squeeze(' ')
string.gsub(/\s/, " ").squeeze(" ")
end

def set_custom_attributes(attributes)
Expand Down
2 changes: 1 addition & 1 deletion app/services/work_packages/update_ancestors_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def derive_attributes(work_package, loader, attributes)

def set_journal_note(work_packages)
work_packages.each do |wp|
wp.journal_notes = I18n.t('work_package.updated_automatically_by_child_changes', child: "##{initiator_work_package.id}")
wp.journal_notes = I18n.t("work_package.updated_automatically_by_child_changes", child: "##{initiator_work_package.id}")
end
end

Expand Down
Loading

0 comments on commit 03d9ff7

Please sign in to comment.