summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGo MAEDA <maeda@farend.jp>2024-08-12 08:45:54 +0000
committerGo MAEDA <maeda@farend.jp>2024-08-12 08:45:54 +0000
commitb3d1deeece819ee25de1b3168393845780d6c51e (patch)
tree327c50539ec5bc580821764c91cee8c550a6ed8b
parent6e21ae720909f9980e58c9411fb9ed8a81f06833 (diff)
downloadredmine-b3d1deeece819ee25de1b3168393845780d6c51e.tar.gz
redmine-b3d1deeece819ee25de1b3168393845780d6c51e.zip
Fix RuboCop offense Layout/SpaceInsideParens, one of the offenses enabled in rubocop-rails-omakase (#39887).
git-svn-id: https://svn.redmine.org/redmine/trunk@22954 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r--.rubocop_todo.yml15
-rw-r--r--app/helpers/issues_helper.rb2
-rw-r--r--app/models/auth_source_ldap.rb2
-rw-r--r--app/models/repository/cvs.rb2
-rw-r--r--lib/redmine/sudo_mode.rb4
-rw-r--r--lib/redmine/wiki_formatting/textile/formatter.rb6
-rw-r--r--lib/redmine/wiki_formatting/textile/redcloth3.rb274
-rw-r--r--test/unit/changeset_test.rb12
-rw-r--r--test/unit/issue_subtasking_test.rb2
-rw-r--r--test/unit/lib/redmine/export/pdf_test.rb2
10 files changed, 153 insertions, 168 deletions
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index 64cf76967..8ae5f7ffc 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -146,21 +146,6 @@ Layout/SpaceInsideArrayLiteralBrackets:
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle.
-# SupportedStyles: space, compact, no_space
-Layout/SpaceInsideParens:
- Exclude:
- - 'app/helpers/issues_helper.rb'
- - 'app/models/auth_source_ldap.rb'
- - 'app/models/repository/cvs.rb'
- - 'lib/redmine/sudo_mode.rb'
- - 'lib/redmine/wiki_formatting/textile/formatter.rb'
- - 'lib/redmine/wiki_formatting/textile/redcloth3.rb'
- - 'test/unit/changeset_test.rb'
- - 'test/unit/issue_subtasking_test.rb'
- - 'test/unit/lib/redmine/export/pdf_test.rb'
-
-# This cop supports safe autocorrection (--autocorrect).
-# Configuration parameters: EnforcedStyle.
# SupportedStyles: space, no_space
Layout/SpaceInsideStringInterpolation:
Exclude:
diff --git a/app/helpers/issues_helper.rb b/app/helpers/issues_helper.rb
index 4784096ac..5661cf377 100644
--- a/app/helpers/issues_helper.rb
+++ b/app/helpers/issues_helper.rb
@@ -392,7 +392,7 @@ module IssuesHelper
content =
content_tag('hr') +
- content_tag('p', content_tag('strong', custom_field_name_tag(value.custom_field) )) +
+ content_tag('p', content_tag('strong', custom_field_name_tag(value.custom_field))) +
content_tag('div', attr_value_tag, class: 'value')
s << content_tag('div', content, class: "#{value.custom_field.css_classes} attribute")
end
diff --git a/app/models/auth_source_ldap.rb b/app/models/auth_source_ldap.rb
index 1ab96c2d2..9e66affe9 100644
--- a/app/models/auth_source_ldap.rb
+++ b/app/models/auth_source_ldap.rb
@@ -229,7 +229,7 @@ class AuthSourceLdap < AuthSource
end
attrs = {}
search_filter = base_filter & Net::LDAP::Filter.eq(self.attr_login, login)
- ldap_con.search( :base => self.base_dn,
+ ldap_con.search(:base => self.base_dn,
:filter => search_filter,
:attributes=> search_attributes) do |entry|
if onthefly_register?
diff --git a/app/models/repository/cvs.rb b/app/models/repository/cvs.rb
index 6797c1893..45ca9fbe8 100644
--- a/app/models/repository/cvs.rb
+++ b/app/models/repository/cvs.rb
@@ -59,7 +59,7 @@ class Repository::Cvs < Repository
entries = scm.entries(path, rev.nil? ? nil : rev.committed_on)
if entries
entries.each do |entry|
- if ( ! entry.lastrev.nil? ) && ( ! entry.lastrev.revision.nil? )
+ if (! entry.lastrev.nil?) && (! entry.lastrev.revision.nil?)
change =
filechanges.where(
:revision => entry.lastrev.revision,
diff --git a/lib/redmine/sudo_mode.rb b/lib/redmine/sudo_mode.rb
index dd1876f11..39daaeeed 100644
--- a/lib/redmine/sudo_mode.rb
+++ b/lib/redmine/sudo_mode.rb
@@ -121,7 +121,7 @@ module Redmine
# display the sudo password form
def render_sudo_form(param_names)
@sudo_form ||= SudoMode::Form.new
- @sudo_form.original_fields = params.slice( *param_names )
+ @sudo_form.original_fields = params.slice(*param_names)
# a simple 'render "sudo_mode/new"' works when used directly inside an
# action, but not when called from a before_action:
respond_to do |format|
@@ -157,7 +157,7 @@ module Redmine
if controller.api_request?
true
elsif SudoMode.possible? && method_matches
- controller.require_sudo_mode( *parameters )
+ controller.require_sudo_mode(*parameters)
else
true
end
diff --git a/lib/redmine/wiki_formatting/textile/formatter.rb b/lib/redmine/wiki_formatting/textile/formatter.rb
index 35684a6c7..cfb941711 100644
--- a/lib/redmine/wiki_formatting/textile/formatter.rb
+++ b/lib/redmine/wiki_formatting/textile/formatter.rb
@@ -95,13 +95,13 @@ module Redmine
# Patch for RedCloth. Fixed in RedCloth r128 but _why hasn't released it yet.
# <a href="http://code.whytheluckystiff.net/redcloth/changeset/128">http://code.whytheluckystiff.net/redcloth/changeset/128</a>
- def hard_break( text )
- text.gsub!( /(.)\n(?!\n|\Z| *([#*=]+(\s|$)|[{|]))/, "\\1<br />" ) if hard_breaks
+ def hard_break(text)
+ text.gsub!(/(.)\n(?!\n|\Z| *([#*=]+(\s|$)|[{|]))/, "\\1<br />") if hard_breaks
end
alias :smooth_offtags_without_code_highlighting :smooth_offtags
# Patch to add code highlighting support to RedCloth
- def smooth_offtags( text )
+ def smooth_offtags(text)
unless @pre_list.empty?
## replace <pre> content
text.gsub!(/<redpre#(\d+)>/) do
diff --git a/lib/redmine/wiki_formatting/textile/redcloth3.rb b/lib/redmine/wiki_formatting/textile/redcloth3.rb
index 8667b2f09..f6e738786 100644
--- a/lib/redmine/wiki_formatting/textile/redcloth3.rb
+++ b/lib/redmine/wiki_formatting/textile/redcloth3.rb
@@ -254,9 +254,9 @@ class RedCloth3 < String
# r.to_html
# #=>"<h1>A &lt;b&gt;bold&lt;/b&gt; man</h1>"
#
- def initialize( string, restrictions = [] )
- restrictions.each { |r| method( :"#{r}=" ).call( true ) }
- super( string )
+ def initialize(string, restrictions = [])
+ restrictions.each { |r| method(:"#{r}=").call(true) }
+ super(string)
end
#
@@ -266,7 +266,7 @@ class RedCloth3 < String
# r.to_html( true )
# #=>"And then? She <strong>fell</strong>!"
#
- def to_html( *rules )
+ def to_html(*rules)
rules = DEFAULT_RULES if rules.empty?
# make our working copy
text = self.dup
@@ -312,8 +312,8 @@ class RedCloth3 < String
retrieve text
- text.gsub!( /<\/?notextile>/, '' )
- text.gsub!( "x%x%", '&#38;' )
+ text.gsub!(/<\/?notextile>/, '')
+ text.gsub!("x%x%", '&#38;')
clean_html text if filter_html
text.strip!
text
@@ -332,7 +332,7 @@ class RedCloth3 < String
[147, 8220], [148, 8221], [149, 8226], [150, 8211], [151, 8212], [152, 732],
[153, 8482], [154, 353], [155, 8250], [156, 339], [157, 0], [158, 0], [159, 376]].
collect! do |a, b|
- [a.chr, ( b.zero? and "" or "&#{b};" )]
+ [a.chr, (b.zero? and "" or "&#{b};")]
end
#
# Regular expressions to convert to HTML.
@@ -348,9 +348,9 @@ class RedCloth3 < String
S = "(?:#{S_CSPN}?#{S_RSPN}|#{S_RSPN}?#{S_CSPN}?)"
C = "(?:#{C_CLAS}?#{C_STYL}?#{C_LNGE}?|#{C_STYL}?#{C_LNGE}?#{C_CLAS}?|#{C_LNGE}?#{C_STYL}?#{C_CLAS}?)"
# PUNCT = Regexp::quote( '!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~' )
- PUNCT = Regexp::quote( '!"#$%&\'*+,-./:;=?@\\^_`|~' )
- PUNCT_NOQ = Regexp::quote( '!"#$&\',./:;=?@\\`|' )
- PUNCT_Q = Regexp::quote( '*-_+^~%' )
+ PUNCT = Regexp::quote('!"#$%&\'*+,-./:;=?@\\^_`|~')
+ PUNCT_NOQ = Regexp::quote('!"#$&\',./:;=?@\\`|')
+ PUNCT_Q = Regexp::quote('*-_+^~%')
HYPERLINK = '(\S+?)([^\w\s/;=\?]*?)(?=\s|<|$)'
# Text markup tags, don't conflict with block tags
@@ -438,19 +438,19 @@ class RedCloth3 < String
#
# Flexible HTML escaping
#
- def htmlesc( str, mode=:Quotes )
+ def htmlesc(str, mode=:Quotes)
if str
- str.gsub!( '&', '&amp;' )
- str.gsub!( '"', '&quot;' ) if mode != :NoQuotes
- str.gsub!( "'", '&#039;' ) if mode == :Quotes
- str.gsub!( '<', '&lt;')
- str.gsub!( '>', '&gt;')
+ str.gsub!('&', '&amp;')
+ str.gsub!('"', '&quot;') if mode != :NoQuotes
+ str.gsub!("'", '&#039;') if mode == :Quotes
+ str.gsub!('<', '&lt;')
+ str.gsub!('>', '&gt;')
end
str
end
# Search and replace for Textile glyphs (quotes, dashes, other symbols)
- def pgl( text )
+ def pgl(text)
# GLYPHS.each do |re, resub, tog|
# next if tog and method( tog ).call
# text.gsub! re, resub
@@ -461,7 +461,7 @@ class RedCloth3 < String
end
# Parses Textile attribute lists and builds an HTML attribute string
- def pba( text_in, element = "" )
+ def pba(text_in, element = "")
return +'' unless text_in
style = []
@@ -472,21 +472,21 @@ class RedCloth3 < String
style << "vertical-align:#{v_align($&)};" if text =~ A_VLGN
end
- if text.sub!( /\{([^"}]*)\}/, '' ) && !filter_styles
+ if text.sub!(/\{([^"}]*)\}/, '') && !filter_styles
sanitized = sanitize_styles($1)
style << "#{sanitized};" unless sanitized.blank?
end
lang = $1 if
- text.sub!( /\[([a-z\-_]+?)\]/, '' )
+ text.sub!(/\[([a-z\-_]+?)\]/, '')
cls = $1 if
- text.sub!( /\(([^()]+?)\)/, '' )
+ text.sub!(/\(([^()]+?)\)/, '')
style << "padding-left:#{$1.length}em;" if
- text.sub!( /([(]+)/, '' )
+ text.sub!(/([(]+)/, '')
- style << "padding-right:#{$1.length}em;" if text.sub!( /([)]+)/, '' )
+ style << "padding-right:#{$1.length}em;" if text.sub!(/([)]+)/, '')
style << "text-align:#{h_align($&)};" if text =~ A_HLGN
@@ -524,15 +524,15 @@ class RedCloth3 < String
TABLE_RE = /^(?:table(_?#{S}#{A}#{C})\. ?\n)?^(#{A}#{C}\.? ?\|.*?\|)(\n\n|\Z)/m
# Parses a Textile table block, building HTML from the result.
- def block_textile_table( text )
- text.gsub!( TABLE_RE ) do |matches|
+ def block_textile_table(text)
+ text.gsub!(TABLE_RE) do |matches|
tatts, fullrow = $~[1..2]
- tatts = pba( tatts, 'table' )
- tatts = shelve( tatts ) if tatts
+ tatts = pba(tatts, 'table')
+ tatts = shelve(tatts) if tatts
rows = []
fullrow.gsub!(/([^|\s])\s*\n/, "\\1<br />")
fullrow.each_line do |row|
- ratts, row = pba( $1, 'tr' ), $2 if row =~ /^(#{A}#{C}\. )(.*)/mo
+ ratts, row = pba($1, 'tr'), $2 if row =~ /^(#{A}#{C}\. )(.*)/mo
cells = []
# the regexp prevents wiki links with a | from being cut as cells
row.scan(/\|(_?#{S}#{A}#{C}\. ?)?((\[\[[^|\]]*\|[^|\]]*\]\]|[^|])*?)(?=\|)/o) do |modifiers, cell|
@@ -540,12 +540,12 @@ class RedCloth3 < String
ctyp = 'h' if modifiers&.start_with?('_')
catts = nil
- catts = pba( modifiers, 'td' ) if modifiers
+ catts = pba(modifiers, 'td') if modifiers
- catts = shelve( catts ) if catts
+ catts = shelve(catts) if catts
cells << "\t\t\t<t#{ctyp}#{catts}>#{cell}</t#{ctyp}>"
end
- ratts = shelve( ratts ) if ratts
+ ratts = shelve(ratts) if ratts
rows << "\t\t<tr#{ratts}>\n#{cells.join("\n")}\n\t\t</tr>"
end
"\t<table#{tatts}>\n#{rows.join("\n")}\n\t</table>\n\n"
@@ -556,9 +556,9 @@ class RedCloth3 < String
LISTS_CONTENT_RE = /^([#*]+)(#{A}#{C}) (.*)$/m
# Parses Textile lists and generates HTML
- def block_textile_lists( text )
- text.gsub!( LISTS_RE ) do |match|
- lines = match.split( "\n" )
+ def block_textile_lists(text)
+ text.gsub!(LISTS_RE) do |match|
+ lines = match.split("\n")
last_line = -1
depth = []
lines.each_with_index do |line, line_id|
@@ -578,8 +578,8 @@ class RedCloth3 < String
end
if depth.last != tl
depth << tl
- atts = pba( atts )
- atts = shelve( atts ) if atts
+ atts = pba(atts)
+ atts = shelve(atts) if atts
lines[line_id] = +"\t<#{lT(tl)}l#{atts}>\n\t<li>#{content}"
else
lines[line_id] = +"\t\t<li>#{content}"
@@ -594,16 +594,16 @@ class RedCloth3 < String
end
end
end
- lines.join( "\n" )
+ lines.join("\n")
end
end
QUOTES_RE = /(^>+([^\n]*?)(\n|$))+/m
QUOTES_CONTENT_RE = /^([> ]+)(.*)$/m
- def block_textile_quotes( text )
- text.gsub!( QUOTES_RE ) do |match|
- lines = match.split( "\n" )
+ def block_textile_quotes(text)
+ text.gsub!(QUOTES_RE) do |match|
+ lines = match.split("\n")
quotes = +''
indent = 0
lines.each do |line|
@@ -628,26 +628,26 @@ class RedCloth3 < String
@
(?=\W)/x
- def inline_textile_code( text )
- text.gsub!( CODE_RE ) do |m|
+ def inline_textile_code(text)
+ text.gsub!(CODE_RE) do |m|
before, lang, code, after = $~[1..4]
lang = " lang=\"#{lang}\"" if lang
- rip_offtags( +"#{before}<code#{lang}>#{code}</code>#{after}", false )
+ rip_offtags(+"#{before}<code#{lang}>#{code}</code>#{after}", false)
end
end
- def lT( text )
+ def lT(text)
text.end_with?('#') ? 'o' : 'u'
end
- def hard_break( text )
- text.gsub!( /(.)\n(?!\Z| *([#*=]+(\s|$)|[{|]))/, "\\1<br />" ) if hard_breaks
+ def hard_break(text)
+ text.gsub!(/(.)\n(?!\Z| *([#*=]+(\s|$)|[{|]))/, "\\1<br />") if hard_breaks
end
BLOCKS_GROUP_RE = /\n{2,}(?! )/m
- def blocks( text, deep_code = false )
- text.replace( text.split( BLOCKS_GROUP_RE ).collect do |blk|
+ def blocks(text, deep_code = false)
+ text.replace(text.split(BLOCKS_GROUP_RE).collect do |blk|
plain = blk !~ /\A[#*> ]/
# skip blocks that are complex HTML
@@ -660,10 +660,10 @@ class RedCloth3 < String
blk
else
code_blk = nil
- blk.gsub!( /((?:\n(?:\n^ +[^\n]*)+)+)/m ) do |iblk|
+ blk.gsub!(/((?:\n(?:\n^ +[^\n]*)+)+)/m) do |iblk|
flush_left iblk
blocks iblk, plain
- iblk.gsub( /^(\S)/, "\t\\1" )
+ iblk.gsub(/^(\S)/, "\t\\1")
if plain
code_blk = iblk; ""
else
@@ -686,18 +686,18 @@ class RedCloth3 < String
blk + "\n#{code_blk}"
end
end
- end.join( "\n\n" ) )
+ end.join("\n\n"))
end
- def textile_bq( tag, atts, cite, content )
- cite, cite_title = check_refs( cite )
+ def textile_bq(tag, atts, cite, content)
+ cite, cite_title = check_refs(cite)
cite = " cite=\"#{htmlesc cite.dup}\"" if cite
- atts = shelve( atts ) if atts
+ atts = shelve(atts) if atts
"\t<blockquote#{cite}>\n\t\t<p#{atts}>#{content}</p>\n\t</blockquote>"
end
- def textile_p( tag, atts, cite, content )
- atts = shelve( atts ) if atts
+ def textile_p(tag, atts, cite, content)
+ atts = shelve(atts) if atts
"\t<#{tag}#{atts}>#{content}</#{tag}>"
end
@@ -708,38 +708,38 @@ class RedCloth3 < String
alias textile_h5 textile_p
alias textile_h6 textile_p
- def textile_fn_( tag, num, atts, cite, content )
+ def textile_fn_(tag, num, atts, cite, content)
atts << " id=\"fn#{num}\" class=\"footnote\""
content = "<sup>#{num}</sup> #{content}"
- atts = shelve( atts ) if atts
+ atts = shelve(atts) if atts
"\t<p#{atts}>#{content}</p>"
end
BLOCK_RE = /^(([a-z]+)(\d*))(#{A}#{C})\.(?::(\S+))? (.*)$/m
- def block_textile_prefix( text )
+ def block_textile_prefix(text)
if text =~ BLOCK_RE
tag, tagpre, num, atts, cite, content = $~[1..6]
- atts = pba( atts )
+ atts = pba(atts)
# pass to prefix handler
replacement = nil
if respond_to? :"textile_#{tag}", true
- replacement = method( :"textile_#{tag}" ).call( tag, atts, cite, content )
+ replacement = method(:"textile_#{tag}").call(tag, atts, cite, content)
elsif respond_to? :"textile_#{tagpre}_", true
- replacement = method( :"textile_#{tagpre}_" ).call( tagpre, num, atts, cite, content )
+ replacement = method(:"textile_#{tagpre}_").call(tagpre, num, atts, cite, content)
end
- text.gsub!( $& ) { replacement } if replacement
+ text.gsub!($&) { replacement } if replacement
end
end
SETEXT_RE = /\A(.+?)\n([=-])[=-]* *$/m
- def block_markdown_setext( text )
+ def block_markdown_setext(text)
if text =~ SETEXT_RE
tag = ($2 == "=" ? "h1" : "h2")
blk, cont = "<#{tag}>#{$1}</#{tag}>", $'
blocks cont
- text.replace( blk + cont )
+ text.replace(blk + cont)
end
end
@@ -749,44 +749,44 @@ class RedCloth3 < String
[ ]*
\#* # optional closing #'s (not counted)
$/x
- def block_markdown_atx( text )
+ def block_markdown_atx(text)
if text =~ ATX_RE
tag = "h#{$1.length}"
blk, cont = "<#{tag}>#{$2}</#{tag}>\n\n", $'
blocks cont
- text.replace( blk + cont )
+ text.replace(blk + cont)
end
end
MARKDOWN_BQ_RE = /\A(^ *> ?.+$(.+\n)*\n*)+/m
- def block_markdown_bq( text )
- text.gsub!( MARKDOWN_BQ_RE ) do |blk|
- blk.gsub!( /^ *> ?/, '' )
+ def block_markdown_bq(text)
+ text.gsub!(MARKDOWN_BQ_RE) do |blk|
+ blk.gsub!(/^ *> ?/, '')
flush_left blk
blocks blk
- blk.gsub!( /^(\S)/, "\t\\1" )
+ blk.gsub!(/^(\S)/, "\t\\1")
"<blockquote>\n#{blk}\n</blockquote>\n\n"
end
end
MARKDOWN_RULE_RE = /^(#{
- ['*', '-', '_'].collect { |ch| ' ?(' + Regexp::quote( ch ) + ' ?){3,}' }.join( '|' )
+ ['*', '-', '_'].collect { |ch| ' ?(' + Regexp::quote(ch) + ' ?){3,}' }.join('|')
})$/
- def block_markdown_rule( text )
- text.gsub!( MARKDOWN_RULE_RE ) do |blk|
+ def block_markdown_rule(text)
+ text.gsub!(MARKDOWN_RULE_RE) do |blk|
"<hr />"
end
end
# XXX TODO XXX
- def block_markdown_lists( text )
+ def block_markdown_lists(text)
end
- def inline_textile_span( text )
+ def inline_textile_span(text)
QTAGS.each do |qtag_rc, ht, qtag_re, rtype|
- text.gsub!( qtag_re ) do |m|
+ text.gsub!(qtag_re) do |m|
case rtype
when :limit
sta, oqs, qtag, content, oqa = $~[1..6]
@@ -798,8 +798,8 @@ class RedCloth3 < String
qtag, atts, cite, content = $~[1..4]
sta = ''
end
- atts = pba( atts )
- atts = shelve( atts ) if atts
+ atts = pba(atts)
+ atts = shelve(atts) if atts
"#{sta}#{oqs}<#{ht}#{atts}>#{content}</#{ht}>#{oqa}"
end
@@ -825,8 +825,8 @@ class RedCloth3 < String
(?=<|\s|$)
/x
- def inline_textile_link( text )
- text.gsub!( LINK_RE ) do |m|
+ def inline_textile_link(text)
+ text.gsub!(LINK_RE) do |m|
all, pre, atts, text, title, url, proto, slash, post = $~[1..9]
if text.include?('<br />')
all
@@ -860,19 +860,19 @@ class RedCloth3 < String
\[(.*?)\] # $id
/x
- def inline_markdown_reflink( text )
- text.gsub!( MARKDOWN_REFLINK_RE ) do |m|
+ def inline_markdown_reflink(text)
+ text.gsub!(MARKDOWN_REFLINK_RE) do |m|
text, id = $~[1..2]
if id.empty?
- url, title = check_refs( text )
+ url, title = check_refs(text)
else
- url, title = check_refs( id )
+ url, title = check_refs(id)
end
atts = " href=\"#{url}\""
atts << " title=\"#{title}\"" if title
- atts = shelve( atts )
+ atts = shelve(atts)
"<a#{atts}>#{text}</a>"
end
@@ -892,13 +892,13 @@ class RedCloth3 < String
\)
/x
- def inline_markdown_link( text )
- text.gsub!( MARKDOWN_LINK_RE ) do |m|
+ def inline_markdown_link(text)
+ text.gsub!(MARKDOWN_LINK_RE) do |m|
text, url, quote, title = $~[1..4]
atts = " href=\"#{url}\""
atts << " title=\"#{title}\"" if title
- atts = shelve( atts )
+ atts = shelve(atts)
"<a#{atts}>#{text}</a>"
end
@@ -907,22 +907,22 @@ class RedCloth3 < String
TEXTILE_REFS_RE = /(^ *)\[([^\[\n]+?)\](#{HYPERLINK})(?=\s|$)/
MARKDOWN_REFS_RE = /(^ *)\[([^\n]+?)\]:\s+<?(#{HYPERLINK})>?(?:\s+"((?:[^"]|\\")+)")?(?=\s|$)/m
- def refs( text )
+ def refs(text)
@rules.each do |rule_name|
- method( rule_name ).call( text ) if rule_name.to_s.start_with?('refs_')
+ method(rule_name).call(text) if rule_name.to_s.start_with?('refs_')
end
end
- def refs_textile( text )
- text.gsub!( TEXTILE_REFS_RE ) do |m|
+ def refs_textile(text)
+ text.gsub!(TEXTILE_REFS_RE) do |m|
flag, url = $~[2..3]
@urlrefs[flag.downcase] = [url, nil]
nil
end
end
- def refs_markdown( text )
- text.gsub!( MARKDOWN_REFS_RE ) do |m|
+ def refs_markdown(text)
+ text.gsub!(MARKDOWN_REFS_RE) do |m|
flag, url = $~[2..3]
title = $~[6]
@urlrefs[flag.downcase] = [url, title]
@@ -930,7 +930,7 @@ class RedCloth3 < String
end
end
- def check_refs( text )
+ def check_refs(text)
ret = @urlrefs[text.downcase] if text
ret || [text, nil]
end
@@ -948,19 +948,19 @@ class RedCloth3 < String
(?::#{HYPERLINK})? # optional href
/x
- def inline_textile_image( text )
- text.gsub!( IMAGE_RE ) do |m|
+ def inline_textile_image(text)
+ text.gsub!(IMAGE_RE) do |m|
stln, algn, atts, url, title, href, href_a1, href_a2 = $~[1..8]
htmlesc title
- atts = pba( atts )
+ atts = pba(atts)
atts = +" src=\"#{htmlesc url.dup}\"#{atts}"
atts << " title=\"#{title}\"" if title
atts << " alt=\"#{title}\""
# size = @getimagesize($url);
# if($size) $atts.= " $size[3]";
- href, alt_title = check_refs( href ) if href
- url, url_title = check_refs( url )
+ href, alt_title = check_refs(href) if href
+ url, url_title = check_refs(url)
next m unless uri_with_safe_scheme?(url.partition('?').first)
if href
@@ -974,7 +974,7 @@ class RedCloth3 < String
out << "</a>#{href_a1}#{href_a2}" if href
if algn
- algn = h_align( algn )
+ algn = h_align(algn)
if stln == "<p>"
out = "<p style=\"float:#{algn}\">#{out}"
else
@@ -988,47 +988,47 @@ class RedCloth3 < String
end
end
- def shelve( val )
+ def shelve(val)
@shelf << val
" :redsh##{@shelf.length}:"
end
- def retrieve( text )
+ def retrieve(text)
text.gsub!(/ :redsh#(\d+):/) do
@shelf[$1.to_i - 1] || $&
end
end
- def incoming_entities( text )
+ def incoming_entities(text)
## turn any incoming ampersands into a dummy character for now.
## This uses a negative lookahead for alphanumerics followed by a semicolon,
## implying an incoming html entity, to be skipped
- text.gsub!( /&(?![#a-z0-9]+;)/i, "x%x%" )
+ text.gsub!(/&(?![#a-z0-9]+;)/i, "x%x%")
end
- def no_textile( text )
+ def no_textile(text)
text.gsub!(/(^|\s)==([^=]+.*?)==(\s|$)?/,
'\1<notextile>\2</notextile>\3')
text.gsub!(/^ *==([^=]+.*?)==/m,
'\1<notextile>\2</notextile>\3')
end
- def clean_white_space( text )
+ def clean_white_space(text)
# normalize line breaks
- text.gsub!( "\r\n", "\n" )
- text.tr!( "\r", "\n" )
- text.gsub!( "\t", ' ' )
- text.gsub!( /^ +$/, '' )
- text.gsub!( /\n{3,}/, "\n\n" )
- text.gsub!( /"$/, "\" " )
+ text.gsub!("\r\n", "\n")
+ text.tr!("\r", "\n")
+ text.gsub!("\t", ' ')
+ text.gsub!(/^ +$/, '')
+ text.gsub!(/\n{3,}/, "\n\n")
+ text.gsub!(/"$/, "\" ")
# if entire document is indented, flush
# to the left side
flush_left text
end
- def flush_left( text )
+ def flush_left(text)
if /(?![\r\n\t ])[[:cntrl:]]/.match?(text)
text.gsub!(/(?![\r\n\t ])[[:cntrl:]]/, '')
end
@@ -1036,12 +1036,12 @@ class RedCloth3 < String
indt = 0
indt += 1 until /^ {#{indt}}\S/.match?(text)
if indt.nonzero?
- text.gsub!( /^ {#{indt}}/, '' )
+ text.gsub!(/^ {#{indt}}/, '')
end
end
end
- def footnote_ref( text )
+ def footnote_ref(text)
text.gsub!(/(?<=[\p{Word}\]])\[([0-9]+?)\](\s)?/,
'<sup><a href="#fn\1">\1</a></sup>\2')
end
@@ -1053,13 +1053,13 @@ class RedCloth3 < String
HASTAG_MATCH = /(<\/?\w[^\n]*?>)/m
ALLTAG_MATCH = /(<\/?\w[^\n]*?>)|.*?(?=<\/?\w[^\n]*?>|$)/m
- def glyphs_textile( text, level = 0 )
+ def glyphs_textile(text, level = 0)
if text !~ HASTAG_MATCH
pgl text
footnote_ref text
else
codepre = 0
- text.gsub!( ALLTAG_MATCH ) do |line|
+ text.gsub!(ALLTAG_MATCH) do |line|
## matches are off if we're between <code>, <pre> etc.
if $1
if OFFTAG_OPEN.match?(line)
@@ -1069,9 +1069,9 @@ class RedCloth3 < String
codepre = 0 if codepre < 0
end
elsif codepre.zero?
- glyphs_textile( line, level + 1 )
+ glyphs_textile(line, level + 1)
else
- htmlesc( line, :NoQuotes )
+ htmlesc(line, :NoQuotes)
end
# p [level, codepre, line]
@@ -1080,17 +1080,17 @@ class RedCloth3 < String
end
end
- def rip_offtags( text, escape_aftertag=true, escape_line=true )
+ def rip_offtags(text, escape_aftertag=true, escape_line=true)
if text =~ /<.*>/
## strip and encode <pre> content
codepre, used_offtags = 0, {}
- text.gsub!( OFFTAG_MATCH ) do |line|
+ text.gsub!(OFFTAG_MATCH) do |line|
if $3
first, offtag, aftertag = $3, $4, $5
codepre += 1
used_offtags[offtag] = true
if codepre - used_offtags.length > 0
- htmlesc( line, :NoQuotes ) if escape_line
+ htmlesc(line, :NoQuotes) if escape_line
@pre_list.last << line
line = +""
else
@@ -1098,7 +1098,7 @@ class RedCloth3 < String
### Regexp in formatter.rb is : /<code\s+class="(\w+)">\s?(.+)/m
### NB: some changes were made not to use $N variables, because we use "match"
### and it breaks following lines
- htmlesc( aftertag, :NoQuotes ) if aftertag && escape_aftertag && !first.match(/<code\s+class="(\w+)">/)
+ htmlesc(aftertag, :NoQuotes) if aftertag && escape_aftertag && !first.match(/<code\s+class="(\w+)">/)
line = +"<redpre##{@pre_list.length}>"
first =~ /<#{OFFTAGS}([^>]*)>/o
tag = $1
@@ -1108,7 +1108,7 @@ class RedCloth3 < String
end
elsif $1 and codepre > 0
if codepre - used_offtags.length > 0
- htmlesc( line, :NoQuotes ) if escape_line
+ htmlesc(line, :NoQuotes) if escape_line
@pre_list.last << line
line = +""
end
@@ -1121,30 +1121,30 @@ class RedCloth3 < String
text
end
- def smooth_offtags( text )
+ def smooth_offtags(text)
unless @pre_list.empty?
## replace <pre> content
- text.gsub!( /<redpre#(\d+)>/ ) { @pre_list[$1.to_i] }
+ text.gsub!(/<redpre#(\d+)>/) { @pre_list[$1.to_i] }
end
end
- def inline( text )
+ def inline(text)
[/^inline_/, /^glyphs_/].each do |meth_re|
@rules.each do |rule_name|
- method( rule_name ).call( text ) if rule_name.to_s.match( meth_re )
+ method(rule_name).call(text) if rule_name.to_s.match(meth_re)
end
end
end
- def h_align( text )
+ def h_align(text)
H_ALGN_VALS[text]
end
- def v_align( text )
+ def v_align(text)
V_ALGN_VALS[text]
end
- def textile_popup_help( name, windowW, windowH )
+ def textile_popup_help(name, windowW, windowH)
' <a target="_blank" href="http://hobix.com/textile/#' + helpvar + '" onclick="window.open(this.href, \'popupwindow\', \'width=' + windowW + ',height=' + windowH + ',scrollbars,resizable\'); return false;">' + name + '</a><br />'
end
@@ -1183,16 +1183,16 @@ class RedCloth3 < String
'blockquote' => ['cite']
}
- def clean_html( text, tags = BASIC_TAGS )
- text.gsub!( "<![CDATA[", '' )
- text.gsub!( /<(\/*)(\w+)([^>]*)>/ ) do
+ def clean_html(text, tags = BASIC_TAGS)
+ text.gsub!("<![CDATA[", '')
+ text.gsub!(/<(\/*)(\w+)([^>]*)>/) do
raw = $~
tag = raw[2].downcase
if tags.has_key? tag
pcs = [tag]
tags[tag].each do |prop|
['"', "'", ''].each do |q|
- q2 = ( q != '' ? q : '\s' )
+ q2 = (q != '' ? q : '\s')
if raw[3] =~ /#{prop}\s*=\s*#{q}([^#{q2}]+)#{q}/i
attrv = $1
next if prop == 'src' and attrv =~ %r{^(?!http)\w+:}
diff --git a/test/unit/changeset_test.rb b/test/unit/changeset_test.rb
index d108861f1..5a7773afb 100644
--- a/test/unit/changeset_test.rb
+++ b/test/unit/changeset_test.rb
@@ -510,7 +510,7 @@ class ChangesetTest < ActiveSupport::TestCase
:revision => '123',
:scmid => '12345',
:comments => str)
- assert( c.save )
+ assert(c.save)
assert_equal 'Texte encodé en ISO-8859-1.', c.comments
end
@@ -530,7 +530,7 @@ class ChangesetTest < ActiveSupport::TestCase
:scmid => '12345',
:comments => "Texte encod\xE9 en ISO-8859-1.",
:committer => str2)
- assert( c.save )
+ assert(c.save)
assert_equal "Texte encod? en ISO-8859-1.", c.comments
assert_equal "?a?b?c?d?e test", c.committer
end
@@ -550,7 +550,7 @@ class ChangesetTest < ActiveSupport::TestCase
:revision => '123',
:scmid => '12345',
:comments => str)
- assert( c.save )
+ assert(c.save)
assert_equal "test??test??", c.comments
end
@@ -577,7 +577,7 @@ class ChangesetTest < ActiveSupport::TestCase
:revision => '123',
:scmid => '12345',
:comments => s1)
- assert( c.save )
+ assert(c.save)
assert_equal s4, c.comments
end
@@ -628,7 +628,7 @@ class ChangesetTest < ActiveSupport::TestCase
:scmid => '12345',
:comments => nil,
:committer => nil)
- assert( c.save )
+ assert(c.save)
assert_equal "", c.comments
assert_nil c.committer
assert_equal "UTF-8", c.comments.encoding.to_s
@@ -649,7 +649,7 @@ class ChangesetTest < ActiveSupport::TestCase
:scmid => '12345',
:comments => "",
:committer => "")
- assert( c.save )
+ assert(c.save)
assert_equal "", c.comments
assert_equal "", c.committer
assert_equal "UTF-8", c.comments.encoding.to_s
diff --git a/test/unit/issue_subtasking_test.rb b/test/unit/issue_subtasking_test.rb
index 86e9e7708..9e4d22194 100644
--- a/test/unit/issue_subtasking_test.rb
+++ b/test/unit/issue_subtasking_test.rb
@@ -53,7 +53,7 @@ class IssueSubtaskingTest < ActiveSupport::TestCase
with_settings :parent_issue_dates => 'derived' do
parent = Issue.generate!
parent.generate_child!(:start_date => '2010-01-25', :due_date => '2010-02-15')
- parent.generate_child!( :due_date => '2010-02-13')
+ parent.generate_child!(:due_date => '2010-02-13')
parent.generate_child!(:start_date => '2010-02-01', :due_date => '2010-02-22')
parent.reload
assert_equal Date.parse('2010-01-25'), parent.start_date
diff --git a/test/unit/lib/redmine/export/pdf_test.rb b/test/unit/lib/redmine/export/pdf_test.rb
index fe94d00f4..ca978d224 100644
--- a/test/unit/lib/redmine/export/pdf_test.rb
+++ b/test/unit/lib/redmine/export/pdf_test.rb
@@ -59,7 +59,7 @@ class PdfTest < ActiveSupport::TestCase
def test_rdm_pdf_iconv_invalid_utf8_should_be_replaced_ja
str1 = "Texte encod\xE9 en ISO-8859-1"
str2 = "\xe9a\xe9b\xe9c\xe9d\xe9e test".b
- encoding = ( RUBY_PLATFORM == 'java' ? "SJIS" : "CP932" )
+ encoding = (RUBY_PLATFORM == 'java' ? "SJIS" : "CP932")
txt_1 = Redmine::Export::PDF::RDMPdfEncoding::rdm_from_utf8(str1, encoding)
txt_2 = Redmine::Export::PDF::RDMPdfEncoding::rdm_from_utf8(str2, encoding)
assert_equal "ASCII-8BIT", txt_1.encoding.to_s