Class: Fastlane::Helper::GitlabLintLine
- Inherits:
-
Object
- Object
- Fastlane::Helper::GitlabLintLine
- Defined in:
- lib/fastlane/plugin/gitlab_increate_line_notes/helper/gitlab_lint_line_parser.rb
Instance Attribute Summary collapse
-
#basename ⇒ Object
Returns the value of attribute basename.
-
#character ⇒ Object
Returns the value of attribute character.
-
#commit ⇒ Object
Returns the value of attribute commit.
-
#line ⇒ Object
Returns the value of attribute line.
-
#new_path ⇒ Object
Returns the value of attribute new_path.
-
#old_path ⇒ Object
Returns the value of attribute old_path.
-
#reason ⇒ Object
Returns the value of attribute reason.
-
#rule_id ⇒ Object
Returns the value of attribute rule_id.
-
#severity ⇒ Object
Returns the value of attribute severity.
-
#type ⇒ Object
Returns the value of attribute type.
Class Method Summary collapse
Instance Method Summary collapse
-
#equal_to_position?(position) ⇒ Boolean
{ “base_sha”: “16692b5cfa1d4dba9a6d060368942992ffba3680”, “start_sha”: “16692b5cfa1d4dba9a6d060368942992ffba3680”, “head_sha”: “6216046ac5a36d0273754c22b06b08236ec6c133”, “old_path”: “ZHCoreHybrid/Classes/Haha.swift”, “new_path”: “ZHCoreHybrid/Classes/Haha.swift”, “position_type”: “text”, “old_line”: null, “new_line”: 18 }.
-
#initialize(args) ⇒ GitlabLintLine
constructor
A new instance of GitlabLintLine.
- #line_in_positons?(positions) ⇒ Boolean
- #to_discussion ⇒ Object
- #to_hash ⇒ Object
Constructor Details
#initialize(args) ⇒ GitlabLintLine
Returns a new instance of GitlabLintLine.
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/fastlane/plugin/gitlab_increate_line_notes/helper/gitlab_lint_line_parser.rb', line 9 def initialize(args) @character = args['character'] @new_path = args['new_path'] @basename = File.basename(@new_path) if @new_path @old_path = args['old_path'] @line = args['line'] @reason = args['reason'] @rule_id = args['rule_id'] @type = args['type'] @severity = args['severity'] @commit = args['commit'] end |
Instance Attribute Details
#basename ⇒ Object
Returns the value of attribute basename.
8 9 10 |
# File 'lib/fastlane/plugin/gitlab_increate_line_notes/helper/gitlab_lint_line_parser.rb', line 8 def basename @basename end |
#character ⇒ Object
Returns the value of attribute character.
8 9 10 |
# File 'lib/fastlane/plugin/gitlab_increate_line_notes/helper/gitlab_lint_line_parser.rb', line 8 def character @character end |
#commit ⇒ Object
Returns the value of attribute commit.
8 9 10 |
# File 'lib/fastlane/plugin/gitlab_increate_line_notes/helper/gitlab_lint_line_parser.rb', line 8 def commit @commit end |
#line ⇒ Object
Returns the value of attribute line.
8 9 10 |
# File 'lib/fastlane/plugin/gitlab_increate_line_notes/helper/gitlab_lint_line_parser.rb', line 8 def line @line end |
#new_path ⇒ Object
Returns the value of attribute new_path.
8 9 10 |
# File 'lib/fastlane/plugin/gitlab_increate_line_notes/helper/gitlab_lint_line_parser.rb', line 8 def new_path @new_path end |
#old_path ⇒ Object
Returns the value of attribute old_path.
8 9 10 |
# File 'lib/fastlane/plugin/gitlab_increate_line_notes/helper/gitlab_lint_line_parser.rb', line 8 def old_path @old_path end |
#reason ⇒ Object
Returns the value of attribute reason.
8 9 10 |
# File 'lib/fastlane/plugin/gitlab_increate_line_notes/helper/gitlab_lint_line_parser.rb', line 8 def reason @reason end |
#rule_id ⇒ Object
Returns the value of attribute rule_id.
8 9 10 |
# File 'lib/fastlane/plugin/gitlab_increate_line_notes/helper/gitlab_lint_line_parser.rb', line 8 def rule_id @rule_id end |
#severity ⇒ Object
Returns the value of attribute severity.
8 9 10 |
# File 'lib/fastlane/plugin/gitlab_increate_line_notes/helper/gitlab_lint_line_parser.rb', line 8 def severity @severity end |
#type ⇒ Object
Returns the value of attribute type.
8 9 10 |
# File 'lib/fastlane/plugin/gitlab_increate_line_notes/helper/gitlab_lint_line_parser.rb', line 8 def type @type end |
Class Method Details
.from_discussion(discussion) ⇒ Object
88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/fastlane/plugin/gitlab_increate_line_notes/helper/gitlab_lint_line_parser.rb', line 88 def from_discussion(discussion) rt = discussion.match(/swiftlint\|(.*)\|(.*)\|(.*)/) return nil unless rt line = LintLine.new({}) line.reason = rt[1] line.commit = rt[3] ru_info = rt[2] rt2 = ru_info.match(/\[(.*).*\]/) line.rule_id = rt2[1] line end |
Instance Method Details
#equal_to_position?(position) ⇒ Boolean
"base_sha": "16692b5cfa1d4dba9a6d060368942992ffba3680",
"start_sha": "16692b5cfa1d4dba9a6d060368942992ffba3680",
"head_sha": "6216046ac5a36d0273754c22b06b08236ec6c133",
"old_path": "ZHCoreHybrid/Classes/Haha.swift",
"new_path": "ZHCoreHybrid/Classes/Haha.swift",
"position_type": "text",
"old_line": null,
"new_line": 18
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/fastlane/plugin/gitlab_increate_line_notes/helper/gitlab_lint_line_parser.rb', line 33 def equal_to_position?(position) position_base_sha = position['base_sha'] position_start_sha = position['start_sha'] position_head_sha = position['head_sha'] position_old_path = position['old_path'] position_new_path = position['new_path'] position_old_line = position['old_line'] position_new_line = position['new_line'] # puts line == position_new_line # puts basename == File.basename(position_new_path) # puts commit == position_head_sha # if line == position_new_line && basename == File.basename(position_new_path) && commit == position_head_sha if line == position_new_line && basename == File.basename(position_new_path) true else false end end |
#line_in_positons?(positions) ⇒ Boolean
54 55 56 57 58 59 |
# File 'lib/fastlane/plugin/gitlab_increate_line_notes/helper/gitlab_lint_line_parser.rb', line 54 def line_in_positons?(positions) positions.each do |position| return true if equal_to_position?(position) end false end |
#to_discussion ⇒ Object
61 62 63 64 65 66 67 68 69 70 |
# File 'lib/fastlane/plugin/gitlab_increate_line_notes/helper/gitlab_lint_line_parser.rb', line 61 def to_discussion # eg: "swiftlint|ZHModuleCreationObjecs.swift|Function should have complexity 10 or less: currently complexity equals 11|101|21dc9ccdc021f0f489f9b9fa50b76d60cee3f04e" # "swiftlint|%s|%s|%s|%s" % [basename, reason, line, commit] # 不需要保存 line、basename # (line、basename 都可以直接从 note/position/new_line 或 old_line 获取到) rule_id_str = rule_id.gsub('_', '-') rule_info = "[#{rule_id}](https://github.com/realm/SwiftLint/blob/master/Rules.md##{rule_id_str})" "swiftlint|%s|%s|%s" % [reason, rule_info, commit] end |
#to_hash ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/fastlane/plugin/gitlab_increate_line_notes/helper/gitlab_lint_line_parser.rb', line 72 def to_hash { basename: @basename, character: @character, commit: @commit, line: @line, new_path: @new_path, old_path: @old_path, reason: @reason, rule_id: @rule_id, severity: @severity, type: @type } end |