]> source.dussan.org Git - redmine.git/commitdiff
Fix RuboCop offense Style/RedundantSelfAssignmentBranch (#36919).
authorGo MAEDA <maeda@farend.jp>
Thu, 29 Jun 2023 01:37:24 +0000 (01:37 +0000)
committerGo MAEDA <maeda@farend.jp>
Thu, 29 Jun 2023 01:37:24 +0000 (01:37 +0000)
git-svn-id: https://svn.redmine.org/redmine/trunk@22263 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/helpers/projects_helper.rb
app/models/project.rb
lib/redmine/wiki_formatting/textile/redcloth3.rb

index b213e2f484dafd018ba7dda31b7cbfac5b426a22..6a995fe6360d823c60f214265ad86918153a570d 100644 (file)
@@ -93,7 +93,7 @@ module ProjectsHelper
       grouped[version.project.name] << [version.name, version.id]
     end
 
-    selected = selected.is_a?(Version) ? selected.id : selected
+    selected = selected.id if selected.is_a?(Version)
     if grouped.keys.size > 1
       grouped_options_for_select(grouped, selected)
     else
index a50fa8807aa60e8ee3c1af948fa099a5f1b23c0f..5f45896fce0e5ecce5fb9a6aba0dfacd78dafe3f 100644 (file)
@@ -928,7 +928,7 @@ class Project < ActiveRecord::Base
   #   project.copy(1, :only => 'members')                # => copies members only
   #   project.copy(1, :only => ['members', 'versions'])  # => copies members and versions
   def copy(project, options={})
-    project = project.is_a?(Project) ? project : Project.find(project)
+    project = Project.find(project) unless project.is_a?(Project)
 
     to_be_copied = %w(members wiki versions issue_categories issues queries boards documents)
     to_be_copied = to_be_copied & Array.wrap(options[:only]) unless options[:only].nil?
@@ -956,7 +956,7 @@ class Project < ActiveRecord::Base
 
   # Returns a new unsaved Project instance with attributes copied from +project+
   def self.copy_from(project)
-    project = project.is_a?(Project) ? project : Project.find(project)
+    project = Project.find(project) unless project.is_a?(Project)
     # clear unique attributes
     attributes =
       project.attributes.dup.except('id', 'name', 'identifier',
index d77a0664bbab9124dccee3425a9ad435ba6f3eda..f0595f438fab3d000b87b0fde8256274a1776eeb 100644 (file)
@@ -498,7 +498,7 @@ class RedCloth3 < String
           c.starts_with?('wiki-class-') ? c : "wiki-class-#{c}"
         end.join(' ') if cls
 
-        id = id.starts_with?('wiki-id-') ? id : "wiki-id-#{id}" if id
+        id = "wiki-id-#{id}" if id && !id.start_with?('wiki-id-')
 
         atts = +''
         atts << " style=\"#{style.join}\"" unless style.empty?