diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 0e36ae041..abf114a2e 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2017-09-04 11:31:12 +0100 using RuboCop version 0.49.1. +# on 2017-12-06 17:18:57 +0000 using RuboCop version 0.51.0. # 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 @@ -21,16 +21,18 @@ Lint/AmbiguousRegexpLiteral: - 'spec/unit/puppet/type/mysql_grant_spec.rb' # Offense count: 1 -Lint/DuplicatedKey: +Lint/RescueWithoutErrorClass: Exclude: - - 'spec/classes/mysql_server_backup_spec.rb' + - 'lib/facter/mysql_server_id.rb' -# Offense count: 1 -Lint/HandleExceptions: +# Offense count: 16 +Lint/ReturnInVoidContext: Exclude: - - 'spec/spec_helper.rb' + - 'lib/puppet/provider/mysql_database/mysql.rb' + - 'lib/puppet/provider/mysql_user/mysql.rb' # Offense count: 1 +# Cop supports --auto-correct. Lint/ScriptPermission: Exclude: - 'spec/unit/puppet/functions/mysql_deepmerge_spec.rb' @@ -40,17 +42,54 @@ Lint/UselessAssignment: Exclude: - 'spec/unit/puppet/functions/mysql_deepmerge_spec.rb' -# Offense count: 11 -# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns. -# URISchemes: http, https -Metrics/LineLength: - Max: 351 +# Offense count: 56 +# Configuration parameters: Blacklist. +# Blacklist: END, (?-mix:EO[A-Z]{1}) +Naming/HeredocDelimiterNaming: + Exclude: + - 'lib/puppet/parser/functions/mysql_deepmerge.rb' + - 'lib/puppet/parser/functions/mysql_dirname.rb' + - 'lib/puppet/parser/functions/mysql_password.rb' + - 'lib/puppet/parser/functions/mysql_strip_hash.rb' + - 'spec/acceptance/locales_spec.rb' + - 'spec/acceptance/mysql_backup_spec.rb' + - 'spec/acceptance/mysql_db_spec.rb' + - 'spec/acceptance/mysql_server_spec.rb' + - 'spec/acceptance/sql_task_spec.rb' + - 'spec/acceptance/types/mysql_database_spec.rb' + - 'spec/acceptance/types/mysql_grant_spec.rb' + - 'spec/acceptance/types/mysql_plugin_spec.rb' + - 'spec/acceptance/types/mysql_user_spec.rb' + - 'spec/classes/mysql_server_account_security_spec.rb' + - 'spec/classes/mysql_server_backup_spec.rb' -# Offense count: 1 -RSpec/BeforeAfterAll: +# Offense count: 6 +# Cop supports --auto-correct. +# Configuration parameters: AutoCorrect. +Performance/HashEachMethods: Exclude: - - 'spec/acceptance/**/*.rb' - - 'spec/unit/puppet/functions/mysql_password_spec.rb' + - 'lib/puppet/parser/functions/mysql_strip_hash.rb' + - 'lib/puppet/provider/mysql_database/mysql.rb' + - 'lib/puppet/provider/mysql_grant/mysql.rb' + - 'lib/puppet/provider/mysql_plugin/mysql.rb' + - 'lib/puppet/provider/mysql_user/mysql.rb' + - 'spec/unit/puppet/provider/mysql_user/mysql_spec.rb' + +# Offense count: 40 +# Configuration parameters: Prefixes. +# Prefixes: when, with, without +RSpec/ContextWording: + Exclude: + - 'spec/acceptance/mysql_backup_spec.rb' + - 'spec/acceptance/types/mysql_user_spec.rb' + - 'spec/classes/graceful_failures_spec.rb' + - 'spec/classes/mycnf_template_spec.rb' + - 'spec/classes/mysql_server_backup_spec.rb' + - 'spec/classes/mysql_server_mysqltuner_spec.rb' + - 'spec/classes/mysql_server_spec.rb' + - 'spec/unit/facter/mysql_server_id_spec.rb' + - 'spec/unit/puppet/type/mysql_grant_spec.rb' + - 'spec/unit/puppet/type/mysql_user_spec.rb' # Offense count: 56 # Configuration parameters: Max. @@ -86,7 +125,7 @@ RSpec/InstanceVariable: - 'spec/unit/puppet/type/mysql_plugin_spec.rb' - 'spec/unit/puppet/type/mysql_user_spec.rb' -# Offense count: 38 +# Offense count: 42 RSpec/MultipleExpectations: Max: 4 @@ -111,6 +150,11 @@ RSpec/ScatteredLet: - 'spec/unit/puppet/provider/mysql_plugin/mysql_spec.rb' - 'spec/unit/puppet/provider/mysql_user/mysql_spec.rb' +# Offense count: 1 +Style/CommentedKeyword: + Exclude: + - 'spec/spec_helper_acceptance.rb' + # Offense count: 7 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, SupportedStyles, AllowInnerSlashes. diff --git a/.sync.yml b/.sync.yml index 6292516d7..1526f98c2 100644 --- a/.sync.yml +++ b/.sync.yml @@ -7,3 +7,7 @@ spec/spec_helper.rb: extras: - rvm: 2.1.9 script: bundle exec rake rubocop +.rubocop.yml: + unmanaged: true +.rubocop_todo.yml: + unmanaged: true diff --git a/.travis.yml b/.travis.yml index 09eacc6d0..6055eb19c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,13 +22,13 @@ matrix: script: bundle exec rake beaker services: docker sudo: required - - rvm: 2.4.0 + - rvm: 2.4.1 bundler_args: --without system_tests env: PUPPET_GEM_VERSION="~> 5.0" - rvm: 2.1.9 bundler_args: --without system_tests env: PUPPET_GEM_VERSION="~> 4.0" - rvm: 2.1.9 - script: bundle exec rubocop lib + script: bundle exec rake rubocop notifications: email: false diff --git a/Gemfile b/Gemfile index 0618bfa91..a9f0161c7 100644 --- a/Gemfile +++ b/Gemfile @@ -31,6 +31,7 @@ end supports_windows = false ruby_version_segments = Gem::Version.new(RUBY_VERSION.dup).segments minor_version = "#{ruby_version_segments[0]}.#{ruby_version_segments[1]}" + group :development do gem "puppet-module-posix-default-r#{minor_version}", :require => false, :platforms => "ruby" gem "puppet-module-win-default-r#{minor_version}", :require => false, :platforms => ["mswin", "mingw", "x64_mingw"] @@ -44,16 +45,12 @@ end group :system_tests do gem "puppet-module-posix-system-r#{minor_version}", :require => false, :platforms => "ruby" gem "puppet-module-win-system-r#{minor_version}", :require => false, :platforms => ["mswin", "mingw", "x64_mingw"] - gem "beaker", *location_for(ENV['BEAKER_VERSION'] || '>= 3') + gem "beaker", *location_for(ENV['BEAKER_VERSION'] || '>= 3') gem "beaker-pe", :require => false - gem "beaker-rspec", *location_for(ENV['BEAKER_RSPEC_VERSION']) + gem "beaker-rspec", *location_for(ENV['BEAKER_RSPEC_VERSION']) gem "beaker-hostgenerator", *location_for(ENV['BEAKER_HOSTGENERATOR_VERSION']) - gem "beaker-abs", *location_for(ENV['BEAKER_ABS_VERSION'] || '~> 0.1') + gem "beaker-abs", *location_for(ENV['BEAKER_ABS_VERSION'] || '~> 0.1') gem "puppet-blacksmith", '~> 3.4', :require => false - gem "puppet-lint-i18n" - gem "puppet_pot_generator" - gem "rubocop-i18n", '~> 1.0' - gem "beaker-i18n_helper" end gem 'puppet', *location_for(ENV['PUPPET_GEM_VERSION']) diff --git a/Rakefile b/Rakefile index 0c0772c76..d12d85495 100644 --- a/Rakefile +++ b/Rakefile @@ -1,6 +1,5 @@ require 'puppetlabs_spec_helper/rake_tasks' require 'puppet-lint/tasks/puppet-lint' -require 'puppet_pot_generator/rake_tasks' if Bundler.rubygems.find_name('puppet_pot_generator').any? require 'puppet_blacksmith/rake_tasks' if Bundler.rubygems.find_name('puppet-blacksmith').any? PuppetLint.configuration.fail_on_warnings = true diff --git a/locales/config.yaml b/locales/config.yaml index 20c34af2f..e3f7805bb 100644 --- a/locales/config.yaml +++ b/locales/config.yaml @@ -22,4 +22,5 @@ gettext: # Patterns for +Dir.glob+ used to find all files that might contain # translatable content, relative to the project root directory source_files: - - './lib/**/*.rb' + - './lib/**/*.rb' + diff --git a/metadata.json b/metadata.json index dea7f5e3c..67adef390 100644 --- a/metadata.json +++ b/metadata.json @@ -10,7 +10,7 @@ "dependencies": [ {"name":"puppetlabs/translate","version_requirement":">= 1.0.0 < 2.0.0"}, {"name":"puppetlabs/stdlib","version_requirement":">= 3.2.0 < 5.0.0"}, - {"name":"puppet/staging","version_requirement":">= 1.0.1 < 3.0.0"} + {"name":"puppet/staging","version_requirement":">= 1.0.1 < 4.0.0"} ], "operatingsystem_support": [ { diff --git a/spec/acceptance/sql_task_spec.rb b/spec/acceptance/sql_task_spec.rb index fcf8ac02e..cc29d2927 100644 --- a/spec/acceptance/sql_task_spec.rb +++ b/spec/acceptance/sql_task_spec.rb @@ -11,7 +11,7 @@ class { 'mysql::server': root_password => 'password' } } EOS - it "sets up a mysql instance" do + it 'sets up a mysql instance' do apply_manifest(pp, catch_failures: true) end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 1b8480d41..01912b60c 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -4,5 +4,6 @@ # put local configuration and setup into spec_helper_local begin require 'spec_helper_local' -rescue LoadError +rescue LoadError => loaderror + puts "Could not require spec_helper_local: #{loaderror.message}" end diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index 64881f1c1..247065348 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -68,7 +68,7 @@ def expect_multiple_regexes(result:, regexes:) # Configure all nodes in nodeset c.before :suite do - run_puppet_access_login(user: 'admin') if pe_install? + run_puppet_access_login(user: 'admin') if pe_install? && puppet_version =~ %r{(5\.\d\.\d)} hosts.each do |host| # This will be removed, this is temporary to test localisation. if (fact('osfamily') == 'Debian' || fact('osfamily') == 'RedHat') && (puppet_version >= '4.10.5' && puppet_version < '5.2.0') diff --git a/tasks/sql.rb b/tasks/sql.rb index c7ddb917a..0d0ee8612 100755 --- a/tasks/sql.rb +++ b/tasks/sql.rb @@ -8,8 +8,8 @@ def get(sql, database, user, password) cmd_string << " --database=#{database}" unless database.nil? cmd_string << " --user=#{user}" unless user.nil? cmd_string << " --password=#{password}" unless password.nil? - stdout, stderr, status = Open3.capture3(cmd_string) - raise Puppet::Error, _("stderr: '#{stderr}'") if status != 0 + stdout, _stderr, status = Open3.capture3(cmd_string) + raise Puppet::Error, _("stderr: ' %{stderr}') % { stderr: stderr }") if status != 0 { status: stdout.strip } end