Corrected with rubocop cop 'Lint/UselessAccessModifier'.

This commit is contained in:
Thorsten Eckel 2015-05-06 14:56:12 +02:00
parent 650e17be7c
commit 89d1768f87
9 changed files with 37 additions and 67 deletions

View file

@ -226,8 +226,6 @@ Style/RedundantSelf:
Enabled: false Enabled: false
Style/Next: Style/Next:
Enabled: false Enabled: false
Lint/UselessAccessModifier:
Enabled: false
Style/CommentIndentation: Style/CommentIndentation:
Enabled: false Enabled: false
Metrics/CyclomaticComplexity: Metrics/CyclomaticComplexity:

View file

@ -336,8 +336,6 @@ returns:
).first ).first
end end
private
def self.set_default_items(object_id, o_id, avatar_id) def self.set_default_items(object_id, o_id, avatar_id)
avatars = Avatar.where( avatars = Avatar.where(
object_lookup_id: object_id, object_lookup_id: object_id,

View file

@ -213,8 +213,6 @@ returns
list list
end end
private
def self.type_lookup_id( id ) def self.type_lookup_id( id )
# use cache # use cache

View file

@ -151,8 +151,6 @@ class Link < ApplicationModel
} }
end end
private
def self.link_type_get(data) def self.link_type_get(data)
linktype = Link::Type.where( name: data[:name] ).first linktype = Link::Type.where( name: data[:name] ).first
if !linktype if !linktype

View file

@ -83,8 +83,6 @@ class RecentView < ApplicationModel
) )
end end
private
def self.access(object, o_id, user) def self.access(object, o_id, user)
# check if object exists # check if object exists

View file

@ -3,20 +3,52 @@
class Store::Provider::File class Store::Provider::File
# write file to fs
def self.add(data, sha) def self.add(data, sha)
write_to_fs(data, sha)
# install file
permission = '600'
if !File.exist?( get_locaton(sha) )
Rails.logger.debug "storge write '#{ get_locaton(sha) }' (#{permission})"
file = File.new( get_locaton(sha), 'wb' )
file.write( data )
file.close
end
File.chmod( permission.to_i(8), get_locaton(sha) )
# check sha
local_sha = Digest::SHA256.hexdigest( get(sha) )
if sha != local_sha
raise "ERROR: Corrupt file in fs #{ get_locaton(sha) }, sha should be #{sha} but is #{local_sha}"
end
true true
end end
# read file from fs
def self.get(sha) def self.get(sha)
read_from_fs(sha) Rails.logger.debug "read from fs #{ get_locaton(sha) }"
if !File.exist?( get_locaton(sha) )
raise "ERROR: No such file #{ get_locaton(sha) }"
end
data = File.open( get_locaton(sha), 'rb' )
content = data.read
# check sha
local_sha = Digest::SHA256.hexdigest( content )
if local_sha != sha
raise "ERROR: Corrupt file in fs #{ get_locaton(sha) }, sha should be #{sha} but is #{local_sha}"
end
content
end end
# unlink file from fs
def self.delete(sha) def self.delete(sha)
unlink_from_fs(sha) if File.exist?( get_locaton(sha) )
Rails.logger.info "storge remove '#{ get_locaton(sha) }'"
File.delete( get_locaton(sha) )
end
end end
private
# generate file location # generate file location
def self.get_locaton(sha) def self.get_locaton(sha)
@ -35,50 +67,4 @@ class Store::Provider::File
location += file location += file
end end
# unlink file from fs
def self.unlink_from_fs(sha)
if File.exist?( get_locaton(sha) )
Rails.logger.info "storge remove '#{ get_locaton(sha) }'"
File.delete( get_locaton(sha) )
end
end
# read file from fs
def self.read_from_fs(sha)
Rails.logger.debug "read from fs #{ get_locaton(sha) }"
if !File.exist?( get_locaton(sha) )
raise "ERROR: No such file #{ get_locaton(sha) }"
end
data = File.open( get_locaton(sha), 'rb' )
content = data.read
# check sha
local_sha = Digest::SHA256.hexdigest( content )
if local_sha != sha
raise "ERROR: Corrupt file in fs #{ get_locaton(sha) }, sha should be #{sha} but is #{local_sha}"
end
content
end
# write file to fs
def self.write_to_fs(data, sha)
# install file
permission = '600'
if !File.exist?( get_locaton(sha) )
Rails.logger.debug "storge write '#{ get_locaton(sha) }' (#{permission})"
file = File.new( get_locaton(sha), 'wb' )
file.write( data )
file.close
end
File.chmod( permission.to_i(8), get_locaton(sha) )
# check sha
local_sha = Digest::SHA256.hexdigest( read_from_fs(sha) )
if sha != local_sha
raise "ERROR: Corrupt file in fs #{ get_locaton(sha) }, sha should be #{sha} but is #{local_sha}"
end
true
end
end end

View file

@ -62,8 +62,6 @@ class Tag < ApplicationModel
tags tags
end end
private
def self.tag_item_lookup_id( id ) def self.tag_item_lookup_id( id )
# use cache # use cache

View file

@ -244,8 +244,6 @@ return true if backend is configured
true true
end end
private
def self.build_url( type = nil, o_id = nil ) def self.build_url( type = nil, o_id = nil )
return if !SearchIndexBackend.enabled? return if !SearchIndexBackend.enabled?
index = Setting.get('es_index').to_s + "_#{Rails.env}" index = Setting.get('es_index').to_s + "_#{Rails.env}"

View file

@ -240,8 +240,6 @@ returns
end end
private
def self.get_http(uri, options) def self.get_http(uri, options)
http = Net::HTTP.new(uri.host, uri.port) http = Net::HTTP.new(uri.host, uri.port)