mirror of
https://github.com/meineerde/redmine.git
synced 2026-02-03 23:53:23 +00:00
Fix RuboCop offense Style/InverseMethods: Use present? instead of inverting blank? (#37248).
git-svn-id: https://svn.redmine.org/redmine/trunk@22152 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
f27de35338
commit
32d2b1c42f
@ -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
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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])
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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>'
|
||||
|
||||
@ -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>)
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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")
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user