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
Style/Next:
Enabled: false
Lint/UselessAccessModifier:
Enabled: false
Style/CommentIndentation:
Enabled: false
Metrics/CyclomaticComplexity:

View file

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

View file

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

View file

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

View file

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

View file

@ -3,21 +3,53 @@
class Store::Provider::File
# write file to fs
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
end
# read file from fs
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
# unlink file from fs
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
private
# generate file location
def self.get_locaton(sha)
@ -35,50 +67,4 @@ class Store::Provider::File
location += file
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

View file

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

View file

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

View file

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