Enable Rubocop Casecmp Performance Cop.

Also fixes the errors caused by enabling the cop. casecmp is more performant than `.downcase` and `==`.
This commit is contained in:
Connor Shea 2016-04-27 16:52:32 -06:00
parent 4a47470feb
commit 377583a361
No known key found for this signature in database
GPG Key ID: F4D9B1FC7DB73ED1
4 changed files with 5 additions and 6 deletions

View File

@ -937,10 +937,9 @@ Lint/Void:
##################### Performance ############################
# TODO: Enable Casecmp Cop.
# Use `casecmp` rather than `downcase ==`.
Performance/Casecmp:
Enabled: false
Enabled: true
# TODO: Enable DoubleStartEndWith Cop.
# Use `str.{start,end}_with?(x, ..., y, ...)` instead of

View File

@ -453,7 +453,7 @@ class Repository
def version
cache.fetch(:version) do
tree(:head).blobs.find do |file|
file.name.downcase == 'version'
file.name.casecmp('version').zero?
end
end
end

View File

@ -5,11 +5,11 @@ module Gitlab
end
def self.mysql?
adapter_name.downcase == 'mysql2'
adapter_name.casecmp('mysql2').zero?
end
def self.postgresql?
adapter_name.downcase == 'postgresql'
adapter_name.casecmp('postgresql').zero?
end
def self.version

View File

@ -40,7 +40,7 @@ module Gitlab
# Returns boolean
def plain?(filename)
filename.downcase.end_with?('.txt') ||
filename.downcase == 'readme'
filename.casecmp('readme').zero?
end
def previewable?(filename)