[Hiki-dev] Ruby 1.8 の warning 対策

Back to archive index

yowa yowak****@cool*****
2003年 7月 4日 (金) 17:34:22 JST


ょゎです。

Ruby 1.8 で warning が出る部分を変更してみました。パッチを添付します。

$ find . -name "*.rb" -exec ruby-1.8 -wc \{\} \;
でチェックしたので、構文以外は見落してると思います。

[変更点]
 * いろいろ: 引数カッコの前の空白を削除
 * misc/plugin/todo.rb: #{\"foo\" ...}  ->  #{'foo' ...}  
 * hiki/algorithm/diff.rb: foo *ary  ->  foo(*ary)

------------------------------
ょゎ <mailto:yowak****@cool*****> 
     <http://yowaken.dip.jp/>
-------------- next part --------------
Index: hiki/command.rb
===================================================================
RCS file: /cvsroot/hiki/hiki/hiki/command.rb,v
retrieving revision 1.4.2.27
diff -u -r1.4.2.27 command.rb
--- hiki/command.rb	27 Jun 2003 13:12:43 -0000	1.4.2.27
+++ hiki/command.rb	4 Jul 2003 08:31:48 -0000
@@ -136,8 +136,8 @@
       formatter = HikiFormatter::new( tokens, @db, @plugin )
       contents, toc = formatter.to_s, formatter.toc
 
-      @db.set_references ( @p, formatter.references )
-      @db.increment_hitcount ( @p )
+      @db.set_references( @p, formatter.references )
+      @db.increment_hitcount( @p )
       ref =****@db*****_references( @p )
       
       data = Hiki::Util::get_common_data( @db, @plugin )
@@ -147,7 +147,7 @@
       
       data[:page_title]   = ('<br>' +****@plugi*****_anchor( @p.escape, @p.escapeHTML )).sanitize
       data[:view_title]   = view_title( pg_title.unescapeHTML ).sanitize
-      data[:title]        = title ( pg_title )
+      data[:title]        = title( pg_title )
       data[:toc]          =****@plugi*****_f ? toc.sanitize : nil
       data[:body]         = formatter.apply_tdiary_theme(contents).sanitize
       data[:references]   = ref.collect! {|a| "[#{@plugin.hiki_anchor(a.escape, @plugin.page_name(a))}] " }.join.sanitize
@@ -226,7 +226,7 @@
       elsif @cmd == 'conflict'
         t =****@db*****( page ) || ''
         d = diff_t( t, text.gsub!(/\r/, '') )
-        differ = HikiFormatter::diff ( d )
+        differ = HikiFormatter::diff( d )
         link =****@plugi*****_anchor( page.escape, page.escapeHTML )
       end
       
@@ -372,7 +372,7 @@
         @cmd = 'edit'
 
         if****@db*****?(@p)
-          s =****@db***** ( @p )
+          s =****@db*****( @p )
           cmd_edit( @p, s, msg_already_exist )
         else
           @db.touch( @p )
Index: hiki/interwiki.rb
===================================================================
RCS file: /cvsroot/hiki/hiki/hiki/interwiki.rb,v
retrieving revision 1.3.2.5
diff -u -r1.3.2.5 interwiki.rb
--- hiki/interwiki.rb	31 May 2003 10:13:01 -0000	1.3.2.5
+++ hiki/interwiki.rb	4 Jul 2003 08:31:48 -0000
@@ -19,7 +19,7 @@
     end
 
     def interwiki(s, p)
-      if @interwiki_names.has_key? (s)
+      if @interwiki_names.has_key?(s)
         encoding = @interwiki_names[s][:encoding]
         page = case encoding
                when 'sjis'
@@ -44,7 +44,7 @@
 
     def outer_alias(s)
       a = nil
-      if @interwiki_names.has_key? (s)
+      if @interwiki_names.has_key?(s)
         if @interwiki_names[s][:encoding] == 'alias'
           a =****@plugi*****_anchor(@interwiki_names[s][:url], s.escapeHTML)
         end
Index: hiki/storage.rb
===================================================================
RCS file: /cvsroot/hiki/hiki/hiki/storage.rb,v
retrieving revision 1.2.2.4
diff -u -r1.2.2.4 storage.rb
--- hiki/storage.rb	27 Jun 2003 13:12:43 -0000	1.2.2.4
+++ hiki/storage.rb	4 Jul 2003 08:31:48 -0000
@@ -49,8 +49,8 @@
       end
     end
     
-    def md5hex ( page )
-      s = load ( page )
+    def md5hex( page )
+      s = load( page )
       MD5.new( s || '' ).hexdigest
     end
 
@@ -58,7 +58,7 @@
       latest = (f = load( page )) ? f : ''
 
       if backup_exist?( page )
-        old = load_backup ( page )
+        old = load_backup( page )
       else
         old = ''
       end
