Patch #7770 ยป code_cleanup_ifnot_unless.diff
| app/controllers/application_controller.rb | ||
|---|---|---|
| 109 | 109 |
end |
| 110 | 110 |
if lang.nil? && request.env['HTTP_ACCEPT_LANGUAGE'] |
| 111 | 111 |
accept_lang = parse_qvalues(request.env['HTTP_ACCEPT_LANGUAGE']).first |
| 112 |
if !accept_lang.blank?
|
|
| 112 |
unless accept_lang.blank?
|
|
| 113 | 113 |
accept_lang = accept_lang.downcase |
| 114 | 114 |
lang = find_language(accept_lang) || find_language(accept_lang.split('-').first)
|
| 115 | 115 |
end |
| ... | ... | |
| 119 | 119 |
end |
| 120 | 120 |
|
| 121 | 121 |
def require_login |
| 122 |
if !User.current.logged?
|
|
| 122 |
unless User.current.logged?
|
|
| 123 | 123 |
# Extract only the basic url parameters on non-GET requests |
| 124 | 124 |
if request.get? |
| 125 | 125 |
url = url_for(params) |
| ... | ... | |
| 140 | 140 | |
| 141 | 141 |
def require_admin |
| 142 | 142 |
return unless require_login |
| 143 |
if !User.current.admin?
|
|
| 143 |
unless User.current.admin?
|
|
| 144 | 144 |
render_403 |
| 145 | 145 |
return false |
| 146 | 146 |
end |
| ... | ... | |
| 258 | 258 | |
| 259 | 259 |
def redirect_back_or_default(default) |
| 260 | 260 |
back_url = CGI.unescape(params[:back_url].to_s) |
| 261 |
if !back_url.blank?
|
|
| 261 |
unless back_url.blank?
|
|
| 262 | 262 |
begin |
| 263 | 263 |
uri = URI.parse(back_url) |
| 264 | 264 |
# do not redirect user to another host or to the login or register page |
| app/controllers/messages_controller.rb | ||
|---|---|---|
| 74 | 74 |
@reply.author = User.current |
| 75 | 75 |
@reply.board = @board |
| 76 | 76 |
@topic.children << @reply |
| 77 |
if !@reply.new_record?
|
|
| 77 |
unless @reply.new_record?
|
|
| 78 | 78 |
call_hook(:controller_messages_reply_after_save, { :params => params, :message => @reply})
|
| 79 | 79 |
attachments = Attachment.attach_files(@reply, params[:attachments]) |
| 80 | 80 |
render_attachment_warning_if_needed(@reply) |
| app/controllers/search_controller.rb | ||
|---|---|---|
| 65 | 65 |
# tokens must be at least 2 characters long |
| 66 | 66 |
@tokens = @tokens.uniq.select {|w| w.length > 1 }
|
| 67 | 67 |
|
| 68 |
if !@tokens.empty?
|
|
| 68 |
unless @tokens.empty?
|
|
| 69 | 69 |
# no more than 5 tokens to search for |
| 70 | 70 |
@tokens.slice! 5..-1 if @tokens.size > 5 |
| 71 | 71 |
|
| app/helpers/application_helper.rb | ||
|---|---|---|
| 484 | 484 |
s = StringScanner.new(text) |
| 485 | 485 |
tags = [] |
| 486 | 486 |
parsed = '' |
| 487 |
while !s.eos?
|
|
| 487 |
until s.eos?
|
|
| 488 | 488 |
s.scan(/(.*?)(<(\/)?(pre|code)(.*?)>|\z)/im) |
| 489 | 489 |
text, full_tag, closing, tag = s[1], s[2], s[3], s[4] |
| 490 | 490 |
if tags.empty? |
| app/helpers/journals_helper.rb | ||
|---|---|---|
| 20 | 20 |
content = '' |
| 21 | 21 |
editable = User.current.logged? && (User.current.allowed_to?(:edit_issue_notes, issue.project) || (journal.user == User.current && User.current.allowed_to?(:edit_own_issue_notes, issue.project))) |
| 22 | 22 |
links = [] |
| 23 |
if !journal.notes.blank?
|
|
| 23 |
unless journal.notes.blank?
|
|
| 24 | 24 |
links << link_to_remote(image_tag('comment.png'),
|
| 25 |
{ :url => {:controller => 'journals', :action => 'new', :id => issue, :journal_id => journal} },
|
|
| 25 |
{ :url => { :controller => 'journals',
|
|
| 26 |
:action => 'new', |
|
| 27 |
:id => issue, |
|
| 28 |
:journal_id => journal} }, |
|
| 26 | 29 |
:title => l(:button_quote)) if options[:reply_links] |
| 27 |
links << link_to_in_place_notes_editor(image_tag('edit.png'), "journal-#{journal.id}-notes",
|
|
| 28 |
{ :controller => 'journals', :action => 'edit', :id => journal },
|
|
| 29 |
:title => l(:button_edit)) if editable |
|
| 30 |
links << link_to_in_place_notes_editor(image_tag('edit.png'),
|
|
| 31 |
"journal-#{journal.id}-notes",
|
|
| 32 |
{ :controller => 'journals',
|
|
| 33 |
:action => 'edit', |
|
| 34 |
:id => journal }, |
|
| 35 |
:title => l(:button_edit)) if editable |
|
| 30 | 36 |
end |
| 31 | 37 |
content << content_tag('div', links.join(' '), :class => 'contextual') unless links.empty?
|
| 32 | 38 |
content << textilizable(journal, :notes) |
| app/helpers/repositories_helper.rb | ||
|---|---|---|
| 47 | 47 |
case change.action |
| 48 | 48 |
when 'A' |
| 49 | 49 |
# Detects moved/copied files |
| 50 |
if !change.from_path.blank?
|
|
| 50 |
unless change.from_path.blank?
|
|
| 51 | 51 |
change.action = @changeset.changes.detect {|c| c.action == 'D' && c.path == change.from_path} ? 'R' : 'C'
|
| 52 | 52 |
end |
| 53 | 53 |
change |
| ... | ... | |
| 141 | 141 |
def replace_invalid_utf8(str) |
| 142 | 142 |
if str.respond_to?(:force_encoding) |
| 143 | 143 |
str.force_encoding('UTF-8')
|
| 144 |
if ! str.valid_encoding? |
|
| 145 |
str = str.encode("US-ASCII", :invalid => :replace,
|
|
| 146 |
:undef => :replace, :replace => '?').encode("UTF-8")
|
|
| 144 |
unless str.valid_encoding? |
|
| 145 |
str = str.encode("US-ASCII", :invalid => :replace, :undef => :replace, :replace => '?').encode("UTF-8")
|
|
| 147 | 146 |
end |
| 148 | 147 |
end |
| 149 | 148 |
str |
| app/models/auth_source_ldap.rb | ||
|---|---|---|
| 123 | 123 |
end |
| 124 | 124 |
|
| 125 | 125 |
def self.get_attr(entry, attr_name) |
| 126 |
if !attr_name.blank?
|
|
| 126 |
unless attr_name.blank?
|
|
| 127 | 127 |
entry[attr_name].is_a?(Array) ? entry[attr_name].first : entry[attr_name] |
| 128 | 128 |
end |
| 129 | 129 |
end |
| app/models/changeset.rb | ||
|---|---|---|
| 255 | 255 |
end |
| 256 | 256 |
if str.respond_to?(:force_encoding) |
| 257 | 257 |
str.force_encoding('UTF-8')
|
| 258 |
if ! str.valid_encoding?
|
|
| 258 |
unless str.valid_encoding?
|
|
| 259 | 259 |
str = str.encode("US-ASCII", :invalid => :replace,
|
| 260 | 260 |
:undef => :replace, :replace => '?').encode("UTF-8")
|
| 261 | 261 |
end |
| app/models/user.rb | ||
|---|---|---|
| 117 | 117 |
user = find_by_login(login) |
| 118 | 118 |
if user |
| 119 | 119 |
# user is already in local database |
| 120 |
return nil if !user.active?
|
|
| 120 |
return nil unless user.active?
|
|
| 121 | 121 |
if user.auth_source |
| 122 | 122 |
# user has an external authentication method |
| 123 | 123 |
return nil unless user.auth_source.authenticate(login, password) |
| app/views/context_menus/issues.html.erb | ||
|---|---|---|
| 96 | 96 |
</li> |
| 97 | 97 |
<% end %> |
| 98 | 98 | |
| 99 |
<% if !@issue.nil? %>
|
|
| 99 |
<% unless @issue.nil? %>
|
|
| 100 | 100 |
<% if @can[:log_time] -%> |
| 101 | 101 |
<li><%= context_menu_link l(:button_log_time), {:controller => 'timelog', :action => 'new', :issue_id => @issue},
|
| 102 | 102 |
:class => 'icon-time-add' %></li> |
| app/views/projects/show.rhtml | ||
|---|---|---|
| 17 | 17 |
<%= @subprojects.collect{|p| link_to(h(p), :action => 'show', :id => p)}.join(", ") %></li>
|
| 18 | 18 |
<% end %> |
| 19 | 19 |
<% @project.visible_custom_field_values.each do |custom_value| %> |
| 20 |
<% if !custom_value.value.blank? %>
|
|
| 21 |
<li><%= custom_value.custom_field.name%>: <%=h show_value(custom_value) %></li> |
|
| 22 |
<% end %> |
|
| 20 |
<% unless custom_value.value.blank? %>
|
|
| 21 |
<li><%= custom_value.custom_field.name%>: <%=h show_value(custom_value) %></li>
|
|
| 22 |
<% end %>
|
|
| 23 | 23 |
<% end %> |
| 24 | 24 |
</ul> |
| 25 | 25 | |
| app/views/users/show.rhtml | ||
|---|---|---|
| 10 | 10 |
<li><%=l(:field_mail)%>: <%= mail_to(h(@user.mail), nil, :encode => 'javascript') %></li> |
| 11 | 11 |
<% end %> |
| 12 | 12 |
<% @user.visible_custom_field_values.each do |custom_value| %> |
| 13 |
<% if !custom_value.value.blank? %>
|
|
| 14 |
<li><%=h custom_value.custom_field.name%>: <%=h show_value(custom_value) %></li>
|
|
| 15 |
<% end %> |
|
| 13 |
<% unless custom_value.value.blank? %>
|
|
| 14 |
<li><%=h custom_value.custom_field.name%>: <%=h show_value(custom_value) %></li>
|
|
| 15 |
<% end %>
|
|
| 16 | 16 |
<% end %> |
| 17 | 17 |
<li><%=l(:label_registered_on)%>: <%= format_date(@user.created_on) %></li> |
| 18 | 18 |
<% unless @user.last_login_on.nil? %> |
| app/views/versions/_overview.rhtml | ||
|---|---|---|
| 7 | 7 |
<p><%=h version.description %></p> |
| 8 | 8 |
<ul> |
| 9 | 9 |
<% version.custom_values.each do |custom_value| %> |
| 10 |
<% if !custom_value.value.blank? %>
|
|
| 10 |
<% unless custom_value.value.blank? %>
|
|
| 11 | 11 |
<li><%=h custom_value.custom_field.name %>: <%=h show_value(custom_value) %></li> |
| 12 | 12 |
<% end %> |
| 13 | 13 |
<% end %> |
| lib/redmine/about.rb | ||
|---|---|---|
| 3 | 3 |
def self.print_plugin_info |
| 4 | 4 |
plugins = Redmine::Plugin.registered_plugins |
| 5 | 5 | |
| 6 |
if !plugins.empty?
|
|
| 6 |
unless plugins.empty?
|
|
| 7 | 7 |
column_with = plugins.map {|internal_name, plugin| plugin.name.length}.max
|
| 8 | 8 |
puts "\nAbout your Redmine plugins" |
| 9 | 9 | |
| lib/redmine/scm/adapters/git_adapter.rb | ||
|---|---|---|
| 164 | 164 |
from_to = "" |
| 165 | 165 |
from_to << "#{identifier_from}.." if identifier_from
|
| 166 | 166 |
from_to << "#{identifier_to}" if identifier_to
|
| 167 |
cmd_args << from_to if !from_to.empty?
|
|
| 167 |
cmd_args << from_to unless from_to.empty?
|
|
| 168 | 168 |
cmd_args << "--since=#{options[:since].strftime("%Y-%m-%d %H:%M:%S")}" if options[:since]
|
| 169 | 169 |
cmd_args << "--" << path if path && !path.empty? |
| 170 | 170 | |
| lib/tasks/migrate_from_trac.rake | ||
|---|---|---|
| 229 | 229 |
return User.anonymous if username.blank? |
| 230 | 230 | |
| 231 | 231 |
u = User.find_by_login(username) |
| 232 |
if !u
|
|
| 232 |
unless u
|
|
| 233 | 233 |
# Create a new user if not found |
| 234 | 234 |
mail = username[0,limit_for(User, 'mail')] |
| 235 | 235 |
if mail_attr = TracSessionAttribute.find_by_sid_and_name(username, 'email') |