diff options
author | Robert Speicher <robert@gitlab.com> | 2016-05-23 18:13:08 +0000 |
---|---|---|
committer | Robert Speicher <robert@gitlab.com> | 2016-05-23 18:13:08 +0000 |
commit | d3fd58570c7116b4065eed49d744d1f66395f64d (patch) | |
tree | 646227b40fd82228d0623f9c7f0654282528e687 | |
parent | e491056e95fadd499601a5e0decc0ab9455f0fb6 (diff) | |
parent | 2de1109da39a46200e741b5a6643ce7fb1418041 (diff) | |
download | gitlab-ce-d3fd58570c7116b4065eed49d744d1f66395f64d.tar.gz |
Merge branch 'rs-start-with' into 'master'
Enable Performance/StartWith cop and fix offenses
Ref: https://gitlab.com/gitlab-org/gitlab-ce/issues/17478
See merge request !4256
-rw-r--r-- | .rubocop.yml | 3 | ||||
-rw-r--r-- | app/helpers/gitlab_markdown_helper.rb | 2 | ||||
-rw-r--r-- | app/helpers/tab_helper.rb | 2 |
3 files changed, 3 insertions, 4 deletions
diff --git a/.rubocop.yml b/.rubocop.yml index d09e493ef38..832c31be162 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -985,11 +985,10 @@ Performance/RedundantMerge: Performance/RedundantSortBy: Enabled: false -# TODO: Enable StartWith Cop. # Use `start_with?` instead of a regex match anchored to the beginning of a # string. Performance/StartWith: - Enabled: false + Enabled: true # Use `tr` instead of `gsub` when you are replacing the same number of # characters. Use `delete` instead of `gsub` when you are deleting diff --git a/app/helpers/gitlab_markdown_helper.rb b/app/helpers/gitlab_markdown_helper.rb index 3a45205563e..0a1b48af219 100644 --- a/app/helpers/gitlab_markdown_helper.rb +++ b/app/helpers/gitlab_markdown_helper.rb @@ -13,7 +13,7 @@ module GitlabMarkdownHelper def link_to_gfm(body, url, html_options = {}) return "" if body.blank? - escaped_body = if body =~ /\A\<img/ + escaped_body = if body.start_with?('<img') body else escape_once(body) diff --git a/app/helpers/tab_helper.rb b/app/helpers/tab_helper.rb index 96a83671009..b4b4d804203 100644 --- a/app/helpers/tab_helper.rb +++ b/app/helpers/tab_helper.rb @@ -112,7 +112,7 @@ module TabHelper end def profile_tab_class - if controller.controller_path =~ /\Aprofiles/ + if controller.controller_path.start_with?('profiles') return 'active' end |