Index: hiki/util.rb
===================================================================
RCS file: /cvsroot/hiki/hiki/hiki/util.rb,v
retrieving revision 1.5.2.19
diff -u -r1.5.2.19 util.rb
--- hiki/util.rb	27 Jun 2003 13:12:43 -0000	1.5.2.19
+++ hiki/util.rb	4 Jul 2003 08:31:48 -0000
@@ -53,7 +53,7 @@
     def csv_split( source, delimiter = ',' )
       status = :IN_FIELD
       csv = []
-      csv.push (last = "")
+      csv.push(last = "")
       while !source.empty?
         case status
         when :IN_FIELD
Index: hiki/algorithm/diff.rb
===================================================================
RCS file: /cvsroot/hiki/hiki/hiki/algorithm/diff.rb,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 diff.rb
--- hiki/algorithm/diff.rb	22 Feb 2003 04:39:31 -0000	1.1.1.1
+++ hiki/algorithm/diff.rb	4 Jul 2003 08:31:48 -0000
@@ -195,7 +195,7 @@
 	if kindofstring
 	  newary << elements
 	else
-	  newary.push *elements
+	  newary.push(*elements)
 	end
 	bi += elements.length
       else
Index: hiki/db/flatfile.rb
===================================================================
RCS file: /cvsroot/hiki/hiki/hiki/db/flatfile.rb,v
retrieving revision 1.2.2.8
diff -u -r1.2.2.8 flatfile.rb
--- hiki/db/flatfile.rb	27 Jun 2003 13:12:44 -0000	1.2.2.8
+++ hiki/db/flatfile.rb	4 Jul 2003 08:31:49 -0000
@@ -42,7 +42,7 @@
     end
     
     def touch( page )
-      create_info_default( page ) unless info_exist? ( page )
+      create_info_default( page ) unless info_exist?( page )
       filename = textdir( page )
       File::open( filename, "w" ) {|f|}
     end
Index: misc/plugin/todo.rb
===================================================================
RCS file: /cvsroot/hiki/hiki/misc/plugin/todo.rb,v
retrieving revision 1.4
diff -u -r1.4 todo.rb
--- misc/plugin/todo.rb	23 Feb 2003 02:20:08 -0000	1.4
+++ misc/plugin/todo.rb	4 Jul 2003 08:31:49 -0000
@@ -17,7 +17,7 @@
   c = 0
   todo_list.each do |t|
     break if (c += 1) > num
-    s << "#{\"%02d\" % t[:priority]} #{t[:todo].escapeHTML}<br>\n"
+    s << "#{'%02d' % t[:priority]} #{t[:todo].escapeHTML}<br>\n"
   end
   s
 end
Index: style/default/parser.rb
===================================================================
RCS file: /cvsroot/hiki/hiki/style/default/Attic/parser.rb,v
retrieving revision 1.1.2.9
diff -u -r1.1.2.9 parser.rb
--- style/default/parser.rb	22 Jun 2003 06:56:22 -0000	1.1.2.9
+++ style/default/parser.rb	4 Jul 2003 08:31:49 -0000
@@ -66,7 +66,7 @@
       @last_blocktype.clear
 
       s.each do |line|
-        line.sub! ( /[\n\r]+\z/, '')
+        line.sub!( /[\n\r]+\z/, '')
         case line
         when /^(\!{1,5})(.+)$/
           @cur_stack.push( {:e => :heading_open, :lv => $1.size} )
@@ -114,7 +114,7 @@
           @cur_stack.push( {:e => :table_row_open} )
           $1.split( /\|\|/ ).each do |s|
             @cur_stack.push( {:e => :table_data_open} )
-            inline (s)
+            inline(s)
             @cur_stack.push( {:e => :table_data_close} )
           end
           @cur_stack.push( {:e => :table_row_close} )
@@ -135,34 +135,34 @@
         case str
         when STRONG_RE
           if a.index( :strong_close )
-            @cur_stack.push ( {:e => :strong_close} )
+            @cur_stack.push( {:e => :strong_close} )
             a.delete( :strong_close )
           else
-            @cur_stack.push ( {:e => :strong_open} )
+            @cur_stack.push( {:e => :strong_open} )
             a << :strong_close
           end
           str = $'
         when EMPHASIS_RE
           if a.index( :emphasis_close )
-            @cur_stack.push ( {:e => :emphasis_close} )
+            @cur_stack.push( {:e => :emphasis_close} )
             a.delete( :emphasis_close )
           else
-            @cur_stack.push ( {:e => :emphasis_open} )
+            @cur_stack.push( {:e => :emphasis_open} )
             a << :emphasis_close
           end
           str = $'
         when DELETE_RE
           if a.index( :delete_close )
-            @cur_stack.push ( {:e => :delete_close} )
+            @cur_stack.push( {:e => :delete_close} )
             a.delete( :delete_close )
           else
