diff --git a/.rubocop.yml b/.rubocop.yml index b1ceb5312..6e2368fff 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -60,6 +60,11 @@ Style/NilComparison: Exclude: - 'spec/**/*' +# let's save space in spec +Style/AlignHash: + Exclude: + - 'spec/**/*' + # No need to force reduce to use |a, e| as parameters. # Configuration parameters: Methods. Style/SingleLineBlockParams: @@ -90,3 +95,15 @@ Style/NumericLiterals: # Too often suggest wrong syntax in subarray, this should be fix in rubocop first Style/WordArray: Enabled: false + +# Ok to use parallel assigment such as: var1, var2 = [], [] +Style/ParallelAssignment: + Enabled: false + +# not working perfectly or not important enough to care +Style/EmptyLinesAroundBlockBody: + Enabled: false + +# The ABC size is a calculated magnitude, so this number can be a Fixnum or a Float. +Metrics/AbcSize: + Max: 25 diff --git a/config/application.rb b/config/application.rb index 9931ce25e..3fe81b40c 100644 --- a/config/application.rb +++ b/config/application.rb @@ -21,8 +21,8 @@ module Registry # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. - config.time_zone = ENV['time_zone'] # NB! It should be defined, - # otherwise ActiveRecord usese other class internally. + config.time_zone = ENV['time_zone'] || 'Tallinn' # NB! It should be defined, + # otherwise ActiveRecord usese other class internally. # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] diff --git a/config/initializers/autolabel.rb b/config/initializers/autolabel.rb index 160d6c322..ad877d540 100644 --- a/config/initializers/autolabel.rb +++ b/config/initializers/autolabel.rb @@ -11,6 +11,7 @@ class ActionView::Helpers::FormBuilder content = content_or_options end + # rubocop:disable Style/MultilineOperationIndentation if object.class.respond_to?(:validators_on) && object.class.validators_on(method).map(&:class).include?(ActiveRecord::Validations::PresenceValidator) @@ -20,6 +21,7 @@ class ActionView::Helpers::FormBuilder options[:class] = ((options[:class] || "") + ' required').split(' ').uniq.join(' ') end end + # rubocop:enable Style/MultilineOperationIndentation orig_label(method, content, options || {}, &block) end diff --git a/config/initializers/money.rb b/config/initializers/money.rb index 30df8eadf..bd14a3f3d 100644 --- a/config/initializers/money.rb +++ b/config/initializers/money.rb @@ -1,7 +1,6 @@ # encoding : utf-8 MoneyRails.configure do |config| - # To set the default currency # config.default_currency = :eur diff --git a/lib/devise_custom_failure.rb b/lib/devise_custom_failure.rb index b902486d4..a8a947173 100644 --- a/lib/devise_custom_failure.rb +++ b/lib/devise_custom_failure.rb @@ -1,9 +1,9 @@ class DeviseCustomFailure < Devise::FailureApp def redirect_url - return registrant_login_url if request.original_fullpath.to_s.match(/^\/registrant/) - return registrar_login_url if request.original_fullpath.to_s.match(/^\/registrar/) + return registrant_login_url if request.original_fullpath.to_s.match(%r{^\/registrant}) + return registrar_login_url if request.original_fullpath.to_s.match(%r{^\/registrar}) return '/admin' if request.original_fullpath.to_s.match(%r{^\/admin\/que}) - return admin_login_url if request.original_fullpath.to_s.match(/^\/admin/) + return admin_login_url if request.original_fullpath.to_s.match(%r{^\/admin}) root_url end diff --git a/lib/tasks/import.rake b/lib/tasks/import.rake index f5c8e409c..9a89d2b72 100644 --- a/lib/tasks/import.rake +++ b/lib/tasks/import.rake @@ -1,4 +1,5 @@ # rubocop: disable Style/SymbolProc +# rubocop: disable Performance/Detect namespace :import do # README # @@ -713,4 +714,5 @@ namespace :import do puts "-----> Imported EIS domains in #{(Time.zone.now.to_f - start).round(2)} seconds" end end +# rubocop: enable Performance/Detect # rubocop: enable Style/SymbolProc diff --git a/spec/epp/contact_spec.rb b/spec/epp/contact_spec.rb index ffbb3cd0b..de1b35df4 100644 --- a/spec/epp/contact_spec.rb +++ b/spec/epp/contact_spec.rb @@ -321,7 +321,7 @@ describe 'EPP Contact', epp: true do response[:msg].should == 'Command completed successfully' @contact.reload - @contact.name.should == 'John Doe Edited' + @contact.name.should == 'John Doe Edited' @contact.email.should == 'edited@example.example' end @@ -339,7 +339,7 @@ describe 'EPP Contact', epp: true do response[:msg].should == 'Command completed successfully' @contact.reload - @contact.name.should == 'John Doe Edited' + @contact.name.should == 'John Doe Edited' end it 'should update other contact with correct password' do @@ -365,7 +365,7 @@ describe 'EPP Contact', epp: true do response[:msg].should == 'Authorization error' @contact.reload - @contact.name.should == 'John Doe Edited' + @contact.name.should == 'John Doe Edited' end end diff --git a/spec/mailers/domain_mailer_spec.rb b/spec/mailers/domain_mailer_spec.rb index 75c0640cd..8734153ee 100644 --- a/spec/mailers/domain_mailer_spec.rb +++ b/spec/mailers/domain_mailer_spec.rb @@ -54,7 +54,7 @@ describe DomainMailer do end it 'should render verification url' do - @mail.body.encoded.should =~ /registrant\/domain_update_confirms/ + @mail.body.encoded.should =~ %r{registrant\/domain_update_confirms} end end @@ -109,7 +109,7 @@ describe DomainMailer do end it 'should render verification url' do - @mail.body.encoded.should =~ /registrant\/domain_delete_con/ # somehowe delete_confirms not matching + @mail.body.encoded.should =~ %r{registrant\/domain_delete_con} # somehowe delete_confirms not matching end end end diff --git a/spec/support/request.rb b/spec/support/request.rb index fedf1ae04..eff4ae878 100644 --- a/spec/support/request.rb +++ b/spec/support/request.rb @@ -33,6 +33,7 @@ end module Autodoc class Document + # rubocop:disable Metrics/AbcSize def route_info_doc return unless example.metadata[:route_info_doc] route = request.env["rack.routing_args"][:route_info] @@ -56,6 +57,7 @@ module Autodoc pretty_table(rows).join("\n") end + # rubocop:enable Metrics/AbcSize def pretty_table(rows) # longest_in_col = 0