BigW Consortium Gitlab

Enable Rubocop Casecmp Performance Cop.

Also fixes the errors caused by enabling the cop. casecmp is more performant than `.downcase` and `==`.
parent 4a47470f
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment