From c8755543f07aa35ec22e9509c0cc2d04e5d3e0d3 Mon Sep 17 00:00:00 2001 From: gfyoung Date: Mon, 8 Oct 2018 07:50:39 -0700 Subject: Enable even more frozen string in lib/**/*.rb Enables frozen string for the following files: * lib/generators/**/*.rb * lib/gitaly/**/*.rb * lib/google_api/**/*.rb * lib/haml_lint/**/*.rb * lib/json_web_token/**/*.rb * lib/mattermost/**/*.rb * lib/microsoft_teams/**/*.rb * lib/object_storage/**/*.rb * lib/omni_auth/**/*.rb * lib/peek/**/*.rb * lib/rouge/**/*.rb * lib/rspec_flaky/**/*.rb * lib/system_check/**/*.rb Partially addresses #47424. --- .rubocop.yml | 3 ++- changelogs/unreleased/even-more-frozen-string-lib.yml | 5 +++++ .../post_deployment_migration_generator.rb | 2 ++ lib/gitaly/server.rb | 2 ++ lib/google_api/auth.rb | 2 ++ lib/google_api/cloud_platform/client.rb | 2 ++ lib/haml_lint/inline_javascript.rb | 5 ++++- lib/json_web_token/rsa_token.rb | 2 ++ lib/json_web_token/token.rb | 2 ++ lib/mattermost/client.rb | 2 ++ lib/mattermost/command.rb | 2 ++ lib/mattermost/error.rb | 2 ++ lib/mattermost/session.rb | 2 ++ lib/mattermost/team.rb | 2 ++ lib/microsoft_teams/activity.rb | 2 ++ lib/microsoft_teams/notifier.rb | 2 ++ lib/object_storage/direct_upload.rb | 2 ++ lib/omni_auth/strategies/bitbucket.rb | 2 ++ lib/omni_auth/strategies/jwt.rb | 2 ++ lib/peek/rblineprof/custom_controller_helpers.rb | 6 ++++-- lib/peek/views/gitaly.rb | 2 ++ lib/peek/views/host.rb | 2 ++ lib/rouge/formatters/html_gitlab.rb | 2 ++ lib/rouge/plugins/common_mark.rb | 2 ++ lib/rspec_flaky/config.rb | 2 ++ lib/rspec_flaky/example.rb | 2 ++ lib/rspec_flaky/flaky_example.rb | 2 ++ lib/rspec_flaky/flaky_examples_collection.rb | 2 ++ lib/rspec_flaky/listener.rb | 2 ++ lib/rspec_flaky/report.rb | 2 ++ lib/system_check/app/active_users_check.rb | 2 ++ lib/system_check/app/database_config_exists_check.rb | 2 ++ lib/system_check/app/git_config_check.rb | 2 ++ lib/system_check/app/git_user_default_ssh_config_check.rb | 2 ++ lib/system_check/app/git_version_check.rb | 2 ++ lib/system_check/app/gitlab_config_exists_check.rb | 2 ++ lib/system_check/app/gitlab_config_up_to_date_check.rb | 2 ++ lib/system_check/app/init_script_exists_check.rb | 2 ++ lib/system_check/app/init_script_up_to_date_check.rb | 2 ++ lib/system_check/app/log_writable_check.rb | 2 ++ lib/system_check/app/migrations_are_up_check.rb | 2 ++ lib/system_check/app/orphaned_group_members_check.rb | 2 ++ lib/system_check/app/projects_have_namespace_check.rb | 2 ++ lib/system_check/app/redis_version_check.rb | 2 ++ lib/system_check/app/ruby_version_check.rb | 2 ++ lib/system_check/app/tmp_writable_check.rb | 2 ++ lib/system_check/app/uploads_directory_exists_check.rb | 2 ++ lib/system_check/app/uploads_path_permission_check.rb | 2 ++ lib/system_check/app/uploads_path_tmp_permission_check.rb | 2 ++ lib/system_check/base_check.rb | 2 ++ lib/system_check/helpers.rb | 2 ++ lib/system_check/incoming_email/foreman_configured_check.rb | 2 ++ lib/system_check/incoming_email/imap_authentication_check.rb | 2 ++ lib/system_check/incoming_email/initd_configured_check.rb | 2 ++ lib/system_check/incoming_email/mail_room_running_check.rb | 2 ++ lib/system_check/orphans/namespace_check.rb | 2 ++ lib/system_check/orphans/repository_check.rb | 2 ++ lib/system_check/simple_executor.rb | 2 ++ 58 files changed, 123 insertions(+), 4 deletions(-) create mode 100644 changelogs/unreleased/even-more-frozen-string-lib.yml diff --git a/.rubocop.yml b/.rubocop.yml index b7aec5b8b14..b10457995b3 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -48,7 +48,8 @@ Style/FrozenStringLiteralComment: - 'danger/**/*' - 'db/**/*' - 'ee/**/*' - - 'lib/**/*' + - 'lib/gitlab/**/*' + - 'lib/tasks/**/*' - 'qa/**/*' - 'rubocop/**/*' - 'scripts/**/*' diff --git a/changelogs/unreleased/even-more-frozen-string-lib.yml b/changelogs/unreleased/even-more-frozen-string-lib.yml new file mode 100644 index 00000000000..3f5fd7710aa --- /dev/null +++ b/changelogs/unreleased/even-more-frozen-string-lib.yml @@ -0,0 +1,5 @@ +--- +title: Enable even more frozen string in lib/**/*.rb +merge_request: +author: gfyoung +type: performance diff --git a/lib/generators/rails/post_deployment_migration/post_deployment_migration_generator.rb b/lib/generators/rails/post_deployment_migration/post_deployment_migration_generator.rb index 91175b49c79..15cdd25e711 100644 --- a/lib/generators/rails/post_deployment_migration/post_deployment_migration_generator.rb +++ b/lib/generators/rails/post_deployment_migration/post_deployment_migration_generator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails/generators' module Rails diff --git a/lib/gitaly/server.rb b/lib/gitaly/server.rb index f95e423ef22..7b238623418 100644 --- a/lib/gitaly/server.rb +++ b/lib/gitaly/server.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Gitaly class Server def self.all diff --git a/lib/google_api/auth.rb b/lib/google_api/auth.rb index 1aeaa387a49..e724e58e9ca 100644 --- a/lib/google_api/auth.rb +++ b/lib/google_api/auth.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module GoogleApi class Auth attr_reader :access_token, :redirect_uri, :state diff --git a/lib/google_api/cloud_platform/client.rb b/lib/google_api/cloud_platform/client.rb index 77b6610286f..e74ff6a9129 100644 --- a/lib/google_api/cloud_platform/client.rb +++ b/lib/google_api/cloud_platform/client.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'google/apis/compute_v1' require 'google/apis/container_v1' require 'google/apis/cloudbilling_v1' diff --git a/lib/haml_lint/inline_javascript.rb b/lib/haml_lint/inline_javascript.rb index adbed20f152..5ecd6169ecf 100644 --- a/lib/haml_lint/inline_javascript.rb +++ b/lib/haml_lint/inline_javascript.rb @@ -1,4 +1,7 @@ -unless Rails.env.production? # rubocop:disable Naming/FileName +# rubocop:disable Naming/FileName +# frozen_string_literal: true + +unless Rails.env.production? require 'haml_lint/haml_visitor' require 'haml_lint/linter' require 'haml_lint/linter_registry' diff --git a/lib/json_web_token/rsa_token.rb b/lib/json_web_token/rsa_token.rb index d6d6af7089c..160e1e506f1 100644 --- a/lib/json_web_token/rsa_token.rb +++ b/lib/json_web_token/rsa_token.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module JSONWebToken class RSAToken < Token attr_reader :key_file diff --git a/lib/json_web_token/token.rb b/lib/json_web_token/token.rb index 5b67715b0b2..ce5d6f248d0 100644 --- a/lib/json_web_token/token.rb +++ b/lib/json_web_token/token.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module JSONWebToken class Token attr_accessor :issuer, :subject, :audience, :id diff --git a/lib/mattermost/client.rb b/lib/mattermost/client.rb index d80cd7d2a4e..293d0c563c5 100644 --- a/lib/mattermost/client.rb +++ b/lib/mattermost/client.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Mattermost ClientError = Class.new(Mattermost::Error) diff --git a/lib/mattermost/command.rb b/lib/mattermost/command.rb index 704813dfdf0..a02745486d6 100644 --- a/lib/mattermost/command.rb +++ b/lib/mattermost/command.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Mattermost class Command < Client def create(params) diff --git a/lib/mattermost/error.rb b/lib/mattermost/error.rb index dee6deb7974..054bd5457bd 100644 --- a/lib/mattermost/error.rb +++ b/lib/mattermost/error.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Mattermost Error = Class.new(StandardError) end diff --git a/lib/mattermost/session.rb b/lib/mattermost/session.rb index 2aa7a2f64d8..e2083848a8d 100644 --- a/lib/mattermost/session.rb +++ b/lib/mattermost/session.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Mattermost class NoSessionError < Mattermost::Error def message diff --git a/lib/mattermost/team.rb b/lib/mattermost/team.rb index 95c2f6f9d6b..58120178f50 100644 --- a/lib/mattermost/team.rb +++ b/lib/mattermost/team.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Mattermost class Team < Client # Returns all teams that the current user is a member of diff --git a/lib/microsoft_teams/activity.rb b/lib/microsoft_teams/activity.rb index d2c420efdaf..207e90d2638 100644 --- a/lib/microsoft_teams/activity.rb +++ b/lib/microsoft_teams/activity.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module MicrosoftTeams class Activity def initialize(title:, subtitle:, text:, image:) diff --git a/lib/microsoft_teams/notifier.rb b/lib/microsoft_teams/notifier.rb index 226ee1373db..c7dec09ba6b 100644 --- a/lib/microsoft_teams/notifier.rb +++ b/lib/microsoft_teams/notifier.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module MicrosoftTeams class Notifier def initialize(webhook) diff --git a/lib/object_storage/direct_upload.rb b/lib/object_storage/direct_upload.rb index 97f56e10ccf..fd26663fef0 100644 --- a/lib/object_storage/direct_upload.rb +++ b/lib/object_storage/direct_upload.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module ObjectStorage # # The DirectUpload c;ass generates a set of presigned URLs diff --git a/lib/omni_auth/strategies/bitbucket.rb b/lib/omni_auth/strategies/bitbucket.rb index ce1bdfe6ee4..6c914b4222a 100644 --- a/lib/omni_auth/strategies/bitbucket.rb +++ b/lib/omni_auth/strategies/bitbucket.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'omniauth-oauth2' module OmniAuth diff --git a/lib/omni_auth/strategies/jwt.rb b/lib/omni_auth/strategies/jwt.rb index ebdb5c7faf0..a792903fde7 100644 --- a/lib/omni_auth/strategies/jwt.rb +++ b/lib/omni_auth/strategies/jwt.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'omniauth' require 'jwt' diff --git a/lib/peek/rblineprof/custom_controller_helpers.rb b/lib/peek/rblineprof/custom_controller_helpers.rb index 9beb442bfa3..581cc6a37b4 100644 --- a/lib/peek/rblineprof/custom_controller_helpers.rb +++ b/lib/peek/rblineprof/custom_controller_helpers.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Peek module Rblineprof module CustomControllerHelpers @@ -41,7 +43,7 @@ module Peek ] end.sort_by{ |a,b,c,d,e,f| -f } - output = "