Fix rubocop lint warnings

This commit is contained in:
Vasily Fedoseyev
2024-04-10 19:15:45 +03:00
parent 4801e731d8
commit 6647c5fa9c
7 changed files with 28 additions and 26 deletions

View File

@@ -47,24 +47,26 @@ task :clean do
Dir.glob("paperclip-*.gem").each{|f| FileUtils.rm f }
end
include_file_globs = ["README*",
"LICENSE",
"Rakefile",
"init.rb",
"{generators,lib,tasks,test,shoulda_macros}/**/*"]
exclude_file_globs = ["test/s3.yml",
"test/debug.log",
"test/paperclip.db",
"test/doc",
"test/doc/*",
"test/pkg",
"test/pkg/*",
"test/tmp",
"test/tmp/*"]
def spec
# TODO: require 'paperclip/version'
require 'paperclip'
include_file_globs = ["README*",
"LICENSE",
"Rakefile",
"init.rb",
"{generators,lib,tasks,test,shoulda_macros}/**/*"]
exclude_file_globs = ["test/s3.yml",
"test/debug.log",
"test/paperclip.db",
"test/doc",
"test/doc/*",
"test/pkg",
"test/pkg/*",
"test/tmp",
"test/tmp/*"]
Gem::Specification.new do |s|
s.name = "paperclip"
s.version = Paperclip::VERSION

View File

@@ -344,6 +344,6 @@ end
# Set it all up.
if Object.const_defined?("ActiveRecord")
ActiveRecord::Base.send(:include, Paperclip)
File.send(:include, Paperclip::Upfile)
ActiveRecord::Base.include(Paperclip)
File.include(Paperclip::Upfile)
end

View File

@@ -56,7 +56,7 @@ module Paperclip
# ignore file-not-found, let everything else pass
end
begin
while(true)
loop do
path = File.dirname(path)
if Dir.entries(path).empty?
FileUtils.rmdir(path)

View File

@@ -1,6 +1,6 @@
require 'test_helper'
class Dummy
class Dummy # rubocop:disable Lint/EmptyClass
# This is a dummy class
end

View File

@@ -16,7 +16,7 @@ class PaperclipTest < Test::Unit::TestCase
should "execute the right command" do
Paperclip.expects(:path_for_command).with("convert").returns("/usr/bin/convert")
Paperclip.expects(:bit_bucket).returns("/dev/null")
Paperclip.expects(:"`").with("timeout 30 /usr/bin/convert #{@file_path} #{@file_path2} 2>/dev/null")
Paperclip.expects(:`).with("timeout 30 /usr/bin/convert #{@file_path} #{@file_path2} 2>/dev/null")
Paperclip.run("convert", "#{@file_path} #{@file_path2}")
end
end
@@ -33,7 +33,7 @@ class PaperclipTest < Test::Unit::TestCase
should "execute the right command" do
Paperclip.expects(:path_for_command).with("convert").returns("convert")
Paperclip.expects(:bit_bucket).returns("/dev/null")
Paperclip.expects(:"`").with("timeout 30 convert #{@file_path} #{@file_path2} 2>/dev/null")
Paperclip.expects(:`).with("timeout 30 convert #{@file_path} #{@file_path2} 2>/dev/null")
Paperclip.run("convert", "#{@file_path} #{@file_path2}")
end
@@ -41,7 +41,7 @@ class PaperclipTest < Test::Unit::TestCase
Paperclip.options[:log_command] = true
Paperclip.expects(:bit_bucket).returns("/dev/null")
Paperclip.expects(:log).with("convert #{@file_path} #{@file_path2} 2>/dev/null")
Paperclip.expects(:"`").with("timeout 30 convert #{@file_path} #{@file_path2} 2>/dev/null")
Paperclip.expects(:`).with("timeout 30 convert #{@file_path} #{@file_path2} 2>/dev/null")
Paperclip.run("convert", "#{@file_path} #{@file_path2}")
end
end
@@ -110,7 +110,7 @@ class PaperclipTest < Test::Unit::TestCase
context "a validation with an if guard clause" do
setup do
Dummy.send(:"validates_attachment_presence", :avatar, :if => lambda{|i| i.foo })
Dummy.send(:validates_attachment_presence, :avatar, :if => lambda{|i| i.foo })
@dummy = Dummy.new
end
@@ -129,7 +129,7 @@ class PaperclipTest < Test::Unit::TestCase
context "a validation with an unless guard clause" do
setup do
Dummy.send(:"validates_attachment_presence", :avatar, :unless => lambda{|i| i.foo })
Dummy.send(:validates_attachment_presence, :avatar, :unless => lambda{|i| i.foo })
@dummy = Dummy.new
end

View File

@@ -1,7 +1,7 @@
require 'test_helper'
class PluralCacheTest < Test::Unit::TestCase
class BigBox; end
class BigBox; end # rubocop:disable Lint/EmptyClass
should 'cache pluralizations' do
cache = Paperclip::Interpolations::PluralCache.new

View File

@@ -65,7 +65,7 @@ class ThumbnailTest < Test::Unit::TestCase
should "send the right command to convert when sent #make" do
Paperclip::Thumbnail.any_instance.stubs(:gamma_correction_if_needed).returns("PNG\nPaletteAlpha")
Paperclip.expects(:"`").with do |arg|
Paperclip.expects(:`).with do |arg|
arg.match? %r{convert\s+"#{File.expand_path(@thumb.file.path)}\[0\]"\s+-auto-orient\s+-resize\s+\"x50\"\s+-crop\s+\"100x50\+114\+0\"\s+\+repage\s+}
end
@thumb.make
@@ -90,7 +90,7 @@ class ThumbnailTest < Test::Unit::TestCase
should "send the right command to convert when sent #make" do
Paperclip::Thumbnail.any_instance.stubs(:gamma_correction_if_needed).returns("PNG\nPaletteAlpha")
Paperclip.expects(:"`").with do |arg|
Paperclip.expects(:`).with do |arg|
arg.match? %r{convert\s+"#{File.expand_path(@thumb.file.path)}\[0\]"\s+-auto-orient\s+-resize\s+"x50"\s+-crop\s+"100x50\+114\+0"\s+\+repage\s+-strip\s+-depth\s+8\s+}
end
@thumb.make