Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

ansi color

  • Loading branch information...
commit 5acc039c7b188286f470cc398db0858e5f6150ae 1 parent 422bf10
Kyle Maxwell authored
Showing with 8 additions and 4 deletions.
  1. +8 −4 style
View
12 style
@@ -12,17 +12,21 @@ while name = STDIN.gets
name.strip!
if name =~ /scala$/
lines = File.open(name).map(&:chomp)
-
+
+
+ packages = lines.yoink!{|line| line =~ /^package\b/ }
javas = lines.yoink!{|line| line =~ /^import\s+java\b/ }.sort.uniq
scalas = lines.yoink!{|line| line =~ /^import\s+scala\b/ }.sort.uniq
imports = lines.yoink!{|line| line =~ /^import\b/ }.sort.uniq
- imports.map {|i|
+ imports.each_with_index {|line, i|
+ unless %w[com org net].include?(line[/^import\s+(\w+)/, 1])
+ no = packages.length + javas.length + scalas.length + 3
+ STDERR.puts "\033[33mWARN: #{name}##{no}: Relative import: #{line}\033[0m"
+ end
}
- packages = lines.yoink!{|line| line =~ /^package\b/ }
-
lines = packages + [""] + javas + [""] + scalas + [""] + imports + [""] + lines
content = lines.join("\n")
File.open(name, "w") {|f| f.puts content.gsub(/[ \t]+\n/, "\n").gsub(/\n{3,}/, "\n\n" ) }

0 comments on commit 5acc039

Please sign in to comment.
Something went wrong with that request. Please try again.