diff options
author | Takuya Noguchi <takninnovationresearch@gmail.com> | 2018-01-27 08:35:53 +0300 |
---|---|---|
committer | Takuya Noguchi <takninnovationresearch@gmail.com> | 2018-01-31 20:06:07 +0300 |
commit | 2b6307f6ad9d09156c42befe4babbfea40dad052 (patch) | |
tree | 2a05eb3e7a481ed803ea62a2d4e7667baff44375 /app/helpers | |
parent | 08e013431acb5238b4806260c4b9c304837097a3 (diff) |
Enable RuboCop Style/RegexpLiteral
Diffstat (limited to 'app/helpers')
-rw-r--r-- | app/helpers/sidekiq_helper.rb | 6 | ||||
-rw-r--r-- | app/helpers/submodule_helper.rb | 10 | ||||
-rw-r--r-- | app/helpers/tree_helper.rb | 2 |
3 files changed, 9 insertions, 9 deletions
diff --git a/app/helpers/sidekiq_helper.rb b/app/helpers/sidekiq_helper.rb index 55f4da0ef85..50aeb7f4b82 100644 --- a/app/helpers/sidekiq_helper.rb +++ b/app/helpers/sidekiq_helper.rb @@ -1,12 +1,12 @@ module SidekiqHelper - SIDEKIQ_PS_REGEXP = /\A + SIDEKIQ_PS_REGEXP = %r{\A (?<pid>\d+)\s+ (?<cpu>[\d\.,]+)\s+ (?<mem>[\d\.,]+)\s+ - (?<state>[DIEKNRSTVWXZNLpsl\+<>\/\d]+)\s+ + (?<state>[DIEKNRSTVWXZNLpsl\+<>/\d]+)\s+ (?<start>.+?)\s+ (?<command>(?:ruby\d+:\s+)?sidekiq.*\].*) - \z/x + \z}x def parse_sidekiq_ps(line) match = line.strip.match(SIDEKIQ_PS_REGEXP) diff --git a/app/helpers/submodule_helper.rb b/app/helpers/submodule_helper.rb index 1db9ae3839c..9151543dfdc 100644 --- a/app/helpers/submodule_helper.rb +++ b/app/helpers/submodule_helper.rb @@ -11,7 +11,7 @@ module SubmoduleHelper url = File.join(Gitlab.config.gitlab.url, @project.full_path) end - if url =~ /([^\/:]+)\/([^\/]+(?:\.git)?)\Z/ + if url =~ %r{([^/:]+)/([^/]+(?:\.git)?)\Z} namespace, project = $1, $2 gitlab_hosts = [Gitlab.config.gitlab.url, Gitlab.config.gitlab_shell.ssh_path_prefix] @@ -23,7 +23,7 @@ module SubmoduleHelper end end - namespace.sub!(/\A\//, '') + namespace.sub!(%r{\A/}, '') project.rstrip! project.sub!(/\.git\z/, '') @@ -47,11 +47,11 @@ module SubmoduleHelper protected def github_dot_com_url?(url) - url =~ /github\.com[\/:][^\/]+\/[^\/]+\Z/ + url =~ %r{github\.com[/:][^/]+/[^/]+\Z} end def gitlab_dot_com_url?(url) - url =~ /gitlab\.com[\/:][^\/]+\/[^\/]+\Z/ + url =~ %r{gitlab\.com[/:][^/]+/[^/]+\Z} end def self_url?(url, namespace, project) @@ -65,7 +65,7 @@ module SubmoduleHelper def relative_self_url?(url) # (./)?(../repo.git) || (./)?(../../project/repo.git) ) - url =~ /\A((\.\/)?(\.\.\/))(?!(\.\.)|(.*\/)).*(\.git)?\z/ || url =~ /\A((\.\/)?(\.\.\/){2})(?!(\.\.))([^\/]*)\/(?!(\.\.)|(.*\/)).*(\.git)?\z/ + url =~ %r{\A((\./)?(\.\./))(?!(\.\.)|(.*/)).*(\.git)?\z} || url =~ %r{\A((\./)?(\.\./){2})(?!(\.\.))([^/]*)/(?!(\.\.)|(.*/)).*(\.git)?\z} end def standard_links(host, namespace, project, commit) diff --git a/app/helpers/tree_helper.rb b/app/helpers/tree_helper.rb index 5b2ea38a03d..d39cac0f510 100644 --- a/app/helpers/tree_helper.rb +++ b/app/helpers/tree_helper.rb @@ -110,7 +110,7 @@ module TreeHelper # returns the relative path of the first subdir that doesn't have only one directory descendant def flatten_tree(root_path, tree) - return tree.flat_path.sub(/\A#{root_path}\//, '') if tree.flat_path.present? + return tree.flat_path.sub(%r{\A#{root_path}/}, '') if tree.flat_path.present? subtree = Gitlab::Git::Tree.where(@repository, @commit.id, tree.path) if subtree.count == 1 && subtree.first.dir? |