[Why] lib/matrix2.rb:81:1: C: Metrics/AbcSize: Assignment Branch Condition size for create_matrix is too high. [<5, 16, 5> 17.49/15] def create_matrix(job_list) ... ^^^^^^^^^^^^^^^^^^^^^^^^^^^ lib/matrix2.rb:81:1: C: Metrics/CyclomaticComplexity: Cyclomatic complexity for create_matrix is too high. [9/7] def create_matrix(job_list) ... ^^^^^^^^^^^^^^^^^^^^^^^^^^^ lib/matrix2.rb:81:1: C: Metrics/MethodLength: Method has too many lines. [18/15] def create_matrix(job_list) ... ^^^^^^^^^^^^^^^^^^^^^^^^^^^
Signed-off-by: Lu Weitao luweitaobe@163.com --- lib/matrix2.rb | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/lib/matrix2.rb b/lib/matrix2.rb index a7b83c6..fc805d8 100644 --- a/lib/matrix2.rb +++ b/lib/matrix2.rb @@ -85,12 +85,7 @@ def create_matrix(job_list) stats = job['stats'] next unless stats
- if job['suite'] - next unless stats.keys.any? { |stat| stat.start_with?(job['suite']) } - - suites << job['suite'] - end - + assign_suites(suites, job, stats) stats.each do |key, value| next if key.include?('timestamp')
@@ -103,6 +98,12 @@ def create_matrix(job_list) return matrix, suites end
+def assign_suites(suites, job, stats) + return unless job['suite'] && stats.keys.any? { |stat| stat.start_with?(job['suite']) } + + suites << job['suite'] +end + # input: query results from es_query # return: matrix def combine_query_data(query_data)