-            @cur_stack.push ( {:e => :delete_open} )
+            @cur_stack.push( {:e => :delete_open} )
             a << :delete_close
           end
           str = $'
         when REF2_RE
           str = $'
-          @cur_stack.push ( {:e => :wikiname, :s => $1} )
+          @cur_stack.push( {:e => :wikiname, :s => $1} )
         when REF1_RE
           href = $2
           s    = $1
@@ -170,9 +170,9 @@
           match_pattern = $&
           
           if IMAGE_RE =~ href
-            @cur_stack.push ( {:e => :image, :href => href.escapeHTML, :s => s} )
+            @cur_stack.push( {:e => :image, :href => href.escapeHTML, :s => s} )
           else
-            @cur_stack.push ( {:e => :reference, :href => href.escapeHTML, :s => s} )
+            @cur_stack.push( {:e => :reference, :href => href.escapeHTML, :s => s} )
           end
         when INTERWIKI_RE
           url = "#{$1}:#{$2}"
@@ -181,41 +181,41 @@
           str  = $'
           
           if URL_RE =~ url and IMAGE_RE =~ url
-            @cur_stack.push ( {:e => :image, :href => url.escapeHTML, :s => File.basename(url)} )
+            @cur_stack.push( {:e => :image, :href => url.escapeHTML, :s => File.basename(url)} )
           else
-            @cur_stack.push ( {:e => :interwiki, :href => href, :s => s} )
+            @cur_stack.push( {:e => :interwiki, :href => href, :s => s} )
           end
         when URL_RE
           href = $&
           str  = $'
-          @cur_stack.push ( {:e => :reference, :href => href, :s => href} )
+          @cur_stack.push( {:e => :reference, :href => href, :s => href} )
         when PLUGIN_RE
           if $use_plugin
             @cur_stack.push( {:e => :inline_plugin, :method => $1, :param => $2} )
             str = $'
           else
-            @cur_stack.push ( {:e => :normal_text, :s => str} )
+            @cur_stack.push( {:e => :normal_text, :s => str} )
             str = ''
           end
         when WIKINAME_RE
           str = ($2 || '') + $'
-          @cur_stack.push ( {:e => :wikiname, :s => $1} )
+          @cur_stack.push( {:e => :wikiname, :s => $1} )
         when NORMAL_TEXT_RE
           m = $&
           after = $'
           if /([^a-zA-Z\d]+)((?:#{WIKINAME})|(?:#{URL}))/ =~ m
-            @cur_stack.push ( {:e => :normal_text, :s => $` + $1} )
+            @cur_stack.push( {:e => :normal_text, :s => $` + $1} )
             str = $2 + $' + after
           else
-            @cur_stack.push ( {:e => :normal_text, :s => m} )
+            @cur_stack.push( {:e => :normal_text, :s => m} )
             str = after
           end
         else
           if /^(.+?)([#{SPECIAL}])/ =~ str
-            @cur_stack.push ( {:e => :normal_text, :s => $1} )
+            @cur_stack.push( {:e => :normal_text, :s => $1} )
             str = $2 + $'
           else
-            @cur_stack.push ( {:e => :normal_text, :s => str} )
+            @cur_stack.push( {:e => :normal_text, :s => str} )
             str = ''
           end
         end
@@ -234,15 +234,15 @@
         case type
         when :horizontal_rule, :plugin
           close_blocks( ns, block_level )
-          ns.push ( e )
+          ns.push( e )
         when :heading_open
           close_blocks( ns, block_level )
           e[:e] = "heading#{e[:lv]}_open".intern
-          ns.push ( e )
+          ns.push( e )
           @last_blocktype.push type
         when :heading_close
           e[:e] = "heading#{e[:lv]}_close".intern
-          ns.push ( e )
+          ns.push( e )
           @last_blocktype.clear
         when :empty
           close_blocks( ns, block_level )
@@ -263,10 +263,10 @@
           block_level[type] = cur_lv
         when :listitem_open
           @last_blocktype.push type
-          ns.push ( e )
+          ns.push( e )
         when :listitem_close
           @last_blocktype.delete_at(@last_blocktype.rindex(:listitem_open)) if @last_blocktype.rindex(:listitem_open)
-          ns.push ( e )
+          ns.push( e )
         when :blockquote
           if !@last_blocktype.index(type)
             close_blocks( ns, block_level )
@@ -307,7 +307,7 @@
             @last_blocktype.push type
           end
         when :emphasis_close, :strong_close, :delete_close
-          ns.push ( e )
+          ns.push( e )
         else
           if (@last_blocktype.index(:pre) || @last_blocktype.index(:blockquote) ||
              (@last_blocktype.index(:list_item) && last_type == :list_item_close) ||
@@ -322,7 +322,7 @@
             ns.push( {:e => :p_open} )
             @last_blocktype.push :p
           end
-          ns.push ( e )
+          ns.push( e )
         end
 
         last_type = e[:e]


Hiki-dev メーリングリストの案内
Back to archive index