Rubocop
This commit is contained in:
parent
5fcede685a
commit
cf7f67e1fb
@ -18,7 +18,6 @@
|
|||||||
AllCops:
|
AllCops:
|
||||||
TargetRubyVersion: 3.2
|
TargetRubyVersion: 3.2
|
||||||
TargetRailsVersion: 7.1
|
TargetRailsVersion: 7.1
|
||||||
|
|
||||||
SuggestExtensions: false
|
SuggestExtensions: false
|
||||||
|
|
||||||
NewCops: enable
|
NewCops: enable
|
||||||
@ -26,10 +25,6 @@ AllCops:
|
|||||||
Exclude:
|
Exclude:
|
||||||
- '**/vendor/**/*'
|
- '**/vendor/**/*'
|
||||||
|
|
||||||
plugins:
|
|
||||||
- rubocop-performance
|
|
||||||
- rubocop-rails
|
|
||||||
|
|
||||||
# Rules for DMSF
|
# Rules for DMSF
|
||||||
Layout/LineLength:
|
Layout/LineLength:
|
||||||
Exclude:
|
Exclude:
|
||||||
@ -81,7 +76,7 @@ Naming/AccessorMethodName:
|
|||||||
Exclude:
|
Exclude:
|
||||||
- lib/dav4rack/resource.rb
|
- lib/dav4rack/resource.rb
|
||||||
|
|
||||||
Naming/PredicateName:
|
Naming/PredicatePrefix:
|
||||||
Exclude:
|
Exclude:
|
||||||
- patches/attachable_patch.rb
|
- patches/attachable_patch.rb
|
||||||
|
|
||||||
|
|||||||
@ -22,10 +22,10 @@ class DmsfFileExtensionValidator < ActiveModel::EachValidator
|
|||||||
include Redmine::I18n
|
include Redmine::I18n
|
||||||
|
|
||||||
def validate_each(record, attribute, value)
|
def validate_each(record, attribute, value)
|
||||||
return true unless attribute.to_s == 'name'
|
return unless attribute.to_s == 'name'
|
||||||
|
|
||||||
extension = File.extname(value)
|
extension = File.extname(value)
|
||||||
return true if Attachment.valid_extension?(extension)
|
return if Attachment.valid_extension?(extension)
|
||||||
|
|
||||||
record.errors.add(:base, l(:error_attachment_extension_not_allowed, extension: extension))
|
record.errors.add(:base, l(:error_attachment_extension_not_allowed, extension: extension))
|
||||||
end
|
end
|
||||||
|
|||||||
@ -25,10 +25,9 @@ class DmsfFolderParentValidator < ActiveModel::EachValidator
|
|||||||
while folder
|
while folder
|
||||||
if folder == record
|
if folder == record
|
||||||
record.errors.add attribute, :invalid
|
record.errors.add attribute, :invalid
|
||||||
return false
|
return
|
||||||
end
|
end
|
||||||
folder = folder.dmsf_folder
|
folder = folder.dmsf_folder
|
||||||
end
|
end
|
||||||
true
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -22,14 +22,11 @@ class DmsfMaxFileSizeValidator < ActiveModel::EachValidator
|
|||||||
include Redmine::I18n
|
include Redmine::I18n
|
||||||
|
|
||||||
def validate_each(record, attribute, value)
|
def validate_each(record, attribute, value)
|
||||||
if value && (value > Setting.attachment_max_size.to_i.kilobytes)
|
return unless value && (value > Setting.attachment_max_size.to_i.kilobytes)
|
||||||
record.errors.add attribute,
|
|
||||||
l(:error_attachment_too_big, max_size: ActiveSupport::NumberHelper.number_to_human_size(
|
record.errors.add attribute,
|
||||||
Setting.attachment_max_size.to_i.kilobytes
|
l(:error_attachment_too_big, max_size: ActiveSupport::NumberHelper.number_to_human_size(
|
||||||
))
|
Setting.attachment_max_size.to_i.kilobytes
|
||||||
false
|
))
|
||||||
else
|
|
||||||
true
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -34,7 +34,7 @@ module RedmineDmsf
|
|||||||
html = +''
|
html = +''
|
||||||
container = context[:container]
|
container = context[:container]
|
||||||
# Radio buttons
|
# Radio buttons
|
||||||
if allowed_to_attach_documents(container)
|
if allowed_to_attach_documents?(container)
|
||||||
html << '<p>'
|
html << '<p>'
|
||||||
classes = +'inline'
|
classes = +'inline'
|
||||||
html << "<label class=\"#{classes}\">"
|
html << "<label class=\"#{classes}\">"
|
||||||
@ -64,7 +64,7 @@ module RedmineDmsf
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
# Upload form
|
# Upload form
|
||||||
html << attach_documents_form(context, label: false) if allowed_to_attach_documents(container)
|
html << attach_documents_form(context, label: false) if allowed_to_attach_documents?(container)
|
||||||
html
|
html
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -94,7 +94,7 @@ module RedmineDmsf
|
|||||||
|
|
||||||
def view_issues_edit_notes_bottom_style(context = {})
|
def view_issues_edit_notes_bottom_style(context = {})
|
||||||
if User.current.pref.dmsf_attachments_upload_choice == 'Attachments' ||
|
if User.current.pref.dmsf_attachments_upload_choice == 'Attachments' ||
|
||||||
!allowed_to_attach_documents(context[:container])
|
!allowed_to_attach_documents?(context[:container])
|
||||||
''
|
''
|
||||||
else
|
else
|
||||||
'display: none'
|
'display: none'
|
||||||
@ -103,7 +103,7 @@ module RedmineDmsf
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def allowed_to_attach_documents(container)
|
def allowed_to_attach_documents?(container)
|
||||||
return false unless container.respond_to?(:project) && container.respond_to?(:saved_dmsf_attachments) &&
|
return false unless container.respond_to?(:project) && container.respond_to?(:saved_dmsf_attachments) &&
|
||||||
RedmineDmsf.dmsf_act_as_attachable?
|
RedmineDmsf.dmsf_act_as_attachable?
|
||||||
|
|
||||||
@ -147,7 +147,7 @@ module RedmineDmsf
|
|||||||
|
|
||||||
# Add Dmsf upload form
|
# Add Dmsf upload form
|
||||||
container = context[:container]
|
container = context[:container]
|
||||||
return unless allowed_to_attach_documents(container)
|
return unless allowed_to_attach_documents?(container)
|
||||||
|
|
||||||
html = +'<p'
|
html = +'<p'
|
||||||
html << ' style="display: none;"' if User.current.pref.dmsf_attachments_upload_choice == 'Attachments'
|
html << ' style="display: none;"' if User.current.pref.dmsf_attachments_upload_choice == 'Attachments'
|
||||||
|
|||||||
@ -22,7 +22,7 @@ module RedmineDmsf
|
|||||||
# Helper test
|
# Helper test
|
||||||
class HelperTest < ActiveSupport::TestCase
|
class HelperTest < ActiveSupport::TestCase
|
||||||
def initialize(name)
|
def initialize(name)
|
||||||
super(name)
|
super
|
||||||
# Load all plugin's fixtures
|
# Load all plugin's fixtures
|
||||||
dir = File.join(File.dirname(__FILE__), 'fixtures')
|
dir = File.join(File.dirname(__FILE__), 'fixtures')
|
||||||
ext = '.yml'
|
ext = '.yml'
|
||||||
|
|||||||
@ -21,7 +21,6 @@ require File.expand_path('../../../test_helper', __FILE__)
|
|||||||
|
|
||||||
# WebDAV HEAD tests
|
# WebDAV HEAD tests
|
||||||
class DmsfWebdavHeadTest < RedmineDmsf::Test::IntegrationTest
|
class DmsfWebdavHeadTest < RedmineDmsf::Test::IntegrationTest
|
||||||
|
|
||||||
def test_head_requires_authentication
|
def test_head_requires_authentication
|
||||||
head "/dmsf/webdav/#{@project1.identifier}"
|
head "/dmsf/webdav/#{@project1.identifier}"
|
||||||
assert_response :unauthorized
|
assert_response :unauthorized
|
||||||
|
|||||||
@ -22,7 +22,6 @@ require 'fileutils'
|
|||||||
|
|
||||||
# WebDAV LOCK test
|
# WebDAV LOCK test
|
||||||
class DmsfWebdavLockTest < RedmineDmsf::Test::IntegrationTest
|
class DmsfWebdavLockTest < RedmineDmsf::Test::IntegrationTest
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
super
|
super
|
||||||
@xml = %(<?xml version="1.0" encoding="utf-8" ?>
|
@xml = %(<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
|||||||
@ -22,7 +22,7 @@ module RedmineDmsf
|
|||||||
# Integration test
|
# Integration test
|
||||||
class IntegrationTest < Redmine::IntegrationTest
|
class IntegrationTest < Redmine::IntegrationTest
|
||||||
def initialize(name)
|
def initialize(name)
|
||||||
super(name)
|
super
|
||||||
# Load all plugin's fixtures
|
# Load all plugin's fixtures
|
||||||
dir = File.join(File.dirname(__FILE__), 'fixtures')
|
dir = File.join(File.dirname(__FILE__), 'fixtures')
|
||||||
ext = '.yml'
|
ext = '.yml'
|
||||||
|
|||||||
@ -22,7 +22,7 @@ module RedmineDmsf
|
|||||||
# Test case
|
# Test case
|
||||||
class TestCase < ActionDispatch::IntegrationTest
|
class TestCase < ActionDispatch::IntegrationTest
|
||||||
def initialize(name)
|
def initialize(name)
|
||||||
super(name)
|
super
|
||||||
# Load all plugin's fixtures
|
# Load all plugin's fixtures
|
||||||
dir = File.join(File.dirname(__FILE__), 'fixtures')
|
dir = File.join(File.dirname(__FILE__), 'fixtures')
|
||||||
ext = '.yml'
|
ext = '.yml'
|
||||||
|
|||||||
@ -22,7 +22,7 @@ module RedmineDmsf
|
|||||||
# Unit test
|
# Unit test
|
||||||
class UnitTest < ActiveSupport::TestCase
|
class UnitTest < ActiveSupport::TestCase
|
||||||
def initialize(name)
|
def initialize(name)
|
||||||
super(name)
|
super
|
||||||
# Load all plugin's fixtures
|
# Load all plugin's fixtures
|
||||||
dir = File.join(File.dirname(__FILE__), 'fixtures')
|
dir = File.join(File.dirname(__FILE__), 'fixtures')
|
||||||
ext = '.yml'
|
ext = '.yml'
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user