]> source.dussan.org Git - redmine.git/commitdiff
Fix RuboCop offense Style/InverseMethods: Use `present?` instead of inverting `blank...
authorGo MAEDA <maeda@farend.jp>
Sat, 25 Mar 2023 01:32:23 +0000 (01:32 +0000)
committerGo MAEDA <maeda@farend.jp>
Sat, 25 Mar 2023 01:32:23 +0000 (01:32 +0000)
git-svn-id: https://svn.redmine.org/redmine/trunk@22152 e93f8b46-1217-0410-a6f0-8f06a7374b81

16 files changed:
app/controllers/application_controller.rb
app/controllers/roles_controller.rb
app/controllers/trackers_controller.rb
app/helpers/custom_fields_helper.rb
app/models/auth_source_ldap.rb
app/models/import.rb
app/models/mail_handler.rb
app/models/query.rb
app/models/setting.rb
app/models/wiki_page.rb
app/views/common/feed.atom.builder
app/views/journals/index.builder
lib/redmine/plugin.rb
test/unit/project_copy_test.rb
test/unit/project_test.rb
test/unit/user_test.rb

index c39fe8ad1ef43deba9f1cd8081923dfd9d4d9523..e83e08989c99c82aaa92382d24b28feee97b4f6a 100644 (file)
@@ -251,7 +251,7 @@ class ApplicationController < ActionController::Base
     end
     if lang.nil? && !Setting.force_default_language_for_anonymous? && request.env['HTTP_ACCEPT_LANGUAGE']
       accept_lang = parse_qvalues(request.env['HTTP_ACCEPT_LANGUAGE']).first
-      if !accept_lang.blank?
+      if accept_lang.present?
         accept_lang = accept_lang.downcase
         lang = find_language(accept_lang) || find_language(accept_lang.split('-').first)
       end
index 70aa19ae6d9255a877f09764b46c152f1c8a93c3..35b753f3111bdc93cd329790243285047663512a 100644 (file)
@@ -63,7 +63,7 @@ class RolesController < ApplicationController
     @role.safe_attributes = params[:role]
     if request.post? && @role.save
       # workflow copy
-      if !params[:copy_workflow_from].blank? && (copy_from = Role.find_by_id(params[:copy_workflow_from]))
+      if params[:copy_workflow_from].present? && (copy_from = Role.find_by_id(params[:copy_workflow_from]))
         @role.copy_workflow_rules(copy_from)
       end
       flash[:notice] = l(:notice_successful_create)
index 88381a1b8d17de12caef2f10aa6c98d6b3dc66cf..64367f3733c8d3d76273008bec32fde07cdd09ae 100644 (file)
@@ -48,7 +48,7 @@ class TrackersController < ApplicationController
     @tracker.safe_attributes = params[:tracker]
     if @tracker.save
       # workflow copy
-      if !params[:copy_workflow_from].blank? && (copy_from = Tracker.find_by_id(params[:copy_workflow_from]))
+      if params[:copy_workflow_from].present? && (copy_from = Tracker.find_by_id(params[:copy_workflow_from]))
         @tracker.copy_workflow_rules(copy_from)
       end
       flash[:notice] = l(:notice_successful_create)
index 13974daff7bec45ed5e63fa3092ee243dd371ed7..435634df8b0d753f43da54e4e498538dc0f0ac6b 100644 (file)
@@ -155,7 +155,7 @@ module CustomFieldsHelper
   def custom_field_value_tag(value)
     attr_value = show_value(value)
 
-    if !attr_value.blank? && value.custom_field.full_text_formatting?
+    if attr_value.present? && value.custom_field.full_text_formatting?
       content_tag('div', attr_value, :class => 'wiki')
     else
       attr_value
index b9cf21cccbfad2acd5ceefcca43e3273e1b7c2be..a2d43b7f70634e81eb16f743b06b48583f89f79f 100644 (file)
@@ -245,7 +245,7 @@ class AuthSourceLdap < AuthSource
   # Singleton class method is public
   class << self
     def get_attr(entry, attr_name)
-      if !attr_name.blank?
+      if attr_name.present?
         value = entry[attr_name].is_a?(Array) ? entry[attr_name].first : entry[attr_name]
         (+value.to_s).force_encoding('UTF-8')
       end
index 5dcb05882ef923e07d76807da98fba92c226551d..fe3f24fab29e0118bef09e51272a44b2706eec9e 100644 (file)
@@ -94,7 +94,7 @@ class Import < ActiveRecord::Base
       'notifications' => '0'
     )
 
-    if options.key?(:project_id) && !options[:project_id].blank?
+    if options.key?(:project_id) && options[:project_id].present?
       # Do not fail if project doesn't exist
       begin
         project = Project.find(options[:project_id])
index 2fa4de00dae942106ce29a8b2ebaee853dc3f562..5925608bda8cec89d44bd74f7aa18f0cec30fd64 100644 (file)
@@ -365,7 +365,7 @@ class MailHandler < ActionMailer::Base
           end
         if override && (v = extract_keyword!(cleaned_up_text_body, attr, options[:format]))
           v
-        elsif !handler_options[:issue][attr].blank?
+        elsif handler_options[:issue][attr].present?
           handler_options[:issue][attr]
         end
       end
index 4a0aeb4fd6024b241e4ce7ce8cf16d14bd70b981..473ea4d866a1bbb33a1242f6993489227097b2aa 100644 (file)
@@ -505,7 +505,7 @@ class Query < ActiveRecord::Base
 
       add_filter_error(field, :blank) unless
           # filter requires one or more values
-          (values_for(field) and !values_for(field).first.blank?) or
+          (values_for(field) and values_for(field).first.present?) or
           # filter doesn't require any value
           ["o", "c", "!*", "*", "nd", "t", "ld", "nw", "w", "lw", "l2w", "nm", "m", "lm", "y", "*o", "!o"].include? operator_for(field)
     end if filters
@@ -830,7 +830,7 @@ class Query < ActiveRecord::Base
 
   def column_names=(names)
     if names
-      names = names.select {|n| n.is_a?(Symbol) || !n.blank?}
+      names = names.select {|n| n.is_a?(Symbol) || n.present?}
       names = names.collect {|n| n.is_a?(Symbol) ? n : n.to_sym}
       if names.delete(:all_inline)
         names = available_inline_columns.map(&:name) | names
index 155ed23b162ff8fdbee740021591341ccc0310b6..81f121db4ad432c2fea33f38d0fc7b36f648c414 100644 (file)
@@ -111,7 +111,7 @@ class Setting < ActiveRecord::Base
       v = YAML.safe_load(v, permitted_classes: Rails.configuration.active_record.yaml_column_permitted_classes)
       v = force_utf8_strings(v)
     end
-    v = v.to_sym if available_settings[name]['format'] == 'symbol' && !v.blank?
+    v = v.to_sym if available_settings[name]['format'] == 'symbol' && v.present?
     v
   end
 
index 594c44bd64f15ca0dfac53fa0cd0dd821faadc10..0ee06673e165a7f94873ccae841b4f9126536086 100644 (file)
@@ -273,7 +273,7 @@ class WikiPage < ActiveRecord::Base
   protected
 
   def validate_parent_title
-    errors.add(:parent_title, :invalid) if !@parent_title.blank? && parent.nil?
+    errors.add(:parent_title, :invalid) if @parent_title.present? && parent.nil?
     errors.add(:parent_title, :circular_dependency) if parent && (parent == self || parent.ancestors.include?(self))
     if parent_id_changed? && parent && (parent.wiki_id != wiki_id)
       errors.add(:parent_title, :not_same_project)
index 13fda6b1bbddf31ffe4d9ba6c171a0a728287b9e..e62b535d18d72771c5cc14bb514737104741d1b4 100644 (file)
@@ -24,7 +24,7 @@ xml.feed "xmlns" => "http://www.w3.org/2005/Atom" do
       author = item.event_author if item.respond_to?(:event_author)
       xml.author do
         xml.name(author)
-        xml.email(author.mail) if author.is_a?(User) && !author.mail.blank? && !author.pref.hide_mail
+        xml.email(author.mail) if author.is_a?(User) && author.mail.present? && !author.pref.hide_mail
       end if author
       xml.content "type" => "html" do
         xml.text! textilizable(item, :event_description, :only_path => false)
index 26a067f6cd4f54c4e3c4204d7a915fe94aad77f3..7682a3fa5f43a53c292dea0c4b6a83db1ea936a5 100644 (file)
@@ -18,7 +18,7 @@ xml.feed "xmlns" => "http://www.w3.org/2005/Atom" do
       xml.updated change.created_on.xmlschema
       xml.author do
         xml.name change.user.name
-        xml.email(change.user.mail) if change.user.is_a?(User) && !change.user.mail.blank? && !change.user.pref.hide_mail
+        xml.email(change.user.mail) if change.user.is_a?(User) && change.user.mail.present? && !change.user.pref.hide_mail
       end
       xml.content "type" => "html" do
         xml.text! '<ul>'
index bf1f67aabf78535472d68c5d0833a5c83ab2599e..b7f2433543f60f88aaec52e8cdbd2081016608b8 100644 (file)
@@ -416,7 +416,7 @@ module Redmine
 
     # Returns +true+ if the plugin can be configured.
     def configurable?
-      settings && settings.is_a?(Hash) && !settings[:partial].blank?
+      settings && settings.is_a?(Hash) && settings[:partial].present?
     end
 
     # The directory containing this plugin's migrations (<tt>plugin/db/migrate</tt>)
index 917805e510e7204503df073bca5da623d0b61532..76cbec891800e62ed88159e3e55fac702dca90e2 100644 (file)
@@ -76,7 +76,7 @@ class ProjectCopyTest < ActiveSupport::TestCase
     assert_equal @source_project.issues.size, @project.issues.size
     @project.issues.each do |issue|
       assert issue.valid?
-      assert ! issue.assigned_to.blank?
+      assert issue.assigned_to.present?
       assert_equal @project, issue.project
     end
 
index 3e478e66eebb6a28f1a759d6e933cf2cbe04238f..43a3bf59497c7977007c719bd62b91dc422105d2 100644 (file)
@@ -66,13 +66,13 @@ class ProjectTest < ActiveSupport::TestCase
     end
 
     with_settings :sequential_project_identifiers => '1' do
-      assert !Project.new.identifier.blank?
+      assert Project.new.identifier.present?
       assert Project.new(:identifier => '').identifier.blank?
     end
 
     with_settings :sequential_project_identifiers => '0' do
       assert Project.new.identifier.blank?
-      assert !Project.new(:identifier => 'test').blank?
+      assert Project.new(:identifier => 'test').present?
     end
 
     with_settings :default_projects_modules => ['issue_tracking', 'repository'] do
index b6d9a34efab2cf1e41a2e72a50ff7a6797ce4088..577a7f972d40741f89cbe6743c8fb456f88ab8bd 100644 (file)
@@ -1094,8 +1094,8 @@ class UserTest < ActiveSupport::TestCase
   def test_random_password
     u = User.new
     u.random_password
-    assert !u.password.blank?
-    assert !u.password_confirmation.blank?
+    assert u.password.present?
+    assert u.password_confirmation.present?
   end
 
   def test_random_password_include_required_characters
@@ -1301,7 +1301,7 @@ class UserTest < ActiveSupport::TestCase
 
     user.reload
     # Salt added
-    assert !user.salt.blank?
+    assert user.salt.present?
     # Password still valid
     assert user.check_password?("unsalted")
     assert_equal user, User.try_to_login(user.login, "unsalted")