Fix most auto-correctable rubocop issues

This commit is contained in:
Tom Hughes 2015-02-16 19:02:59 +00:00
parent 34e3e51456
commit ef7f3d800c
206 changed files with 2925 additions and 3473 deletions

View file

@ -1,2 +1,2 @@
#!/usr/bin/env ruby
Dir[File.dirname(__FILE__) + "/../lib/daemons/*_ctl"].each {|f| `#{f} #{ARGV.first}`}
Dir[File.dirname(__FILE__) + "/../lib/daemons/*_ctl"].each { |f| `#{f} #{ARGV.first}` }

View file

@ -18,7 +18,7 @@ else
to = message.sender
end
exit 0 unless recipient[3] == digest[0,6]
exit 0 unless recipient[3] == digest[0, 6]
exit 0 if date < 1.month.ago
message.update_attribute(:message_read, true) if message

View file

@ -11,7 +11,7 @@ def add_translation(hash, keys, value)
if keys.empty?
hash[key] = value
else
unless hash.has_key? key
unless hash.key? key
hash[key] = {}
end
add_translation(hash[key], keys, value)
@ -23,7 +23,7 @@ def po2hash(f)
trs = {}
path = []
msgstr = ''
f.each_line { |line|
f.each_line do |line|
line.strip!
if line[0..8] == 'msgctxt "'
path = line[9..-2].split(':')
@ -31,12 +31,12 @@ def po2hash(f)
msgstr = line[8..-2]
end
if !path.empty? and !msgstr.empty?
if !path.empty? && !msgstr.empty?
add_translation(trs, path, msgstr)
path = []
msgstr = ''
end
}
end
trs
end
@ -45,6 +45,6 @@ pofile = File.open(filename, "r")
langcode = File.basename(filename, '.po')
tr = {langcode => po2hash(pofile)}
tr = { langcode => po2hash(pofile) }
print tr.to_yaml

View file

@ -13,29 +13,29 @@ require "yaml"
require "optparse"
LOCALE_DIR = File.dirname(__FILE__) + '/../../config/locales/'
EN = YAML::load_file(LOCALE_DIR+'en.yml')
EN = YAML.load_file(LOCALE_DIR + 'en.yml')
def iterate(hash, fhash={}, path='', outfile=$stdout)
def iterate(hash, fhash = {}, path = '', outfile = $stdout)
postr = ''
hash.each {|key, val|
fhash[key] = {} unless fhash.has_key? key
hash.each do |key, val|
fhash[key] = {} unless fhash.key? key
if val.is_a? Hash
fhash[key] = {} unless fhash[key].is_a? Hash
iterate(val, fhash[key], path+key+':', outfile)
iterate(val, fhash[key], path + key + ':', outfile)
else
outfile.puts "msgctxt \"#{path}#{key}\""
outfile.puts "msgid \"#{val}\""
outfile.puts "msgstr \"#{fhash[key]}\""
end
}
end
end
def lang2po(lang, outfile=$stdout)
def lang2po(lang, outfile = $stdout)
puts lang
oth = {}
infile = LOCALE_DIR+lang+'.yml'
if File.exists? infile
oth = YAML::load_file(infile)
infile = LOCALE_DIR + lang + '.yml'
if File.exist? infile
oth = YAML.load_file(infile)
oth = oth[lang]
iterate(EN['en'], oth, '', outfile)
else
@ -46,17 +46,17 @@ end
opt = ARGV[0]
if opt == '--all'
# Produce .po files for all langs, and a .pot template
PO_DIR = LOCALE_DIR+'po/'
PO_DIR = LOCALE_DIR + 'po/'
Dir.mkdir(PO_DIR) unless File.directory?(PO_DIR)
Dir.glob(LOCALE_DIR+"*.yml") {|filename|
Dir.glob(LOCALE_DIR + "*.yml") do |filename|
lang = File.basename(filename, '.yml')
unless lang == 'en'
outfile = File.new(PO_DIR+"#{lang}.po", 'w')
outfile = File.new(PO_DIR + "#{lang}.po", 'w')
lang2po(lang, outfile)
outfile.close
end
}
outfile = File.new(PO_DIR+"rails_port.pot", 'w')
end
outfile = File.new(PO_DIR + "rails_port.pot", 'w')
iterate(EN['en'], {}, '', outfile)
outfile.close
elsif opt

View file

@ -11,11 +11,11 @@ puts "<title>OpenStreetMap Statistics</title>"
puts "<style>th { text-align: left }</style>"
puts "</head>"
puts "<body>"
puts "<h2>OpenStreetMap stats report run at #{start_time.to_s}</h2>"
puts "<h2>OpenStreetMap stats report run at #{start_time}</h2>"
begin
ActiveRecord::Base.transaction do
user_count = User.where(:status => ["active", "confirmed", "suspended"]).count
user_count = User.where(:status => %w(active confirmed suspended)).count
tracepoint_count = Tracepoint.count
node_count = Node.where(:visible => true).count
way_count = Way.where(:visible => true).count
@ -83,10 +83,10 @@ begin
puts "</table>"
end
rescue Exception => e
puts "<p><em>Exception: #{e.to_s}</em><br />#{e.backtrace.join('<br />')}</p>"
puts "<p><em>Exception: #{e}</em><br />#{e.backtrace.join('<br />')}</p>"
end
puts "<p>Report took #{(Time.new - start_time).to_s} seconds to run</p>"
puts "<p>Report took #{(Time.new - start_time)} seconds to run</p>"
puts "</body>"
puts "</html>"

View file

@ -5,24 +5,24 @@ require 'generator'
addresses = User.count(
:conditions => {
:status => ["suspended", "deleted"],
:creation_time => Time.now - 28.days .. Time.now
:status => %w(suspended deleted),
:creation_time => Time.now - 28.days..Time.now
},
:group => :creation_ip
)
addresses.each do |address,count|
addresses.each do |address, count|
if count > 1
acl = Acl.find(:first, :conditions => {
:address => address,
})
:address => address
})
unless acl
Acl.create({
:address => address,
:k => "no_account_creation",
:v => "auto_spam_block"
}, :without_protection => true)
:address => address,
:k => "no_account_creation",
:v => "auto_spam_block"
}, { :without_protection => true })
puts "Blocked #{address}"
end
@ -30,9 +30,9 @@ addresses.each do |address,count|
end
acls = Acl.find(:all, :conditions => {
:k => "no_account_creation",
:v => "auto_spam_block"
})
:k => "no_account_creation",
:v => "auto_spam_block"
})
acls.each do |acl|
unless addresses[acl.address]