On Mon, Feb 22, 2021 at 11:45:08AM +0800, Luan Shengde wrote:
- puts line
+require 'json'
+def parse_msg_1(ansible_failed_json)
- case ansible_failed_json.chomp
no need to add .chomp if you don't match line end: $.
Ok.
- when /Unable to start service (.+):/
- puts "service.error.unable-to-start-service.#{$1}: 1"
- puts "service.error.unable-to-start-service.#{$1}.message: #{@ansible_failed_info}"
- end
+end
+def parse_msg_2(ansible_failed_json)
- case ansible_failed_json.chomp
it seems that parse_msg_1 and parse_msg_2 is separated from one, it's better puts the same one case test in one method.
I know. but if puts them in one method, the rubocop will warning: ansible_test:11:1: C:Metrics/CyclomaticComplexity: Cyclomatic complexity for parse_msg_1 is too high. [12/7] def parse_msg_1(ansible_failed_json) ...
Thanks, Chenglong
Thanks, Luan Shengde