summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2017-04-26 10:40:29 +0000
committerRémy Coutable <remy@rymai.me>2017-04-26 10:40:29 +0000
commit04fcf3fabf00b62eb8da91a6ed9fb0fb9561d76a (patch)
treed212fdd340a15c0e95d471364264158911db31a6
parent081dfc455b049c3d7cdf269f24ff764def5af31b (diff)
parent37c2c4a4339053403d3ac45a8e5c76df083fd454 (diff)
downloadgitlab-ce-04fcf3fabf00b62eb8da91a6ed9fb0fb9561d76a.tar.gz
Merge branch '31362_decrease_cyclomatic_complexity_threshold_step1' into 'master'
Decrease Cyclomatic Complexity threshold to 16 See merge request !10928
-rw-r--r--.rubocop.yml2
-rw-r--r--changelogs/unreleased/31362_decrease_cyclomatic_complexity_threshold_step1.yml4
-rw-r--r--lib/gitlab/google_code_import/importer.rb70
3 files changed, 35 insertions, 41 deletions
diff --git a/.rubocop.yml b/.rubocop.yml
index e5549b64503..1625fbec333 100644
--- a/.rubocop.yml
+++ b/.rubocop.yml
@@ -562,7 +562,7 @@ Metrics/ClassLength:
# of test cases needed to validate a method.
Metrics/CyclomaticComplexity:
Enabled: true
- Max: 17
+ Max: 16
# Limit lines to 80 characters.
Metrics/LineLength:
diff --git a/changelogs/unreleased/31362_decrease_cyclomatic_complexity_threshold_step1.yml b/changelogs/unreleased/31362_decrease_cyclomatic_complexity_threshold_step1.yml
new file mode 100644
index 00000000000..fedf4de04d3
--- /dev/null
+++ b/changelogs/unreleased/31362_decrease_cyclomatic_complexity_threshold_step1.yml
@@ -0,0 +1,4 @@
+---
+title: Decrease Cyclomatic Complexity threshold to 16
+merge_request: 10928
+author: Rydkin Maxim
diff --git a/lib/gitlab/google_code_import/importer.rb b/lib/gitlab/google_code_import/importer.rb
index b02b9737493..5ca3e6a95ca 100644
--- a/lib/gitlab/google_code_import/importer.rb
+++ b/lib/gitlab/google_code_import/importer.rb
@@ -1,7 +1,23 @@
module Gitlab
module GoogleCodeImport
class Importer
- attr_reader :project, :repo
+ attr_reader :project, :repo, :closed_statuses
+
+ NICE_LABEL_COLOR_HASH =
+ {
+ 'Status: New' => '#428bca',
+ 'Status: Accepted' => '#5cb85c',
+ 'Status: Started' => '#8e44ad',
+ 'Priority: Critical' => '#ffcfcf',
+ 'Priority: High' => '#deffcf',
+ 'Priority: Medium' => '#fff5cc',
+ 'Priority: Low' => '#cfe9ff',
+ 'Type: Defect' => '#d9534f',
+ 'Type: Enhancement' => '#44ad8e',
+ 'Type: Task' => '#4b6dd0',
+ 'Type: Review' => '#8e44ad',
+ 'Type: Other' => '#7f8c8d'
+ }.freeze
def initialize(project)
@project = project
@@ -161,45 +177,19 @@ module Gitlab
end
def nice_label_color(name)
- case name
- when /\AComponent:/
- "#fff39e"
- when /\AOpSys:/
- "#e2e2e2"
- when /\AMilestone:/
- "#fee3ff"
-
- when "Status: New"
- "#428bca"
- when "Status: Accepted"
- "#5cb85c"
- when "Status: Started"
- "#8e44ad"
-
- when "Priority: Critical"
- "#ffcfcf"
- when "Priority: High"
- "#deffcf"
- when "Priority: Medium"
- "#fff5cc"
- when "Priority: Low"
- "#cfe9ff"
-
- when "Type: Defect"
- "#d9534f"
- when "Type: Enhancement"
- "#44ad8e"
- when "Type: Task"
- "#4b6dd0"
- when "Type: Review"
- "#8e44ad"
- when "Type: Other"
- "#7f8c8d"
- when *@closed_statuses.map { |s| nice_status_name(s) }
- "#cfcfcf"
- else
- "#e2e2e2"
- end
+ NICE_LABEL_COLOR_HASH[name] ||
+ case name
+ when /\AComponent:/
+ '#fff39e'
+ when /\AOpSys:/
+ '#e2e2e2'
+ when /\AMilestone:/
+ '#fee3ff'
+ when *closed_statuses.map { |s| nice_status_name(s) }
+ '#cfcfcf'
+ else
+ '#e2e2e2'
+ end
end
def nice_label_name(name)