Pārlūkot izejas kodu

Fix bugs/refactor lint a little bit

Ruduki2 5 gadi atpakaļ
vecāks
revīzija
5d43289588
1 mainītis faili ar 9 papildinājumiem un 10 dzēšanām
  1. 9 10
      Rakefile

+ 9 - 10
Rakefile

@@ -89,9 +89,8 @@ task :clean do
 end
 
 task :lint do
-  FILES.each do |short_name, long_name|
-    filename = "#{short_name}.tw2"
-    twee_source = IO.read(filename)
+  files.each do |file|
+    twee_source = IO.read(file.source_file)
     twee_source.lines.each_with_index do |line, lineno|
       lineno += 1
       line
@@ -106,12 +105,12 @@ task :lint do
           # no problem
           text, dest = link.split('->')
         else
-          puts("link contains multiple -> definitely a problem")
+          warn("link contains multiple -> definitely a problem")
           next
         end
         if text.start_with?('\'')
           if !text.end_with?('\'')
-            puts("#{filename}:#{lineno} link text (#{text.inspect}) does not end with single quote despite starting with one")
+            warn "#{file.source_file}:#{lineno} link text (#{text.inspect}) does not end with single quote despite starting with one"
             next
           end
           text = text[1..-2]
@@ -120,12 +119,12 @@ task :lint do
           .map {Regexp.last_match.offset(0)[0]}
           .each do |offset|
             if text[offset - 1] != '\\'
-              puts "#{filename}:#{lineno} link text (#{text.inspect}) contains unquoted single quote in body"
+              warn "#{file.source_file}:#{lineno} link text (#{text.inspect}) contains unquoted single quote in body"
             end
           end
         elsif text.start_with?('"')
           if !text.end_with?('"')
-            puts("#{filename}:#{lineno} link text (#{text.inspect}) does not end with double quote despite starting with one")
+            warn "#{file.source_file}:#{lineno} link text (#{text.inspect}) does not end with double quote despite starting with one"
             next
           end
           text = text[1..-2]
@@ -134,11 +133,11 @@ task :lint do
           .map {Regexp.last_match.offset(0)[0]}
           .each do |offset|
             if text[offset - 1] != '\\'
-              puts "#{filename}:#{lineno} link text (#{text.inspect}) contains unquoted double quote in body"
+              warn "#{file.source_file}:#{lineno} link text (#{text.inspect}) contains unquoted double quote in body"
             end
           end
-        elsif text =~ /\A[\[\]'"\\]*\Z/
-          puts "#{filename}:#{lineno} link text (#{text.inspect}) contains special characters but is not quoted with single or double quotes"
+        elsif text =~ /\A[\[\]'"\\]*\z/
+          warn "#{file.source_file}:#{lineno} link text (#{text.inspect}) contains special characters but is not quoted with single or double quotes"
         end
       end
     end