|
@@ -89,9 +89,8 @@ task :clean do
|
|
end
|
|
end
|
|
|
|
|
|
task :lint do
|
|
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|
|
|
twee_source.lines.each_with_index do |line, lineno|
|
|
lineno += 1
|
|
lineno += 1
|
|
line
|
|
line
|
|
@@ -106,12 +105,12 @@ task :lint do
|
|
# no problem
|
|
# no problem
|
|
text, dest = link.split('->')
|
|
text, dest = link.split('->')
|
|
else
|
|
else
|
|
- puts("link contains multiple -> definitely a problem")
|
|
|
|
|
|
+ warn("link contains multiple -> definitely a problem")
|
|
next
|
|
next
|
|
end
|
|
end
|
|
if text.start_with?('\'')
|
|
if text.start_with?('\'')
|
|
if !text.end_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
|
|
next
|
|
end
|
|
end
|
|
text = text[1..-2]
|
|
text = text[1..-2]
|
|
@@ -120,12 +119,12 @@ task :lint do
|
|
.map {Regexp.last_match.offset(0)[0]}
|
|
.map {Regexp.last_match.offset(0)[0]}
|
|
.each do |offset|
|
|
.each do |offset|
|
|
if text[offset - 1] != '\\'
|
|
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
|
|
end
|
|
end
|
|
elsif text.start_with?('"')
|
|
elsif text.start_with?('"')
|
|
if !text.end_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
|
|
next
|
|
end
|
|
end
|
|
text = text[1..-2]
|
|
text = text[1..-2]
|
|
@@ -134,11 +133,11 @@ task :lint do
|
|
.map {Regexp.last_match.offset(0)[0]}
|
|
.map {Regexp.last_match.offset(0)[0]}
|
|
.each do |offset|
|
|
.each do |offset|
|
|
if text[offset - 1] != '\\'
|
|
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
|
|
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
|
|
end
|
|
end
|
|
end
|