fastlane-plugin-swiftlint_codequality 1.0.1 β 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b89de6a3679654cb2828d0ef86169f4e811c0f1b5f57fe01a05f5de546233893
|
4
|
+
data.tar.gz: c4d3fe9240bf1c2e324c86981af465941ff35070b9b1f889b368f0ec26b367d1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8311edcc371f126c6373f4664ade3988939e14dfecb386194a87bcbc784e194f027db45e10d91b9b6741eb5737197dc5812f706563653c6f778447a7df15f3f9
|
7
|
+
data.tar.gz: 257b8eb68c5c93132bea3b12719f3ec468fe9bfce587b44f76c76c25600bdd1be4df151bcbb52ec14ce2e9ec9efa123cb4b0b65d08120f804d2421a9b38c167b
|
@@ -7,50 +7,81 @@ module Fastlane
|
|
7
7
|
def self.run(params)
|
8
8
|
UI.message("Parsing SwiftLint report at #{params[:path]}")
|
9
9
|
|
10
|
-
pwd =
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
issue_type, failure_type, description, rule = reason.match(/(.*?):?\s(.*?):\s(.*)\((.*)\)/).captures
|
21
|
-
|
22
|
-
case issue_type
|
23
|
-
when 'error'
|
24
|
-
severity = 'critical'
|
25
|
-
when 'warning'
|
26
|
-
severity = 'minor'
|
27
|
-
else
|
28
|
-
severity = 'info'
|
29
|
-
end
|
30
|
-
|
31
|
-
{
|
32
|
-
:type => "issue",
|
33
|
-
:check_name => failure_type.strip,
|
34
|
-
:description => description.strip,
|
35
|
-
:fingerprint => Digest::MD5.hexdigest(line),
|
36
|
-
:severity => severity,
|
37
|
-
:location => {
|
38
|
-
:path => params[:prefix] + filename.sub(pwd, ''),
|
39
|
-
:lines => {
|
40
|
-
:begin => start.to_i,
|
41
|
-
:end => start.to_i
|
42
|
-
}
|
43
|
-
}
|
44
|
-
}
|
45
|
-
}
|
46
|
-
.to_a
|
47
|
-
.to_json
|
10
|
+
pwd = Fastlane::Actions.sh("pwd", log: false).strip
|
11
|
+
|
12
|
+
report = File.open(params[:path])
|
13
|
+
result = report
|
14
|
+
.each
|
15
|
+
.select { |l| l.include?("Warning Threshold Violation") == false }
|
16
|
+
.map { |line| self.line_to_code_climate_object(line, params[:prefix], pwd) }
|
17
|
+
.to_a
|
18
|
+
|
19
|
+
IO.write(params[:output], result.to_json)
|
48
20
|
|
21
|
+
UI.success("π Generated Code Quality report at #{params[:output]} π")
|
49
22
|
|
23
|
+
handle_result(result, params[:fail_build_conditions])
|
24
|
+
end
|
50
25
|
|
51
|
-
|
26
|
+
def self.line_to_code_climate_object(line, prefix, pwd)
|
27
|
+
filename, start, reason = line.match(/(.*\.swift):(\d+):\d+:\s*(.*)/).captures
|
28
|
+
|
29
|
+
# example: error: Type Name Violation: Type name should only contain alphanumeric characters: 'FILE' (type_name)
|
30
|
+
|
31
|
+
issue_type, failure_type, description, _rule = reason.match(/(.*?):?\s(.*?):\s(.*)\((.*)\)/).captures
|
32
|
+
|
33
|
+
case issue_type
|
34
|
+
when 'error'
|
35
|
+
severity = Severity::CRITICAL
|
36
|
+
when 'warning'
|
37
|
+
severity = Severity::MINOR
|
38
|
+
else
|
39
|
+
severity = Severity::INFO
|
40
|
+
end
|
41
|
+
|
42
|
+
{
|
43
|
+
type: "issue",
|
44
|
+
check_name: failure_type.strip,
|
45
|
+
description: description.strip,
|
46
|
+
fingerprint: Digest::MD5.hexdigest(line),
|
47
|
+
severity: severity,
|
48
|
+
location: {
|
49
|
+
path: prefix + filename.sub(pwd, ''),
|
50
|
+
lines: {
|
51
|
+
begin: start.to_i,
|
52
|
+
end: start.to_i
|
53
|
+
}
|
54
|
+
}
|
55
|
+
}
|
56
|
+
end
|
52
57
|
|
53
|
-
|
58
|
+
def self.handle_result(result, fail_build_conditions)
|
59
|
+
critical_limit = fail_build_conditions.fetch(Severity::CRITICAL.to_sym, 0)
|
60
|
+
minor_limit = fail_build_conditions.fetch(Severity::MINOR.to_sym, 0)
|
61
|
+
info_limit = fail_build_conditions.fetch(Severity::INFO.to_sym, 0)
|
62
|
+
|
63
|
+
critical_count = result.select { |issue| issue[:severity] == Severity::CRITICAL }.length
|
64
|
+
minor_count = result.select { |issue| issue[:severity] == Severity::MINOR }.length
|
65
|
+
info_count = result.select { |issue| issue[:severity] == Severity::INFO }.length
|
66
|
+
|
67
|
+
UI.important("")
|
68
|
+
violations = false
|
69
|
+
if critical_count > critical_limit
|
70
|
+
UI.important("Critical issue limit (#{critical_limit}) exceeded: #{critical_count}")
|
71
|
+
violations = true
|
72
|
+
end
|
73
|
+
if minor_count > minor_limit
|
74
|
+
UI.important("Minor issue limit (#{minor_limit}) exceeded: #{minor_count}")
|
75
|
+
violations = true
|
76
|
+
end
|
77
|
+
if info_count > info_limit
|
78
|
+
UI.important("Info issue limit (#{info_limit}) exceeded: #{info_count}")
|
79
|
+
violations = true
|
80
|
+
end
|
81
|
+
|
82
|
+
UI.important("")
|
83
|
+
|
84
|
+
UI.user_error!("Severity limits where exceeded.") if violations
|
54
85
|
end
|
55
86
|
|
56
87
|
def self.description
|
@@ -61,10 +92,6 @@ module Fastlane
|
|
61
92
|
["madsbogeskov"]
|
62
93
|
end
|
63
94
|
|
64
|
-
def self.return_value
|
65
|
-
|
66
|
-
end
|
67
|
-
|
68
95
|
def self.details
|
69
96
|
"Converts SwiftLint reports into GitLab support CodeQuality reports"
|
70
97
|
end
|
@@ -86,13 +113,25 @@ module Fastlane
|
|
86
113
|
description: "Used to prefix the path of a file. Usefull in e.g. React Native projects where the iOS project is in a subfolder",
|
87
114
|
optional: true,
|
88
115
|
default_value: '',
|
89
|
-
type: String)
|
116
|
+
type: String),
|
117
|
+
FastlaneCore::ConfigItem.new(key: :fail_build_conditions,
|
118
|
+
env_name: "SWIFTLINT_CODEQUALITY_FAIL_BUILD_CONDITIONS",
|
119
|
+
description: "A hash with severities and their limits, that if exceeded should result in an exception. Supported severities: critical, minor and info.",
|
120
|
+
is_string: false,
|
121
|
+
default_value: {},
|
122
|
+
optional: true)
|
90
123
|
]
|
91
124
|
end
|
92
125
|
|
93
126
|
def self.is_supported?(platform)
|
94
127
|
true
|
95
128
|
end
|
129
|
+
|
130
|
+
class Severity
|
131
|
+
CRITICAL = "critical".freeze
|
132
|
+
MINOR = "minor".freeze
|
133
|
+
INFO = "info".freeze
|
134
|
+
end
|
96
135
|
end
|
97
136
|
end
|
98
137
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fastlane-plugin-swiftlint_codequality
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mads BΓΈgeskov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-11-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pry
|