Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
4db6b8f0
Commit
4db6b8f0
authored
7 years ago
by
Maxim Rydkin
Committed by
Robert Speicher
7 years ago
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Decrease Cyclomatic Complexity threshold to 13
parent
a1a2ce4a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
42 additions
and
20 deletions
+42
-20
.rubocop.yml
.rubocop.yml
+1
-1
changelogs/unreleased/31362_decrease_cyclomatic_complexity_threshold_step4.yml
.../31362_decrease_cyclomatic_complexity_threshold_step4.yml
+5
-0
lib/gitlab/conflict/parser.rb
lib/gitlab/conflict/parser.rb
+19
-9
lib/gitlab/mail_room.rb
lib/gitlab/mail_room.rb
+17
-10
No files found.
.rubocop.yml
View file @
4db6b8f0
...
@@ -643,7 +643,7 @@ Metrics/ClassLength:
...
@@ -643,7 +643,7 @@ Metrics/ClassLength:
# of test cases needed to validate a method.
# of test cases needed to validate a method.
Metrics/CyclomaticComplexity
:
Metrics/CyclomaticComplexity
:
Enabled
:
true
Enabled
:
true
Max
:
1
4
Max
:
1
3
# Limit lines to 80 characters.
# Limit lines to 80 characters.
Metrics/LineLength
:
Metrics/LineLength
:
...
...
This diff is collapsed.
Click to expand it.
changelogs/unreleased/31362_decrease_cyclomatic_complexity_threshold_step4.yml
0 → 100644
View file @
4db6b8f0
---
title
:
Decrease Cyclomatic Complexity threshold to
13
merge_request
:
14152
author
:
Maxim Rydkin
type
:
other
This diff is collapsed.
Click to expand it.
lib/gitlab/conflict/parser.rb
View file @
4db6b8f0
...
@@ -12,12 +12,7 @@ module Gitlab
...
@@ -12,12 +12,7 @@ module Gitlab
MissingEndDelimiter
=
Class
.
new
(
ParserError
)
MissingEndDelimiter
=
Class
.
new
(
ParserError
)
def
parse
(
text
,
our_path
:,
their_path
:,
parent_file:
nil
)
def
parse
(
text
,
our_path
:,
their_path
:,
parent_file:
nil
)
raise
UnmergeableFile
if
text
.
blank?
# Typically a binary file
validate_text!
(
text
)
raise
UnmergeableFile
if
text
.
length
>
200
.
kilobytes
text
.
force_encoding
(
'UTF-8'
)
raise
UnsupportedEncoding
unless
text
.
valid_encoding?
line_obj_index
=
0
line_obj_index
=
0
line_old
=
1
line_old
=
1
...
@@ -32,15 +27,15 @@ module Gitlab
...
@@ -32,15 +27,15 @@ module Gitlab
full_line
=
line
.
delete
(
"
\n
"
)
full_line
=
line
.
delete
(
"
\n
"
)
if
full_line
==
conflict_start
if
full_line
==
conflict_start
raise
UnexpectedDelimiter
unless
type
.
nil?
validate_delimiter!
(
type
.
nil?
)
type
=
'new'
type
=
'new'
elsif
full_line
==
conflict_middle
elsif
full_line
==
conflict_middle
raise
UnexpectedDelimiter
unless
type
==
'new'
validate_delimiter!
(
type
==
'new'
)
type
=
'old'
type
=
'old'
elsif
full_line
==
conflict_end
elsif
full_line
==
conflict_end
raise
UnexpectedDelimiter
unless
type
==
'old'
validate_delimiter!
(
type
==
'old'
)
type
=
nil
type
=
nil
elsif
line
[
0
]
==
'\\'
elsif
line
[
0
]
==
'\\'
...
@@ -59,6 +54,21 @@ module Gitlab
...
@@ -59,6 +54,21 @@ module Gitlab
lines
lines
end
end
private
def
validate_text!
(
text
)
raise
UnmergeableFile
if
text
.
blank?
# Typically a binary file
raise
UnmergeableFile
if
text
.
length
>
200
.
kilobytes
text
.
force_encoding
(
'UTF-8'
)
raise
UnsupportedEncoding
unless
text
.
valid_encoding?
end
def
validate_delimiter!
(
condition
)
raise
UnexpectedDelimiter
unless
condition
end
end
end
end
end
end
end
This diff is collapsed.
Click to expand it.
lib/gitlab/mail_room.rb
View file @
4db6b8f0
...
@@ -4,6 +4,15 @@ require_relative 'redis/queues' unless defined?(Gitlab::Redis::Queues)
...
@@ -4,6 +4,15 @@ require_relative 'redis/queues' unless defined?(Gitlab::Redis::Queues)
module
Gitlab
module
Gitlab
module
MailRoom
module
MailRoom
DEFAULT_CONFIG
=
{
enabled:
false
,
port:
143
,
ssl:
false
,
start_tls:
false
,
mailbox:
'inbox'
,
idle_timeout:
60
}.
freeze
class
<<
self
class
<<
self
def
enabled?
def
enabled?
config
[
:enabled
]
&&
config
[
:address
]
config
[
:enabled
]
&&
config
[
:address
]
...
@@ -22,16 +31,10 @@ module Gitlab
...
@@ -22,16 +31,10 @@ module Gitlab
def
fetch_config
def
fetch_config
return
{}
unless
File
.
exist?
(
config_file
)
return
{}
unless
File
.
exist?
(
config_file
)
rails_env
=
ENV
[
'RAILS_ENV'
]
||
ENV
[
'RACK_ENV'
]
||
'development'
config
=
YAML
.
load_file
(
config_file
)[
rails_env
].
deep_symbolize_keys
[
:incoming_email
]
||
{}
all_config
=
YAML
.
load_file
(
config_file
)[
rails_env
].
deep_symbolize_keys
config
=
DEFAULT_CONFIG
.
merge
(
config
)
do
|
_key
,
oldval
,
newval
|
newval
.
nil?
?
oldval
:
newval
config
=
all_config
[
:incoming_email
]
||
{}
end
config
[
:enabled
]
=
false
if
config
[
:enabled
].
nil?
config
[
:port
]
=
143
if
config
[
:port
].
nil?
config
[
:ssl
]
=
false
if
config
[
:ssl
].
nil?
config
[
:start_tls
]
=
false
if
config
[
:start_tls
].
nil?
config
[
:mailbox
]
=
'inbox'
if
config
[
:mailbox
].
nil?
config
[
:idle_timeout
]
=
60
if
config
[
:idle_timeout
].
nil?
if
config
[
:enabled
]
&&
config
[
:address
]
if
config
[
:enabled
]
&&
config
[
:address
]
gitlab_redis_queues
=
Gitlab
::
Redis
::
Queues
.
new
(
rails_env
)
gitlab_redis_queues
=
Gitlab
::
Redis
::
Queues
.
new
(
rails_env
)
...
@@ -45,6 +48,10 @@ module Gitlab
...
@@ -45,6 +48,10 @@ module Gitlab
config
config
end
end
def
rails_env
@rails_env
||=
ENV
[
'RAILS_ENV'
]
||
ENV
[
'RACK_ENV'
]
||
'development'
end
def
config_file
def
config_file
ENV
[
'MAIL_ROOM_GITLAB_CONFIG_FILE'
]
||
File
.
expand_path
(
'../../../config/gitlab.yml'
,
__FILE__
)
ENV
[
'MAIL_ROOM_GITLAB_CONFIG_FILE'
]
||
File
.
expand_path
(
'../../../config/gitlab.yml'
,
__FILE__
)
end
end
...
...
This diff is collapsed.
Click to expand it.
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