BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
377583a3
Unverified
Commit
377583a3
authored
Apr 27, 2016
by
Connor Shea
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Enable Rubocop Casecmp Performance Cop.
Also fixes the errors caused by enabling the cop. casecmp is more performant than `.downcase` and `==`.
parent
4a47470f
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
5 additions
and
6 deletions
+5
-6
.rubocop.yml
.rubocop.yml
+1
-2
repository.rb
app/models/repository.rb
+1
-1
database.rb
lib/gitlab/database.rb
+2
-2
markup_helper.rb
lib/gitlab/markup_helper.rb
+1
-1
No files found.
.rubocop.yml
View file @
377583a3
...
@@ -937,10 +937,9 @@ Lint/Void:
...
@@ -937,10 +937,9 @@ Lint/Void:
##################### Performance ############################
##################### Performance ############################
# TODO: Enable Casecmp Cop.
# Use `casecmp` rather than `downcase ==`.
# Use `casecmp` rather than `downcase ==`.
Performance/Casecmp
:
Performance/Casecmp
:
Enabled
:
fals
e
Enabled
:
tru
e
# TODO: Enable DoubleStartEndWith Cop.
# TODO: Enable DoubleStartEndWith Cop.
# Use `str.{start,end}_with?(x, ..., y, ...)` instead of
# Use `str.{start,end}_with?(x, ..., y, ...)` instead of
...
...
app/models/repository.rb
View file @
377583a3
...
@@ -453,7 +453,7 @@ class Repository
...
@@ -453,7 +453,7 @@ class Repository
def
version
def
version
cache
.
fetch
(
:version
)
do
cache
.
fetch
(
:version
)
do
tree
(
:head
).
blobs
.
find
do
|
file
|
tree
(
:head
).
blobs
.
find
do
|
file
|
file
.
name
.
downcase
==
'version'
file
.
name
.
casecmp
(
'version'
).
zero?
end
end
end
end
end
end
...
...
lib/gitlab/database.rb
View file @
377583a3
...
@@ -5,11 +5,11 @@ module Gitlab
...
@@ -5,11 +5,11 @@ module Gitlab
end
end
def
self
.
mysql?
def
self
.
mysql?
adapter_name
.
downcase
==
'mysql2'
adapter_name
.
casecmp
(
'mysql2'
).
zero?
end
end
def
self
.
postgresql?
def
self
.
postgresql?
adapter_name
.
downcase
==
'postgresql'
adapter_name
.
casecmp
(
'postgresql'
).
zero?
end
end
def
self
.
version
def
self
.
version
...
...
lib/gitlab/markup_helper.rb
View file @
377583a3
...
@@ -40,7 +40,7 @@ module Gitlab
...
@@ -40,7 +40,7 @@ module Gitlab
# Returns boolean
# Returns boolean
def
plain?
(
filename
)
def
plain?
(
filename
)
filename
.
downcase
.
end_with?
(
'.txt'
)
||
filename
.
downcase
.
end_with?
(
'.txt'
)
||
filename
.
downcase
==
'readme'
filename
.
casecmp
(
'readme'
).
zero?
end
end
def
previewable?
(
filename
)
def
previewable?
(
filename
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment