diff --git a/CHANGELOG.md b/CHANGELOG.md index a9deb1e87a..d6ab484e6c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## V4.1.2 or V4.2.0 + +### Fixed +- Fixed rubocop errors after V4.1.1 release ## V4.1.1 ### Added diff --git a/app/controllers/plan_exports_controller.rb b/app/controllers/plan_exports_controller.rb index a000a53588..c9f191c339 100644 --- a/app/controllers/plan_exports_controller.rb +++ b/app/controllers/plan_exports_controller.rb @@ -155,6 +155,6 @@ def export_params # in html that break docx creation by htmltoword gem. def clean_html_for_docx_creation(html) # Replaces single backslash \ with \\ with gsub. - html.gsub(/\\/, '\&\&') + html.gsub('\\', '\&\&') end end diff --git a/app/helpers/customizable_template_link_helper.rb b/app/helpers/customizable_template_link_helper.rb index f0cb62dfd8..d8b72e8353 100644 --- a/app/helpers/customizable_template_link_helper.rb +++ b/app/helpers/customizable_template_link_helper.rb @@ -10,16 +10,16 @@ def link_to_customizable_template(name, customization, template) if customization.present? if customization.created_at < template.created_at - name = name.blank? ? _('Transfer customisation') : name + name = _('Transfer customisation') if name.blank? link_to name, org_admin_template_customization_transfers_path(customization.id), data: { method: 'post' } else - name = name.blank? ? _('Edit customisation') : name + name = _('Edit customisation') if name.blank? link_to name, org_admin_template_path(id: customization.id) end else - name = name.blank? ? _('Customise') : name + name = _('Customise') if name.blank? link_to name, org_admin_template_customizations_path(template.id), 'data-method': 'post' diff --git a/app/models/answer.rb b/app/models/answer.rb index d1ff70e9b3..9a4dcb4d14 100644 --- a/app/models/answer.rb +++ b/app/models/answer.rb @@ -105,7 +105,7 @@ def answered? # # Returns Array def non_archived_notes - notes.select { |n| n.archived.blank? }.sort! { |x, y| x.created_at <=> y.created_at } + notes.select { |n| n.archived.blank? }.sort_by!(&:created_at) end # The parsed JSON hash for the current answer object. Generates a new hash if none diff --git a/app/models/exported_plan.rb b/app/models/exported_plan.rb index 65890d3286..a6219edab2 100644 --- a/app/models/exported_plan.rb +++ b/app/models/exported_plan.rb @@ -182,7 +182,7 @@ def as_txt(sections, unanswered_questions, question_headings, details) next if answer.nil? && !unanswered_questions if question_headings - qtext = sanitize_text(question.text.gsub(/
  • /, ' * ')) + qtext = sanitize_text(question.text.gsub('
  • ', ' * ')) output += "\n* #{qtext}" end if answer.nil? diff --git a/app/models/plan.rb b/app/models/plan.rb index 3b7e18ec85..7626bba207 100644 --- a/app/models/plan.rb +++ b/app/models/plan.rb @@ -375,7 +375,7 @@ def complete_feedback(org_admin) # # Returns Boolean def editable_by?(user_id) - roles.select { |r| r.user_id == user_id && r.active && r.editor }.any? + roles.any? { |r| r.user_id == user_id && r.active && r.editor } end ## @@ -409,7 +409,7 @@ def readable_by?(user_id) # # Returns Boolean def commentable_by?(user_id) - roles.select { |r| r.user_id == user_id && r.active && r.commenter }.any? || + roles.any? { |r| r.user_id == user_id && r.active && r.commenter } || reviewable_by?(user_id) end @@ -419,7 +419,7 @@ def commentable_by?(user_id) # # Returns Boolean def administerable_by?(user_id) - roles.select { |r| r.user_id == user_id && r.active && r.administrator }.any? + roles.any? { |r| r.user_id == user_id && r.active && r.administrator } end # determines if the plan is reviewable by the specified user @@ -539,7 +539,7 @@ def num_questions # # Returns Boolean def visibility_allowed? - !is_test? && phases.select { |phase| phase.visibility_allowed?(self) }.any? + !is_test? && phases.any? { |phase| phase.visibility_allowed?(self) } end # Determines whether or not a question (given its id) exists for the self plan diff --git a/app/models/question.rb b/app/models/question.rb index adf8753f66..509a977136 100644 --- a/app/models/question.rb +++ b/app/models/question.rb @@ -118,7 +118,7 @@ def deep_copy(**options) copy = dup copy.modifiable = options.fetch(:modifiable, modifiable) copy.section_id = options.fetch(:section_id, nil) - copy.save!(validate: false) if options.fetch(:save, false) + copy.save!(validate: false) if options.fetch(:save, false) options[:question_id] = copy.id question_options.each { |qo| copy.question_options << qo.deep_copy(**options) } annotations.each do |annotation| diff --git a/lib/csvable.rb b/lib/csvable.rb index b86c19bf02..9a2b3d004f 100644 --- a/lib/csvable.rb +++ b/lib/csvable.rb @@ -5,14 +5,13 @@ module Csvable require 'csv' class << self # rubocop:disable Style/OptionalBooleanParameter - # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity + # rubocop:disable Metrics/AbcSize def from_array_of_hashes(data = [], humanize = true, sep = ',') return '' unless data.first&.keys headers = if humanize data.first.keys - .map(&:to_s) - .map(&:humanize) + .map { |x| x.to_s.humanize } else data.first.keys .map(&:to_s) @@ -27,6 +26,6 @@ def from_array_of_hashes(data = [], humanize = true, sep = ',') end end # rubocop:enable Style/OptionalBooleanParameter - # rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity + # rubocop:enable Metrics/AbcSize end end diff --git a/lib/tasks/upgrade.rake b/lib/tasks/upgrade.rake index 66fc66998c..98c97cdcb2 100644 --- a/lib/tasks/upgrade.rake +++ b/lib/tasks/upgrade.rake @@ -924,7 +924,7 @@ namespace :upgrade do orgs.each do |org| # If the Org already has a ROR identifier skip it - next if org.identifiers.select { |id| id.identifier_scheme_id == ror.id }.any? + next if org.identifiers.any? { |id| id.identifier_scheme_id == ror.id } # The abbreviation sometimes causes weird results so strip it off # in this instance diff --git a/spec/support/helpers/identifier_helper.rb b/spec/support/helpers/identifier_helper.rb index 53afc495e3..caeabe70de 100644 --- a/spec/support/helpers/identifier_helper.rb +++ b/spec/support/helpers/identifier_helper.rb @@ -19,7 +19,7 @@ def orcid_scheme end def append_prefix(scheme:, val:) - val = val.start_with?('/') ? val[1..val.length] : val + val = val[1..val.length] if val.start_with?('/') url = landing_page_for(scheme: scheme) val.start_with?(url) ? val : "#{url}#{val}" end