diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index d16245ec4..116f80228 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2018-08-27 17:05:32 +0200 using RuboCop version 0.58.2. +# on 2019-01-30 10:50:33 +0100 using RuboCop version 0.63.1. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new @@ -22,7 +22,7 @@ Layout/ElseAlignment: Exclude: - 'lib/node_group_graph.rb' -# Offense count: 39 +# Offense count: 38 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. # SupportedStyles: empty_lines, no_empty_lines @@ -60,13 +60,12 @@ Layout/EmptyLinesAroundModuleBody: - 'lib/puppet/report_sanitizer.rb' - 'spec/support/describe_reports.rb' -# Offense count: 4 +# Offense count: 3 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyleAlignWith, AutoCorrect, Severity. # SupportedStylesAlignWith: keyword, variable, start_of_line Layout/EndAlignment: Exclude: - - 'config/initializers/01_serialize_flash_as_hash.rb' - 'lib/node_group_graph.rb' - 'lib/report_transformer.rb' @@ -79,17 +78,16 @@ Layout/IndentationConsistency: - 'spec/helpers/application_helper_spec.rb' - 'spec/lib/puppet/report_sanitizer_spec.rb' -# Offense count: 22 +# Offense count: 23 # Cop supports --auto-correct. # Configuration parameters: Width, IgnoredPatterns. Layout/IndentationWidth: Enabled: false -# Offense count: 17 +# Offense count: 15 # Cop supports --auto-correct. Layout/LeadingCommentSpace: Exclude: - - 'config/initializers/safe_yaml.rb' - 'lib/node_group_graph.rb' - 'lib/tasks/classesgroups.rake' - 'spec/helpers/pages_helper_spec.rb' @@ -97,7 +95,7 @@ Layout/LeadingCommentSpace: - 'spec/models/report_spec.rb' - 'spec/spec_helper.rb' -# Offense count: 96 +# Offense count: 95 # Cop supports --auto-correct. Layout/SpaceAfterComma: Enabled: false @@ -144,7 +142,7 @@ Layout/SpaceAroundOperators: - 'spec/models/report_spec.rb' - 'spec/models/resource_status_spec.rb' -# Offense count: 55 +# Offense count: 54 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces. # SupportedStyles: space, no_space @@ -159,7 +157,7 @@ Layout/SpaceBeforeComma: - 'app/helpers/application_helper.rb' - 'spec/models/report_spec.rb' -# Offense count: 217 +# Offense count: 212 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters. # SupportedStyles: space, no_space @@ -167,7 +165,7 @@ Layout/SpaceBeforeComma: Layout/SpaceInsideBlockBraces: Enabled: false -# Offense count: 199 +# Offense count: 195 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces. # SupportedStyles: space, no_space, compact @@ -175,7 +173,7 @@ Layout/SpaceInsideBlockBraces: Layout/SpaceInsideHashLiteralBraces: Enabled: false -# Offense count: 34 +# Offense count: 33 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. # SupportedStyles: space, no_space @@ -185,22 +183,19 @@ Layout/SpaceInsideParens: - 'app/helpers/paginate_scope_helper.rb' - 'app/helpers/reports_helper.rb' - 'app/models/report.rb' - - 'config/initializers/check_migration_version.rb' - 'lib/registry.rb' - 'lib/tasks/install.rake' - 'spec/controllers/nodes_controller_spec.rb' - 'spec/helpers/application_helper_spec.rb' - 'spec/models/report_spec.rb' -# Offense count: 12 +# Offense count: 10 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. # SupportedStyles: final_newline, final_blank_line Layout/TrailingBlankLines: Exclude: - 'app/helpers/conflict_html.rb' - - 'config/initializers/check_migration_version.rb' - - 'config/initializers/time_formats.rb' - 'lib/progress_bar.rb' - 'lib/tasks/rake_helpers.rb' - 'lib/tasks/schematize_reports.rake' @@ -211,17 +206,43 @@ Layout/TrailingBlankLines: - 'spec/shared_behaviors/controller_search.rb' - 'spec/support/should_matchers.rb' -# Offense count: 12 +# Offense count: 11 # Cop supports --auto-correct. # Configuration parameters: AllowInHeredoc. Layout/TrailingWhitespace: Exclude: - 'app/helpers/conflict_analyzer.rb' - - 'config/initializers/check_migration_version.rb' - 'lib/node_group_graph.rb' - 'lib/tasks/install.rake' - 'spec/shared_behaviors/restful_routing_behavior.rb' +# Offense count: 7 +# Cop supports --auto-correct. +Lint/DeprecatedClassMethods: + Exclude: + - 'lib/puppet_https.rb' + - 'lib/tasks/import_reports.rake' + - 'lib/tasks/install.rake' + - 'lib/tasks/plugins.rake' + +# Offense count: 8 +Lint/ShadowingOuterLocalVariable: + Exclude: + - 'app/controllers/node_groups_controller.rb' + - 'spec/factories.rb' + +# Offense count: 24 +Lint/UselessAssignment: + Exclude: + - 'app/controllers/nodes_controller.rb' + - 'app/helpers/application_helper.rb' + - 'app/helpers/conflict_html.rb' + - 'lib/progress_bar.rb' + - 'spec/controllers/nodes_controller_spec.rb' + - 'spec/helpers/application_helper_spec.rb' + - 'spec/lib/report_transformer_spec.rb' + - 'spec/models/report_spec.rb' + # Offense count: 25 # Cop supports --auto-correct. # Configuration parameters: MaxKeyValuePairs. @@ -230,7 +251,7 @@ Performance/RedundantMerge: - 'spec/controllers/node_groups_controller_spec.rb' - 'spec/controllers/nodes_controller_spec.rb' -# Offense count: 28 +# Offense count: 26 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. # SupportedStyles: always, conditionals @@ -240,7 +261,6 @@ Style/AndOr: - 'app/helpers/reports_helper.rb' - 'app/models/node.rb' - 'app/models/report.rb' - - 'config/initializers/check_migration_version.rb' - 'lib/data_generator.rb' - 'lib/find_from_form.rb' - 'lib/node_group_graph.rb' @@ -279,14 +299,14 @@ Style/DefWithParentheses: Exclude: - 'lib/puppet/report_sanitizer.rb' -# Offense count: 194 +# Offense count: 156 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. # SupportedStyles: when_needed, always, never Style/FrozenStringLiteralComment: Enabled: false -# Offense count: 1199 +# Offense count: 1196 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols. # SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys @@ -301,7 +321,15 @@ Style/MethodDefParentheses: Exclude: - 'lib/trimmer.rb' -# Offense count: 20 +# Offense count: 3 +# Cop supports --auto-correct. +Style/RedundantBegin: + Exclude: + - 'app/controllers/nodes_controller.rb' + - 'app/controllers/reports_controller.rb' + - 'app/models/resource_event.rb' + +# Offense count: 18 # Cop supports --auto-correct. # Configuration parameters: AllowMultipleReturnValues. Style/RedundantReturn: @@ -311,7 +339,6 @@ Style/RedundantReturn: - 'app/models/node.rb' - 'app/models/report.rb' - 'app/models/status.rb' - - 'config/initializers/app_version_init.rb' - 'lib/settings_reader.rb' - 'lib/tasks/db_raw.rake' - 'lib/tasks/install.rake' @@ -329,7 +356,7 @@ Style/Semicolon: - 'lib/node_group_graph.rb' - 'lib/progress_bar.rb' -# Offense count: 2052 +# Offense count: 1974 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline. # SupportedStyles: single_quotes, double_quotes @@ -349,9 +376,3 @@ Style/TrivialAccessors: Style/UnneededPercentQ: Exclude: - 'spec/controllers/nodes_controller_spec.rb' - -# Offense count: 945 -# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns. -# URISchemes: http, https -Metrics/LineLength: - Max: 275 diff --git a/Gemfile.lock b/Gemfile.lock index 0e5a78335..768838f39 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -46,30 +46,30 @@ GEM arel (9.0.0) ast (2.4.0) bindex (0.5.0) - bootsnap (1.3.0) + bootsnap (1.3.2) msgpack (~> 1.0) builder (3.2.3) - concurrent-ruby (1.0.5) + concurrent-ruby (1.1.4) crass (1.0.4) - daemons (1.2.6) + daemons (1.3.1) delayed_job (4.1.5) activesupport (>= 3.0, < 5.3) delayed_job_active_record (4.1.3) activerecord (>= 3.0, < 5.3) delayed_job (>= 3.0, < 5) diff-lcs (1.3) - docile (1.3.0) - erubi (1.7.1) + docile (1.3.1) + erubi (1.8.0) erubis (2.7.0) - eventmachine (1.2.6) + eventmachine (1.2.7) execjs (2.7.0) - factory_bot (4.8.2) + factory_bot (4.11.1) activesupport (>= 3.0.0) - factory_bot_rails (4.8.2) - factory_bot (~> 4.8.2) + factory_bot_rails (4.11.1) + factory_bot (~> 4.11.1) railties (>= 3.0.0) - ffi (1.9.24) - globalid (0.4.1) + ffi (1.10.0) + globalid (0.4.2) activesupport (>= 4.2.0) haml (5.0.4) temple (>= 0.8.0) @@ -95,14 +95,14 @@ GEM haml (>= 4.0, < 6) nokogiri (>= 1.6.0) ruby_parser (~> 3.5) - i18n (1.0.1) + i18n (1.5.3) concurrent-ruby (~> 1.0) - inherited_resources (1.8.0) - actionpack (>= 4.2, <= 5.2) + inherited_resources (1.9.0) + actionpack (>= 4.2, < 5.3) has_scope (~> 0.6) - railties (>= 4.2, <= 5.2) + railties (>= 4.2, < 5.3) responders - jaro_winkler (1.5.1) + jaro_winkler (1.5.2) jquery-rails (4.3.3) rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) @@ -119,30 +119,30 @@ GEM loofah (2.2.3) crass (~> 1.0.2) nokogiri (>= 1.5.9) - mail (2.7.0) + mail (2.7.1) mini_mime (>= 0.1.1) - marcel (0.3.2) + marcel (0.3.3) mimemagic (~> 0.3.2) metaclass (0.0.4) - method_source (0.9.0) - mimemagic (0.3.2) - mini_mime (1.0.0) - mini_portile2 (2.3.0) + method_source (0.9.2) + mimemagic (0.3.3) + mini_mime (1.0.1) + mini_portile2 (2.4.0) minitest (5.11.3) - mocha (1.5.0) + mocha (1.8.0) metaclass (~> 0.0.1) - msgpack (1.2.4) - mysql2 (0.5.1) - nio4r (2.3.0) - nokogiri (1.8.2) - mini_portile2 (~> 2.3.0) - parallel (1.12.1) - parser (2.5.1.2) + msgpack (1.2.6) + mysql2 (0.5.2) + nio4r (2.3.1) + nokogiri (1.10.1) + mini_portile2 (~> 2.4.0) + parallel (1.13.0) + parser (2.6.0.0) ast (~> 2.4.0) - pg (1.0.0) + pg (1.1.4) powerpack (0.1.2) rack (2.0.6) - rack-test (1.0.0) + rack-test (1.1.0) rack (>= 1.0, < 3) rails (5.2.2) actioncable (= 5.2.2) @@ -157,10 +157,10 @@ GEM bundler (>= 1.3.0) railties (= 5.2.2) sprockets-rails (>= 2.0.0) - rails-controller-testing (1.0.2) - actionpack (~> 5.x, >= 5.0.1) - actionview (~> 5.x, >= 5.0.1) - activesupport (~> 5.x) + rails-controller-testing (1.0.4) + actionpack (>= 5.0.1.x) + actionview (>= 5.0.1.x) + activesupport (>= 5.0.1.x) rails-dom-testing (2.0.3) activesupport (>= 4.2.0) nokogiri (>= 1.6) @@ -171,60 +171,60 @@ GEM activesupport (= 5.2.2) method_source rake (>= 0.8.7) - thor (>= 0.18.1, < 2.0) + thor (>= 0.19.0, < 2.0) rainbow (3.0.0) - rake (12.3.1) + rake (12.3.2) rb-fsevent (0.10.3) - rb-inotify (0.9.10) - ffi (>= 0.5.0, < 2) - rdoc (6.0.3) + rb-inotify (0.10.0) + ffi (~> 1.0) + rdoc (6.1.1) ref (2.0.0) - responders (2.4.0) - actionpack (>= 4.2.0, < 5.3) - railties (>= 4.2.0, < 5.3) - rspec (3.7.0) - rspec-core (~> 3.7.0) - rspec-expectations (~> 3.7.0) - rspec-mocks (~> 3.7.0) + responders (2.4.1) + actionpack (>= 4.2.0, < 6.0) + railties (>= 4.2.0, < 6.0) + rspec (3.8.0) + rspec-core (~> 3.8.0) + rspec-expectations (~> 3.8.0) + rspec-mocks (~> 3.8.0) rspec-collection_matchers (1.1.3) rspec-expectations (>= 2.99.0.beta1) - rspec-core (3.7.1) - rspec-support (~> 3.7.0) - rspec-expectations (3.7.0) + rspec-core (3.8.0) + rspec-support (~> 3.8.0) + rspec-expectations (3.8.2) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.7.0) + rspec-support (~> 3.8.0) rspec-html-matchers (0.9.1) nokogiri (~> 1) rspec (>= 3.0.0.a, < 4) - rspec-mocks (3.7.0) + rspec-mocks (3.8.0) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.7.0) - rspec-rails (3.7.2) + rspec-support (~> 3.8.0) + rspec-rails (3.8.2) actionpack (>= 3.0) activesupport (>= 3.0) railties (>= 3.0) - rspec-core (~> 3.7.0) - rspec-expectations (~> 3.7.0) - rspec-mocks (~> 3.7.0) - rspec-support (~> 3.7.0) - rspec-support (3.7.1) - rubocop (0.58.2) + rspec-core (~> 3.8.0) + rspec-expectations (~> 3.8.0) + rspec-mocks (~> 3.8.0) + rspec-support (~> 3.8.0) + rspec-support (3.8.0) + rubocop (0.63.1) jaro_winkler (~> 1.5.1) parallel (~> 1.10) parser (>= 2.5, != 2.5.1.1) powerpack (~> 0.1) rainbow (>= 2.2.2, < 4.0) ruby-progressbar (~> 1.7) - unicode-display_width (~> 1.0, >= 1.0.1) - rubocop-rails_config (0.2.3) + unicode-display_width (~> 1.4.0) + rubocop-rails_config (0.4.2) railties (>= 3.0) - rubocop (~> 0.56) + rubocop (~> 0.58) ruby-progressbar (1.10.0) ruby_dep (1.5.0) - ruby_parser (3.11.0) + ruby_parser (3.12.0) sexp_processor (~> 4.9) safe_yaml (1.0.4) - sass (3.5.6) + sass (3.7.3) sass-listen (~> 4.0.0) sass-listen (4.0.0) rb-fsevent (~> 0.9, >= 0.9.4) @@ -236,7 +236,7 @@ GEM sprockets-rails (>= 2.0, < 4.0) tilt (>= 1.1, < 3) sexp_processor (4.11.0) - shoulda-matchers (3.1.2) + shoulda-matchers (3.1.3) activesupport (>= 4.0.0) simplecov (0.16.1) docile (~> 1.1) @@ -264,16 +264,16 @@ GEM daemons (~> 1.0, >= 1.0.9) eventmachine (~> 1.0, >= 1.0.4) rack (>= 1, < 3) - thor (0.20.0) + thor (0.20.3) thread_safe (0.3.6) - tilt (2.0.8) + tilt (2.0.9) timeline_fu (0.3.0) tzinfo (1.2.5) thread_safe (~> 0.1) - uglifier (4.1.10) + uglifier (4.1.20) execjs (>= 0.3.0, < 3) - unicode-display_width (1.4.0) - web-console (3.6.2) + unicode-display_width (1.4.1) + web-console (3.7.0) actionview (>= 5.0) activemodel (>= 5.0) bindex (>= 0.4.0) @@ -329,4 +329,4 @@ DEPENDENCIES will_paginate BUNDLED WITH - 1.16.2 + 1.17.3 diff --git a/config/environments/production.rb b/config/environments/production.rb index 5f60d52ad..cf672da8b 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -71,7 +71,7 @@ # Enable locale fallbacks for I18n (makes lookups for any locale fall back to # the I18n.default_locale when a translation cannot be found). - config.i18n.fallbacks = true + config.i18n.fallbacks = [I18n.default_locale] # Send deprecation notices to registered listeners. config.active_support.deprecation = :notify diff --git a/spec/controllers/reports_controller_spec.rb b/spec/controllers/reports_controller_spec.rb index 28362b1a3..5e9a8eb75 100644 --- a/spec/controllers/reports_controller_spec.rb +++ b/spec/controllers/reports_controller_spec.rb @@ -24,7 +24,7 @@ def model; Report end describe "with a POST from Puppet 2.6.x" do subject do lambda { - post_with_body :upload, @yaml, as: :yaml + post :upload, body: @yaml, as: :yaml Delayed::Worker.new.work_off } end @@ -78,13 +78,13 @@ def model; Report end describe "#create" do it "should fail with a 403 error when disable_legacy_report_upload_url is true" do SETTINGS.stubs(:disable_legacy_report_upload_url).returns(true) - response = post_with_body :create, @yaml, as: :yaml + post :create, body: @yaml, as: :yaml response.should be_forbidden end it "should succeed when disable_legacy_report_upload_url is false" do SETTINGS.stubs(:disable_legacy_report_upload_url).returns(false) - response = post_with_body :create, @yaml, as: :yaml + post :create, body: @yaml, as: :yaml response.should be_successful end end @@ -151,11 +151,4 @@ def model; Report end assigns[:reports].should include @unchanged end end - - def post_with_body(action, body, args) - @request.env['RAW_POST_DATA'] = body - response = post(action, args) - @request.env.delete('RAW_POST_DATA') - response - end end diff --git a/spec/factories.rb b/spec/factories.rb index c8870204f..b3761112e 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -85,8 +85,8 @@ end factory :report do - status "failed" - kind "apply" + status { 'failed' } + kind { 'apply' } host do |rep| if rep.node rep.node.name @@ -97,33 +97,33 @@ time factory :successful_report do - status 'changed' + status { 'changed' } end factory :failing_report do - status 'failed' + status { 'failed' } end factory :inspect_report do - kind 'inspect' + kind { 'inspect' } end end factory :resource_status do - resource_type 'File' + resource_type { 'File' } title { generate(:filename) } evaluation_time { rand(60)+1 } file { generate(:filename) } line { rand(60)+1 } time - change_count 0 - out_of_sync_count 0 - skipped false - failed false + change_count { 0 } + out_of_sync_count { 0 } + skipped { false } + failed { false } factory :failed_resource do - failed true + failed { true } after(:create) do |status| create(:resource_event, :resource_status => status, :status => 'failed') status.change_count += 1