From b551e3634f5ae21034bed02a19a83da254350ce8 Mon Sep 17 00:00:00 2001 From: evazion Date: Tue, 16 Jun 2020 21:36:15 -0500 Subject: [PATCH] Fix misc rubocop warnings. --- app/logical/apng_inspector.rb | 8 +++--- app/logical/artist_finder.rb | 10 +++---- app/logical/bulk_update_request_processor.rb | 2 -- app/logical/concerns/has_bit_flags.rb | 2 +- app/logical/concerns/mentionable.rb | 2 -- app/logical/concerns/searchable.rb | 7 ++--- app/logical/d_text.rb | 8 +++--- app/logical/image_proxy.rb | 7 ++--- app/logical/ip_lookup.rb | 2 +- app/logical/media_file/flash.rb | 12 ++++----- app/logical/pagination_extension.rb | 7 ++--- app/logical/pawoo_api_client.rb | 6 ++--- app/logical/pixiv_web_agent.rb | 2 +- app/logical/post_sets/post.rb | 6 ++--- app/logical/spam_detector.rb | 9 ++++--- app/logical/storage_manager/sftp.rb | 4 +-- app/logical/tag_autocomplete.rb | 5 ++-- .../tag_relationship_retirement_service.rb | 16 +++-------- app/logical/upload_limit.rb | 4 +-- app/logical/upload_service.rb | 13 +++++---- .../upload_service/controller_helper.rb | 4 +-- app/logical/upload_service/preprocessor.rb | 27 +++++++++---------- app/logical/upload_service/replacer.rb | 4 +-- app/logical/upload_service/utils.rb | 2 +- app/logical/user_deletion.rb | 1 + 25 files changed, 75 insertions(+), 95 deletions(-) diff --git a/app/logical/apng_inspector.rb b/app/logical/apng_inspector.rb index 4921c226a..68cc62c06 100644 --- a/app/logical/apng_inspector.rb +++ b/app/logical/apng_inspector.rb @@ -57,7 +57,7 @@ class APNGInspector # if we did, file is probably maliciously formed # fail gracefully without marking the file as corrupt chunks += 1 - if chunks > 100000 + if chunks > 100_000 iend_reached = true break end @@ -66,7 +66,8 @@ class APNGInspector file.seek(current_pos + chunk_len + 4, IO::SEEK_SET) end end - return iend_reached + + iend_reached end def inspect! @@ -105,6 +106,7 @@ class APNGInspector if framedata.nil? || framedata.length != 4 return -1 end - return framedata.unpack1("N".freeze) + + framedata.unpack1("N".freeze) end end diff --git a/app/logical/artist_finder.rb b/app/logical/artist_finder.rb index 3cf5c9581..a91d0f5e1 100644 --- a/app/logical/artist_finder.rb +++ b/app/logical/artist_finder.rb @@ -6,7 +6,7 @@ module ArtistFinder SITE_BLACKLIST = [ "artstation.com/artist", # http://www.artstation.com/artist/serafleur/ "www.artstation.com", # http://www.artstation.com/serafleur/ - %r!cdn[ab]?\.artstation\.com/p/assets/images/images!i, # https://cdna.artstation.com/p/assets/images/images/001/658/068/large/yang-waterkuma-b402.jpg?1450269769 + %r{cdn[ab]?\.artstation\.com/p/assets/images/images}i, # https://cdna.artstation.com/p/assets/images/images/001/658/068/large/yang-waterkuma-b402.jpg?1450269769 "ask.fm", # http://ask.fm/mikuroko_396 "bcyimg.com", "bcyimg.com/drawer", # https://img9.bcyimg.com/drawer/32360/post/178vu/46229ec06e8111e79558c1b725ebc9e6.jpg @@ -52,7 +52,7 @@ module ArtistFinder "hentai-foundry.com", "hentai-foundry.com/pictures/user", # http://www.hentai-foundry.com/pictures/user/aaaninja/ "hentai-foundry.com/user", # http://www.hentai-foundry.com/user/aaaninja/profile - %r!pictures\.hentai-foundry\.com(?:/\w)?!i, # http://pictures.hentai-foundry.com/a/aaaninja/ + %r{pictures\.hentai-foundry\.com(?:/\w)?}i, # http://pictures.hentai-foundry.com/a/aaaninja/ "i.imgur.com", # http://i.imgur.com/Ic9q3.jpg "instagram.com", # http://www.instagram.com/serafleur.art/ "iwara.tv", @@ -68,7 +68,7 @@ module ArtistFinder "nicovideo.jp/user", # http://www.nicovideo.jp/user/317609 "nicovideo.jp/user/illust", # http://seiga.nicovideo.jp/user/illust/29075429 "nijie.info", # http://nijie.info/members.php?id=15235 - %r!nijie\.info/nijie_picture!i, # http://pic03.nijie.info/nijie_picture/32243_20150609224803_0.png + %r{nijie\.info/nijie_picture}i, # http://pic03.nijie.info/nijie_picture/32243_20150609224803_0.png "patreon.com", # http://patreon.com/serafleur "pawoo.net", # https://pawoo.net/@148nasuka "pawoo.net/web/accounts", # https://pawoo.net/web/accounts/228341 @@ -120,7 +120,7 @@ module ArtistFinder SITE_BLACKLIST_REGEXP = Regexp.union(SITE_BLACKLIST.map do |domain| domain = Regexp.escape(domain) if domain.is_a?(String) - %r!\Ahttps?://(?:[a-zA-Z0-9_-]+\.)*#{domain}/\z!i + %r{\Ahttps?://(?:[a-zA-Z0-9_-]+\.)*#{domain}/\z}i end) def find_artists(url) @@ -128,7 +128,7 @@ module ArtistFinder artists = [] while artists.empty? && url.size > 10 - u = url.sub(/\/+$/, "") + "/" + u = url.sub(%r{/+$}, "") + "/" u = u.to_escaped_for_sql_like.gsub(/\*/, '%') + '%' artists += Artist.joins(:urls).where(["artists.is_deleted = FALSE AND artist_urls.normalized_url LIKE ? ESCAPE E'\\\\'", u]).limit(10).order("artists.name").all url = File.dirname(url) + "/" diff --git a/app/logical/bulk_update_request_processor.rb b/app/logical/bulk_update_request_processor.rb index 96212a72e..293320510 100644 --- a/app/logical/bulk_update_request_processor.rb +++ b/app/logical/bulk_update_request_processor.rb @@ -148,8 +148,6 @@ class BulkUpdateRequestProcessor end.join("\n") end - private - def self.is_tag_move_allowed?(antecedent_name, consequent_name) antecedent_tag = Tag.find_by_name(Tag.normalize_name(antecedent_name)) consequent_tag = Tag.find_by_name(Tag.normalize_name(consequent_name)) diff --git a/app/logical/concerns/has_bit_flags.rb b/app/logical/concerns/has_bit_flags.rb index 2b2e2a355..c05b6d54a 100644 --- a/app/logical/concerns/has_bit_flags.rb +++ b/app/logical/concerns/has_bit_flags.rb @@ -16,7 +16,7 @@ module HasBitFlags end define_method("#{attribute}=") do |val| - if val.to_s =~ /t|1|y/ + if val.to_s =~ /[t1y]/ send("#{field}=", send(field) | bit_flag) else send("#{field}=", send(field) & ~bit_flag) diff --git a/app/logical/concerns/mentionable.rb b/app/logical/concerns/mentionable.rb index f6dda15e9..f0a8e16ee 100644 --- a/app/logical/concerns/mentionable.rb +++ b/app/logical/concerns/mentionable.rb @@ -11,8 +11,6 @@ module Mentionable # - user_field def mentionable(options = {}) @mentionable_options = options - - message_field = mentionable_option(:message_field) after_save :queue_mention_messages end diff --git a/app/logical/concerns/searchable.rb b/app/logical/concerns/searchable.rb index 3b2996b54..640692263 100644 --- a/app/logical/concerns/searchable.rb +++ b/app/logical/concerns/searchable.rb @@ -89,7 +89,7 @@ module Searchable def where_array_count(attr, value) qualified_column = "cardinality(#{qualified_column_for(attr)})" range = PostQueryBuilder.new(nil).parse_range(value, :integer) - where_operator("cardinality(#{qualified_column_for(attr)})", *range) + where_operator(qualified_column, *range) end def search_boolean_attribute(attribute, params) @@ -170,7 +170,7 @@ module Searchable end end - def search_text_attribute(attr, params, **options) + def search_text_attribute(attr, params) if params[attr].present? where(attr => params[attr]) elsif params[:"#{attr}_eq"].present? @@ -279,7 +279,8 @@ module Searchable return find_ordered(parse_ids[1]) end end - return default_order + + default_order end def default_order diff --git a/app/logical/d_text.rb b/app/logical/d_text.rb index 9d37d74ec..26f451a47 100644 --- a/app/logical/d_text.rb +++ b/app/logical/d_text.rb @@ -11,7 +11,7 @@ class DText html = DTextRagel.parse(text, **options) html = postprocess(html, *data) html - rescue DTextRagel::Error => e + rescue DTextRagel::Error "" end @@ -135,7 +135,7 @@ class DText fragment = Nokogiri::HTML.fragment(html) titles = fragment.css("a.dtext-wiki-link").map do |node| - title = node["href"][%r!\A/wiki_pages/(.*)\z!i, 1] + title = node["href"][%r{\A/wiki_pages/(.*)\z}i, 1] title = CGI.unescape(title) title = WikiPage.normalize_title(title) title @@ -163,7 +163,7 @@ class DText string = string.dup string.gsub!(/\s*\[#{tag}\](?!\])\s*/mi, "\n\n[#{tag}]\n\n") - string.gsub!(/\s*\[\/#{tag}\]\s*/mi, "\n\n[/#{tag}]\n\n") + string.gsub!(%r{\s*\[/#{tag}\]\s*}mi, "\n\n[/#{tag}]\n\n") string.gsub!(/(?:\r?\n){3,}/, "\n\n") string.strip! @@ -203,7 +203,7 @@ class DText end end - text = text.gsub(/\A[[:space:]]+|[[:space:]]+\z/, "") + text.gsub(/\A[[:space:]]+|[[:space:]]+\z/, "") end def self.from_html(text, inline: false, &block) diff --git a/app/logical/image_proxy.rb b/app/logical/image_proxy.rb index f10fd53c4..80982c7cc 100644 --- a/app/logical/image_proxy.rb +++ b/app/logical/image_proxy.rb @@ -17,10 +17,7 @@ class ImageProxy end response = HTTParty.get(url, Danbooru.config.httparty_options.deep_merge(headers: {"Referer" => fake_referer_for(url)})) - if response.success? - return response - else - raise "HTTP error code: #{response.code} #{response.message}" - end + raise "HTTP error code: #{response.code} #{response.message}" unless response.success? + response end end diff --git a/app/logical/ip_lookup.rb b/app/logical/ip_lookup.rb index dc9f5bfce..7a6e3bf1a 100644 --- a/app/logical/ip_lookup.rb +++ b/app/logical/ip_lookup.rb @@ -16,7 +16,7 @@ class IpLookup end def info - return {} unless api_key.present? + return {} if api_key.blank? response = Danbooru::Http.cache(cache_duration).get("https://api.ipregistry.co/#{ip_addr}?key=#{api_key}") return {} if response.status != 200 json = response.parse.deep_symbolize_keys.with_indifferent_access diff --git a/app/logical/media_file/flash.rb b/app/logical/media_file/flash.rb index 6ff99c239..b3d3815ae 100644 --- a/app/logical/media_file/flash.rb +++ b/app/logical/media_file/flash.rb @@ -42,7 +42,7 @@ class MediaFile::Flash < MediaFile signature = contents[0..2] # SWF version - version = contents[3].unpack('C').join.to_i + _version = contents[3].unpack('C').join.to_i # Determine the length of the uncompressed stream length = contents[4..7].unpack('V').join.to_i @@ -50,7 +50,7 @@ class MediaFile::Flash < MediaFile # If we do, in fact, have compression if signature == 'CWS' # Decompress the body of the SWF - body = Zlib::Inflate.inflate( contents[8..length] ) + body = Zlib::Inflate.inflate(contents[8..length]) # And reconstruct the stream contents to the first 8 bytes (header) # Plus our decompressed body @@ -58,10 +58,10 @@ class MediaFile::Flash < MediaFile end # Determine the nbits of our dimensions rectangle - nbits = contents.unpack('C'*contents.length)[8] >> 3 + nbits = contents.unpack('C' * contents.length)[8] >> 3 # Determine how many bits long this entire RECT structure is - rectbits = 5 + nbits * 4 # 5 bits for nbits, as well as nbits * number of fields (4) + rectbits = 5 + nbits * 4 # 5 bits for nbits, as well as nbits * number of fields (4) # Determine how many bytes rectbits composes (ceil(rectbits/8)) rectbytes = (rectbits.to_f / 8).ceil @@ -70,11 +70,11 @@ class MediaFile::Flash < MediaFile rect = contents[8..(8 + rectbytes)].unpack("#{'B8' * rectbytes}").join # Read in nbits incremenets starting from 5 - dimensions = Array.new + dimensions = [] 4.times do |n| s = 5 + (n * nbits) # Calculate our start index e = s + (nbits - 1) # Calculate our end index - dimensions[n] = rect[s..e].to_i(2) # Read that range (binary) and convert it to an integer + dimensions[n] = rect[s..e].to_i(2) # Read that range (binary) and convert it to an integer end # The values we have here are in "twips" diff --git a/app/logical/pagination_extension.rb b/app/logical/pagination_extension.rb index 5d5113e8c..dcb89ee5b 100644 --- a/app/logical/pagination_extension.rb +++ b/app/logical/pagination_extension.rb @@ -106,10 +106,7 @@ module PaginationExtension def total_count @paginator_count ||= unscoped.from(except(:offset, :limit, :order).reorder(nil)).count rescue ActiveRecord::StatementInvalid => e - if e.to_s =~ /statement timeout/ - @paginator_count ||= 1_000_000 - else - raise - end + raise unless e.to_s =~ /statement timeout/ + @paginator_count ||= 1_000_000 end end diff --git a/app/logical/pawoo_api_client.rb b/app/logical/pawoo_api_client.rb index 20daf1fd7..f74d42e38 100644 --- a/app/logical/pawoo_api_client.rb +++ b/app/logical/pawoo_api_client.rb @@ -128,15 +128,15 @@ class PawooApiClient rescue data = {} end - return Account.new(data) + Account.new(data) end end private def fetch_access_token - raise MissingConfigurationError.new("missing pawoo client id") if Danbooru.config.pawoo_client_id.nil? - raise MissingConfigurationError.new("missing pawoo client secret") if Danbooru.config.pawoo_client_secret.nil? + raise MissingConfigurationError, "missing pawoo client id" if Danbooru.config.pawoo_client_id.nil? + raise MissingConfigurationError, "missing pawoo client secret" if Danbooru.config.pawoo_client_secret.nil? Cache.get("pawoo-token") do result = client.client_credentials.get_token diff --git a/app/logical/pixiv_web_agent.rb b/app/logical/pixiv_web_agent.rb index f48a20c50..1a181672b 100644 --- a/app/logical/pixiv_web_agent.rb +++ b/app/logical/pixiv_web_agent.rb @@ -58,7 +58,7 @@ class PixivWebAgent end begin - mech.get("https://comic.pixiv.net") do |page| + mech.get("https://comic.pixiv.net") do cookie = mech.cookies.select {|x| x.name == COMIC_SESSION_COOKIE_KEY}.first if cookie Cache.put(COMIC_SESSION_CACHE_KEY, cookie.value, 1.week) diff --git a/app/logical/post_sets/post.rb b/app/logical/post_sets/post.rb index 2858b9b64..30d76717e 100644 --- a/app/logical/post_sets/post.rb +++ b/app/logical/post_sets/post.rb @@ -94,7 +94,7 @@ module PostSets end def get_random_posts - per_page.times.inject([]) do |all, x| + per_page.times.inject([]) do |all, _| all << ::Post.user_tag_match(tag_string).random end.compact.uniq end @@ -104,9 +104,9 @@ module PostSets @post_count = get_post_count if is_random? - temp = get_random_posts + get_random_posts else - temp = normalized_query.build.paginate(page, count: post_count, search_count: !post_count.nil?, limit: per_page) + normalized_query.build.paginate(page, count: post_count, search_count: !post_count.nil?, limit: per_page) end end end diff --git a/app/logical/spam_detector.rb b/app/logical/spam_detector.rb index a6ca4c2b0..176cc40d6 100644 --- a/app/logical/spam_detector.rb +++ b/app/logical/spam_detector.rb @@ -7,10 +7,11 @@ class SpamDetector # if a person receives more than 10 automatic spam reports within a 1 hour # window, automatically ban them forever. AUTOBAN_THRESHOLD = 10 - AUTOBAN_WINDOW = 1.hours - AUTOBAN_DURATION = 999999 + AUTOBAN_WINDOW = 1.hour + AUTOBAN_DURATION = 999_999 attr_accessor :record, :user, :user_ip, :content, :comment_type + rakismet_attrs author: proc { user.name }, author_email: proc { user.email_address&.address }, blog_lang: "en", @@ -84,8 +85,8 @@ class SpamDetector end is_spam - rescue StandardError => exception - DanbooruLogger.log(exception) + rescue StandardError => e + DanbooruLogger.log(e) false end end diff --git a/app/logical/storage_manager/sftp.rb b/app/logical/storage_manager/sftp.rb index 1eeb1fdce..ef2a2de02 100644 --- a/app/logical/storage_manager/sftp.rb +++ b/app/logical/storage_manager/sftp.rb @@ -21,7 +21,7 @@ class StorageManager::SFTP < StorageManager temp_upload_path = dest_path + "-" + SecureRandom.uuid + ".tmp" dest_backup_path = dest_path + "-" + SecureRandom.uuid + ".bak" - each_host do |host, sftp| + each_host do |_host, sftp| sftp.upload!(file.path, temp_upload_path) sftp.setstat!(temp_upload_path, permissions: DEFAULT_PERMISSIONS) @@ -40,7 +40,7 @@ class StorageManager::SFTP < StorageManager end def delete(dest_path) - each_host do |host, sftp| + each_host do |_host, sftp| force { sftp.remove!(dest_path) } end end diff --git a/app/logical/tag_autocomplete.rb b/app/logical/tag_autocomplete.rb index 31f4c1566..ba34e658c 100644 --- a/app/logical/tag_autocomplete.rb +++ b/app/logical/tag_autocomplete.rb @@ -25,8 +25,7 @@ module TagAutocomplete def search(query) query = Tag.normalize_name(query) - candidates = count_sort( - query, + count_sort( search_exact(query, 8) + search_prefix(query, 4) + search_correct(query, 2) + @@ -34,7 +33,7 @@ module TagAutocomplete ) end - def count_sort(query, words) + def count_sort(words) words.uniq(&:name).sort_by do |x| x.post_count * x.weight end.reverse.slice(0, LIMIT) diff --git a/app/logical/tag_relationship_retirement_service.rb b/app/logical/tag_relationship_retirement_service.rb index e3ad7eda8..0f11ee931 100644 --- a/app/logical/tag_relationship_retirement_service.rb +++ b/app/logical/tag_relationship_retirement_service.rb @@ -4,11 +4,11 @@ module TagRelationshipRetirementService THRESHOLD = 2.years def forum_topic_title - return "Retired tag aliases & implications" + "Retired tag aliases & implications" end def forum_topic_body - return "This topic deals with tag relationships created two or more years ago that have not been used since. They will be retired. This topic will be updated as an automated system retires expired relationships." + "This topic deals with tag relationships created two or more years ago that have not been used since. They will be retired. This topic will be updated as an automated system retires expired relationships." end def dry_run @@ -27,7 +27,7 @@ module TagRelationshipRetirementService forum_post = ForumPost.create!(creator: User.system, body: forum_topic_body, topic: topic) end end - return topic + topic end def find_and_retire! @@ -50,16 +50,6 @@ module TagRelationshipRetirementService yield(rel) end end - - # model.active.where("created_at < ?", SMALL_THRESHOLD.ago).find_each do |rel| - # if is_underused?(rel.consequent_name) - # yield(rel) - # end - # end - end - - def is_underused?(name) - (Tag.find_by_name(name).try(:post_count) || 0) < COUNT_THRESHOLD end def is_unused?(name) diff --git a/app/logical/upload_limit.rb b/app/logical/upload_limit.rb index 014706210..752741d05 100644 --- a/app/logical/upload_limit.rb +++ b/app/logical/upload_limit.rb @@ -2,7 +2,7 @@ class UploadLimit extend Memoist INITIAL_POINTS = 1000 - MAXIMUM_POINTS = 10000 + MAXIMUM_POINTS = 10_000 attr_reader :user @@ -75,7 +75,7 @@ class UploadLimit points += upload_value(points, is_deleted) points = points.clamp(0, MAXIMUM_POINTS) - #warn "slots: %2d, points: %3d, value: %2d" % [UploadLimit.points_to_level(points) + 5, points, UploadLimit.upload_value(level, is_deleted)] + # warn "slots: %2d, points: %3d, value: %2d" % [UploadLimit.points_to_level(points) + 5, points, UploadLimit.upload_value(level, is_deleted)] end points diff --git a/app/logical/upload_service.rb b/app/logical/upload_service.rb index c2473284c..5a5d415b9 100644 --- a/app/logical/upload_service.rb +++ b/app/logical/upload_service.rb @@ -15,7 +15,6 @@ class UploadService start! end rescue ActiveRecord::RecordNotUnique - return end def start! @@ -31,8 +30,8 @@ class UploadService begin create_post_from_upload(@upload) - rescue Exception => x - @upload.update(status: "error: #{x.class} - #{x.message}", backtrace: x.backtrace.join("\n")) + rescue Exception => e + @upload.update(status: "error: #{e.class} - #{e.message}", backtrace: e.backtrace.join("\n")) end return @upload end @@ -53,16 +52,16 @@ class UploadService @upload.save! @post = create_post_from_upload(@upload) - return @upload - rescue Exception => x - @upload.update(status: "error: #{x.class} - #{x.message}", backtrace: x.backtrace.join("\n")) + @upload + rescue Exception => e + @upload.update(status: "error: #{e.class} - #{e.message}", backtrace: e.backtrace.join("\n")) @upload end end def warnings return [] if @post.nil? - return @post.warnings.full_messages + @post.warnings.full_messages end def create_post_from_upload(upload) diff --git a/app/logical/upload_service/controller_helper.rb b/app/logical/upload_service/controller_helper.rb index d311ca19b..f074c8069 100644 --- a/app/logical/upload_service/controller_helper.rb +++ b/app/logical/upload_service/controller_helper.rb @@ -13,7 +13,7 @@ class UploadService rescue Exception end - return [upload, remote_size] + [upload, remote_size] end if file @@ -21,7 +21,7 @@ class UploadService Preprocessor.new(file: file).delayed_start(CurrentUser.id) end - return [upload] + [upload] end end end diff --git a/app/logical/upload_service/preprocessor.rb b/app/logical/upload_service/preprocessor.rb index a0b411818..042c50cc6 100644 --- a/app/logical/upload_service/preprocessor.rb +++ b/app/logical/upload_service/preprocessor.rb @@ -46,11 +46,9 @@ class UploadService def predecessor if md5.present? - return Upload.where(status: ["preprocessed", "preprocessing"], md5: md5).first - end - - if Utils.is_downloadable?(source) - return Upload.where(status: ["preprocessed", "preprocessing"], source: source).first + Upload.where(status: ["preprocessed", "preprocessing"], md5: md5).first + elsif Utils.is_downloadable?(source) + Upload.where(status: ["preprocessed", "preprocessing"], source: source).first end end @@ -63,21 +61,20 @@ class UploadService start! end rescue ActiveRecord::RecordNotUnique - return end def start! if Utils.is_downloadable?(source) if Post.system_tag_match("source:#{canonical_source}").where.not(id: original_post_id).exists? - raise ActiveRecord::RecordNotUnique.new("A post with source #{canonical_source} already exists") + raise ActiveRecord::RecordNotUnique, "A post with source #{canonical_source} already exists" end if Upload.where(source: source, status: "completed").exists? - raise ActiveRecord::RecordNotUnique.new("A completed upload with source #{source} already exists") + raise ActiveRecord::RecordNotUnique, "A completed upload with source #{source} already exists" end if Upload.where(source: source).where("status like ?", "error%").exists? - raise ActiveRecord::RecordNotUnique.new("An errored upload with source #{source} already exists") + raise ActiveRecord::RecordNotUnique, "An errored upload with source #{source} already exists" end end @@ -95,21 +92,21 @@ class UploadService upload.tag_string = params[:tag_string] upload.status = "preprocessed" upload.save! - rescue Exception => x - upload.update(file_ext: nil, status: "error: #{x.class} - #{x.message}", backtrace: x.backtrace.join("\n")) + rescue Exception => e + upload.update(file_ext: nil, status: "error: #{e.class} - #{e.message}", backtrace: e.backtrace.join("\n")) end - return upload + upload end def finish!(upload = nil) - pred = upload || self.predecessor + pred = upload || predecessor # regardless of who initialized the upload, credit should # goto whoever submitted the form pred.initialize_attributes - pred.attributes = self.params + pred.attributes = params # if a file was uploaded after the preprocessing occurred, # then process the file and overwrite whatever the preprocessor @@ -118,7 +115,7 @@ class UploadService pred.status = "completed" pred.save - return pred + pred end end end diff --git a/app/logical/upload_service/replacer.rb b/app/logical/upload_service/replacer.rb index b1ac345d6..f64198c5a 100644 --- a/app/logical/upload_service/replacer.rb +++ b/app/logical/upload_service/replacer.rb @@ -62,7 +62,7 @@ class UploadService end def source_strategy(upload) - return Sources::Strategies.find(upload.source, upload.referer_url) + Sources::Strategies.find(upload.source, upload.referer_url) end def find_replacement_url(repl, upload) @@ -78,7 +78,7 @@ class UploadService return source_strategy(upload).canonical_url end - return upload.source + upload.source end def process! diff --git a/app/logical/upload_service/utils.rb b/app/logical/upload_service/utils.rb index 09c2e47e6..7482d43b6 100644 --- a/app/logical/upload_service/utils.rb +++ b/app/logical/upload_service/utils.rb @@ -83,7 +83,7 @@ class UploadService } end - return file + file end end end diff --git a/app/logical/user_deletion.rb b/app/logical/user_deletion.rb index b87e6297f..8577f19a1 100644 --- a/app/logical/user_deletion.rb +++ b/app/logical/user_deletion.rb @@ -2,6 +2,7 @@ class UserDeletion include ActiveModel::Validations attr_reader :user, :password + validate :validate_deletion def initialize(user, password)