diff --git a/.rubocop.yml b/.rubocop.yml index b1ceb5312..16450b1d3 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,23 @@ 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: 35 + +# Very strange intention requirement, disabled for now +Style/FirstParameterIndentation: + Enabled: false + +# old school regex // works fine +Style/RegexpLiteral: + Enabled: false diff --git a/.spring.rb b/.spring.rb new file mode 100644 index 000000000..48b5ff783 --- /dev/null +++ b/.spring.rb @@ -0,0 +1,2 @@ +Spring.watch 'config/application.yml' +eee diff --git a/Gemfile b/Gemfile index fc91ac71e..a9dea2b9f 100644 --- a/Gemfile +++ b/Gemfile @@ -8,7 +8,7 @@ end if Bundler::VERSION < '2' source 'https://rubygems.org' # core -gem 'rails', '4.2.1' +gem 'rails', '4.2.3' gem 'iso8601', '~> 0.8.2' # for dates and times gem 'hashie-forbidden_attributes', '~> 0.1.1' @@ -19,7 +19,9 @@ gem 'figaro', '~> 1.1.0' gem 'pg', '~> 0.18.0' gem 'ransack', '~> 1.5.1' # for searching # with polymorphic fix -gem 'paper_trail', github: 'airblade/paper_trail', ref: 'a453811226ec4ea59753ba6b827e390ced2fc140' +gem 'paper_trail', + github: 'airblade/paper_trail', + ref: 'a453811226ec4ea59753ba6b827e390ced2fc140' gem 'rails-settings-cached', '~> 0.4.1' # for settings # html-xml @@ -28,7 +30,7 @@ gem 'nokogiri', '~> 1.6.6.2' # For XML parsing # style gem 'sass-rails', '~> 5.0.3' # sass style -gem 'bootstrap-sass', '~> 3.3.4.1' # bootstrap style +gem 'bootstrap-sass', '~> 3.3.5.1' # bootstrap style # js gem 'uglifier', '~> 2.7.1' # minifies js @@ -48,11 +50,11 @@ gem 'select2-rails', '~> 3.5.9.3' # for autocomplete gem 'bootstrap-datepicker-rails', '~> 1.3.1.1' # datepicker # rights -gem 'devise', '~> 3.4.1' # authenitcation -gem 'cancancan', '~> 1.9.2' # autharization +gem 'devise', '~> 3.5.1' # authenitcation +gem 'cancancan', '~> 1.11.0' # autharization # rest api -gem 'grape', '~> 0.10.1' +gem 'grape', '~> 0.12.0' gem 'jbuilder', '~> 2.2.6' # json api # registry specfic @@ -70,7 +72,7 @@ gem 'data_migrate', gem 'newrelic_rpm', '~> 3.12.0.288' # country listing -gem 'countries', '~> 0.10.0' +gem 'countries', '~> 0.11.4' # cloning activerecord objects gem 'deep_cloneable', '~> 2.1.1' @@ -98,18 +100,21 @@ gem 'jquery-ui-rails', '~> 5.0.3' group :development do # dev tools - gem 'spring', '~> 1.3.3' + gem 'spring', '~> 1.3.6' gem 'spring-commands-rspec', '~> 1.0.4' - gem 'guard', '~> 2.6.1' # run tests automatically - gem 'guard-rspec', '~> 4.3.1' - gem 'guard-rails', '~> 0.7.0' # run EPP server automatically - gem 'rubocop', '~> 0.26.1' - gem 'guard-rubocop', '~> 1.1.0' + gem 'spring-watcher-listen', # otherwise spring polls the filesystem on every 0.2 seconds + github: 'jonleighton/spring-watcher-listen', + ref: '7f6003e14f8f9ca178a5194f210c07f54cfb67ec' + gem 'guard', '~> 2.12.6' # run tests automatically + gem 'guard-rspec', '~> 4.5.2' + gem 'guard-rails', '~> 0.7.1' # run EPP server automatically + gem 'rubocop', '~> 0.32.1' + gem 'guard-rubocop', '~> 1.2.0' # improved errors - gem 'better_errors', '~> 2.0.0' + gem 'better_errors', '~> 2.1.1' # webconsole replacement gem 'binding_of_caller', '~> 0.7.2' - gem 'traceroute', '~> 0.4.0' # for finding dead routes and unused actions + gem 'traceroute', '~> 0.5.0' # for finding dead routes and unused actions # deploy gem 'mina', '~> 0.3.1' # for fast deployment @@ -117,32 +122,33 @@ end group :development, :test do # test stack - gem 'rspec-rails', '~> 3.0.2' + gem 'rspec-rails', '~> 3.3.2' gem 'capybara', '~> 2.4.1' gem 'phantomjs-binaries', '~> 1.9.2.4' - gem 'poltergeist', '~> 1.5.1' # We are using PhantomJS instead - gem 'phantomjs', '~> 1.9.7.1' - gem 'fabrication', '~> 2.12.2' # Replacement for fixtures - gem 'shoulda-matchers', '~> 2.6.1', require: false # Additional matchers for RSpec + gem 'poltergeist', '~> 1.6.0' # We are using PhantomJS instead + gem 'phantomjs', '~> 1.9.8.0' + gem 'fabrication', '~> 2.13.2' # Replacement for fixtures + gem 'shoulda-matchers', '~> 2.8.0', require: false # Additional matchers for RSpec gem 'launchy', '~> 2.4.3' # for opening browser automatically # helper gems - gem 'database_cleaner', '~> 1.3.0' # For cleaning db in feature and epp tests - gem 'faker', '~> 1.3.0' # Library to generate fake data + gem 'database_cleaner', '~> 1.4.1' # For cleaning db in feature and epp tests + gem 'faker', '~> 1.4.3' # Library to generate fake data # debug gem 'pry', '~> 0.10.1' # code review - gem 'simplecov', '~> 0.9.1', require: false - gem 'rubycritic', '~> 1.1.1' + gem 'simplecov', '~> 0.10.0', require: false + gem 'rubycritic', '~> 1.4.0' gem 'bullet', '~> 4.14.4' # for finding database optimizations gem 'bundler-audit', github: 'rubysec/bundler-audit', ref: 'f89ef7fae1090bbad825ea76812d56d72b417055' # for finding future vulnerable gems - gem 'brakeman', '~> 2.6.2', require: false # for security audit' + gem 'brakeman', '~> 3.0.5', require: false # for security audit' # tmp, otherwise conflics with breakman - gem 'html2haml', github: 'haml/html2haml', ref: '6984f50bdbbd6291535027726a5697f28778ee8d' + # gem 'html2haml', github: 'haml/html2haml', ref: '6984f50bdbbd6291535027726a5697f28778ee8d' + gem 'html2haml', '~> 2.0.0' gem 'sdoc', '~> 0.4.0' # bundle exec rake doc:rails generates the API under doc/api. gem 'railroady', '~> 1.3.0' # to generate database diagrams @@ -152,5 +158,5 @@ group :development, :test do # for travis gem 'rake' - gem "autodoc" + gem 'autodoc' end diff --git a/Gemfile.lock b/Gemfile.lock index 322135254..edae15b53 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -16,17 +16,6 @@ GIT data_migrate (1.3.0) rails (>= 4.1.0) -GIT - remote: https://github.com/haml/html2haml.git - revision: 6984f50bdbbd6291535027726a5697f28778ee8d - ref: 6984f50bdbbd6291535027726a5697f28778ee8d - specs: - html2haml (2.0.0.beta.2) - erubis (~> 2.7.0) - haml (~> 4.0.0) - nokogiri (~> 1.6.0) - ruby_parser (~> 3.5) - GIT remote: https://github.com/internetee/epp.git revision: 505c3f2739eb1da918e54111aecfb138a822739d @@ -35,6 +24,15 @@ GIT hpricot libxml-ruby +GIT + remote: https://github.com/jonleighton/spring-watcher-listen.git + revision: 7f6003e14f8f9ca178a5194f210c07f54cfb67ec + ref: 7f6003e14f8f9ca178a5194f210c07f54cfb67ec + specs: + spring-watcher-listen (1.0.0) + listen (~> 2.7) + spring (~> 1.2) + GIT remote: https://github.com/rubysec/bundler-audit.git revision: f89ef7fae1090bbad825ea76812d56d72b417055 @@ -47,43 +45,47 @@ GIT GEM remote: https://rubygems.org/ specs: - actionmailer (4.2.1) - actionpack (= 4.2.1) - actionview (= 4.2.1) - activejob (= 4.2.1) + abstract_type (0.0.7) + actionmailer (4.2.3) + actionpack (= 4.2.3) + actionview (= 4.2.3) + activejob (= 4.2.3) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 1.0, >= 1.0.5) - actionpack (4.2.1) - actionview (= 4.2.1) - activesupport (= 4.2.1) + actionpack (4.2.3) + actionview (= 4.2.3) + activesupport (= 4.2.3) rack (~> 1.6) rack-test (~> 0.6.2) rails-dom-testing (~> 1.0, >= 1.0.5) - rails-html-sanitizer (~> 1.0, >= 1.0.1) - actionview (4.2.1) - activesupport (= 4.2.1) + rails-html-sanitizer (~> 1.0, >= 1.0.2) + actionview (4.2.3) + activesupport (= 4.2.3) builder (~> 3.1) erubis (~> 2.7.0) rails-dom-testing (~> 1.0, >= 1.0.5) - rails-html-sanitizer (~> 1.0, >= 1.0.1) - activejob (4.2.1) - activesupport (= 4.2.1) + rails-html-sanitizer (~> 1.0, >= 1.0.2) + activejob (4.2.3) + activesupport (= 4.2.3) globalid (>= 0.3.0) - activemodel (4.2.1) - activesupport (= 4.2.1) + activemodel (4.2.3) + activesupport (= 4.2.3) builder (~> 3.1) - activerecord (4.2.1) - activemodel (= 4.2.1) - activesupport (= 4.2.1) + activerecord (4.2.3) + activemodel (= 4.2.3) + activesupport (= 4.2.3) arel (~> 6.0) activerecord-import (0.7.0) activerecord (>= 3.0) - activesupport (4.2.1) + activesupport (4.2.3) i18n (~> 0.7) json (~> 1.7, >= 1.7.7) minitest (~> 5.1) thread_safe (~> 0.3, >= 0.3.4) tzinfo (~> 1.1) + adamantium (0.2.0) + ice_nine (~> 0.11.0) + memoizable (~> 0.4.0) addressable (2.3.8) akami (1.3.1) gyoku (>= 0.4.0) @@ -96,7 +98,7 @@ GEM actionpack activesupport (>= 3.0.0) rspec - autoprefixer-rails (5.2.0.1) + autoprefixer-rails (5.2.1) execjs json axiom-types (0.1.1) @@ -104,7 +106,7 @@ GEM ice_nine (~> 0.11.0) thread_safe (~> 0.3, >= 0.3.1) bcrypt (3.1.10) - better_errors (2.0.0) + better_errors (2.1.1) coderay (>= 1.0.0) erubis (>= 2.6.6) rack (>= 0.9.0) @@ -112,25 +114,24 @@ GEM debug_inspector (>= 0.0.1) bootstrap-datepicker-rails (1.3.1.1) railties (>= 3.0) - bootstrap-sass (3.3.4.1) + bootstrap-sass (3.3.5.1) autoprefixer-rails (>= 5.0.0.1) - sass (>= 3.2.19) - brakeman (2.6.3) + sass (>= 3.3.0) + brakeman (3.0.5) erubis (~> 2.6) fastercsv (~> 1.5) haml (>= 3.0, < 5.0) highline (~> 1.6.20) multi_json (~> 1.2) ruby2ruby (~> 2.1.1) - ruby_parser (~> 3.5.0) + ruby_parser (~> 3.7.0) sass (~> 3.0) - slim (>= 1.3.6, < 3.0) terminal-table (~> 1.4) builder (3.2.2) bullet (4.14.7) activesupport (>= 3.0.0) uniform_notifier (~> 1.9.0) - cancancan (1.9.2) + cancancan (1.11.0) capybara (2.4.4) mime-types (>= 1.16) nokogiri (>= 1.3.3) @@ -151,18 +152,22 @@ GEM coffee-script-source execjs coffee-script-source (1.9.1.1) - countries (0.10.0) + concord (0.1.5) + adamantium (~> 0.2.0) + equalizer (~> 0.0.9) + countries (0.11.4) currencies (~> 0.4.2) + i18n_data (~> 0.7.0) crack (0.4.2) safe_yaml (~> 1.0.0) currencies (0.4.2) - database_cleaner (1.3.0) + database_cleaner (1.4.1) debug_inspector (0.0.2) deep_cloneable (2.1.1) activerecord (>= 3.1.0, < 5.0.0) descendants_tracker (0.0.4) thread_safe (~> 0.3, >= 0.3.1) - devise (3.4.1) + devise (3.5.1) bcrypt (~> 3.0) orm_adapter (~> 0.1) railties (>= 3.2.6, < 5) @@ -183,8 +188,8 @@ GEM equalizer (0.0.11) erubis (2.7.0) execjs (2.5.2) - fabrication (2.12.2) - faker (1.3.0) + fabrication (2.13.2) + faker (1.4.3) i18n (~> 0.5) fastercsv (1.5.5) ffi (1.9.8) @@ -199,7 +204,7 @@ GEM formatador (0.2.5) globalid (0.3.5) activesupport (>= 4.1.0) - grape (0.10.1) + grape (0.12.0) activesupport builder hashie (>= 2.1.0) @@ -209,18 +214,24 @@ GEM rack-accept rack-mount virtus (>= 1.0.0) - guard (2.6.1) + guard (2.12.6) formatador (>= 0.2.4) listen (~> 2.7) lumberjack (~> 1.0) + nenv (~> 0.1) + notiffany (~> 0.0) pry (>= 0.9.12) + shellany (~> 0.0) thor (>= 0.18.1) - guard-rails (0.7.0) - guard (~> 2.0) - guard-rspec (4.3.1) + guard-compat (1.2.1) + guard-rails (0.7.1) + guard (~> 2.11) + guard-compat (~> 1.0) + guard-rspec (4.5.2) guard (~> 2.1) - rspec (>= 2.14, < 4.0) - guard-rubocop (1.1.0) + guard-compat (~> 1.1) + rspec (>= 2.99.0, < 4.0) + guard-rubocop (1.2.0) guard (~> 2.0) rubocop (~> 0.20) gyoku (1.3.1) @@ -239,11 +250,17 @@ GEM highline (1.6.21) hitimes (1.2.2) hpricot (0.8.6) + html2haml (2.0.0) + erubis (~> 2.7.0) + haml (~> 4.0.0) + nokogiri (~> 1.6.0) + ruby_parser (~> 3.5) html5_validators (1.2.0) httpclient (2.6.0.1) httpi (2.4.1) rack i18n (0.7.0) + i18n_data (0.7.0) ice_nine (0.11.1) isikukood (0.1.2) iso8601 (0.8.6) @@ -277,6 +294,8 @@ GEM lumberjack (1.0.9) mail (2.6.3) mime-types (>= 1.16, < 3) + memoizable (0.4.2) + thread_safe (~> 0.3, >= 0.3.1) method_source (0.8.2) mime-types (2.6.1) mina (0.3.4) @@ -295,28 +314,33 @@ GEM railties (>= 3.0) multi_json (1.11.1) multi_xml (0.5.5) + nenv (0.2.0) newrelic_rpm (3.12.0.288) nokogiri (1.6.6.2) mini_portile (~> 0.6.0) nori (2.6.0) + notiffany (0.0.6) + nenv (~> 0.1) + shellany (~> 0.0) nprogress-rails (0.1.6.7) open4 (1.3.4) orm_adapter (0.5.0) - parser (2.3.0.pre.2) + parser (2.2.2.5) ast (>= 1.1, < 3.0) pdfkit (0.6.2) pg (0.18.2) - phantomjs (1.9.7.1) + phantomjs (1.9.8.0) phantomjs-binaries (1.9.2.4) sys-uname (= 0.9.0) - poltergeist (1.5.1) + poltergeist (1.6.0) capybara (~> 2.1) cliver (~> 0.3.1) multi_json (~> 1.0) websocket-driver (>= 0.2.0) polyamorous (1.2.0) activerecord (>= 3.0) - powerpack (0.0.9) + powerpack (0.1.1) + procto (0.0.2) pry (0.10.1) coderay (~> 1.1.0) method_source (~> 0.8.1) @@ -336,16 +360,16 @@ GEM rack-test (0.6.3) rack (>= 1.0) railroady (1.3.0) - rails (4.2.1) - actionmailer (= 4.2.1) - actionpack (= 4.2.1) - actionview (= 4.2.1) - activejob (= 4.2.1) - activemodel (= 4.2.1) - activerecord (= 4.2.1) - activesupport (= 4.2.1) + rails (4.2.3) + actionmailer (= 4.2.3) + actionpack (= 4.2.3) + actionview (= 4.2.3) + activejob (= 4.2.3) + activemodel (= 4.2.3) + activerecord (= 4.2.3) + activesupport (= 4.2.3) bundler (>= 1.3.0, < 2.0) - railties (= 4.2.1) + railties (= 4.2.3) sprockets-rails rails-deprecated_sanitizer (1.0.3) activesupport (>= 4.2.0.alpha) @@ -357,13 +381,13 @@ GEM loofah (~> 2.0) rails-settings-cached (0.4.1) rails (>= 4.0.0) - railties (4.2.1) - actionpack (= 4.2.1) - activesupport (= 4.2.1) + railties (4.2.3) + actionpack (= 4.2.3) + activesupport (= 4.2.3) rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) rainbow (2.0.0) - raindrops (0.13.0) + raindrops (0.14.0) rake (10.4.2) ransack (1.5.1) actionpack (>= 3.0) @@ -375,56 +399,55 @@ GEM rb-inotify (0.9.5) ffi (>= 0.5.0) rdoc (4.2.0) - reek (1.3.8) + reek (1.6.5) + parser (~> 2.2.0.pre.7) rainbow (>= 1.99, < 3.0) - ruby2ruby (>= 2.0.8, < 3.0) - ruby_parser (~> 3.3) - sexp_processor + unparser (~> 0.2.2) ref (1.0.5) request_store (1.1.0) responders (2.1.0) railties (>= 4.2.0, < 5) - rspec (3.0.0) - rspec-core (~> 3.0.0) - rspec-expectations (~> 3.0.0) - rspec-mocks (~> 3.0.0) - rspec-core (3.0.4) - rspec-support (~> 3.0.0) - rspec-expectations (3.0.4) + rspec (3.3.0) + rspec-core (~> 3.3.0) + rspec-expectations (~> 3.3.0) + rspec-mocks (~> 3.3.0) + rspec-core (3.3.1) + rspec-support (~> 3.3.0) + rspec-expectations (3.3.0) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.0.0) - rspec-mocks (3.0.4) - rspec-support (~> 3.0.0) - rspec-rails (3.0.2) - actionpack (>= 3.0) - activesupport (>= 3.0) - railties (>= 3.0) - rspec-core (~> 3.0.0) - rspec-expectations (~> 3.0.0) - rspec-mocks (~> 3.0.0) - rspec-support (~> 3.0.0) - rspec-support (3.0.4) - rubocop (0.26.1) + rspec-support (~> 3.3.0) + rspec-mocks (3.3.1) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.3.0) + rspec-rails (3.3.2) + actionpack (>= 3.0, < 4.3) + activesupport (>= 3.0, < 4.3) + railties (>= 3.0, < 4.3) + rspec-core (~> 3.3.0) + rspec-expectations (~> 3.3.0) + rspec-mocks (~> 3.3.0) + rspec-support (~> 3.3.0) + rspec-support (3.3.0) + rubocop (0.32.1) astrolabe (~> 1.3) - parser (>= 2.2.0.pre.4, < 3.0) - powerpack (~> 0.0.6) + parser (>= 2.2.2.5, < 3.0) + powerpack (~> 0.1) rainbow (>= 1.99.1, < 3.0) ruby-progressbar (~> 1.4) ruby-progressbar (1.7.5) ruby2ruby (2.1.4) ruby_parser (~> 3.1) sexp_processor (~> 4.0) - ruby_parser (3.5.0) + ruby_parser (3.7.0) sexp_processor (~> 4.1) - rubycritic (1.1.1) + rubycritic (1.4.0) flay (= 2.4.0) flog (= 4.2.1) - parser (~> 2.1) - reek (= 1.3.8) - ruby2ruby (>= 2.1.1, < 3.0) + parser (>= 2.2.0, < 3.0) + reek (= 1.6.5) virtus (~> 1.0) safe_yaml (1.0.4) - sass (3.4.14) + sass (3.4.15) sass-rails (5.0.3) railties (>= 4.0.0, < 5.0) sass (~> 3.1) @@ -446,34 +469,31 @@ GEM thor (~> 0.14) selectize-rails (0.12.1) sexp_processor (4.6.0) - shoulda-matchers (2.6.2) + shellany (0.0.1) + shoulda-matchers (2.8.0) activesupport (>= 3.0.0) - simplecov (0.9.2) + simplecov (0.10.0) docile (~> 1.1.0) - multi_json (~> 1.0) - simplecov-html (~> 0.9.0) - simplecov-html (0.9.0) + json (~> 1.8) + simplecov-html (~> 0.10.0) + simplecov-html (0.10.0) simpleidn (0.0.5) sinatra (1.4.6) rack (~> 1.4) rack-protection (~> 1.4) tilt (>= 1.3, < 3) - slim (2.1.0) - temple (~> 0.6.9) - tilt (>= 1.3.3, < 2.1) slop (3.6.0) spring (1.3.6) spring-commands-rspec (1.0.4) spring (>= 0.9.1) sprockets (3.2.0) rack (~> 1.0) - sprockets-rails (2.3.1) + sprockets-rails (2.3.2) actionpack (>= 3.0) activesupport (>= 3.0) sprockets (>= 2.8, < 4.0) sys-uname (0.9.0) ffi (>= 1.0.0) - temple (0.6.10) terminal-table (1.4.5) therubyracer (0.12.2) libv8 (~> 3.16.14.0) @@ -483,7 +503,7 @@ GEM tilt (1.4.1) timers (4.0.1) hitimes - traceroute (0.4.0) + traceroute (0.5.0) rails (>= 3.0.0) turbolinks (2.5.3) coffee-rails @@ -497,6 +517,14 @@ GEM rack raindrops (~> 0.7) uniform_notifier (1.9.0) + unparser (0.2.4) + abstract_type (~> 0.0.7) + adamantium (~> 0.2.0) + concord (~> 0.1.5) + diff-lcs (~> 1.2.5) + equalizer (~> 0.0.9) + parser (~> 2.2.2) + procto (~> 0.0.2) uuidtools (2.1.5) virtus (1.0.5) axiom-types (~> 0.1) @@ -522,36 +550,36 @@ PLATFORMS DEPENDENCIES activerecord-import (~> 0.7.0) autodoc - better_errors (~> 2.0.0) + better_errors (~> 2.1.1) binding_of_caller (~> 0.7.2) bootstrap-datepicker-rails (~> 1.3.1.1) - bootstrap-sass (~> 3.3.4.1) - brakeman (~> 2.6.2) + bootstrap-sass (~> 3.3.5.1) + brakeman (~> 3.0.5) bullet (~> 4.14.4) bundler-audit! - cancancan (~> 1.9.2) + cancancan (~> 1.11.0) capybara (~> 2.4.1) coderay (~> 1.1.0) coffee-rails (~> 4.1.0) - countries (~> 0.10.0) + countries (~> 0.11.4) data_migrate! - database_cleaner (~> 1.3.0) + database_cleaner (~> 1.4.1) deep_cloneable (~> 2.1.1) - devise (~> 3.4.1) + devise (~> 3.5.1) digidoc_client (~> 0.2.1) epp (~> 1.4.2)! epp-xml (~> 1.0.3) - fabrication (~> 2.12.2) - faker (~> 1.3.0) + fabrication (~> 2.13.2) + faker (~> 1.4.3) figaro (~> 1.1.0) - grape (~> 0.10.1) - guard (~> 2.6.1) - guard-rails (~> 0.7.0) - guard-rspec (~> 4.3.1) - guard-rubocop (~> 1.1.0) + grape (~> 0.12.0) + guard (~> 2.12.6) + guard-rails (~> 0.7.1) + guard-rspec (~> 4.5.2) + guard-rubocop (~> 1.2.0) haml-rails (~> 0.9.0) hashie-forbidden_attributes (~> 0.1.1) - html2haml! + html2haml (~> 2.0.0) html5_validators (~> 1.2.0) isikukood iso8601 (~> 0.8.2) @@ -569,31 +597,32 @@ DEPENDENCIES paper_trail! pdfkit (~> 0.6.2) pg (~> 0.18.0) - phantomjs (~> 1.9.7.1) + phantomjs (~> 1.9.8.0) phantomjs-binaries (~> 1.9.2.4) - poltergeist (~> 1.5.1) + poltergeist (~> 1.6.0) pry (~> 0.10.1) que (~> 0.10.0) que-web (~> 0.4.0) railroady (~> 1.3.0) - rails (= 4.2.1) + rails (= 4.2.3) rails-settings-cached (~> 0.4.1) rake ransack (~> 1.5.1) - rspec-rails (~> 3.0.2) - rubocop (~> 0.26.1) - rubycritic (~> 1.1.1) + rspec-rails (~> 3.3.2) + rubocop (~> 0.32.1) + rubycritic (~> 1.4.0) sass-rails (~> 5.0.3) sdoc (~> 0.4.0) select2-rails (~> 3.5.9.3) selectize-rails (~> 0.12.1) - shoulda-matchers (~> 2.6.1) - simplecov (~> 0.9.1) + shoulda-matchers (~> 2.8.0) + simplecov (~> 0.10.0) simpleidn (~> 0.0.5) - spring (~> 1.3.3) + spring (~> 1.3.6) spring-commands-rspec (~> 1.0.4) + spring-watcher-listen! therubyracer (~> 0.12.2) - traceroute (~> 0.4.0) + traceroute (~> 0.5.0) turbolinks (~> 2.5.3) uglifier (~> 2.7.1) unicorn diff --git a/app/controllers/admin/zonefiles_controller.rb b/app/controllers/admin/zonefiles_controller.rb index 9977d30b6..7d3b68ec6 100644 --- a/app/controllers/admin/zonefiles_controller.rb +++ b/app/controllers/admin/zonefiles_controller.rb @@ -1,7 +1,6 @@ class Admin::ZonefilesController < ApplicationController authorize_resource class: false # TODO: Refactor this - # rubocop:disable Metrics/MethodLength def create if ZonefileSetting.pluck(:origin).include?(params[:origin]) diff --git a/app/controllers/epp/domains_controller.rb b/app/controllers/epp/domains_controller.rb index 9f7ffb6ec..a3977e8e2 100644 --- a/app/controllers/epp/domains_controller.rb +++ b/app/controllers/epp/domains_controller.rb @@ -29,7 +29,6 @@ class Epp::DomainsController < EppController end end - # rubocop:disable Metrics/CyclomaticComplexity def update authorize! :update, @domain, @password @@ -44,7 +43,6 @@ class Epp::DomainsController < EppController end end - # rubocop:disable Metrics/CyclomaticComplexity def delete authorize! :delete, @domain, @password @@ -66,7 +64,6 @@ class Epp::DomainsController < EppController handle_errors(@domain) end end - # rubocop:enbale Metrics/CyclomaticComplexity def check authorize! :check, Epp::Domain @@ -88,8 +85,6 @@ class Epp::DomainsController < EppController render_epp_response '/epp/domains/renew' end - # rubocop: disable Metrics/PerceivedComplexity - # rubocop: disable Metrics/MethodLength def transfer authorize! :transfer, @domain, @password action = params[:parsed_frame].css('transfer').first[:op] @@ -102,8 +97,6 @@ class Epp::DomainsController < EppController handle_errors(@domain) end end - # rubocop: enable Metrics/MethodLength - # rubocop: enable Metrics/CyclomaticComplexity private diff --git a/app/controllers/epp/keyrelays_controller.rb b/app/controllers/epp/keyrelays_controller.rb index cbfdae665..d6515758f 100644 --- a/app/controllers/epp/keyrelays_controller.rb +++ b/app/controllers/epp/keyrelays_controller.rb @@ -1,7 +1,6 @@ class Epp::KeyrelaysController < EppController skip_authorization_check # TODO: move authorization under ability - # rubocop: disable Metrics/PerceivedComplexity # rubocop: disable Metrics/CyclomaticComplexity def keyrelay # keyrelay temp turned off @@ -30,7 +29,6 @@ class Epp::KeyrelaysController < EppController exactly_one_of 'expiry > relative', 'expiry > absolute' end - # rubocop: enable Metrics/PerceivedComplexity # rubocop: enable Metrics/CyclomaticComplexity def find_domain diff --git a/app/controllers/epp/sessions_controller.rb b/app/controllers/epp/sessions_controller.rb index f0a1e2458..fe241d94e 100644 --- a/app/controllers/epp/sessions_controller.rb +++ b/app/controllers/epp/sessions_controller.rb @@ -8,6 +8,7 @@ class Epp::SessionsController < EppController # rubocop: disable Metrics/PerceivedComplexity # rubocop: disable Metrics/CyclomaticComplexity # rubocop: disable Metrics/MethodLength + # rubocop: disable Metrics/AbcSize def login success = true @api_user = ApiUser.find_by(login_params) @@ -56,6 +57,9 @@ class Epp::SessionsController < EppController end end # rubocop: enable Metrics/MethodLength + # rubocop: enable Metrics/AbcSize + # rubocop: enable Metrics/PerceivedComplexity + # rubocop: enable Metrics/CyclomaticComplexity def ip_white? return true if request.ip == ENV['webclient_ip'] @@ -75,9 +79,6 @@ class Epp::SessionsController < EppController true end - # rubocop: enable Metrics/PerceivedComplexity - # rubocop: enable Metrics/CyclomaticComplexity - def logout @api_user = current_user # cache current_user for logging epp_session.destroy diff --git a/app/controllers/epp_controller.rb b/app/controllers/epp_controller.rb index 8817e150e..16090a885 100644 --- a/app/controllers/epp_controller.rb +++ b/app/controllers/epp_controller.rb @@ -272,7 +272,6 @@ class EppController < ApplicationController end # rubocop: enable Style/PredicateName - # rubocop: disable Metrics/PerceivedComplexity # rubocop: disable Metrics/CyclomaticComplexity def write_to_epp_log # return nil if EPP_LOG_ENABLED @@ -295,7 +294,6 @@ class EppController < ApplicationController ip: request.ip }) end - # rubocop: enable Metrics/PerceivedComplexity # rubocop: enable Metrics/CyclomaticComplexity def iptables_counter_update diff --git a/app/controllers/registrant/domain_delete_confirms_controller.rb b/app/controllers/registrant/domain_delete_confirms_controller.rb index 73d7f21b5..f6f05d628 100644 --- a/app/controllers/registrant/domain_delete_confirms_controller.rb +++ b/app/controllers/registrant/domain_delete_confirms_controller.rb @@ -9,7 +9,7 @@ class Registrant::DomainDeleteConfirmsController < RegistrantController end # rubocop: disable Metrics/PerceivedComplexity - # rubocop: disable Metrics/CyclomaticComplexity + # rubocop: disable Metrics/AbcSize def update @domain = Domain.find(params[:id]) unless @domain.registrant_delete_confirmable?(params[:token]) @@ -39,5 +39,5 @@ class Registrant::DomainDeleteConfirmsController < RegistrantController end end # rubocop: enable Metrics/PerceivedComplexity - # rubocop: enable Metrics/CyclomaticComplexity + # rubocop: enable Metrics/AbcSize end diff --git a/app/controllers/registrant/domain_update_confirms_controller.rb b/app/controllers/registrant/domain_update_confirms_controller.rb index debe7294b..598681d7a 100644 --- a/app/controllers/registrant/domain_update_confirms_controller.rb +++ b/app/controllers/registrant/domain_update_confirms_controller.rb @@ -9,7 +9,7 @@ class Registrant::DomainUpdateConfirmsController < RegistrantController end # rubocop: disable Metrics/PerceivedComplexity - # rubocop: disable Metrics/CyclomaticComplexity + # rubocop: disable Metrics/AbcSize def update @domain = Domain.find(params[:id]) unless @domain.registrant_update_confirmable?(params[:token]) @@ -39,5 +39,5 @@ class Registrant::DomainUpdateConfirmsController < RegistrantController end end # rubocop: enable Metrics/PerceivedComplexity - # rubocop: enable Metrics/CyclomaticComplexity + # rubocop: enable Metrics/AbcSize end diff --git a/app/controllers/registrant/sessions_controller.rb b/app/controllers/registrant/sessions_controller.rb index 2d8c3013d..f0a292137 100644 --- a/app/controllers/registrant/sessions_controller.rb +++ b/app/controllers/registrant/sessions_controller.rb @@ -4,6 +4,7 @@ class Registrant::SessionsController < Devise::SessionsController def login end + # rubocop: disable Metrics/AbcSize def id if Rails.env.development? sign_in(RegistrantUser.find_or_create_by_idc_data('test'), event: :authentication) @@ -22,12 +23,14 @@ class Registrant::SessionsController < Devise::SessionsController redirect_to registrant_login_url end end + # rubocop: enable Metrics/AbcSize def login_mid @user = User.new end - def mid # rubocop: disable Metrics/MethodLength + # rubocop: disable Metrics/MethodLength + def mid phone = params[:user][:phone] endpoint = "#{ENV['sk_digi_doc_service_endpoint']}" client = Digidoc::Client.new(endpoint) @@ -64,8 +67,9 @@ class Registrant::SessionsController < Devise::SessionsController render json: { message: t(:no_such_user) }, status: :unauthorized end end + # rubocop: enable Metrics/MethodLength - # rubocop: disable Metrics/PerceivedComplexity + # rubocop: disable Metrics/AbcSize # rubocop: disable Metrics/CyclomaticComplexity # rubocop: disable Metrics/MethodLength def mid_status @@ -104,7 +108,7 @@ class Registrant::SessionsController < Devise::SessionsController render json: { message: t(:internal_error) }, status: :bad_request end end - # rubocop: enable Metrics/PerceivedComplexity + # rubocop: enable Metrics/AbcSize # rubocop: enable Metrics/CyclomaticComplexity # rubocop: enable Metrics/MethodLength diff --git a/app/controllers/registrar/sessions_controller.rb b/app/controllers/registrar/sessions_controller.rb index 3fea41f75..940e5f415 100644 --- a/app/controllers/registrar/sessions_controller.rb +++ b/app/controllers/registrar/sessions_controller.rb @@ -14,11 +14,9 @@ class Registrar::SessionsController < Devise::SessionsController # rubocop:disable Metrics/PerceivedComplexity # rubocop:disable Metrics/CyclomaticComplexity # rubocop:disable Metrics/MethodLength + # rubocop:disable Metrics/AbcSize def create - @depp_user = Depp::User.new(params[:depp_user].merge( - pki: !(Rails.env.development? || Rails.env.test?) - ) - ) + @depp_user = Depp::User.new(params[:depp_user].merge(pki: !(Rails.env.development? || Rails.env.test?))) if @depp_user.pki && request.env['HTTP_SSL_CLIENT_S_DN_CN'].blank? @depp_user.errors.add(:base, :webserver_missing_user_name_directive) @@ -64,6 +62,7 @@ class Registrar::SessionsController < Devise::SessionsController # rubocop:enable Metrics/CyclomaticComplexity # rubocop:enable Metrics/PerceivedComplexity # rubocop:enable Metrics/MethodLength + # rubocop:enable Metrics/AbcSize def id @user = ApiUser.find_by_idc_data(request.env['SSL_CLIENT_S_DN']) @@ -119,9 +118,9 @@ class Registrar::SessionsController < Devise::SessionsController render json: { message: t(:no_such_user) }, status: :unauthorized end end - # rubocop: enable Metrics/MethodLength + # rubocop:enable Metrics/MethodLength - # rubocop: disable Metrics/PerceivedComplexity + # rubocop: disable Metrics/AbcSize # rubocop: disable Metrics/CyclomaticComplexity # rubocop: disable Metrics/MethodLength def mid_status @@ -159,7 +158,7 @@ class Registrar::SessionsController < Devise::SessionsController render json: { message: t(:internal_error) }, status: :bad_request end end - # rubocop: enable Metrics/PerceivedComplexity + # rubocop: enable Metrics/AbcSize # rubocop: enable Metrics/CyclomaticComplexity # rubocop: enable Metrics/MethodLength diff --git a/app/models/ability.rb b/app/models/ability.rb index 3c641fdcb..7ab23e4dc 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -3,6 +3,7 @@ class Ability # rubocop: disable Metrics/CyclomaticComplexity # rubocop: disable Metrics/PerceivedComplexity # rubocop: disable Metrics/LineLength + # rubocop: disable Metrics/AbcSize def initialize(user) alias_action :show, to: :view alias_action :show, :create, :update, :destroy, to: :crud diff --git a/app/models/api_user.rb b/app/models/api_user.rb index 3312de5d4..3d18ea181 100644 --- a/app/models/api_user.rb +++ b/app/models/api_user.rb @@ -1,9 +1,9 @@ require 'open3' -# rubocop: disable Metrics/ClassLength class ApiUser < User include EppErrors - def epp_code_map # rubocop:disable Metrics/MethodLength + + def epp_code_map { '2306' => [ # Parameter policy error [:password, :blank] @@ -77,4 +77,3 @@ class ApiUser < User end end end -# rubocop: enable Metrics/ClassLength diff --git a/app/models/bank_statement.rb b/app/models/bank_statement.rb index a5102ce78..7267b4773 100644 --- a/app/models/bank_statement.rb +++ b/app/models/bank_statement.rb @@ -27,6 +27,7 @@ class BankStatement < ActiveRecord::Base File.open(import_file_path, 'w') { |f| f.write(th6_file.open.read) } end + # rubocop: disable Metrics/AbcSize def parse_th6_row(row) return parse_th6_header(row) if row[4, 3].strip == '000' return if row[4, 3].strip == '999' # skip footer @@ -47,6 +48,7 @@ class BankStatement < ActiveRecord::Base reference_no: row[280, 35].strip } end + # rubocop: enable Metrics/AbcSize def parse_th6_header(row) self.bank_code = row[7, 3].strip diff --git a/app/models/certificate.rb b/app/models/certificate.rb index b354f87f2..c1a7d3019 100644 --- a/app/models/certificate.rb +++ b/app/models/certificate.rb @@ -76,6 +76,7 @@ class Certificate < ActiveRecord::Base @cached_status = REVOKED end + # rubocop: disable Metrics/AbcSize def sign! csr_file = Tempfile.new('client_csr') csr_file.write(csr) @@ -107,6 +108,7 @@ class Certificate < ActiveRecord::Base return false end end + # rubocop: enable Metrics/AbcSize def revoke! crt_file = Tempfile.new('client_crt') diff --git a/app/models/depp/contact.rb b/app/models/depp/contact.rb index be0429c2f..ddac61049 100644 --- a/app/models/depp/contact.rb +++ b/app/models/depp/contact.rb @@ -20,7 +20,6 @@ module Depp class << self attr_reader :epp_xml, :user - # rubocop: disable Metrics/MethodLength def new_from_params(params) new( id: params[:code], @@ -43,8 +42,8 @@ module Depp country_code: params[:country_code] ) end - # rubocop: enable Metrics/MethodLength + # rubocop:disable Metrics/AbcSize def find_by_id(id) data = info_xml(id) @@ -77,6 +76,7 @@ module Depp statuses: data.css('status').map { |s| [s['s'], s.text] } ) end + # rubocop:enable Metrics/AbcSize def user=(user) @user = user @@ -170,7 +170,8 @@ module Depp handle_errors(data) end - # rubocop: disable Metrics/MethodLength + # rubocop:disable Metrics/MethodLength + # rubocop:disable Metrics/AbcSize def update_attributes(params) self.ident_country_code = params[:ident_country_code] self.ident_type = params[:ident_type] @@ -214,7 +215,8 @@ module Depp data = Depp::Contact.user.request(update_xml) handle_errors(data) end - # rubocop: enable Metrics/MethodLength + # rubocop:enbale Metrics/AbcSize + # rubocop:enable Metrics/MethodLength def delete delete_xml = Contact.epp_xml.delete( diff --git a/app/models/depp/domain.rb b/app/models/depp/domain.rb index 4a13d5ba5..649d00964 100644 --- a/app/models/depp/domain.rb +++ b/app/models/depp/domain.rb @@ -130,7 +130,9 @@ module Depp ret.with_indifferent_access end - def construct_params_from_server_data(data) # rubocop:disable Metrics/MethodLength + # rubocop:disable Metrics/MethodLength + # rubocop:disable Metrics/AbcSize + def construct_params_from_server_data(data) ret = default_params ret[:name] = data.css('name').text ret[:registrant] = data.css('registrant').text @@ -176,6 +178,8 @@ module Depp ret end + # rubocop:enable Metrics/MethodLength + # rubocop:enable Metrics/AbcSize def construct_custom_params_hash(domain_params) custom_params = {} @@ -233,7 +237,7 @@ module Depp host_attr << { hostAddr: { value: v['ipv4'], attrs: { ip: 'v4' } } } if v['ipv4'].present? host_attr << { hostAddr: { value: v['ipv6'], attrs: { ip: 'v6' } } } if v['ipv6'].present? - ret << { hostAttr: host_attr } + ret << { hostAttr: host_attr } end ret @@ -256,11 +260,11 @@ module Depp domain_params[:dnskeys_attributes].each do |_k, v| if v['ds_key_tag'].blank? kd = create_key_data_hash(v) - ret << { + ret << { keyData: kd } if kd else - ret << { + ret << { dsData: [ keyTag: { value: v['ds_key_tag'] }, alg: { value: v['ds_alg'] }, diff --git a/app/models/depp/keyrelay.rb b/app/models/depp/keyrelay.rb index f4e609c05..8e8eaec26 100644 --- a/app/models/depp/keyrelay.rb +++ b/app/models/depp/keyrelay.rb @@ -8,7 +8,7 @@ module Depp self.epp_xml = EppXml::Keyrelay.new(cl_trid_prefix: current_user.tag) end - def keyrelay(params) # rubocop:disable Metrics/MethodLength + def keyrelay(params) custom_params = {} if params[:legal_document].present? type = params[:legal_document].original_filename.split('.').last.downcase diff --git a/app/models/depp/user.rb b/app/models/depp/user.rb index fcce49c10..4efbd42d9 100644 --- a/app/models/depp/user.rb +++ b/app/models/depp/user.rb @@ -36,6 +36,7 @@ module Depp Nokogiri::XML(e.response_xml.to_s).remove_namespaces! end + # rubocop:disable Metrics/AbcSize def repp_request(path, params = {}) client_cert = File.read(ENV['cert_path']) client_key = File.read(ENV['key_path']) @@ -51,8 +52,7 @@ module Depp use_ssl: (uri.scheme == 'https'), verify_mode: OpenSSL::SSL::VERIFY_NONE, cert: OpenSSL::X509::Certificate.new(client_cert), - key: OpenSSL::PKey::RSA.new(client_key) - ) do |http| + key: OpenSSL::PKey::RSA.new(client_key)) do |http| http.request(req) end @@ -67,6 +67,7 @@ module Depp ret end + # rubocop:enable Metrics/AbcSize private diff --git a/app/models/dnskey.rb b/app/models/dnskey.rb index 5dd03ae50..0c426978c 100644 --- a/app/models/dnskey.rb +++ b/app/models/dnskey.rb @@ -114,7 +114,7 @@ class Dnskey < ActiveRecord::Base end def bin_to_hex(s) - s.each_byte.map { |b| sprintf('%02X', b) }.join + s.each_byte.map { |b| format('%02X', b) }.join end end end diff --git a/app/models/domain.rb b/app/models/domain.rb index 50e8b6fa4..2fa8e338e 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -207,6 +207,7 @@ class Domain < ActiveRecord::Base STDOUT << "#{Time.zone.now.utc} - Successfully set delete_candidate to #{d.count} domains\n" end + # rubocop:disable Rails/FindEach def destroy_delete_candidates STDOUT << "#{Time.zone.now.utc} - Destroying domains\n" unless Rails.env.test? @@ -223,6 +224,7 @@ class Domain < ActiveRecord::Base STDOUT << "#{Time.zone.now.utc} - Successfully destroyed #{c} domains\n" unless Rails.env.test? end + # rubocop:enable Rails/FindEach end def name=(value) @@ -410,8 +412,8 @@ class Domain < ActiveRecord::Base res = '' parts = name.split('.') parts.each do |x| - res += sprintf('%02X', x.length) # length of label in hex - res += x.each_byte.map { |b| sprintf('%02X', b) }.join # label + res += format('%02X', x.length) # length of label in hex + res += x.each_byte.map { |b| format('%02X', b) }.join # label end res += '00' diff --git a/app/models/epp/contact.rb b/app/models/epp/contact.rb index d9ba0a48a..d85b16cec 100644 --- a/app/models/epp/contact.rb +++ b/app/models/epp/contact.rb @@ -1,4 +1,3 @@ -# rubocop: disable Metrics/ClassLength class Epp::Contact < Contact include EppErrors @@ -15,6 +14,7 @@ class Epp::Contact < Contact # rubocop: disable Metrics/PerceivedComplexity # rubocop: disable Metrics/CyclomaticComplexity # rubocop: disable Metrics/MethodLength + # rubocop: disable Metrics/AbcSize def attrs_from(frame, rem = nil) f = frame at = {}.with_indifferent_access @@ -53,6 +53,7 @@ class Epp::Contact < Contact # rubocop: enable Metrics/MethodLength # rubocop: enable Metrics/PerceivedComplexity # rubocop: enable Metrics/CyclomaticComplexity + # rubocop: enable Metrics/AbcSize def new(frame, registrar) return super if frame.blank? @@ -149,4 +150,3 @@ class Epp::Contact < Contact super(at) end end -# rubocop: enable Metrics/ClassLength diff --git a/app/models/epp/domain.rb b/app/models/epp/domain.rb index bca034f52..de88619e6 100644 --- a/app/models/epp/domain.rb +++ b/app/models/epp/domain.rb @@ -81,13 +81,14 @@ class Epp::Domain < Domain def attach_default_contacts return if registrant.blank? regt = Registrant.find(registrant.id) # temp for bullet - tech_contacts << regt if tech_domain_contacts.blank? + tech_contacts << regt if tech_domain_contacts.blank? admin_contacts << regt if admin_domain_contacts.blank? && regt.priv? end # rubocop: disable Metrics/PerceivedComplexity # rubocop: disable Metrics/CyclomaticComplexity # rubocop: disable Metrics/MethodLength + # rubocop: disable Metrics/AbcSize def attrs_from(frame, current_user, action = nil) at = {}.with_indifferent_access @@ -130,6 +131,7 @@ class Epp::Domain < Domain # rubocop: enable Metrics/PerceivedComplexity # rubocop: enable Metrics/CyclomaticComplexity # rubocop: enable Metrics/MethodLength + # rubocop: enable Metrics/AbcSize def nameservers_attrs(frame, action) ns_list = nameservers_from(frame) @@ -358,6 +360,7 @@ class Epp::Domain < Domain }] end + # rubocop: disable Metrics/AbcSize def update(frame, current_user, verify = true) return super if frame.blank? at = {}.with_indifferent_access @@ -380,6 +383,7 @@ class Epp::Domain < Domain self.deliver_emails = true # turn on email delivery for epp errors.empty? && super(at) end + # rubocop: enable Metrics/AbcSize def apply_pending_update! preclean_pendings @@ -524,6 +528,7 @@ class Epp::Domain < Domain # rubocop: enable Metrics/CyclomaticComplexity # rubocop: disable Metrics/MethodLength + # rubocop: disable Metrics/AbcSize def query_transfer(frame, current_user) return false unless can_be_transferred_to?(current_user.registrar) @@ -533,10 +538,10 @@ class Epp::Domain < Domain transaction do begin dt = domain_transfers.create!( - transfer_requested_at: Time.zone.now, - transfer_to: current_user.registrar, - transfer_from: registrar - ) + transfer_requested_at: Time.zone.now, + transfer_to: current_user.registrar, + transfer_from: registrar + ) if dt.pending? registrar.messages.create!( @@ -565,6 +570,7 @@ class Epp::Domain < Domain end end end + # rubocop: enable Metrics/AbcSize # rubocop: enable Metrics/MethodLength def approve_transfer(frame, current_user) @@ -621,13 +627,14 @@ class Epp::Domain < Domain end # rubocop:disable Metrics/MethodLength + # rubocop:disable Metrics/AbcSize def keyrelay(parsed_frame, requester) if registrar == requester errors.add(:base, :domain_already_belongs_to_the_querying_registrar) and return false end abs_datetime = parsed_frame.css('absolute').text - abs_datetime = DateTime.parse(abs_datetime) if abs_datetime.present? + abs_datetime = DateTime.zone.parse(abs_datetime) if abs_datetime.present? transaction do kr = keyrelays.build( @@ -664,6 +671,7 @@ class Epp::Domain < Domain true end + # rubocop:enable Metrics/AbcSize # rubocop:enable Metrics/MethodLength ### VALIDATIONS ### diff --git a/app/models/nameserver.rb b/app/models/nameserver.rb index 0fad0ff5c..6206a4f16 100644 --- a/app/models/nameserver.rb +++ b/app/models/nameserver.rb @@ -47,8 +47,7 @@ class Nameserver < ActiveRecord::Base def replace_hostname_ends(domains, old_end, new_end) domains = domains.where('EXISTS( select 1 from nameservers ns where ns.domain_id = domains.id AND ns.hostname LIKE ? - )', "%#{old_end}" - ) + )', "%#{old_end}") count, success_count = 0.0, 0.0 domains.each do |d| diff --git a/app/models/registrar.rb b/app/models/registrar.rb index 38f09aa04..bc4eb3297 100644 --- a/app/models/registrar.rb +++ b/app/models/registrar.rb @@ -73,7 +73,9 @@ class Registrar < ActiveRecord::Base end end - def issue_prepayment_invoice(amount, description = nil) # rubocop:disable Metrics/MethodLength + # rubocop:disable Metrics/AbcSize + # rubocop:disable Metrics/MethodLength + def issue_prepayment_invoice(amount, description = nil) # Currently only EIS can issue invoices eis = self.class.eis @@ -122,6 +124,8 @@ class Registrar < ActiveRecord::Base ] ) end + # rubocop:enable Metrics/AbcSize + # rubocop:enable Metrics/MethodLength def cash_account accounts.find_by(account_type: Account::CASH) diff --git a/app/models/whois_record.rb b/app/models/whois_record.rb index e1b168935..5113b331f 100644 --- a/app/models/whois_record.rb +++ b/app/models/whois_record.rb @@ -30,6 +30,7 @@ class WhoisRecord < ActiveRecord::Base end # rubocop:disable Metrics/MethodLength + # rubocop:disable Metrics/AbcSize def generate_json h = HashWithIndifferentAccess.new return h if domain.blank? @@ -108,10 +109,11 @@ More information at http://internet.ee EOS end # rubocop:enable Metrics/MethodLength + # rubocop:enable Metrics/AbcSize def contacts_body(admins, techs) admins ||= [] - techs ||= [] + techs ||= [] out = '' out << (admins.size > 1 ? "\nAdministrative contacts" : "\nAdministrative contact") diff --git a/app/validators/date_time_iso8601_validator.rb b/app/validators/date_time_iso8601_validator.rb index d764620e8..cc77e0d9e 100644 --- a/app/validators/date_time_iso8601_validator.rb +++ b/app/validators/date_time_iso8601_validator.rb @@ -9,7 +9,7 @@ class DateTimeIso8601Validator < ActiveModel::EachValidator return true if value.empty? begin - DateTime.parse(value) + DateTime.zone.parse(value) rescue => _e return false end diff --git a/app/validators/object_count_validator.rb b/app/validators/object_count_validator.rb index b442a360a..d2d880fea 100644 --- a/app/validators/object_count_validator.rb +++ b/app/validators/object_count_validator.rb @@ -1,7 +1,9 @@ class ObjectCountValidator < ActiveModel::EachValidator def validate_each(record, attribute, value) min, max = options[:min].call, options[:max].call - return if value.reject(&:marked_for_destruction?).length.between?(min, max) + values = value.reject(&:marked_for_destruction?) + + return if values.size.between?(min, max) association = options[:association] || attribute record.errors.add(association, :out_of_range, { min: min, max: max }) end 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/config/spring.rb b/config/spring.rb new file mode 100644 index 000000000..12c701147 --- /dev/null +++ b/config/spring.rb @@ -0,0 +1 @@ +Spring.watch 'config/application.yml' 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..752f017ef 100644 --- a/spec/epp/contact_spec.rb +++ b/spec/epp/contact_spec.rb @@ -151,7 +151,7 @@ describe 'EPP Contact', epp: true do id.text.length.should == 15 # 5 seconds for what-ever weird lag reasons might happen - cr_date.text.to_time.should be_within(5).of(Time.zone.now) + cr_date.text.in_time_zone.utc.should be_within(5).of(Time.zone.now) end it 'should add registrar prefix for code when missing' do @@ -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/epp/domain_spec.rb b/spec/epp/domain_spec.rb index 9161f5cdc..aa9ebd389 100644 --- a/spec/epp/domain_spec.rb +++ b/spec/epp/domain_spec.rb @@ -89,8 +89,8 @@ describe 'EPP Domain', epp: true do cre_data = response[:parsed].css('creData') cre_data.css('name').text.should == dn - cre_data.css('crDate').text.should == d.created_at.to_time.utc.iso8601 - cre_data.css('exDate').text.should == d.valid_to.to_time.utc.iso8601 + cre_data.css('crDate').text.should == d.created_at.in_time_zone.utc.utc.iso8601 + cre_data.css('exDate').text.should == d.valid_to.in_time_zone.utc.utc.iso8601 response[:clTRID].should == 'ABC-12345' @@ -746,10 +746,10 @@ describe 'EPP Domain', epp: true do trn_data.css('name').text.should == domain.name trn_data.css('trStatus').text.should == 'serverApproved' trn_data.css('reID').text.should == 'REGDOMAIN2' - trn_data.css('reDate').text.should == dtl.transfer_requested_at.to_time.utc.iso8601 + trn_data.css('reDate').text.should == dtl.transfer_requested_at.in_time_zone.utc.utc.iso8601 trn_data.css('acID').text.should == 'REGDOMAIN1' - trn_data.css('acDate').text.should == dtl.transferred_at.to_time.utc.iso8601 - trn_data.css('exDate').text.should == domain.valid_to.to_time.utc.iso8601 + trn_data.css('acDate').text.should == dtl.transferred_at.in_time_zone.utc.utc.iso8601 + trn_data.css('exDate').text.should == domain.valid_to.in_time_zone.utc.utc.iso8601 domain.registrar.should == @registrar2 @@ -791,10 +791,10 @@ describe 'EPP Domain', epp: true do trn_data.css('name').text.should == domain.name trn_data.css('trStatus').text.should == 'pending' trn_data.css('reID').text.should == 'REGDOMAIN1' - trn_data.css('reDate').text.should == dtl.transfer_requested_at.to_time.utc.iso8601 - trn_data.css('acDate').text.should == dtl.wait_until.to_time.utc.iso8601 + trn_data.css('reDate').text.should == dtl.transfer_requested_at.in_time_zone.utc.utc.iso8601 + trn_data.css('acDate').text.should == dtl.wait_until.in_time_zone.utc.utc.iso8601 trn_data.css('acID').text.should == 'REGDOMAIN2' - trn_data.css('exDate').text.should == domain.valid_to.to_time.utc.iso8601 + trn_data.css('exDate').text.should == domain.valid_to.in_time_zone.utc.utc.iso8601 domain.registrar.should == @registrar2 @@ -806,10 +806,10 @@ describe 'EPP Domain', epp: true do trn_data.css('name').text.should == domain.name trn_data.css('trStatus').text.should == 'pending' trn_data.css('reID').text.should == 'REGDOMAIN1' - trn_data.css('reDate').text.should == dtl.transfer_requested_at.to_time.utc.iso8601 - trn_data.css('acDate').text.should == dtl.wait_until.to_time.utc.iso8601 + trn_data.css('reDate').text.should == dtl.transfer_requested_at.in_time_zone.utc.utc.iso8601 + trn_data.css('acDate').text.should == dtl.wait_until.in_time_zone.utc.utc.iso8601 trn_data.css('acID').text.should == 'REGDOMAIN2' - trn_data.css('exDate').text.should == domain.valid_to.to_time.utc.iso8601 + trn_data.css('exDate').text.should == domain.valid_to.in_time_zone.utc.utc.iso8601 domain.registrar.should == @registrar2 @@ -1213,9 +1213,9 @@ describe 'EPP Domain', epp: true do trn_data.css('name').text.should == domain.name trn_data.css('trStatus').text.should == 'clientApproved' trn_data.css('reID').text.should == 'REGDOMAIN2' - trn_data.css('reDate').text.should == dtl.transfer_requested_at.to_time.utc.iso8601 + trn_data.css('reDate').text.should == dtl.transfer_requested_at.in_time_zone.utc.utc.iso8601 trn_data.css('acID').text.should == 'REGDOMAIN1' - trn_data.css('exDate').text.should == domain.valid_to.to_time.utc.iso8601 + trn_data.css('exDate').text.should == domain.valid_to.in_time_zone.utc.utc.iso8601 end it 'rejects a domain transfer' do @@ -2187,8 +2187,8 @@ describe 'EPP Domain', epp: true do ns1.css('hostName').last.text.should == 'ns1.example.com' ns1.css('hostAddr').first.text.should == '192.168.1.1' ns1.css('hostAddr').last.text.should == '1080:0:0:0:8:800:200C:417A' - inf_data.css('crDate').text.should == domain.created_at.to_time.utc.iso8601 - inf_data.css('exDate').text.should == domain.valid_to.to_time.utc.iso8601 + inf_data.css('crDate').text.should == domain.created_at.in_time_zone.utc.utc.iso8601 + inf_data.css('exDate').text.should == domain.valid_to.in_time_zone.utc.utc.iso8601 inf_data.css('pw').text.should == domain.auth_info ds_data_1 = response[:parsed].css('dsData')[0] @@ -2217,7 +2217,7 @@ describe 'EPP Domain', epp: true do response = epp_plain_request(domain_info_xml(name: { value: domain.name })) inf_data = response[:parsed].css('resData infData') - inf_data.css('upDate').text.should == domain.updated_at.to_time.utc.iso8601 + inf_data.css('upDate').text.should == domain.updated_at.in_time_zone.utc.utc.iso8601 end it 'returns domain info with different nameservers' do 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/models/dnskey_spec.rb b/spec/models/dnskey_spec.rb index 911713da5..a7ddfece4 100644 --- a/spec/models/dnskey_spec.rb +++ b/spec/models/dnskey_spec.rb @@ -49,7 +49,7 @@ describe Dnskey do dk = d.dnskeys.last dk.generate_digest - dk.ds_digest.should == '0B62D1BC64EFD1EE652FB102BDF1011BF514CCD9A1A0CFB7472AEA3B01F38C92' + dk.ds_digest.should == '0B62D1BC64EFD1EE652FB102BDF1011BF514CCD9A1A0CFB7472AEA3B01F38C92' dk.ds_key_tag.should == '30607' end