diff options
author | Toon Claes <toon@gitlab.com> | 2019-02-28 19:57:34 +0100 |
---|---|---|
committer | Toon Claes <toon@gitlab.com> | 2019-02-28 19:57:34 +0100 |
commit | 62d7990b9bb30cf33ed87017c5c633d1cccc75c2 (patch) | |
tree | c3e1b69c58a412ba1c6f50a0337a23d9f9d6e1a4 /lib/system_check | |
parent | f6453eca992a9c142268e78ac782cef98110d183 (diff) | |
download | gitlab-ce-tc-standard-gem.tar.gz |
Ran standardrb --fix on the whole codebasetc-standard-gem
Inspired by https://twitter.com/searls/status/1101137953743613952 I
decided to try https://github.com/testdouble/standard on our codebase.
It's opinionated, but at least it's a _standard_.
Diffstat (limited to 'lib/system_check')
44 files changed, 179 insertions, 183 deletions
diff --git a/lib/system_check/app/active_users_check.rb b/lib/system_check/app/active_users_check.rb index 8446c2fc2c8..f837a12aea9 100644 --- a/lib/system_check/app/active_users_check.rb +++ b/lib/system_check/app/active_users_check.rb @@ -3,7 +3,7 @@ module SystemCheck module App class ActiveUsersCheck < SystemCheck::BaseCheck - set_name 'Active users:' + set_name "Active users:" def multi_check active_users = User.active.count diff --git a/lib/system_check/app/database_config_exists_check.rb b/lib/system_check/app/database_config_exists_check.rb index 1769145ed63..e0a6a5c64a7 100644 --- a/lib/system_check/app/database_config_exists_check.rb +++ b/lib/system_check/app/database_config_exists_check.rb @@ -3,22 +3,22 @@ module SystemCheck module App class DatabaseConfigExistsCheck < SystemCheck::BaseCheck - set_name 'Database config exists?' + set_name "Database config exists?" def check? - database_config_file = Rails.root.join('config', 'database.yml') + database_config_file = Rails.root.join("config", "database.yml") File.exist?(database_config_file) end def show_error try_fixing_it( - 'Copy config/database.yml.<your db> to config/database.yml', - 'Check that the information in config/database.yml is correct' + "Copy config/database.yml.<your db> to config/database.yml", + "Check that the information in config/database.yml is correct" ) for_more_information( - 'doc/install/databases.md', - 'http://guides.rubyonrails.org/getting_started.html#configuring-a-database' + "doc/install/databases.md", + "http://guides.rubyonrails.org/getting_started.html#configuring-a-database" ) fix_and_rerun end diff --git a/lib/system_check/app/git_config_check.rb b/lib/system_check/app/git_config_check.rb index 4e8d607096c..e50a103a089 100644 --- a/lib/system_check/app/git_config_check.rb +++ b/lib/system_check/app/git_config_check.rb @@ -4,15 +4,15 @@ module SystemCheck module App class GitConfigCheck < SystemCheck::BaseCheck OPTIONS = { - 'core.autocrlf' => 'input' + "core.autocrlf" => "input", }.freeze - set_name 'Git configured correctly?' + set_name "Git configured correctly?" def check? - correct_options = OPTIONS.map do |name, value| - run_command(%W(#{Gitlab.config.git.bin_path} config --global --get #{name})).try(:squish) == value - end + correct_options = OPTIONS.map { |name, value| + run_command(%W[#{Gitlab.config.git.bin_path} config --global --get #{name}]).try(:squish) == value + } correct_options.all? end @@ -24,19 +24,19 @@ module SystemCheck def repair! return false unless gitlab_user? - command_success = OPTIONS.map do |name, value| - system(*%W(#{Gitlab.config.git.bin_path} config --global #{name} #{value})) - end + command_success = OPTIONS.map { |name, value| + system(Gitlab.config.git.bin_path.to_s, "config", "--global", name.to_s, value.to_s) + } command_success.all? end def show_error try_fixing_it( - sudo_gitlab("\"#{Gitlab.config.git.bin_path}\" config --global core.autocrlf \"#{OPTIONS['core.autocrlf']}\"") + sudo_gitlab("\"#{Gitlab.config.git.bin_path}\" config --global core.autocrlf \"#{OPTIONS["core.autocrlf"]}\"") ) for_more_information( - see_installation_guide_section 'GitLab' + see_installation_guide_section("GitLab") ) end end diff --git a/lib/system_check/app/git_user_default_ssh_config_check.rb b/lib/system_check/app/git_user_default_ssh_config_check.rb index 6cd53779bfd..bac06a6108f 100644 --- a/lib/system_check/app/git_user_default_ssh_config_check.rb +++ b/lib/system_check/app/git_user_default_ssh_config_check.rb @@ -12,8 +12,8 @@ module SystemCheck known_hosts ].freeze - set_name 'Git user has default SSH configuration?' - set_skip_reason 'skipped (git user is not present / configured)' + set_name "Git user has default SSH configuration?" + set_skip_reason "skipped (git user is not present / configured)" def skip? !home_dir || !File.directory?(home_dir) @@ -26,9 +26,9 @@ module SystemCheck def show_error backup_dir = "~/gitlab-check-backup-#{Time.now.to_i}" - instructions = forbidden_files.map do |filename| + instructions = forbidden_files.map { |filename| "sudo mv #{Shellwords.escape(filename)} #{backup_dir}" - end + } try_fixing_it("mkdir #{backup_dir}", *instructions) for_more_information('doc/ssh/README.md in section "SSH on the GitLab server"') @@ -55,13 +55,13 @@ module SystemCheck def ssh_dir return nil unless home_dir - File.join(home_dir, '.ssh') + File.join(home_dir, ".ssh") end def forbidden_files @forbidden_files ||= begin - present = Dir[File.join(ssh_dir, '*')] + present = Dir[File.join(ssh_dir, "*")] whitelisted = WHITELIST.map { |basename| File.join(ssh_dir, basename) } present - whitelisted diff --git a/lib/system_check/app/git_version_check.rb b/lib/system_check/app/git_version_check.rb index 7c3e7759dd0..59f6abba2ce 100644 --- a/lib/system_check/app/git_version_check.rb +++ b/lib/system_check/app/git_version_check.rb @@ -3,15 +3,15 @@ module SystemCheck module App class GitVersionCheck < SystemCheck::BaseCheck - set_name -> { "Git version >= #{self.required_version} ?" } - set_check_pass -> { "yes (#{self.current_version})" } + set_name -> { "Git version >= #{required_version} ?" } + set_check_pass -> { "yes (#{current_version})" } def self.required_version - @required_version ||= Gitlab::VersionInfo.parse('2.18.0') + @required_version ||= Gitlab::VersionInfo.parse("2.18.0") end def self.current_version - @current_version ||= Gitlab::VersionInfo.parse(Gitlab::TaskHelpers.run_command(%W(#{Gitlab.config.git.bin_path} --version))) + @current_version ||= Gitlab::VersionInfo.parse(Gitlab::TaskHelpers.run_command(%W[#{Gitlab.config.git.bin_path} --version])) end def check? diff --git a/lib/system_check/app/gitlab_config_exists_check.rb b/lib/system_check/app/gitlab_config_exists_check.rb index 1cc5ead0d89..b29aa66d8a9 100644 --- a/lib/system_check/app/gitlab_config_exists_check.rb +++ b/lib/system_check/app/gitlab_config_exists_check.rb @@ -3,21 +3,21 @@ module SystemCheck module App class GitlabConfigExistsCheck < SystemCheck::BaseCheck - set_name 'GitLab config exists?' + set_name "GitLab config exists?" def check? - gitlab_config_file = Rails.root.join('config', 'gitlab.yml') + gitlab_config_file = Rails.root.join("config", "gitlab.yml") File.exist?(gitlab_config_file) end def show_error try_fixing_it( - 'Copy config/gitlab.yml.example to config/gitlab.yml', - 'Update config/gitlab.yml to match your setup' + "Copy config/gitlab.yml.example to config/gitlab.yml", + "Update config/gitlab.yml to match your setup" ) for_more_information( - see_installation_guide_section 'GitLab' + see_installation_guide_section("GitLab") ) fix_and_rerun end diff --git a/lib/system_check/app/gitlab_config_up_to_date_check.rb b/lib/system_check/app/gitlab_config_up_to_date_check.rb index 58c7e3039c8..be4144941c1 100644 --- a/lib/system_check/app/gitlab_config_up_to_date_check.rb +++ b/lib/system_check/app/gitlab_config_up_to_date_check.rb @@ -3,27 +3,27 @@ module SystemCheck module App class GitlabConfigUpToDateCheck < SystemCheck::BaseCheck - set_name 'GitLab config up to date?' + set_name "GitLab config up to date?" set_skip_reason "can't check because of previous errors" def skip? - gitlab_config_file = Rails.root.join('config', 'gitlab.yml') + gitlab_config_file = Rails.root.join("config", "gitlab.yml") !File.exist?(gitlab_config_file) end def check? # omniauth or ldap could have been deleted from the file - !Gitlab.config['git_host'] + !Gitlab.config["git_host"] end def show_error try_fixing_it( - 'Back-up your config/gitlab.yml', - 'Copy config/gitlab.yml.example to config/gitlab.yml', - 'Update config/gitlab.yml to match your setup' + "Back-up your config/gitlab.yml", + "Copy config/gitlab.yml.example to config/gitlab.yml", + "Update config/gitlab.yml to match your setup" ) for_more_information( - see_installation_guide_section 'GitLab' + see_installation_guide_section("GitLab") ) fix_and_rerun end diff --git a/lib/system_check/app/init_script_exists_check.rb b/lib/system_check/app/init_script_exists_check.rb index d36dbe7d67d..99c1f8eab91 100644 --- a/lib/system_check/app/init_script_exists_check.rb +++ b/lib/system_check/app/init_script_exists_check.rb @@ -3,24 +3,24 @@ module SystemCheck module App class InitScriptExistsCheck < SystemCheck::BaseCheck - set_name 'Init script exists?' - set_skip_reason 'skipped (omnibus-gitlab has no init script)' + set_name "Init script exists?" + set_skip_reason "skipped (omnibus-gitlab has no init script)" def skip? omnibus_gitlab? end def check? - script_path = '/etc/init.d/gitlab' + script_path = "/etc/init.d/gitlab" File.exist?(script_path) end def show_error try_fixing_it( - 'Install the init script' + "Install the init script" ) for_more_information( - see_installation_guide_section 'Install Init Script' + see_installation_guide_section("Install Init Script") ) fix_and_rerun end diff --git a/lib/system_check/app/init_script_up_to_date_check.rb b/lib/system_check/app/init_script_up_to_date_check.rb index 569c41df6e4..79ef616b5cd 100644 --- a/lib/system_check/app/init_script_up_to_date_check.rb +++ b/lib/system_check/app/init_script_up_to_date_check.rb @@ -3,10 +3,10 @@ module SystemCheck module App class InitScriptUpToDateCheck < SystemCheck::BaseCheck - SCRIPT_PATH = '/etc/init.d/gitlab'.freeze + SCRIPT_PATH = "/etc/init.d/gitlab" - set_name 'Init script up-to-date?' - set_skip_reason 'skipped (omnibus-gitlab has no init script)' + set_name "Init script up-to-date?" + set_skip_reason "skipped (omnibus-gitlab has no init script)" def skip? return true if omnibus_gitlab? @@ -19,7 +19,7 @@ module SystemCheck end def check? - recipe_path = Rails.root.join('lib/support/init.d/', 'gitlab') + recipe_path = Rails.root.join("lib/support/init.d/", "gitlab") recipe_content = File.read(recipe_path) script_content = File.read(SCRIPT_PATH) @@ -29,10 +29,10 @@ module SystemCheck def show_error try_fixing_it( - 'Re-download the init script' + "Re-download the init script" ) for_more_information( - see_installation_guide_section 'Install Init Script' + see_installation_guide_section("Install Init Script") ) fix_and_rerun end diff --git a/lib/system_check/app/log_writable_check.rb b/lib/system_check/app/log_writable_check.rb index e26ad143eb8..15c69a53c75 100644 --- a/lib/system_check/app/log_writable_check.rb +++ b/lib/system_check/app/log_writable_check.rb @@ -3,7 +3,7 @@ module SystemCheck module App class LogWritableCheck < SystemCheck::BaseCheck - set_name 'Log directory writable?' + set_name "Log directory writable?" def check? File.writable?(log_path) @@ -15,7 +15,7 @@ module SystemCheck "sudo chmod -R u+rwX #{log_path}" ) for_more_information( - see_installation_guide_section 'GitLab' + see_installation_guide_section("GitLab") ) fix_and_rerun end @@ -23,7 +23,7 @@ module SystemCheck private def log_path - Rails.root.join('log') + Rails.root.join("log") end end end diff --git a/lib/system_check/app/migrations_are_up_check.rb b/lib/system_check/app/migrations_are_up_check.rb index b12e9ac6bba..4d84a248e31 100644 --- a/lib/system_check/app/migrations_are_up_check.rb +++ b/lib/system_check/app/migrations_are_up_check.rb @@ -3,17 +3,17 @@ module SystemCheck module App class MigrationsAreUpCheck < SystemCheck::BaseCheck - set_name 'All migrations up?' + set_name "All migrations up?" def check? - migration_status, _ = Gitlab::Popen.popen(%w(bundle exec rake db:migrate:status)) + migration_status, _ = Gitlab::Popen.popen(%w[bundle exec rake db:migrate:status]) migration_status !~ /down\s+\d{14}/ end def show_error try_fixing_it( - sudo_gitlab('bundle exec rake db:migrate RAILS_ENV=production') + sudo_gitlab("bundle exec rake db:migrate RAILS_ENV=production") ) fix_and_rerun end diff --git a/lib/system_check/app/orphaned_group_members_check.rb b/lib/system_check/app/orphaned_group_members_check.rb index 3e6ffb8190b..4d8b4b5a54d 100644 --- a/lib/system_check/app/orphaned_group_members_check.rb +++ b/lib/system_check/app/orphaned_group_members_check.rb @@ -3,17 +3,17 @@ module SystemCheck module App class OrphanedGroupMembersCheck < SystemCheck::BaseCheck - set_name 'Database contains orphaned GroupMembers?' - set_check_pass 'no' - set_check_fail 'yes' + set_name "Database contains orphaned GroupMembers?" + set_check_pass "no" + set_check_fail "yes" def check? - !GroupMember.where('user_id not in (select id from users)').exists? + !GroupMember.where("user_id not in (select id from users)").exists? end def show_error try_fixing_it( - 'You can delete the orphaned records using something along the lines of:', + "You can delete the orphaned records using something along the lines of:", sudo_gitlab("bundle exec rails runner -e production 'GroupMember.where(\"user_id NOT IN (SELECT id FROM users)\").delete_all'") ) end diff --git a/lib/system_check/app/projects_have_namespace_check.rb b/lib/system_check/app/projects_have_namespace_check.rb index 2bf2529acf1..b47ce5ac0b7 100644 --- a/lib/system_check/app/projects_have_namespace_check.rb +++ b/lib/system_check/app/projects_have_namespace_check.rb @@ -3,7 +3,7 @@ module SystemCheck module App class ProjectsHaveNamespaceCheck < SystemCheck::BaseCheck - set_name 'Projects have namespace:' + set_name "Projects have namespace:" set_skip_reason "can't check, you have no projects" def skip? @@ -11,15 +11,15 @@ module SystemCheck end def multi_check - $stdout.puts '' + $stdout.puts "" Project.find_each(batch_size: 100) do |project| $stdout.print sanitized_message(project) if project.namespace - $stdout.puts 'yes'.color(:green) + $stdout.puts "yes".color(:green) else - $stdout.puts 'no'.color(:red) + $stdout.puts "no".color(:red) show_error end end diff --git a/lib/system_check/app/redis_version_check.rb b/lib/system_check/app/redis_version_check.rb index 890f8b44d13..6f66fe8fe43 100644 --- a/lib/system_check/app/redis_version_check.rb +++ b/lib/system_check/app/redis_version_check.rb @@ -3,11 +3,11 @@ module SystemCheck module App class RedisVersionCheck < SystemCheck::BaseCheck - MIN_REDIS_VERSION = '2.8.0'.freeze + MIN_REDIS_VERSION = "2.8.0" set_name "Redis version >= #{MIN_REDIS_VERSION}?" def check? - redis_version = run_command(%w(redis-cli --version)) + redis_version = run_command(%w[redis-cli --version]) redis_version = redis_version.try(:match, /redis-cli (\d+\.\d+\.\d+)/) redis_version && (Gem::Version.new(redis_version[1]) > Gem::Version.new(MIN_REDIS_VERSION)) @@ -18,7 +18,7 @@ module SystemCheck "Update your redis server to a version >= #{MIN_REDIS_VERSION}" ) for_more_information( - 'gitlab-public-wiki/wiki/Trouble-Shooting-Guide in section sidekiq' + "gitlab-public-wiki/wiki/Trouble-Shooting-Guide in section sidekiq" ) fix_and_rerun end diff --git a/lib/system_check/app/ruby_version_check.rb b/lib/system_check/app/ruby_version_check.rb index 60e07718338..81540b43f49 100644 --- a/lib/system_check/app/ruby_version_check.rb +++ b/lib/system_check/app/ruby_version_check.rb @@ -3,8 +3,8 @@ module SystemCheck module App class RubyVersionCheck < SystemCheck::BaseCheck - set_name -> { "Ruby version >= #{self.required_version} ?" } - set_check_pass -> { "yes (#{self.current_version})" } + set_name -> { "Ruby version >= #{required_version} ?" } + set_check_pass -> { "yes (#{current_version})" } def self.required_version @required_version ||= Gitlab::VersionInfo.new(2, 3, 5) diff --git a/lib/system_check/app/tmp_writable_check.rb b/lib/system_check/app/tmp_writable_check.rb index 6687df091d3..63f6e57b498 100644 --- a/lib/system_check/app/tmp_writable_check.rb +++ b/lib/system_check/app/tmp_writable_check.rb @@ -3,7 +3,7 @@ module SystemCheck module App class TmpWritableCheck < SystemCheck::BaseCheck - set_name 'Tmp directory writable?' + set_name "Tmp directory writable?" def check? File.writable?(tmp_path) @@ -15,7 +15,7 @@ module SystemCheck "sudo chmod -R u+rwX #{tmp_path}" ) for_more_information( - see_installation_guide_section 'GitLab' + see_installation_guide_section("GitLab") ) fix_and_rerun end @@ -23,7 +23,7 @@ module SystemCheck private def tmp_path - Rails.root.join('tmp') + Rails.root.join("tmp") end end end diff --git a/lib/system_check/app/uploads_directory_exists_check.rb b/lib/system_check/app/uploads_directory_exists_check.rb index 940eff9d4cf..dd61b8093c8 100644 --- a/lib/system_check/app/uploads_directory_exists_check.rb +++ b/lib/system_check/app/uploads_directory_exists_check.rb @@ -3,10 +3,10 @@ module SystemCheck module App class UploadsDirectoryExistsCheck < SystemCheck::BaseCheck - set_name 'Uploads directory exists?' + set_name "Uploads directory exists?" def check? - File.directory?(Rails.root.join('public/uploads')) + File.directory?(Rails.root.join("public/uploads")) end def show_error @@ -14,7 +14,7 @@ module SystemCheck "sudo -u #{gitlab_user} mkdir #{Rails.root}/public/uploads" ) for_more_information( - see_installation_guide_section 'GitLab' + see_installation_guide_section("GitLab") ) fix_and_rerun end diff --git a/lib/system_check/app/uploads_path_permission_check.rb b/lib/system_check/app/uploads_path_permission_check.rb index 4a49f3bc2bb..e1fdf88d6f7 100644 --- a/lib/system_check/app/uploads_path_permission_check.rb +++ b/lib/system_check/app/uploads_path_permission_check.rb @@ -3,15 +3,15 @@ module SystemCheck module App class UploadsPathPermissionCheck < SystemCheck::BaseCheck - set_name 'Uploads directory has correct permissions?' - set_skip_reason 'skipped (no uploads folder found)' + set_name "Uploads directory has correct permissions?" + set_skip_reason "skipped (no uploads folder found)" def skip? !File.directory?(rails_uploads_path) end def check? - File.stat(uploads_fullpath).mode == 040700 + File.stat(uploads_fullpath).mode == 0o40700 end def show_error @@ -19,7 +19,7 @@ module SystemCheck "sudo chmod 700 #{uploads_fullpath}" ) for_more_information( - see_installation_guide_section 'GitLab' + see_installation_guide_section("GitLab") ) fix_and_rerun end @@ -27,7 +27,7 @@ module SystemCheck private def rails_uploads_path - Rails.root.join('public/uploads') + Rails.root.join("public/uploads") end def uploads_fullpath diff --git a/lib/system_check/app/uploads_path_tmp_permission_check.rb b/lib/system_check/app/uploads_path_tmp_permission_check.rb index ae374f4707c..1c6aea6d9ac 100644 --- a/lib/system_check/app/uploads_path_tmp_permission_check.rb +++ b/lib/system_check/app/uploads_path_tmp_permission_check.rb @@ -3,8 +3,8 @@ module SystemCheck module App class UploadsPathTmpPermissionCheck < SystemCheck::BaseCheck - set_name 'Uploads directory tmp has correct permissions?' - set_skip_reason 'skipped (no tmp uploads folder yet)' + set_name "Uploads directory tmp has correct permissions?" + set_skip_reason "skipped (no tmp uploads folder yet)" def skip? !File.directory?(uploads_fullpath) || !Dir.exist?(upload_path_tmp) @@ -13,7 +13,7 @@ module SystemCheck def check? # If tmp upload dir has incorrect permissions, assume others do as well # Verify drwx------ permissions - File.stat(upload_path_tmp).mode == 040700 && File.owned?(upload_path_tmp) + File.stat(upload_path_tmp).mode == 0o40700 && File.owned?(upload_path_tmp) end def show_error @@ -23,7 +23,7 @@ module SystemCheck "sudo find #{uploads_fullpath} -type d -not -path #{uploads_fullpath} -exec chmod 0700 {} \\;" ) for_more_information( - see_installation_guide_section 'GitLab' + see_installation_guide_section("GitLab") ) fix_and_rerun end @@ -31,11 +31,11 @@ module SystemCheck private def upload_path_tmp - File.join(uploads_fullpath, 'tmp') + File.join(uploads_fullpath, "tmp") end def uploads_fullpath - File.realpath(Rails.root.join('public/uploads')) + File.realpath(Rails.root.join("public/uploads")) end end end diff --git a/lib/system_check/base_check.rb b/lib/system_check/base_check.rb index 46aad8aa885..d374bea1936 100644 --- a/lib/system_check/base_check.rb +++ b/lib/system_check/base_check.rb @@ -40,28 +40,28 @@ module SystemCheck # # @return [String] term when check passed ('yes' if not re-defined in a subclass) def self.check_pass - call_or_return(@check_pass) || 'yes' + call_or_return(@check_pass) || "yes" end ## Term to be displayed when check failed # # @return [String] term when check failed ('no' if not re-defined in a subclass) def self.check_fail - call_or_return(@check_fail) || 'no' + call_or_return(@check_fail) || "no" end # Name of the SystemCheck defined by the subclass # # @return [String] the name def self.display_name - call_or_return(@name) || self.name + call_or_return(@name) || name end # Skip reason defined by the subclass # # @return [String] the reason def self.skip_reason - call_or_return(@skip_reason) || 'skipped' + call_or_return(@skip_reason) || "skipped" end # Define a reason why we skipped the SystemCheck (during runtime) diff --git a/lib/system_check/gitaly_check.rb b/lib/system_check/gitaly_check.rb index 3d2517a7aca..9ce78d9c8d3 100644 --- a/lib/system_check/gitaly_check.rb +++ b/lib/system_check/gitaly_check.rb @@ -2,14 +2,14 @@ module SystemCheck class GitalyCheck < BaseCheck - set_name 'Gitaly:' + set_name "Gitaly:" def multi_check Gitlab::HealthChecks::GitalyCheck.readiness.each do |result| $stdout.print "#{result.labels[:shard]} ... " if result.success - $stdout.puts 'OK'.color(:green) + $stdout.puts "OK".color(:green) else $stdout.puts "FAIL: #{result.message}".color(:red) end diff --git a/lib/system_check/gitlab_shell_check.rb b/lib/system_check/gitlab_shell_check.rb index 31c4ec33247..bd12c57051b 100644 --- a/lib/system_check/gitlab_shell_check.rb +++ b/lib/system_check/gitlab_shell_check.rb @@ -3,7 +3,7 @@ module SystemCheck # Used by gitlab:gitlab_shell:check rake task class GitlabShellCheck < BaseCheck - set_name 'GitLab Shell:' + set_name "GitLab Shell:" def multi_check check_gitlab_shell @@ -26,17 +26,17 @@ module SystemCheck def check_gitlab_shell_self_test gitlab_shell_repo_base = gitlab_shell_path - check_cmd = File.expand_path('bin/check', gitlab_shell_repo_base) + check_cmd = File.expand_path("bin/check", gitlab_shell_repo_base) $stdout.puts "Running #{check_cmd}" if system(check_cmd, chdir: gitlab_shell_repo_base) - $stdout.puts 'gitlab-shell self-check successful'.color(:green) + $stdout.puts "gitlab-shell self-check successful".color(:green) else - $stdout.puts 'gitlab-shell self-check failed'.color(:red) + $stdout.puts "gitlab-shell self-check failed".color(:red) try_fixing_it( - 'Make sure GitLab is running;', - 'Check the gitlab-shell configuration file:', - sudo_gitlab("editor #{File.expand_path('config.yml', gitlab_shell_repo_base)}") + "Make sure GitLab is running;", + "Check the gitlab-shell configuration file:", + sudo_gitlab("editor #{File.expand_path("config.yml", gitlab_shell_repo_base)}") ) fix_and_rerun end diff --git a/lib/system_check/helpers.rb b/lib/system_check/helpers.rb index 07d479848fe..daad28c78ff 100644 --- a/lib/system_check/helpers.rb +++ b/lib/system_check/helpers.rb @@ -6,14 +6,14 @@ module SystemCheck # Display a message telling to fix and rerun the checks def fix_and_rerun - $stdout.puts ' Please fix the error above and rerun the checks.'.color(:red) + $stdout.puts " Please fix the error above and rerun the checks.".color(:red) end # Display a formatted list of references (documentation or links) where to find more information # # @param [Array<String>] sources one or more references (documentation or links) def for_more_information(*sources) - $stdout.puts ' For more information see:'.color(:blue) + $stdout.puts " For more information see:".color(:blue) sources.each do |source| $stdout.puts " #{source}" end @@ -25,15 +25,15 @@ module SystemCheck # @deprecated This will no longer be used when all checks were executed using SystemCheck def finished_checking(component) - $stdout.puts '' - $stdout.puts "Checking #{component.color(:yellow)} ... #{'Finished'.color(:green)}" - $stdout.puts '' + $stdout.puts "" + $stdout.puts "Checking #{component.color(:yellow)} ... #{"Finished".color(:green)}" + $stdout.puts "" end # @deprecated This will no longer be used when all checks were executed using SystemCheck def start_checking(component) $stdout.puts "Checking #{component.color(:yellow)} ..." - $stdout.puts '' + $stdout.puts "" end # Display a formatted list of instructions on how to fix the issue identified by the #check? @@ -42,7 +42,7 @@ module SystemCheck def try_fixing_it(*steps) steps = steps.shift if steps.first.is_a?(Array) - $stdout.puts ' Try fixing it:'.color(:blue) + $stdout.puts " Try fixing it:".color(:blue) steps.each do |step| $stdout.puts " #{step}" end @@ -57,15 +57,11 @@ module SystemCheck end def should_sanitize? - if ENV['SANITIZE'] == 'true' - true - else - false - end + ENV["SANITIZE"] == "true" end def omnibus_gitlab? - Dir.pwd == '/opt/gitlab/embedded/service/gitlab-rails' + Dir.pwd == "/opt/gitlab/embedded/service/gitlab-rails" end def sudo_gitlab(command) diff --git a/lib/system_check/incoming_email/foreman_configured_check.rb b/lib/system_check/incoming_email/foreman_configured_check.rb index 944913087da..f5206998276 100644 --- a/lib/system_check/incoming_email/foreman_configured_check.rb +++ b/lib/system_check/incoming_email/foreman_configured_check.rb @@ -3,20 +3,20 @@ module SystemCheck module IncomingEmail class ForemanConfiguredCheck < SystemCheck::BaseCheck - set_name 'Foreman configured correctly?' + set_name "Foreman configured correctly?" def check? - path = Rails.root.join('Procfile') + path = Rails.root.join("Procfile") File.exist?(path) && File.read(path) =~ /^mail_room:/ end def show_error try_fixing_it( - 'Enable mail_room in your Procfile.' + "Enable mail_room in your Procfile." ) for_more_information( - 'doc/administration/reply_by_email.md' + "doc/administration/reply_by_email.md" ) fix_and_rerun end diff --git a/lib/system_check/incoming_email/imap_authentication_check.rb b/lib/system_check/incoming_email/imap_authentication_check.rb index 613c2296375..d9f67011ee2 100644 --- a/lib/system_check/incoming_email/imap_authentication_check.rb +++ b/lib/system_check/incoming_email/imap_authentication_check.rb @@ -3,7 +3,7 @@ module SystemCheck module IncomingEmail class ImapAuthenticationCheck < SystemCheck::BaseCheck - set_name 'IMAP server credentials are correct?' + set_name "IMAP server credentials are correct?" def check? if config @@ -17,10 +17,10 @@ module SystemCheck def show_error try_fixing_it( "An error occurred: #{@error.class}: #{@error.message}", - 'Check that the information in config/gitlab.yml is correct' + "Check that the information in config/gitlab.yml is correct" ) for_more_information( - 'doc/administration/reply_by_email.md' + "doc/administration/reply_by_email.md" ) fix_and_rerun end @@ -43,7 +43,7 @@ module SystemCheck def mail_room_config_path @mail_room_config_path ||= - Rails.root.join('config', 'mail_room.yml').to_s + Rails.root.join("config", "mail_room.yml").to_s end def load_config diff --git a/lib/system_check/incoming_email/initd_configured_check.rb b/lib/system_check/incoming_email/initd_configured_check.rb index acb4b5a9e74..ae300938958 100644 --- a/lib/system_check/incoming_email/initd_configured_check.rb +++ b/lib/system_check/incoming_email/initd_configured_check.rb @@ -3,7 +3,7 @@ module SystemCheck module IncomingEmail class InitdConfiguredCheck < SystemCheck::BaseCheck - set_name 'Init.d configured correctly?' + set_name "Init.d configured correctly?" def skip? omnibus_gitlab? @@ -15,10 +15,10 @@ module SystemCheck def show_error try_fixing_it( - 'Enable mail_room in the init.d configuration.' + "Enable mail_room in the init.d configuration." ) for_more_information( - 'doc/administration/reply_by_email.md' + "doc/administration/reply_by_email.md" ) fix_and_rerun end @@ -26,8 +26,8 @@ module SystemCheck private def mail_room_configured? - path = '/etc/default/gitlab' - File.exist?(path) && File.read(path).include?('mail_room_enabled=true') + path = "/etc/default/gitlab" + File.exist?(path) && File.read(path).include?("mail_room_enabled=true") end end end diff --git a/lib/system_check/incoming_email/mail_room_running_check.rb b/lib/system_check/incoming_email/mail_room_running_check.rb index b7aead4624e..f979b1f322d 100644 --- a/lib/system_check/incoming_email/mail_room_running_check.rb +++ b/lib/system_check/incoming_email/mail_room_running_check.rb @@ -3,7 +3,7 @@ module SystemCheck module IncomingEmail class MailRoomRunningCheck < SystemCheck::BaseCheck - set_name 'MailRoom running?' + set_name "MailRoom running?" def skip? return true if omnibus_gitlab? @@ -20,11 +20,11 @@ module SystemCheck def show_error try_fixing_it( - sudo_gitlab('RAILS_ENV=production bin/mail_room start') + sudo_gitlab("RAILS_ENV=production bin/mail_room start") ) for_more_information( - see_installation_guide_section('Install Init Script'), - 'see log/mail_room.log for possible errors' + see_installation_guide_section("Install Init Script"), + "see log/mail_room.log for possible errors" ) fix_and_rerun end @@ -32,12 +32,12 @@ module SystemCheck private def mail_room_configured? - path = '/etc/default/gitlab' - File.exist?(path) && File.read(path).include?('mail_room_enabled=true') + path = "/etc/default/gitlab" + File.exist?(path) && File.read(path).include?("mail_room_enabled=true") end def mail_room_running? - ps_ux, _ = Gitlab::Popen.popen(%w(ps uxww)) + ps_ux, _ = Gitlab::Popen.popen(%w[ps uxww]) ps_ux.include?("mail_room") end end diff --git a/lib/system_check/incoming_email_check.rb b/lib/system_check/incoming_email_check.rb index 155b6547595..96642eb651d 100644 --- a/lib/system_check/incoming_email_check.rb +++ b/lib/system_check/incoming_email_check.rb @@ -3,12 +3,12 @@ module SystemCheck # Used by gitlab:incoming_email:check rake task class IncomingEmailCheck < BaseCheck - set_name 'Incoming Email:' + set_name "Incoming Email:" def multi_check if Gitlab.config.incoming_email.enabled checks = [ - SystemCheck::IncomingEmail::ImapAuthenticationCheck + SystemCheck::IncomingEmail::ImapAuthenticationCheck, ] if Rails.env.production? @@ -18,9 +18,9 @@ module SystemCheck checks << SystemCheck::IncomingEmail::ForemanConfiguredCheck end - SystemCheck.run('Reply by email', checks) + SystemCheck.run("Reply by email", checks) else - $stdout.puts 'Reply by email is disabled in config/gitlab.yml' + $stdout.puts "Reply by email is disabled in config/gitlab.yml" end end end diff --git a/lib/system_check/ldap_check.rb b/lib/system_check/ldap_check.rb index 619fb3cccb8..45fd6285829 100644 --- a/lib/system_check/ldap_check.rb +++ b/lib/system_check/ldap_check.rb @@ -3,18 +3,18 @@ module SystemCheck # Used by gitlab:ldap:check rake task class LdapCheck < BaseCheck - set_name 'LDAP:' + set_name "LDAP:" def multi_check if Gitlab::Auth::LDAP::Config.enabled? # Only show up to 100 results because LDAP directories can be very big. # This setting only affects the `rake gitlab:check` script. - limit = ENV['LDAP_CHECK_LIMIT'] + limit = ENV["LDAP_CHECK_LIMIT"] limit = 100 if limit.blank? check_ldap(limit) else - $stdout.puts 'LDAP is disabled in config/gitlab.yml' + $stdout.puts "LDAP is disabled in config/gitlab.yml" end end @@ -32,7 +32,7 @@ module SystemCheck $stdout.puts "LDAP users with access to your GitLab server (only showing the first #{limit} results)" - users = adapter.users(adapter.config.uid, '*', limit) + users = adapter.users(adapter.config.uid, "*", limit) users.each do |user| $stdout.puts "\tDN: #{user.dn}\t #{adapter.config.uid}: #{user.uid}" end @@ -47,12 +47,12 @@ module SystemCheck auth = adapter.config.has_auth? message = if auth && adapter.ldap.bind - 'Success'.color(:green) - elsif auth - 'Failed. Check `bind_dn` and `password` configuration values'.color(:red) - else - 'Anonymous. No `bind_dn` or `password` configured'.color(:yellow) - end + "Success".color(:green) + elsif auth + "Failed. Check `bind_dn` and `password` configuration values".color(:red) + else + "Anonymous. No `bind_dn` or `password` configured".color(:yellow) + end $stdout.puts "LDAP authentication... #{message}" end diff --git a/lib/system_check/orphans/namespace_check.rb b/lib/system_check/orphans/namespace_check.rb index 53b2d8fd5b3..71bb4809a45 100644 --- a/lib/system_check/orphans/namespace_check.rb +++ b/lib/system_check/orphans/namespace_check.rb @@ -3,7 +3,7 @@ module SystemCheck module Orphans class NamespaceCheck < SystemCheck::BaseCheck - set_name 'Orphaned namespaces:' + set_name "Orphaned namespaces:" def multi_check Gitlab::GitalyClient::StorageSettings.allow_disk_access do @@ -36,14 +36,14 @@ module SystemCheck def disk_namespaces(storage_path) fetch_disk_namespaces(storage_path).each_with_object([]) do |namespace_path, result| namespace = File.basename(namespace_path) - next if namespace.eql?('@hashed') + next if namespace.eql?("@hashed") result << namespace end end def fetch_disk_namespaces(storage_path) - Dir.glob(File.join(storage_path, '*')) + Dir.glob(File.join(storage_path, "*")) end def existing_namespaces diff --git a/lib/system_check/orphans/repository_check.rb b/lib/system_check/orphans/repository_check.rb index 33020417e95..c1b290486b0 100644 --- a/lib/system_check/orphans/repository_check.rb +++ b/lib/system_check/orphans/repository_check.rb @@ -3,7 +3,7 @@ module SystemCheck module Orphans class RepositoryCheck < SystemCheck::BaseCheck - set_name 'Orphaned repositories:' + set_name "Orphaned repositories:" def multi_check Gitlab::GitalyClient::StorageSettings.allow_disk_access do @@ -37,7 +37,7 @@ module SystemCheck def disk_repositories(storage_path) fetch_disk_namespaces(storage_path).each_with_object([]) do |namespace_path, result| namespace = File.basename(namespace_path) - next if namespace.eql?('@hashed') + next if namespace.eql?("@hashed") fetch_disk_repositories(namespace_path).each do |repo| result << "#{namespace}/#{File.basename(repo)}" @@ -62,11 +62,11 @@ module SystemCheck end def fetch_disk_namespaces(storage_path) - Dir.glob(File.join(storage_path, '*')) + Dir.glob(File.join(storage_path, "*")) end def fetch_disk_repositories(namespace_path) - Dir.glob(File.join(namespace_path, '*')) + Dir.glob(File.join(namespace_path, "*")) end end end diff --git a/lib/system_check/rake_task/app_task.rb b/lib/system_check/rake_task/app_task.rb index cc32feb8604..3dba8800139 100644 --- a/lib/system_check/rake_task/app_task.rb +++ b/lib/system_check/rake_task/app_task.rb @@ -7,7 +7,7 @@ module SystemCheck extend RakeTaskHelpers def self.name - 'GitLab App' + "GitLab App" end def self.checks @@ -30,7 +30,7 @@ module SystemCheck SystemCheck::App::RubyVersionCheck, SystemCheck::App::GitVersionCheck, SystemCheck::App::GitUserDefaultSSHConfigCheck, - SystemCheck::App::ActiveUsersCheck + SystemCheck::App::ActiveUsersCheck, ] end end diff --git a/lib/system_check/rake_task/gitaly_task.rb b/lib/system_check/rake_task/gitaly_task.rb index 0c3f694f98a..cf7ac292445 100644 --- a/lib/system_check/rake_task/gitaly_task.rb +++ b/lib/system_check/rake_task/gitaly_task.rb @@ -7,7 +7,7 @@ module SystemCheck extend RakeTaskHelpers def self.name - 'Gitaly' + "Gitaly" end def self.checks diff --git a/lib/system_check/rake_task/gitlab_shell_task.rb b/lib/system_check/rake_task/gitlab_shell_task.rb index 120e984c68b..453962260cb 100644 --- a/lib/system_check/rake_task/gitlab_shell_task.rb +++ b/lib/system_check/rake_task/gitlab_shell_task.rb @@ -7,7 +7,7 @@ module SystemCheck extend RakeTaskHelpers def self.name - 'GitLab Shell' + "GitLab Shell" end def self.checks diff --git a/lib/system_check/rake_task/gitlab_task.rb b/lib/system_check/rake_task/gitlab_task.rb index 7ff36fd6eb5..6001d72f643 100644 --- a/lib/system_check/rake_task/gitlab_task.rb +++ b/lib/system_check/rake_task/gitlab_task.rb @@ -7,7 +7,7 @@ module SystemCheck extend RakeTaskHelpers def self.name - 'GitLab' + "GitLab" end def self.manual_run_checks! @@ -25,7 +25,7 @@ module SystemCheck SystemCheck::RakeTask::SidekiqTask, SystemCheck::RakeTask::IncomingEmailTask, SystemCheck::RakeTask::LdapTask, - SystemCheck::RakeTask::AppTask + SystemCheck::RakeTask::AppTask, ] end end diff --git a/lib/system_check/rake_task/incoming_email_task.rb b/lib/system_check/rake_task/incoming_email_task.rb index c296c46feab..562367d63fa 100644 --- a/lib/system_check/rake_task/incoming_email_task.rb +++ b/lib/system_check/rake_task/incoming_email_task.rb @@ -7,7 +7,7 @@ module SystemCheck extend RakeTaskHelpers def self.name - 'Incoming Email' + "Incoming Email" end def self.checks diff --git a/lib/system_check/rake_task/ldap_task.rb b/lib/system_check/rake_task/ldap_task.rb index 03a180b9dfb..10e85da0c1f 100644 --- a/lib/system_check/rake_task/ldap_task.rb +++ b/lib/system_check/rake_task/ldap_task.rb @@ -7,7 +7,7 @@ module SystemCheck extend RakeTaskHelpers def self.name - 'LDAP' + "LDAP" end def self.checks diff --git a/lib/system_check/rake_task/orphans/namespace_task.rb b/lib/system_check/rake_task/orphans/namespace_task.rb index 2822da45bc1..20a321ef4df 100644 --- a/lib/system_check/rake_task/orphans/namespace_task.rb +++ b/lib/system_check/rake_task/orphans/namespace_task.rb @@ -8,7 +8,7 @@ module SystemCheck extend RakeTaskHelpers def self.name - 'Orphans' + "Orphans" end def self.checks diff --git a/lib/system_check/rake_task/orphans/repository_task.rb b/lib/system_check/rake_task/orphans/repository_task.rb index f14b3af22e8..8eb84c707da 100644 --- a/lib/system_check/rake_task/orphans/repository_task.rb +++ b/lib/system_check/rake_task/orphans/repository_task.rb @@ -8,7 +8,7 @@ module SystemCheck extend RakeTaskHelpers def self.name - 'Orphans' + "Orphans" end def self.checks diff --git a/lib/system_check/rake_task/orphans_task.rb b/lib/system_check/rake_task/orphans_task.rb index 31f8ede25e0..5677e4e21a8 100644 --- a/lib/system_check/rake_task/orphans_task.rb +++ b/lib/system_check/rake_task/orphans_task.rb @@ -7,13 +7,13 @@ module SystemCheck extend RakeTaskHelpers def self.name - 'Orphans' + "Orphans" end def self.checks [ SystemCheck::Orphans::NamespaceCheck, - SystemCheck::Orphans::RepositoryCheck + SystemCheck::Orphans::RepositoryCheck, ] end end diff --git a/lib/system_check/rake_task/rake_task_helpers.rb b/lib/system_check/rake_task/rake_task_helpers.rb index 95f2a34a719..0c4b3967168 100644 --- a/lib/system_check/rake_task/rake_task_helpers.rb +++ b/lib/system_check/rake_task/rake_task_helpers.rb @@ -9,7 +9,7 @@ module SystemCheck def run! warn_user_is_not_gitlab - if self.respond_to?(:manual_run_checks!) + if respond_to?(:manual_run_checks!) manual_run_checks! else run_checks! diff --git a/lib/system_check/rake_task/sidekiq_task.rb b/lib/system_check/rake_task/sidekiq_task.rb index 3ccf009d4b9..5c3af5e1a2c 100644 --- a/lib/system_check/rake_task/sidekiq_task.rb +++ b/lib/system_check/rake_task/sidekiq_task.rb @@ -7,7 +7,7 @@ module SystemCheck extend RakeTaskHelpers def self.name - 'Sidekiq' + "Sidekiq" end def self.checks diff --git a/lib/system_check/sidekiq_check.rb b/lib/system_check/sidekiq_check.rb index 2f5fc2cea89..f7d1e7bf172 100644 --- a/lib/system_check/sidekiq_check.rb +++ b/lib/system_check/sidekiq_check.rb @@ -3,7 +3,7 @@ module SystemCheck # Used by gitlab:sidekiq:check rake task class SidekiqCheck < BaseCheck - set_name 'Sidekiq:' + set_name "Sidekiq:" def multi_check check_sidekiq_running @@ -34,24 +34,24 @@ module SystemCheck process_count = sidekiq_process_count return if process_count.zero? - $stdout.print 'Number of Sidekiq processes ... ' + $stdout.print "Number of Sidekiq processes ... " if process_count == 1 - $stdout.puts '1'.color(:green) + $stdout.puts "1".color(:green) else - $stdout.puts "#{process_count}".color(:red) + $stdout.puts process_count.to_s.color(:red) try_fixing_it( - 'sudo service gitlab stop', + "sudo service gitlab stop", "sudo pkill -u #{gitlab_user} -f sidekiq", "sleep 10 && sudo pkill -9 -u #{gitlab_user} -f sidekiq", - 'sudo service gitlab start' + "sudo service gitlab start" ) fix_and_rerun end end def sidekiq_process_count - ps_ux, _ = Gitlab::Popen.popen(%w(ps uxww)) + ps_ux, _ = Gitlab::Popen.popen(%w[ps uxww]) ps_ux.scan(/sidekiq \d+\.\d+\.\d+/).count end end diff --git a/lib/system_check/simple_executor.rb b/lib/system_check/simple_executor.rb index 11818ae54f8..0801e4e0d9b 100644 --- a/lib/system_check/simple_executor.rb +++ b/lib/system_check/simple_executor.rb @@ -67,7 +67,7 @@ module SystemCheck print_check_failure(check_klass) if check.can_repair? - $stdout.print 'Trying to fix error automatically. ...' + $stdout.print "Trying to fix error automatically. ..." if check.repair! print_success @@ -79,7 +79,7 @@ module SystemCheck check.show_error end - rescue StandardError => e + rescue => e $stdout.puts "Exception: #{e.message}".color(:red) end @@ -98,11 +98,11 @@ module SystemCheck end def print_success - $stdout.puts 'Success'.color(:green) + $stdout.puts "Success".color(:green) end def print_failure - $stdout.puts 'Failed'.color(:red) + $stdout.puts "Failed".color(:red) end # Prints header content for the series of checks to be executed for this component @@ -110,16 +110,16 @@ module SystemCheck # @param [String] component name of the component relative to the checks being executed def start_checking(component) $stdout.puts "Checking #{component.color(:yellow)} ..." - $stdout.puts '' + $stdout.puts "" end # Prints footer content for the series of checks executed for this component # # @param [String] component name of the component relative to the checks being executed def finished_checking(component) - $stdout.puts '' - $stdout.puts "Checking #{component.color(:yellow)} ... #{'Finished'.color(:green)}" - $stdout.puts '' + $stdout.puts "" + $stdout.puts "Checking #{component.color(:yellow)} ... #{"Finished".color(:green)}" + $stdout.puts "" end end end |