OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
refactor: Remove double negative
Christophe Bliard78b5ad9b68e0
diff --git a/app/models/work_package/pdf_export/work_package_to_pdf.rb b/app/models/work_package/pdf_export/work_package_to_pdf.rbindex 63175653edb..e1a73dccd0f 100644--- a/app/models/work_package/pdf_export/work_package_to_pdf.rb+++ b/app/models/work_package/pdf_export/work_package_to_pdf.rb@@ -252,7 +252,7 @@ class WorkPackage::PDFExport::WorkPackageToPdf < ::Exports::Exporterpdf.font style: :italic, size: 8journal.details.each do |detail|text = journal- .render_detail(detail, no_html: true, only_path: false)+ .render_detail(detail, html: false, only_path: false).gsub(/\((https?[^)]+)\)$/, "(<link href='\\1'>\\1</link>)")pdf.text('- ' + text, inline_format: true)diff --git a/app/views/journals/index.atom.builder b/app/views/journals/index.atom.builderindex 28cffc1d8d2..c96f4d7c387 100644--- a/app/views/journals/index.atom.builder+++ b/app/views/journals/index.atom.builder@@ -49,7 +49,7 @@ xml.feed "xmlns" => "http://www.w3.org/2005/Atom" doxml.content "type" => "html" doxml.text! '<ul>'change.details.each do |detail|- change_content = change.render_detail(detail, no_html: false)+ change_content = change.render_detail(detail, html: true)xml.text!(content_tag(:li, change_content)) if change_content.present?endxml.text! '</ul>'diff --git a/lib/api/v3/activities/activity_property_formatters.rb b/lib/api/v3/activities/activity_property_formatters.rbindex 280a58b3d3c..9b689c7f69b 100644--- a/lib/api/v3/activities/activity_property_formatters.rb+++ b/lib/api/v3/activities/activity_property_formatters.rb@@ -37,7 +37,7 @@ module APIenddef formatted_details(journal)- details = render_details(journal, no_html: true)+ details = render_details(journal, html: false)html_details = render_details(journal)details@@ -47,10 +47,10 @@ module APIprivate- def render_details(journal, no_html: false)+ def render_details(journal, html: true)journal.details- .map { |d| journal.render_detail(d, no_html:) }+ .map { |d| journal.render_detail(d, html:) }.compactenddiff --git a/lib/open_project/journal_formatter/active_status.rb b/lib/open_project/journal_formatter/active_status.rbindex 1f09fdd0d19..cb171805bd3 100644--- a/lib/open_project/journal_formatter/active_status.rb+++ b/lib/open_project/journal_formatter/active_status.rb@@ -27,8 +27,8 @@#++class OpenProject::JournalFormatter::ActiveStatus < JournalFormatter::Base- def render(key, values, options = { no_html: false })- label_text = options[:no_html] ? "Project" : content_tag('strong', "Project")+ def render(_key, values, options = { html: true })+ label_text = options[:html] ? content_tag('strong', "Project") : "Project"activated_text = values.last ? "unarchived" : "archived"I18n.t(:text_journal_label_value, label: label_text, value: activated_text)diff --git a/lib/open_project/journal_formatter/attachment.rb b/lib/open_project/journal_formatter/attachment.rbindex 4e37a9c73a3..d9b18b3cfe7 100644--- a/lib/open_project/journal_formatter/attachment.rb+++ b/lib/open_project/journal_formatter/attachment.rb@@ -35,10 +35,10 @@ class OpenProject::JournalFormatter::Attachment < ::JournalFormatter::Base{ only_path: true }end- def render(key, values, options = { no_html: false })+ def render(key, values, options = { html: true })label, old_value, value = format_details(key.to_s.sub('attachments_', ''), values)- unless options[:no_html]+ if options[:html]label, old_value, value = *format_html_details(label, old_value, value)value = format_html_attachment_detail(key.to_s.sub('attachments_', ''), value)diff --git a/lib/open_project/journal_formatter/diff.rb b/lib/open_project/journal_formatter/diff.rbindex 610f21d9069..da76e57d347 100644--- a/lib/open_project/journal_formatter/diff.rb+++ b/lib/open_project/journal_formatter/diff.rb@@ -31,27 +31,27 @@ class OpenProject::JournalFormatter::Diff < JournalFormatter::Basedef render(key, values, options = {})merge_options = { only_path: true,- no_html: false }.merge(options)+ html: true }.merge(options)render_ternary_detail_text(key, values.last, values.first, merge_options)endprivate- def label(key, no_html = false)- label = super key+ def label(key, html: true)+ label = super(key)- if no_html- label- else+ if htmlcontent_tag('strong', label)+ else+ labelendenddef render_ternary_detail_text(key, value, old_value, options)link = link(key, options)- label = label(key, options[:no_html])+ label = label(key, html: options[:html])if value.blank?I18n.t(:text_journal_deleted_with_diff, label:, link:)@@ -74,12 +74,12 @@ class OpenProject::JournalFormatter::Diff < JournalFormatter::Baseid: @journal.id,field: key.downcase)- if options[:no_html]- url_for url_attr- else+ if options[:html]link_to(I18n.t(:label_details),url_attr,class: 'description-details')+ else+ url_for url_attrendenddiff --git a/lib/open_project/journal_formatter/schedule_manually.rb b/lib/open_project/journal_formatter/schedule_manually.rbindex e543e219f5a..f2b75d261a4 100644--- a/lib/open_project/journal_formatter/schedule_manually.rb+++ b/lib/open_project/journal_formatter/schedule_manually.rb@@ -27,8 +27,8 @@#++class OpenProject::JournalFormatter::ScheduleManually < JournalFormatter::Base- def render(key, values, options = { no_html: false })- label_text = options[:no_html] ? label(key) : content_tag('strong', label(key))+ def render(key, values, options = { html: true })+ label_text = options[:html] ? content_tag('strong', label(key)) : label(key)activated_text = values.last ? I18n.t('scheduling.activated') : I18n.t('scheduling.deactivated')I18n.t(:text_journal_label_value, label: label_text, value: activated_text)diff --git a/lib_static/plugins/acts_as_journalized/lib/journal_formatter.rb b/lib_static/plugins/acts_as_journalized/lib/journal_formatter.rbindex c61f56691e0..2806b34ac6c 100644--- a/lib_static/plugins/acts_as_journalized/lib/journal_formatter.rb+++ b/lib_static/plugins/acts_as_journalized/lib/journal_formatter.rb@@ -95,7 +95,7 @@ module JournalFormatterenddef render_detail(detail, options = {})- merge_options = { no_html: false, only_path: true }.merge(options)+ merge_options = { html: true, only_path: true }.merge(options)if detail.respond_to? :to_arykey = detail.firstdiff --git a/lib_static/plugins/acts_as_journalized/lib/journal_formatter/base.rb b/lib_static/plugins/acts_as_journalized/lib/journal_formatter/base.rbindex d69535d8424..cdcac312464 100644--- a/lib_static/plugins/acts_as_journalized/lib/journal_formatter/base.rb+++ b/lib_static/plugins/acts_as_journalized/lib/journal_formatter/base.rb@@ -44,10 +44,10 @@ module JournalFormatter@journal = journalend- def render(key, values, options = { no_html: false })+ def render(key, values, options = { html: true })label, old_value, value = format_details(key, values)- unless options[:no_html]+ if options[:html]label, old_value, value = *format_html_details(label, old_value, value)end@@ -85,16 +85,16 @@ module JournalFormatterlinebreak = should_linebreak?(old_value.to_s, value.to_s)- if options[:no_html]- I18n.t(:text_journal_changed_plain,+ if options[:html]+ I18n.t(:text_journal_changed_html,label:,- linebreak: linebreak ? "\n" : '',+ linebreak: linebreak ? "<br/>".html_safe : '',old: old_value,new: value)else- I18n.t(:text_journal_changed_html,+ I18n.t(:text_journal_changed_plain,label:,- linebreak: linebreak ? "<br/>".html_safe : '',+ linebreak: linebreak ? "\n" : '',old: old_value,new: value)enddiff --git a/lib_static/plugins/acts_as_journalized/lib/journal_formatter/named_association.rb b/lib_static/plugins/acts_as_journalized/lib/journal_formatter/named_association.rbindex 61c7048760e..804c94e9625 100644--- a/lib_static/plugins/acts_as_journalized/lib/journal_formatter/named_association.rb+++ b/lib_static/plugins/acts_as_journalized/lib/journal_formatter/named_association.rb@@ -28,10 +28,10 @@module JournalFormatterclass NamedAssociation < Attribute- def render(key, values, options = { no_html: false })+ def render(key, values, options = { html: true })label, old_value, value = format_details(key, values, options)- unless options[:no_html]+ if options[:html]label, old_value, value = *format_html_details(label, old_value, value)enddiff --git a/spec/lib/journal_formatter/active_status_spec.rb b/spec/lib/journal_formatter/active_status_spec.rbindex 984fbf5cc86..c280f1f5995 100644--- a/spec/lib/journal_formatter/active_status_spec.rb+++ b/spec/lib/journal_formatter/active_status_spec.rb@@ -32,18 +32,18 @@ describe OpenProject::JournalFormatter::ActiveStatus dolet(:instance) { described_class.new(build(:journal)) }it "renders correctly when unarchiving" do- html = instance.render("active", [false, true], no_html: false)+ html = instance.render("active", [false, true], html: true)expect(html).to eq("<strong>Project</strong> unarchived")- html = instance.render("active", [false, true], no_html: true)+ html = instance.render("active", [false, true], html: false)expect(html).to eq("Project unarchived")endit "renders correctly when archiving" do- html = instance.render("active", [true, false], no_html: false)+ html = instance.render("active", [true, false], html: true)expect(html).to eq("<strong>Project</strong> archived")- html = instance.render("active", [true, false], no_html: true)+ html = instance.render("active", [true, false], html: false)expect(html).to eq("Project archived")endenddiff --git a/spec/lib/journal_formatter/attachment_spec.rb b/spec/lib/journal_formatter/attachment_spec.rbindex 825c14f3ebe..db35201394b 100644--- a/spec/lib/journal_formatter/attachment_spec.rb+++ b/spec/lib/journal_formatter/attachment_spec.rb@@ -98,7 +98,7 @@ describe OpenProject::JournalFormatter::Attachment dovalue: attachment.id)end- it { expect(instance.render(key, [nil, attachment.id.to_s], no_html: true)).to eq(expected) }+ it { expect(instance.render(key, [nil, attachment.id.to_s], html: false)).to eq(expected) }enddescribe "WITH the first value being an id as string, and the second nil,@@ -109,7 +109,7 @@ describe OpenProject::JournalFormatter::Attachment doold: attachment.id)end- it { expect(instance.render(key, [attachment.id.to_s, nil], no_html: true)).to eq(expected) }+ it { expect(instance.render(key, [attachment.id.to_s, nil], html: false)).to eq(expected) }endendenddiff --git a/spec/lib/journal_formatter/custom_field_spec.rb b/spec/lib/journal_formatter/custom_field_spec.rbindex d279652c199..38b578f5b19 100644--- a/spec/lib/journal_formatter/custom_field_spec.rb+++ b/spec/lib/journal_formatter/custom_field_spec.rb@@ -166,7 +166,7 @@ describe OpenProject::JournalFormatter::CustomField dovalue: format_value(values.last, custom_field))end- it { expect(instance.render(key, values, no_html: true)).to eq(expected) }+ it { expect(instance.render(key, values, html: false)).to eq(expected) }enddescribe "WITH the first value being a valid value as a string, and the second being a valid value as a string@@ -181,7 +181,7 @@ describe OpenProject::JournalFormatter::CustomField donew: format_value(values.last, custom_field))end- it { expect(instance.render(key, values, no_html: true)).to eq(expected) }+ it { expect(instance.render(key, values, html: false)).to eq(expected) }enddescribe "WITH the first value being a valid value as a string, and the second being nil@@ -194,7 +194,7 @@ describe OpenProject::JournalFormatter::CustomField doold: format_value(values.first, custom_field))end- it { expect(instance.render(key, values, no_html: true)).to eq(expected) }+ it { expect(instance.render(key, values, html: false)).to eq(expected) }enddescribe "WITH the first value being nil, and the second a valid value as stringdiff --git a/spec/lib/journal_formatter/diff_spec.rb b/spec/lib/journal_formatter/diff_spec.rbindex 50b0c7ce0d4..c48061017cb 100644--- a/spec/lib/journal_formatter/diff_spec.rb+++ b/spec/lib/journal_formatter/diff_spec.rb@@ -117,7 +117,7 @@ describe OpenProject::JournalFormatter::Diff dolink: url)end- it { expect(instance.render(key, [nil, 'new value'], no_html: true)).to eq(expected) }+ it { expect(instance.render(key, [nil, 'new value'], html: false)).to eq(expected) }enddescribe "WITH the first value being a string, and the second a string@@ -128,7 +128,7 @@ describe OpenProject::JournalFormatter::Diff dolink: url)end- it { expect(instance.render(key, ['old value', 'new value'], no_html: true)).to eq(expected) }+ it { expect(instance.render(key, ['old value', 'new value'], html: false)).to eq(expected) }enddescribe "WITH the first value being a string, and the second a string@@ -149,7 +149,7 @@ describe OpenProject::JournalFormatter::Diff dolink: url)end- it { expect(instance.render(key, ['old_value', nil], no_html: true)).to eq(expected) }+ it { expect(instance.render(key, ['old_value', nil], html: false)).to eq(expected) }endendend